effective_posts 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a73d09c2c4fda7417d196c7ce701792f4972a269
4
- data.tar.gz: 40bd397f0941f6403819db29b6e5c5a6a0b505c2
3
+ metadata.gz: b92998992d3bbc6241ed4b3f9069f4bb64534e7c
4
+ data.tar.gz: d15314fde411d0b8629cb6f37902a839d73eeee6
5
5
  SHA512:
6
- metadata.gz: 93f00476ee697241229faf88324137ecb167e3677e9f9fe9fcfb0b5f7752204426e4c95caa7d748fb0b745aa1a348edfcc21fa9618ad10cab777e8de5778a4e5
7
- data.tar.gz: 1e295bc8f6ba1a1a1059a03d041e3b7b3f913803b5aba5b2f99422d6703c77a9bf34bd8af9092a09bd0a0ad6adabe20f21d09082d195b62c61699fd0604f95cd
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.use_category_routes
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.use_category_routes
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
- = render 'effective/posts/header', post: post
3
- = render 'effective/posts/event', post: post
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
- = render 'effective/posts/header', post: @post
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
@@ -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
- resources :posts, only: ([:index, :show] unless EffectivePosts.submissions_enabled)
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.use_category_routes
16
- Array(EffectivePosts.categories).map { |category| category.to_s }.each do |category|
17
- next if category == 'posts'
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
- match category, to: 'posts#index', via: :get, defaults: {:category => category }
20
- match "#{category}/:id", to: 'posts#show', via: :get, defaults: {:category => category }
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
 
@@ -17,6 +17,7 @@ module EffectivePosts
17
17
 
18
18
  mattr_accessor :categories
19
19
  mattr_accessor :use_category_routes
20
+ mattr_accessor :use_blog_routes
20
21
 
21
22
  mattr_accessor :use_effective_roles
22
23
  mattr_accessor :use_fullscreen_editor
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
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.2
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-05 00:00:00.000000000 Z
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
@@ -1,4 +0,0 @@
1
- %h2.post-title= link_to post, effective_post_path(post)
2
- %p.post-meta.text-muted
3
- = post_meta(post, author: false)
4
- = admin_post_status_badge(post)