blogg 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/app/assets/images/blogg/fallback/about-bg.jpg +0 -0
- data/app/assets/images/blogg/fallback/contact-bg.jpg +0 -0
- data/app/assets/images/blogg/fallback/default-image-header.jpg +0 -0
- data/app/assets/images/blogg/fallback/post-bg.jpg +0 -0
- data/app/assets/images/blogg/fallback/post-sample-image.jpg +0 -0
- data/app/assets/javascripts/blogg/application.js +2 -13
- data/app/assets/javascripts/blogg/bootstrap.js +2363 -0
- data/app/assets/javascripts/blogg/scripts.js.coffee +23 -0
- data/app/assets/stylesheets/blogg/application.sass +3 -0
- data/app/assets/stylesheets/blogg/bootstrap.css +6760 -0
- data/app/assets/stylesheets/blogg/style.sass +345 -0
- data/app/controllers/blogg/application_controller.rb +12 -0
- data/app/controllers/blogg/posts_controller.rb +21 -75
- data/app/helpers/blogg/application_helper.rb +29 -0
- data/app/models/blogg/post.rb +42 -1
- data/app/models/user_ability.rb +37 -0
- data/app/uploaders/blogg/image_uploader.rb +26 -0
- data/app/views/blogg/posts/_form.html.haml +46 -0
- data/app/views/blogg/posts/edit.html.haml +6 -0
- data/app/views/blogg/posts/index.html.haml +30 -0
- data/app/views/blogg/posts/new.html.haml +6 -0
- data/app/views/blogg/posts/show.html.haml +38 -0
- data/app/views/blogg/shared/_disqus_thread.html.haml +17 -0
- data/app/views/blogg/shared/_flash_messages.html.haml +5 -0
- data/app/views/blogg/shared/_footer.html.haml +6 -0
- data/app/views/blogg/shared/_header.html.haml +11 -0
- data/app/views/blogg/shared/_nav.html.haml +15 -0
- data/app/views/blogg/shared/_posted_by.html.haml +1 -0
- data/app/views/blogg/shared/_social.html.haml +7 -0
- data/app/views/layouts/blogg/application.haml +34 -0
- data/config/blogg/initializers/meta_tags.rb +6 -0
- data/config/locales/blogg.en.yml +21 -0
- data/config/locales/blogg.ru.yml +21 -0
- data/config/locales/blogg.uk.yml +21 -0
- data/db/migrate/20151127175927_add_author_id_to_blogg_posts.rb +5 -0
- data/db/migrate/20151128104131_add_subtitle_to_blogg_posts.rb +5 -0
- data/db/migrate/20151130232512_add_image_to_blogg_posts.rb +5 -0
- data/db/migrate/20151204181631_add_slug_to_blogg_post.rb +6 -0
- data/db/migrate/20151206194451_add_static_to_blogg_posts.rb +5 -0
- data/lib/blogg/engine.rb +1 -0
- data/lib/blogg/version.rb +1 -1
- data/lib/blogg.rb +40 -0
- metadata +229 -24
- data/app/assets/javascripts/blogg/posts.js +0 -2
- data/app/assets/stylesheets/blogg/application.css +0 -13
- data/app/assets/stylesheets/blogg/posts.css +0 -4
- data/app/assets/stylesheets/scaffold.css +0 -56
- data/app/views/blogg/posts/_form.html.erb +0 -25
- data/app/views/blogg/posts/edit.html.erb +0 -6
- data/app/views/blogg/posts/index.html.erb +0 -25
- data/app/views/blogg/posts/new.html.erb +0 -5
- data/app/views/blogg/posts/show.html.erb +0 -15
- data/app/views/layouts/blogg/application.html.erb +0 -14
@@ -0,0 +1,345 @@
|
|
1
|
+
/*!
|
2
|
+
* Clean Blog v1.0.0 (http://startbootstrap.com)
|
3
|
+
* Copyright 2014 Start Bootstrap
|
4
|
+
* Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE)
|
5
|
+
|
6
|
+
body
|
7
|
+
font-family: 'Lora', 'Times New Roman', serif
|
8
|
+
font-size: 20px
|
9
|
+
color: #404040
|
10
|
+
|
11
|
+
p
|
12
|
+
line-height: 1.5
|
13
|
+
margin: 30px 0
|
14
|
+
a
|
15
|
+
text-decoration: underline
|
16
|
+
|
17
|
+
h1, h2, h3, h4, h5, h6
|
18
|
+
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
|
19
|
+
font-weight: 800
|
20
|
+
|
21
|
+
a
|
22
|
+
color: #404040
|
23
|
+
&:hover, &:focus
|
24
|
+
color: #0085a1
|
25
|
+
img
|
26
|
+
&:hover, &:focus
|
27
|
+
cursor: zoom-in
|
28
|
+
|
29
|
+
blockquote
|
30
|
+
color: #808080
|
31
|
+
font-style: italic
|
32
|
+
p
|
33
|
+
margin-top: 0
|
34
|
+
|
35
|
+
hr.small
|
36
|
+
max-width: 100px
|
37
|
+
margin: 15px auto
|
38
|
+
border-width: 4px
|
39
|
+
border-color: white
|
40
|
+
|
41
|
+
.post-actions >
|
42
|
+
a
|
43
|
+
text-decoration: none
|
44
|
+
|
45
|
+
form
|
46
|
+
.form-group
|
47
|
+
.help-block
|
48
|
+
font-size: medium
|
49
|
+
a
|
50
|
+
text-decoration: none
|
51
|
+
|
52
|
+
|
53
|
+
.navbar-custom
|
54
|
+
position: absolute
|
55
|
+
top: 0
|
56
|
+
left: 0
|
57
|
+
width: 100%
|
58
|
+
z-index: 3
|
59
|
+
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
|
60
|
+
.navbar-brand
|
61
|
+
font-weight: 800
|
62
|
+
.nav li a
|
63
|
+
text-transform: uppercase
|
64
|
+
font-size: 12px
|
65
|
+
font-weight: 800
|
66
|
+
letter-spacing: 1px
|
67
|
+
|
68
|
+
@media only screen and (min-width: 768px)
|
69
|
+
.navbar-custom
|
70
|
+
background: transparent
|
71
|
+
border-bottom: 1px solid transparent
|
72
|
+
.navbar-brand
|
73
|
+
color: white
|
74
|
+
padding: 20px
|
75
|
+
&:hover, &:focus
|
76
|
+
color: rgba(255, 255, 255, 0.8)
|
77
|
+
.nav li a
|
78
|
+
color: white
|
79
|
+
padding: 20px
|
80
|
+
&:hover, &:focus
|
81
|
+
color: rgba(255, 255, 255, 0.8)
|
82
|
+
|
83
|
+
@media only screen and (min-width: 1170px)
|
84
|
+
.navbar-custom
|
85
|
+
-webkit-transition: background-color 0.3s
|
86
|
+
-moz-transition: background-color 0.3s
|
87
|
+
transition: background-color 0.3s
|
88
|
+
/* Force Hardware Acceleration in WebKit
|
89
|
+
-webkit-transform: translate3d(0, 0, 0)
|
90
|
+
-moz-transform: translate3d(0, 0, 0)
|
91
|
+
-ms-transform: translate3d(0, 0, 0)
|
92
|
+
-o-transform: translate3d(0, 0, 0)
|
93
|
+
transform: translate3d(0, 0, 0)
|
94
|
+
-webkit-backface-visibility: hidden
|
95
|
+
backface-visibility: hidden
|
96
|
+
&.is-fixed
|
97
|
+
/* when the user scrolls down, we hide the header right above the viewport
|
98
|
+
position: fixed
|
99
|
+
top: -61px
|
100
|
+
background-color: rgba(255, 255, 255, 0.9)
|
101
|
+
border-bottom: 1px solid #f2f2f2
|
102
|
+
-webkit-transition: -webkit-transform 0.3s
|
103
|
+
-moz-transition: -moz-transform 0.3s
|
104
|
+
transition: transform 0.3s
|
105
|
+
.navbar-brand
|
106
|
+
color: #404040
|
107
|
+
&:hover, &:focus
|
108
|
+
color: #0085a1
|
109
|
+
.nav li a
|
110
|
+
color: #404040
|
111
|
+
&:hover, &:focus
|
112
|
+
color: #0085a1
|
113
|
+
&.is-visible
|
114
|
+
/* if the user changes the scrolling direction, we show the header
|
115
|
+
-webkit-transform: translate3d(0, 100%, 0)
|
116
|
+
-moz-transform: translate3d(0, 100%, 0)
|
117
|
+
-ms-transform: translate3d(0, 100%, 0)
|
118
|
+
-o-transform: translate3d(0, 100%, 0)
|
119
|
+
transform: translate3d(0, 100%, 0)
|
120
|
+
|
121
|
+
.intro-header
|
122
|
+
background-color: #808080
|
123
|
+
background: no-repeat center center
|
124
|
+
background-attachment: scroll
|
125
|
+
-webkit-background-size: cover
|
126
|
+
-moz-background-size: cover
|
127
|
+
background-size: cover
|
128
|
+
-o-background-size: cover
|
129
|
+
margin-bottom: 50px
|
130
|
+
.site-heading, .post-heading, .page-heading
|
131
|
+
padding: 100px 0 50px
|
132
|
+
color: white
|
133
|
+
.site-heading, .page-heading
|
134
|
+
text-align: center
|
135
|
+
.site-heading h1, .page-heading h1
|
136
|
+
margin-top: 0
|
137
|
+
font-size: 50px
|
138
|
+
.site-heading .subheading, .page-heading .subheading
|
139
|
+
font-size: 24px
|
140
|
+
line-height: 1.1
|
141
|
+
display: block
|
142
|
+
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
|
143
|
+
font-weight: 300
|
144
|
+
margin: 10px 0 0
|
145
|
+
.post-heading
|
146
|
+
h1
|
147
|
+
font-size: 35px
|
148
|
+
.subheading, .meta
|
149
|
+
line-height: 1.1
|
150
|
+
display: block
|
151
|
+
.subheading
|
152
|
+
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
|
153
|
+
font-size: 24px
|
154
|
+
margin: 10px 0 30px
|
155
|
+
font-weight: 600
|
156
|
+
.meta
|
157
|
+
font-family: 'Lora', 'Times New Roman', serif
|
158
|
+
font-style: italic
|
159
|
+
font-weight: 300
|
160
|
+
font-size: 20px
|
161
|
+
a
|
162
|
+
color: white
|
163
|
+
|
164
|
+
@media only screen and (min-width: 768px)
|
165
|
+
.intro-header
|
166
|
+
.site-heading, .post-heading, .page-heading
|
167
|
+
padding: 150px 0
|
168
|
+
|
169
|
+
@media only screen and (min-width: 768px)
|
170
|
+
.intro-header
|
171
|
+
.site-heading h1, .page-heading h1
|
172
|
+
font-size: 80px
|
173
|
+
|
174
|
+
@media only screen and (min-width: 768px)
|
175
|
+
.intro-header .post-heading
|
176
|
+
h1
|
177
|
+
font-size: 55px
|
178
|
+
.subheading
|
179
|
+
font-size: 30px
|
180
|
+
|
181
|
+
.post-preview >
|
182
|
+
a
|
183
|
+
color: #404040
|
184
|
+
&:hover, &:focus
|
185
|
+
text-decoration: none
|
186
|
+
color: #0085a1
|
187
|
+
>
|
188
|
+
.post-title
|
189
|
+
font-size: 30px
|
190
|
+
margin-top: 30px
|
191
|
+
margin-bottom: 10px
|
192
|
+
.post-subtitle
|
193
|
+
margin: 0
|
194
|
+
font-weight: 300
|
195
|
+
margin-bottom: 10px
|
196
|
+
.post-meta
|
197
|
+
color: #808080
|
198
|
+
font-size: 18px
|
199
|
+
font-style: italic
|
200
|
+
margin-top: 0
|
201
|
+
a
|
202
|
+
text-decoration: none
|
203
|
+
color: #808080
|
204
|
+
&:hover, &:focus
|
205
|
+
color: #0085a1
|
206
|
+
text-decoration: underline
|
207
|
+
|
208
|
+
@media only screen and (min-width: 768px)
|
209
|
+
.post-preview > a > .post-title
|
210
|
+
font-size: 36px
|
211
|
+
|
212
|
+
.section-heading
|
213
|
+
font-size: 36px
|
214
|
+
margin-top: 60px
|
215
|
+
font-weight: 700
|
216
|
+
|
217
|
+
.caption
|
218
|
+
text-align: center
|
219
|
+
font-size: 14px
|
220
|
+
padding: 10px
|
221
|
+
font-style: italic
|
222
|
+
margin: 0
|
223
|
+
display: block
|
224
|
+
border-bottom-right-radius: 5px
|
225
|
+
border-bottom-left-radius: 5px
|
226
|
+
|
227
|
+
footer
|
228
|
+
padding: 50px 0 65px
|
229
|
+
.list-inline
|
230
|
+
margin: 0
|
231
|
+
padding: 0
|
232
|
+
.copyright
|
233
|
+
font-size: 14px
|
234
|
+
text-align: center
|
235
|
+
margin-bottom: 0
|
236
|
+
|
237
|
+
.floating-label-form-group
|
238
|
+
font-size: 14px
|
239
|
+
position: relative
|
240
|
+
margin-bottom: 0
|
241
|
+
padding-bottom: 0.5em
|
242
|
+
border-bottom: 1px solid #eeeeee
|
243
|
+
input, textarea
|
244
|
+
z-index: 1
|
245
|
+
position: relative
|
246
|
+
padding-right: 0
|
247
|
+
padding-left: 0
|
248
|
+
border: none
|
249
|
+
border-radius: 0
|
250
|
+
font-size: 1.5em
|
251
|
+
background: none
|
252
|
+
box-shadow: none !important
|
253
|
+
resize: none
|
254
|
+
label
|
255
|
+
display: block
|
256
|
+
z-index: 0
|
257
|
+
position: relative
|
258
|
+
top: 2em
|
259
|
+
margin: 0
|
260
|
+
font-size: 0.85em
|
261
|
+
line-height: 1.764705882em
|
262
|
+
vertical-align: middle
|
263
|
+
vertical-align: baseline
|
264
|
+
opacity: 0
|
265
|
+
-webkit-transition: top 0.3s ease,opacity 0.3s ease
|
266
|
+
-moz-transition: top 0.3s ease,opacity 0.3s ease
|
267
|
+
-ms-transition: top 0.3s ease,opacity 0.3s ease
|
268
|
+
transition: top 0.3s ease,opacity 0.3s ease
|
269
|
+
&:not(:first-child)
|
270
|
+
padding-left: 14px
|
271
|
+
border-left: 1px solid #eeeeee
|
272
|
+
|
273
|
+
.floating-label-form-group-with-value label
|
274
|
+
top: 0
|
275
|
+
opacity: 1
|
276
|
+
|
277
|
+
.floating-label-form-group-with-focus label
|
278
|
+
color: #0085a1
|
279
|
+
|
280
|
+
form .row:first-child .floating-label-form-group
|
281
|
+
border-top: 1px solid #eeeeee
|
282
|
+
|
283
|
+
.btn
|
284
|
+
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
|
285
|
+
text-transform: uppercase
|
286
|
+
font-size: 14px
|
287
|
+
font-weight: 800
|
288
|
+
letter-spacing: 1px
|
289
|
+
border-radius: 0
|
290
|
+
padding: 15px 25px
|
291
|
+
|
292
|
+
.btn-lg
|
293
|
+
font-size: 16px
|
294
|
+
padding: 25px 35px
|
295
|
+
|
296
|
+
.btn-default
|
297
|
+
&:hover, &:focus
|
298
|
+
background-color: #0085a1
|
299
|
+
border: 1px solid #0085a1
|
300
|
+
color: white
|
301
|
+
|
302
|
+
.pager
|
303
|
+
margin: 20px 0 0
|
304
|
+
text-align: inherit
|
305
|
+
li >
|
306
|
+
a, span
|
307
|
+
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
|
308
|
+
text-transform: uppercase
|
309
|
+
font-size: 14px
|
310
|
+
font-weight: 800
|
311
|
+
letter-spacing: 1px
|
312
|
+
padding: 15px 25px
|
313
|
+
background-color: white
|
314
|
+
border-radius: 0
|
315
|
+
a
|
316
|
+
&:hover, &:focus
|
317
|
+
color: white
|
318
|
+
background-color: #0085a1
|
319
|
+
border: 1px solid #0085a1
|
320
|
+
.disabled >
|
321
|
+
a
|
322
|
+
color: #808080
|
323
|
+
background-color: #404040
|
324
|
+
cursor: not-allowed
|
325
|
+
&:hover, &:focus
|
326
|
+
color: #808080
|
327
|
+
background-color: #404040
|
328
|
+
cursor: not-allowed
|
329
|
+
span
|
330
|
+
color: #808080
|
331
|
+
background-color: #404040
|
332
|
+
cursor: not-allowed
|
333
|
+
|
334
|
+
\::-moz-selection, ::selection
|
335
|
+
color: white
|
336
|
+
text-shadow: none
|
337
|
+
background: #0085a1
|
338
|
+
|
339
|
+
img
|
340
|
+
&::selection, &::-moz-selection
|
341
|
+
color: white
|
342
|
+
background: transparent
|
343
|
+
|
344
|
+
body
|
345
|
+
webkit-tap-highlight-color: #0085a1
|
@@ -1,4 +1,16 @@
|
|
1
1
|
module Blogg
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
|
4
|
+
rescue_from CanCan::AccessDenied do |exception|
|
5
|
+
respond_to do |format|
|
6
|
+
format.html { redirect_to root_url, :alert => exception.message }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# layout Blogg.layout
|
11
|
+
|
12
|
+
def current_ability
|
13
|
+
@current_ability ||= UserAbility.new(current_user)
|
14
|
+
end
|
3
15
|
end
|
4
16
|
end
|
@@ -2,86 +2,32 @@ require_dependency "blogg/application_controller"
|
|
2
2
|
|
3
3
|
module Blogg
|
4
4
|
class PostsController < ApplicationController
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET /posts/1
|
17
|
-
# GET /posts/1.json
|
18
|
-
def show
|
19
|
-
@post = Post.find(params[:id])
|
20
|
-
|
21
|
-
respond_to do |format|
|
22
|
-
format.html # show.html.erb
|
23
|
-
format.json { render json: @post }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# GET /posts/new
|
28
|
-
# GET /posts/new.json
|
29
|
-
def new
|
30
|
-
@post = Post.new
|
31
|
-
|
32
|
-
respond_to do |format|
|
33
|
-
format.html # new.html.erb
|
34
|
-
format.json { render json: @post }
|
35
|
-
end
|
5
|
+
|
6
|
+
respond_to :html
|
7
|
+
inherit_resources
|
8
|
+
|
9
|
+
load_and_authorize_resource
|
10
|
+
skip_authorize_resource :only => [:index, :show]
|
11
|
+
|
12
|
+
def destroy
|
13
|
+
destroy!(:notice => "Blog post was successfully deleted.")
|
36
14
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@post = Post.find(params[:id])
|
15
|
+
|
16
|
+
def update
|
17
|
+
update!(:notice => "Blog post was successfully updated.")
|
41
18
|
end
|
42
|
-
|
43
|
-
# POST /posts
|
44
|
-
# POST /posts.json
|
19
|
+
|
45
20
|
def create
|
46
21
|
@post = Post.new(params[:post])
|
47
|
-
|
48
|
-
|
49
|
-
if @post.save
|
50
|
-
format.html { redirect_to @post, notice: 'Post was successfully created.' }
|
51
|
-
format.json { render json: @post, status: :created, location: @post }
|
52
|
-
else
|
53
|
-
format.html { render action: "new" }
|
54
|
-
format.json { render json: @post.errors, status: :unprocessable_entity }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# PUT /posts/1
|
60
|
-
# PUT /posts/1.json
|
61
|
-
def update
|
62
|
-
@post = Post.find(params[:id])
|
63
|
-
|
64
|
-
respond_to do |format|
|
65
|
-
if @post.update_attributes(params[:post])
|
66
|
-
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
|
67
|
-
format.json { head :no_content }
|
68
|
-
else
|
69
|
-
format.html { render action: "edit" }
|
70
|
-
format.json { render json: @post.errors, status: :unprocessable_entity }
|
71
|
-
end
|
72
|
-
end
|
22
|
+
@post.author = current_user
|
23
|
+
create!(:notice => "Blog post was successfully created.")
|
73
24
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
def
|
78
|
-
|
79
|
-
@post.destroy
|
80
|
-
|
81
|
-
respond_to do |format|
|
82
|
-
format.html { redirect_to posts_url }
|
83
|
-
format.json { head :no_content }
|
84
|
-
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def collection
|
29
|
+
end_of_association_chain.articles
|
85
30
|
end
|
31
|
+
|
86
32
|
end
|
87
33
|
end
|
@@ -1,4 +1,33 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'rouge'
|
3
|
+
require 'rouge/plugins/redcarpet'
|
4
|
+
|
1
5
|
module Blogg
|
2
6
|
module ApplicationHelper
|
7
|
+
|
8
|
+
class HTML < Redcarpet::Render::HTML
|
9
|
+
include Rouge::Plugins::Redcarpet
|
10
|
+
def rouge_formatter(opts={})
|
11
|
+
opts ={
|
12
|
+
line_numbers: true,
|
13
|
+
wrap: true,
|
14
|
+
}
|
15
|
+
Rouge::Formatters::HTML.new(opts)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def markdown(text)
|
20
|
+
renderer = HTML.new(hard_wrap: true, filter_html: true)
|
21
|
+
options = {
|
22
|
+
autolink: true,
|
23
|
+
no_intra_emphasis: true,
|
24
|
+
fenced_code_blocks: true,
|
25
|
+
lax_html_blocks: true,
|
26
|
+
strikethrough: true,
|
27
|
+
superscript: true
|
28
|
+
}
|
29
|
+
Redcarpet::Markdown.new(renderer, options).render(text).html_safe
|
30
|
+
end
|
31
|
+
|
3
32
|
end
|
4
33
|
end
|
data/app/models/blogg/post.rb
CHANGED
@@ -1,5 +1,46 @@
|
|
1
|
+
require "babosa"
|
2
|
+
|
1
3
|
module Blogg
|
2
4
|
class Post < ActiveRecord::Base
|
3
|
-
|
5
|
+
|
6
|
+
# Use FriendlyId for pretty urls
|
7
|
+
extend FriendlyId
|
8
|
+
friendly_id :title, use: :slugged
|
9
|
+
|
10
|
+
attr_accessible :text, :title, :subtitle, :image, :image_cache, :remove_image, :static
|
11
|
+
belongs_to :author, :class_name => Blogg.user_class
|
12
|
+
validates_presence_of :text, :title, :subtitle, :author
|
13
|
+
|
14
|
+
scope :static, where(static: true)
|
15
|
+
scope :articles, where(static: false)
|
16
|
+
|
17
|
+
mount_uploader :image, Blogg::ImageUploader
|
18
|
+
|
19
|
+
# Override FriendlyId method to transliterate slug with Babosa gem
|
20
|
+
def normalize_friendly_id(value)
|
21
|
+
case I18n.locale
|
22
|
+
when :ru, :uk
|
23
|
+
value.to_s.to_slug.normalize(transliterations: :russian).to_s
|
24
|
+
else
|
25
|
+
value.to_s.to_slug.normalize.to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def is_static?
|
30
|
+
static
|
31
|
+
end
|
32
|
+
|
33
|
+
def is_article?
|
34
|
+
!static
|
35
|
+
end
|
36
|
+
|
37
|
+
def next
|
38
|
+
self.class.articles.where("id > ?", id).first
|
39
|
+
end
|
40
|
+
|
41
|
+
def prev
|
42
|
+
self.class.articles.where("id < ?", id).last
|
43
|
+
end
|
44
|
+
|
4
45
|
end
|
5
46
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class UserAbility
|
2
|
+
include CanCan::Ability
|
3
|
+
|
4
|
+
def initialize(user)
|
5
|
+
|
6
|
+
user ||= User.new
|
7
|
+
|
8
|
+
unless user.new_record?
|
9
|
+
can :manage, Blogg::Post#, :author_id => user.id
|
10
|
+
else
|
11
|
+
can :read, Blogg::Post
|
12
|
+
end
|
13
|
+
|
14
|
+
# Define abilities for the passed in user here. For example:
|
15
|
+
#
|
16
|
+
# user ||= User.new # guest user (not logged in)
|
17
|
+
# if user.admin?
|
18
|
+
# can :manage, :all
|
19
|
+
# else
|
20
|
+
# can :read, :all
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# The first argument to `can` is the action you are giving the user permission to do.
|
24
|
+
# If you pass :manage it will apply to every action. Other common actions here are
|
25
|
+
# :read, :create, :update and :destroy.
|
26
|
+
#
|
27
|
+
# The second argument is the resource the user can perform the action on. If you pass
|
28
|
+
# :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
|
29
|
+
#
|
30
|
+
# The third argument is an optional hash of conditions to further filter the objects.
|
31
|
+
# For example, here the user can only update published articles.
|
32
|
+
#
|
33
|
+
# can :update, Article, :published => true
|
34
|
+
#
|
35
|
+
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Blogg::ImageUploader < CarrierWave::Uploader::Base
|
2
|
+
|
3
|
+
include CarrierWave::MiniMagick
|
4
|
+
|
5
|
+
include Sprockets::Helpers::RailsHelper
|
6
|
+
include Sprockets::Helpers::IsolatedHelper
|
7
|
+
|
8
|
+
CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/
|
9
|
+
|
10
|
+
storage :file
|
11
|
+
|
12
|
+
def store_dir
|
13
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def extension_white_list
|
17
|
+
%w(jpg jpeg png)
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_url
|
21
|
+
ActionController::Base.helpers.asset_path("blogg/fallback/" + [version_name, "default-image-header.jpg"].compact.join('_'))
|
22
|
+
end
|
23
|
+
|
24
|
+
process :resize_to_fit => [1000, 600]
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
= form_for resource do |f|
|
2
|
+
- if resource.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
%h2
|
5
|
+
= pluralize(@post.errors.count, "error")
|
6
|
+
prohibited this post from being saved:
|
7
|
+
%ul
|
8
|
+
- @post.errors.full_messages.each do |msg|
|
9
|
+
%li= msg
|
10
|
+
.form-group
|
11
|
+
= f.label :title
|
12
|
+
= f.text_field :title, class: 'form-control'
|
13
|
+
.form-group
|
14
|
+
= f.label :subtitle
|
15
|
+
= f.text_field :subtitle, class: 'form-control'
|
16
|
+
.form-group
|
17
|
+
= f.label :text
|
18
|
+
= f.text_area :text, class: 'form-control'
|
19
|
+
%p.help-block.text-right
|
20
|
+
= link_to 'https://daringfireball.net/projects/markdown/basics', target: '_blank' do
|
21
|
+
Markdown is supported
|
22
|
+
%i.fa.fa-info-circle
|
23
|
+
.form-group
|
24
|
+
= f.label :image
|
25
|
+
.row
|
26
|
+
.col-md-6
|
27
|
+
%br
|
28
|
+
= f.file_field :image
|
29
|
+
= f.hidden_field :image_cache
|
30
|
+
.col-md-6
|
31
|
+
- if @post.image?
|
32
|
+
= image_tag(@post.image_url, class: 'img-responsive')
|
33
|
+
.checkbox
|
34
|
+
%label
|
35
|
+
= f.check_box :remove_image
|
36
|
+
Remove existing image
|
37
|
+
.form-group
|
38
|
+
.checkbox
|
39
|
+
%label
|
40
|
+
= f.check_box :static
|
41
|
+
Static page
|
42
|
+
%hr
|
43
|
+
|
44
|
+
= f.submit 'Save changes', class: 'btn btn-success'
|
45
|
+
.pull-right
|
46
|
+
= link_to 'Cancel', resource, class: 'btn btn-warning'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
= render 'blogg/shared/header', post: nil
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.col-lg-8.col-lg-offset-2.col-md-10.col-md-offset-1
|
5
|
+
= render 'blogg/shared/flash_messages'
|
6
|
+
- collection.each do |post|
|
7
|
+
.post-preview
|
8
|
+
= link_to post do
|
9
|
+
%h2.post-title
|
10
|
+
= post.title
|
11
|
+
%h3.post-subtitle
|
12
|
+
= post.subtitle
|
13
|
+
%p.post-meta
|
14
|
+
= render 'blogg/shared/posted_by', post: post
|
15
|
+
- if Blogg.disqus
|
16
|
+
|
|
17
|
+
%i.fa.fa-comments-o.fa-fw.text-small
|
18
|
+
= link_to 'Comments', post_url(post, anchor: "disqus_thread"), "data-disqus-identifier": "post_#{post.created_at.to_i}"
|
19
|
+
- if can? :manage, post
|
20
|
+
%p.post-meta
|
21
|
+
%i.fa.fa-edit
|
22
|
+
= link_to t('blogg.posts.actions.edit'), edit_post_path(post)
|
23
|
+
%i.fa.fa-trash-o
|
24
|
+
= link_to t('blogg.posts.actions.delete'), post, method: :delete, data: { confirm: 'Are you sure?' }
|
25
|
+
%i.fa.fa-file-o
|
26
|
+
= link_to t('blogg.posts.actions.new'), new_post_path
|
27
|
+
%hr/
|
28
|
+
-# %ul.pager
|
29
|
+
-# %li.next
|
30
|
+
-# %a{:href => "#"} Older Posts →
|