effective_posts 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_posts_helper.rb +11 -7
- data/app/views/effective/posts/_post.html.haml +5 -2
- data/app/views/effective/posts/show.html.haml +6 -1
- data/config/effective_posts.rb +7 -0
- data/config/routes.rb +15 -6
- data/lib/effective_posts.rb +1 -0
- data/lib/effective_posts/version.rb +1 -1
- metadata +2 -3
- data/app/views/effective/posts/_header.html.haml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92998992d3bbc6241ed4b3f9069f4bb64534e7c
|
4
|
+
data.tar.gz: d15314fde411d0b8629cb6f37902a839d73eeee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72f48a2d8e10798746146da15a8a3c6a6e855555969871484669c9525f37f1ec0deb52eafff337b24ae293d9085abce1657a1b6e01f945fd7eabac860dc7373f
|
7
|
+
data.tar.gz: 54c499bd42808da6c0950d13cb286cff353e3696c1d71cea1c267162ee41f6fc70ea65104ea58fbc14f0b88d8e8a19e9bee5d4d5c826fb3ec181bba94238ca51
|
@@ -19,7 +19,9 @@ module EffectivePostsHelper
|
|
19
19
|
category = post.category.to_s.downcase
|
20
20
|
opts ||= {}
|
21
21
|
|
22
|
-
if EffectivePosts.
|
22
|
+
if EffectivePosts.use_blog_routes
|
23
|
+
effective_posts.post_path(post, opts)
|
24
|
+
elsif EffectivePosts.use_category_routes
|
23
25
|
effective_posts.post_path(post, opts).sub('/posts', "/#{category}")
|
24
26
|
else
|
25
27
|
effective_posts.post_path(post, opts.merge(category: category))
|
@@ -32,13 +34,20 @@ module EffectivePostsHelper
|
|
32
34
|
category = category.to_s.downcase
|
33
35
|
opts ||= {}
|
34
36
|
|
35
|
-
if EffectivePosts.
|
37
|
+
if EffectivePosts.use_blog_routes
|
38
|
+
"/blog/category/#{category}"
|
39
|
+
elsif EffectivePosts.use_category_routes
|
36
40
|
"/#{category}"
|
37
41
|
else
|
38
42
|
effective_posts.posts_path(opts.merge(category: category))
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
46
|
+
def link_to_post_category(category, options = {})
|
47
|
+
category = category.to_s.downcase
|
48
|
+
link_to(category.to_s.titleize, effective_post_category_path(category), title: category.to_s.titleize)
|
49
|
+
end
|
50
|
+
|
42
51
|
def render_post(post)
|
43
52
|
render(partial: 'effective/posts/post', locals: { post: post })
|
44
53
|
end
|
@@ -101,12 +110,7 @@ module EffectivePostsHelper
|
|
101
110
|
render(partial: '/effective/posts/categories', locals: { categories: (reverse ? post_categories.reverse : post_categories) })
|
102
111
|
end
|
103
112
|
|
104
|
-
def link_to_post_category(category, options = {})
|
105
|
-
category = category.to_s.downcase
|
106
113
|
|
107
|
-
href = EffectivePosts.use_category_routes ? "/#{category}" : effective_posts.posts_path(category: category.to_s)
|
108
|
-
link_to(category.to_s.titleize, href, options)
|
109
|
-
end
|
110
114
|
|
111
115
|
### Recent Posts
|
112
116
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
.effective-post
|
2
|
-
=
|
3
|
-
|
2
|
+
%h2.post-title= link_to post, effective_post_path(post)
|
3
|
+
|
4
|
+
%p.post-meta.text-muted
|
5
|
+
= post_meta(post, author: false)
|
6
|
+
= admin_post_status_badge(post)
|
4
7
|
|
5
8
|
.post-content.post-excerpt
|
6
9
|
= post_excerpt(post)
|
@@ -1,6 +1,11 @@
|
|
1
1
|
= render 'layout' do
|
2
2
|
.effective-post
|
3
|
-
=
|
3
|
+
%h1.post-title= link_to @post, effective_post_path(@post)
|
4
|
+
|
5
|
+
%p.post-meta.text-muted
|
6
|
+
= post_meta(@post, author: false)
|
7
|
+
= admin_post_status_badge(@post)
|
8
|
+
|
4
9
|
= render 'effective/posts/event', post: @post
|
5
10
|
|
6
11
|
.post-body.post-content
|
data/config/effective_posts.rb
CHANGED
@@ -14,6 +14,13 @@ EffectivePosts.setup do |config|
|
|
14
14
|
# Regardless of this setting, posts will always be available via /posts?category=events
|
15
15
|
config.use_category_routes = true
|
16
16
|
|
17
|
+
# Create routes for a blog.
|
18
|
+
# Includes category routes, but they're not top level.
|
19
|
+
# /blog is posts#index
|
20
|
+
# /blog/category/announcements is posts#index?category=announcements
|
21
|
+
# /blog/1-post-title is posts#show
|
22
|
+
config.use_blog_routes = false
|
23
|
+
|
17
24
|
# Number of posts displayed per page (Kaminari)
|
18
25
|
config.per_page = 10
|
19
26
|
|
data/config/routes.rb
CHANGED
@@ -10,15 +10,24 @@ EffectivePosts::Engine.routes.draw do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
scope :module => 'effective' do
|
13
|
-
|
13
|
+
categories = Array(EffectivePosts.categories).map { |cat| cat.to_s unless cat == 'posts'}.compact
|
14
|
+
onlies = ([:index, :show] unless EffectivePosts.submissions_enabled)
|
14
15
|
|
15
|
-
if EffectivePosts.
|
16
|
-
|
17
|
-
|
16
|
+
if EffectivePosts.use_blog_routes
|
17
|
+
categories.each do |category|
|
18
|
+
match "blog/category/#{category}", to: 'posts#index', via: :get, defaults: { category: category }
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
resources :posts, only: onlies, path: 'blog'
|
22
|
+
elsif EffectivePosts.use_category_routes
|
23
|
+
categories.each do |category|
|
24
|
+
match category, to: 'posts#index', via: :get, defaults: { category: category }
|
25
|
+
match "#{category}/:id", to: 'posts#show', via: :get, defaults: { category: category }
|
21
26
|
end
|
27
|
+
|
28
|
+
resources :posts, only: onlies
|
29
|
+
else
|
30
|
+
resources :posts, only: onlies
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
data/lib/effective_posts.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_posts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -156,7 +156,6 @@ files:
|
|
156
156
|
- app/views/effective/posts/_categories.html.haml
|
157
157
|
- app/views/effective/posts/_event.html.haml
|
158
158
|
- app/views/effective/posts/_form.html.haml
|
159
|
-
- app/views/effective/posts/_header.html.haml
|
160
159
|
- app/views/effective/posts/_layout.html.haml
|
161
160
|
- app/views/effective/posts/_post.html.haml
|
162
161
|
- app/views/effective/posts/_recent_posts.html.haml
|