cartoonist-blog 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,25 +36,16 @@ class BlogController < CartoonistController
36
36
  format.html { redirect_to "/blog/feed" }
37
37
 
38
38
  format.rss do
39
- @feed = feed_content
40
- render :content_type => "application/xml", :layout => "cartoonist"
39
+ @feed = BlogFeed.new BlogPost.feed
40
+
41
+ cache_page_as "blog/feed.#{cache_type}.tmp.rss" do
42
+ render :content_type => "application/xml", :layout => "cartoonist"
43
+ end
41
44
  end
42
45
  end
43
46
  end
44
47
 
45
48
  private
46
- def feed_content
47
- result = blog_cache.read "blog-feed"
48
- return result if result
49
- result = BlogFeed.new BlogPost.feed
50
- blog_cache.write "blog-feed", result
51
- result
52
- end
53
-
54
- def blog_cache
55
- @@blog_cache ||= ActiveSupport::Cache::MemoryStore.new(:expires_in => 2.hours)
56
- end
57
-
58
49
  def show_page_cache_path
59
50
  if @disabled_next
60
51
  "blog/#{@post.url_title}.#{cache_type}.tmp.html"
@@ -1,20 +1,10 @@
1
1
  module Admin::BlogHelper
2
- def lock_toggle_target
3
- if @post.locked
4
- "unlock"
5
- else
6
- "lock"
7
- end
8
- end
9
-
10
2
  def lock_disabled
11
- if @post.locked
12
- 'disabled="disabled"'.html_safe
13
- end
3
+ @post.lock_disabled_html
14
4
  end
15
5
 
16
6
  def post_lock_disabled
17
- if @post.locked || @post.posted?
7
+ if @post.locked? || @post.posted?
18
8
  'disabled="disabled"'.html_safe
19
9
  end
20
10
  end
@@ -1,6 +1,7 @@
1
1
  class BlogPost < ActiveRecord::Base
2
2
  include Postable
3
3
  include Entity
4
+ include Lockable
4
5
  entity_type :blog
5
6
  entity_global_url "/blog"
6
7
  entity_url &:url
@@ -28,16 +29,6 @@ class BlogPost < ActiveRecord::Base
28
29
  "/admin/blog/#{id}/edit"
29
30
  end
30
31
 
31
- def lock!
32
- self.locked = true
33
- save!
34
- end
35
-
36
- def unlock!
37
- self.locked = false
38
- save!
39
- end
40
-
41
32
  def first_post
42
33
  return @first_post if @first_post_retrieved
43
34
  @first_post_retrieved = true
@@ -125,29 +116,14 @@ class BlogPost < ActiveRecord::Base
125
116
 
126
117
  def update_post(params)
127
118
  post = find params[:id].to_i
128
- raise "Cannot update locked post!" if post.locked
119
+ post.ensure_unlocked!
129
120
  original_url_title = post.url_title
130
121
  post.title = params[:title]
131
122
  post.url_title = url_titlize params[:title]
132
123
  post.author = params[:author]
133
124
  post.content = params[:content]
134
125
  post.locked = true
135
-
136
- if params[:post_now].present? && !post.posted?
137
- post.posted_at = Time.now
138
- elsif params[:post_in_hour].present? && !post.posted?
139
- post.posted_at = 1.hour.from_now
140
- elsif params[:posted] && params[:posted_at_date].present?
141
- time = "#{params[:posted_at_date]} #{params[:posted_at_hour]}:#{params[:posted_at_minute]} #{params[:posted_at_meridiem]}"
142
- time = DateTime.parse time
143
- time = Time.local time.year, time.month, time.day, time.hour, time.min
144
- post.posted_at = time
145
- elsif params[:posted]
146
- post.posted_at = 1.hour.from_now
147
- else
148
- post.posted_at = nil
149
- end
150
-
126
+ post.post_from params
151
127
  post.save!
152
128
  post
153
129
  end
@@ -1,5 +1,5 @@
1
1
  <% Cartoonist::Entity.hooks_with(:edit_entity_before_partial).each do |hook| %>
2
- <%= render :partial => hook.edit_entity_before_partial, :locals => { :entity => @post } %>
2
+ <%= partial hook.edit_entity_before_partial, :entity => @post %>
3
3
  <hr />
4
4
  <% end %>
5
5
 
@@ -8,31 +8,14 @@
8
8
  </p>
9
9
 
10
10
  <p>
11
- <%= form_tag "/admin/blog/#{@post.id}/#{lock_toggle_target}", :method => :post do %>
12
- <input type="submit" value="<%= lock_toggle_target %>" />
11
+ <%= form_tag "/admin/blog/#{@post.id}/#{@post.toggle_lock_target}", :method => :post do %>
12
+ <input type="submit" value="<%= @post.toggle_lock_target %>" />
13
13
  <% end %>
14
14
  </p>
15
15
 
16
16
  <%= form_tag "/admin/blog/#{@post.id}", :method => :put do %>
17
17
  <p>
18
- <label><input type="checkbox" name="posted" value="true" <%= checked="checked".html_safe if @post.posted_at %> <%= lock_disabled %> />Posted at</label>
19
- <input type="text" name="posted_at_date" value="<%= format_posted_at "%Y-%m-%d" %>" <%= lock_disabled %> />
20
- <select name="posted_at_hour" <%= lock_disabled %>>
21
- <% 1.upto 12 do |h| %>
22
- <option value="<%= h %>" <%= selected h, format_posted_at("%-l").to_i %>><%= h %></option>
23
- <% end %>
24
- </select>
25
- <select name="posted_at_minute" <%= lock_disabled %>>
26
- <% 0.upto 60 do |m| %>
27
- <option value="<%= m %>" <%= selected m, format_posted_at("%-M").to_i %>><%= m %></option>
28
- <% end %>
29
- </select>
30
- <select name="posted_at_meridiem" <%= lock_disabled %>>
31
- <option value="am" <%= selected "am", format_posted_at("%P") %>>am</option>
32
- <option value="pm" <%= selected "pm", format_posted_at("%P") %>>pm</option>
33
- </select>
34
- <input type="submit" name="post_now" value="Post Now" <%= post_lock_disabled %> />
35
- <input type="submit" name="post_in_hour" value="Post in an Hour" <%= post_lock_disabled %> />
18
+ <%= partial "shared/post_date_time", :postable => @post %>
36
19
  </p>
37
20
 
38
21
  <p>
@@ -72,5 +55,5 @@
72
55
 
73
56
  <% Cartoonist::Entity.hooks_with(:edit_entity_after_partial).each do |hook| %>
74
57
  <hr />
75
- <%= render :partial => hook.edit_entity_after_partial, :locals => { :entity => @post } %>
58
+ <%= partial hook.edit_entity_after_partial, :entity => @post %>
76
59
  <% end %>
@@ -13,7 +13,7 @@
13
13
 
14
14
  <% content_for :content do %>
15
15
  <% Cartoonist::Entity.hooks_with(:show_entity_before_partial).each do |hook| %>
16
- <%= render :partial => hook.show_entity_before_partial, :locals => { :entity => @post } %>
16
+ <%= partial hook.show_entity_before_partial, :entity => @post %>
17
17
  <hr />
18
18
  <% end %>
19
19
 
@@ -62,7 +62,7 @@
62
62
  </div>
63
63
 
64
64
  <% Cartoonist::Entity.hooks_with(:show_entity_after_partial).each do |hook| %>
65
- <%= render :partial => hook.show_entity_after_partial, :locals => { :entity => @post } %>
65
+ <%= partial hook.show_entity_after_partial, :entity => @post %>
66
66
  <hr />
67
67
  <% end %>
68
68
  <% end %>
@@ -2,7 +2,7 @@ module CartoonistBlog
2
2
  class Version
3
3
  class << self
4
4
  def to_s
5
- "0.0.16"
5
+ "0.0.17"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,59 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cartoonist-blog
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.17
4
5
  prerelease:
5
- version: 0.0.16
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Mike Virata-Stone
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-12-15 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: jquery-rails
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
20
+ - !ruby/object:Gem::Version
23
21
  version: 2.1.4
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: jquery-ui-rails
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
30
25
  none: false
31
- requirements:
26
+ requirements:
32
27
  - - ~>
33
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ version: 2.1.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: jquery-ui-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
34
37
  version: 2.0.2
35
38
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: cartoonist
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - "="
44
- - !ruby/object:Gem::Version
45
- version: 0.0.16
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.0.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: cartoonist
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.17
46
54
  type: :runtime
47
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.17
48
62
  description: This core plugin for Cartoonist adds a simple blog.
49
63
  email: reasonnumber@gmail.com
50
64
  executables: []
51
-
52
65
  extensions: []
53
-
54
66
  extra_rdoc_files: []
55
-
56
- files:
67
+ files:
57
68
  - app/assets/javascripts/admin/blog.js.coffee
58
69
  - app/assets/stylesheets/admin/blog.css.scss
59
70
  - app/controllers/admin/blog_controller.rb
@@ -79,30 +90,26 @@ files:
79
90
  - lib/cartoonist-blog/version.rb
80
91
  homepage: http://reasonnumber.com/cartoonist
81
92
  licenses: []
82
-
83
93
  post_install_message:
84
94
  rdoc_options: []
85
-
86
- require_paths:
95
+ require_paths:
87
96
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
97
+ required_ruby_version: !ruby/object:Gem::Requirement
89
98
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
104
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
100
109
  requirements: []
101
-
102
110
  rubyforge_project:
103
111
  rubygems_version: 1.8.24
104
112
  signing_key:
105
113
  specification_version: 3
106
114
  summary: Cartoonist Blog
107
115
  test_files: []
108
-