wheelhouse-blog 1.0.3 → 1.0.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0cfc6b5046f139c9cddb6c9fcf1400d13d5c776
4
+ data.tar.gz: 8352caac4c126120878fb06ed8600f8ab1e89140
5
+ SHA512:
6
+ metadata.gz: b2720ecaf821bbd4ad77d56c53d60a024718699a529588b868ac9f31853f5f11b437058dbac33f418676cfd39035fa0f848d6bb30bd51a1472fbd068b3e84dd4
7
+ data.tar.gz: 20807ca9f2c5f41cb2d86072de2e925a154d298d25fda7ab48713119e9c5316c2f883f840def35d6ab509452a8dd84dadd4c83837772ee1db2ce5ce938722122
@@ -1,5 +1,7 @@
1
1
  class Blog::BlogHandler < Wheelhouse::ResourceHandler
2
- get "/(page/:page)", :cache => true do
2
+ extend Blog::WheelhouseRouteConstraints
3
+
4
+ get "/(page/:page)", :cache => true, :page => /\d+/ do
3
5
  @posts = paginate(@blog.posts)
4
6
  end
5
7
 
@@ -7,17 +9,17 @@ class Blog::BlogHandler < Wheelhouse::ResourceHandler
7
9
  render :template => "feed", :formats => [:rss], :layout => false
8
10
  end
9
11
 
10
- get '/tag/:tag(/page/:page)', :cache => true do
12
+ get '/tag/:tag(/page/:page)', :cache => true, :page => /\d+/ do
11
13
  @posts = paginate(@blog.posts.tagged_with(params[:tag]))
12
14
  render :template => "tag"
13
15
  end
14
16
 
15
- get '/category/:category(/page/:page)', :cache => true do
17
+ get '/category/:category(/page/:page)', :cache => true, :page => /\d+/ do
16
18
  @posts = paginate(@blog.posts.in_category(params[:category]))
17
19
  render :template => "category"
18
20
  end
19
21
 
20
- get "/:year(/:month)(/page/:page)", :cache => true do
22
+ get "/:year(/:month)(/page/:page)", :cache => true, :year => /\d{4}/, :month => /\d\d?/, :page => /\d+/ do
21
23
  @archive = Blog::Archive.new(@blog, params[:year], params[:month].presence)
22
24
  raise ActionController::RoutingError, "No route matches #{request.path.inspect}" if @archive.invalid?
23
25
 
@@ -25,7 +27,7 @@ class Blog::BlogHandler < Wheelhouse::ResourceHandler
25
27
  render :template => "archive"
26
28
  end
27
29
 
28
- get "/:year/:month/:permalink", :cache => true do
30
+ get "/:year/:month/:permalink", :cache => true, :year => /\d{4}/, :month => /\d\d?/ do
29
31
  @post = @blog.find_post(params[:year], params[:month], params[:permalink])
30
32
  render @post
31
33
  end
@@ -8,8 +8,4 @@ module Blog::BlogHelper
8
8
  @_blogs[:default] ||= Blog::Blog.first
9
9
  end
10
10
  end
11
-
12
- def blog_post_tag_links(post)
13
- post.tags.map { |tag| link_to(tag, post.blog.tag_path(tag), :title => "View all posts tagged #{tag}") }.join(', ').html_safe
14
- end
15
11
  end
@@ -9,13 +9,16 @@ module Blog::PaginationHelper
9
9
  path = @template.request.path
10
10
 
11
11
  if page == 1
12
- path.sub(PAGE_PARAMETER, "")
12
+ path = path.sub(PAGE_PARAMETER, "")
13
13
  elsif path =~ PAGE_PARAMETER
14
- path.sub(PAGE_PARAMETER, "/page/#{page}")
14
+ path = path.sub(PAGE_PARAMETER, "/page/#{page}")
15
15
  else
16
- path + "/page/#{page}"
16
+ path += "/page/#{page}"
17
17
  end
18
+
19
+ Wheelhouse::PathUtils.normalize_path(path)
18
20
  end
21
+
19
22
  alias url_for url
20
23
  end
21
24
 
@@ -0,0 +1,17 @@
1
+ module Blog::PostHelper
2
+ def current_post?(post)
3
+ request.path == post.path
4
+ end
5
+
6
+ def blog_post_tag_links(post, separator=", ")
7
+ safe_join(post.tags.map { |tag|
8
+ link_to(tag, post.blog.tag_path(tag), :title => "View all posts tagged #{tag}")
9
+ }, separator)
10
+ end
11
+
12
+ def blog_post_category_links(post, separator=", ")
13
+ safe_join(post.categories.map { |category|
14
+ link_to(category, post.blog.category_path(category), :title => "View all posts in category #{category}")
15
+ }, separator)
16
+ end
17
+ end
@@ -10,6 +10,8 @@ class Blog::Blog < Wheelhouse::Resource
10
10
  has_many :posts_for_admin, :class => "Blog::Post", :order => [:_admin_sort_index.desc, :created_at.desc],
11
11
  :select => [:id, :type, :title, :state, :published_at, :created_by_id, :author_name, :blog_id]
12
12
 
13
+ scope :sections_for_site, lambda { |site| where(:site_id => site.id).order(:created_at.asc).select(:id, :label) }
14
+
13
15
  activities :all
14
16
 
15
17
  icon "wheelhouse-blog/blog.png"
@@ -27,6 +27,7 @@ class Blog::Post < Wheelhouse::Resource
27
27
 
28
28
  validates_uniqueness_of :permalink, :scope => :blog_id
29
29
 
30
+ scope :published, where(:state => 'Published').order(:published_at.desc)
30
31
  scope :tagged_with, lambda { |tag| where(:_tags => tag.parameterize) }
31
32
  scope :in_category, lambda { |category| where(:_categories => category.parameterize) }
32
33
 
@@ -1,5 +1,5 @@
1
1
  %article.post
2
- %h3= link_to_unless_current post.title, post
2
+ %h3= link_to_unless current_post?(post), post.title, post
3
3
 
4
4
  %p
5
5
  %em
@@ -1,6 +1,3 @@
1
- - content_for(:head) do
2
- = stylesheet_link_tag "wheelhouse-blog/admin"
3
-
4
1
  .buttons
5
2
  = link_to "New Post", new_blog_post_path(@blog), :class => 'add'
6
3
 
@@ -22,4 +22,6 @@
22
22
  - if @blog.persisted?
23
23
  %hr
24
24
  = owner
25
-
25
+
26
+ - content_for(:head) do
27
+ = stylesheet_link_tag "wheelhouse-blog/admin"
@@ -19,7 +19,7 @@
19
19
 
20
20
  = sidebar_expander "Tags & Categories" do
21
21
  = field :categories do
22
- = form.checkboxes :categories, @blog.categories, :editable => true, :placeholder => "Add a category..."
22
+ = form.checkboxes :categories, @blog.categories.map(&:name), :editable => true, :placeholder => "Add a category..."
23
23
 
24
24
  = field :tags do
25
- = form.tags :tags, @blog.tags, :placeholder => "Add a tag..."
25
+ = form.tags :tags, @blog.tags.map(&:name), :placeholder => "Add a tag..."
@@ -0,0 +1,10 @@
1
+ module Blog
2
+ module WheelhouseRouteConstraints
3
+ # Fixes handler route definitions in Wheelhouse 1.0 (fixed in 1.1) to allow
4
+ # route constraints to be set (e.g. match route segments to a regex).
5
+ def define_action(path, action_name, method, options={}, &block)
6
+ define_method(action_name, &block)
7
+ _mapper.match(path, { :via => method, :to => action(action_name) }.merge(options))
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,8 @@
1
1
  require "wheelhouse"
2
2
  require "will_paginate"
3
3
 
4
+ require "blog/wheelhouse_route_constraints"
5
+
4
6
  module Blog
5
7
  class Plugin < Wheelhouse::Plugin
6
8
  config.wheelhouse.blog = ActiveSupport::OrderedOptions.new
@@ -13,7 +15,7 @@ module Blog
13
15
  isolate_namespace Blog
14
16
 
15
17
  resources do
16
- ::Blog::Blog.select(:id, :label).map do |b|
18
+ ::Blog::Blog.sections_for_site(site).map do |b|
17
19
  Resource(::Blog::Post, :sublabel => b.label, :url => blog.new_blog_post_path(b))
18
20
  end
19
21
  end
@@ -21,9 +23,14 @@ module Blog
21
23
  resource { Resource(::Blog::Blog) }
22
24
 
23
25
  sections do
24
- ::Blog::Blog.select(:id, :label).map do |blog|
26
+ ::Blog::Blog.sections_for_site(site).map do |blog|
25
27
  Section(blog.label, blog)
26
28
  end if ::Blog::Plugin.config.wheelhouse.blog.sections
27
29
  end
28
30
  end
31
+
32
+ def self.all_posts_for(site)
33
+ blog_ids = ::Blog::Blog.where(:site_id => site.id).select(:id).map(&:id)
34
+ ::Blog::Post.where(:blog_id.in => blog_ids).published
35
+ end
29
36
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheelhouse-blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
5
- prerelease:
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sam Pohlenz
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-14 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: wheelhouse
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 1.0.1
19
+ version: 1.0.14
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 1.0.1
26
+ version: 1.0.14
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mongomodel
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.4.6
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.4.6
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: will_paginate
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: Integrates blogs into your Wheelhouse CMS site.
@@ -65,6 +58,8 @@ executables: []
65
58
  extensions: []
66
59
  extra_rdoc_files: []
67
60
  files:
61
+ - LICENSE
62
+ - README.md
68
63
  - app/assets/images/wheelhouse-blog/blog.png
69
64
  - app/assets/images/wheelhouse-blog/post.png
70
65
  - app/assets/stylesheets/wheelhouse-blog/admin.css.sass
@@ -74,6 +69,7 @@ files:
74
69
  - app/handlers/blog/post_handler.rb
75
70
  - app/helpers/blog/blog_helper.rb
76
71
  - app/helpers/blog/pagination_helper.rb
72
+ - app/helpers/blog/post_helper.rb
77
73
  - app/models/blog/archive.rb
78
74
  - app/models/blog/blog.rb
79
75
  - app/models/blog/category.rb
@@ -93,32 +89,29 @@ files:
93
89
  - app/views/blog/posts/form.haml
94
90
  - config/locales/en.yml
95
91
  - config/routes.rb
92
+ - lib/blog/wheelhouse_route_constraints.rb
96
93
  - lib/wheelhouse-blog.rb
97
- - README.md
98
- - LICENSE
99
94
  homepage: https://www.wheelhousecms.com
100
95
  licenses: []
96
+ metadata: {}
101
97
  post_install_message:
102
98
  rdoc_options: []
103
99
  require_paths:
104
100
  - lib
105
101
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
102
  requirements:
108
- - - ! '>='
103
+ - - ">="
109
104
  - !ruby/object:Gem::Version
110
105
  version: 1.8.7
111
106
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
107
  requirements:
114
- - - ! '>='
108
+ - - ">="
115
109
  - !ruby/object:Gem::Version
116
110
  version: 1.3.6
117
111
  requirements: []
118
112
  rubyforge_project:
119
- rubygems_version: 1.8.24
113
+ rubygems_version: 2.2.2
120
114
  signing_key:
121
- specification_version: 3
115
+ specification_version: 4
122
116
  summary: Wheelhouse CMS Blog Plugin
123
117
  test_files: []
124
- has_rdoc: