cartoonist-blog 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,14 @@
1
1
  class Admin::BlogController < CartoonistController
2
2
  helper :blog
3
- before_filter :preview!, :only => [:preview]
3
+ before_filter :preview!, :only => [:preview, :archives]
4
4
  before_filter :ensure_ssl!
5
5
  before_filter :check_admin!
6
6
 
7
+ def archives
8
+ @posts = BlogPost.archives true
9
+ render "blog/archives", :layout => "blog_archives"
10
+ end
11
+
7
12
  def preview
8
13
  if params[:id].present?
9
14
  begin
@@ -1,4 +1,12 @@
1
1
  module BlogHelper
2
+ def blog_archives_url
3
+ if preview?
4
+ "/admin/blog/archives"
5
+ else
6
+ "/blog/archives"
7
+ end
8
+ end
9
+
2
10
  def blog_current_url
3
11
  if preview?
4
12
  "/admin/blog/preview"
@@ -4,6 +4,7 @@ class BlogPost < ActiveRecord::Base
4
4
  entity_type :blog
5
5
  entity_global_url "/blog"
6
6
  entity_url &:url
7
+ entity_preview_url &:preview_url
7
8
  entity_edit_url &:edit_url
8
9
  entity_description &:title
9
10
  attr_accessor :for_preview
@@ -19,6 +20,10 @@ class BlogPost < ActiveRecord::Base
19
20
  "/blog/#{url_title}"
20
21
  end
21
22
 
23
+ def preview_url
24
+ "/admin/blog/#{url_title}/preview"
25
+ end
26
+
22
27
  def edit_url
23
28
  "/admin/blog/#{id}/edit"
24
29
  end
@@ -201,8 +206,10 @@ class BlogPost < ActiveRecord::Base
201
206
  post
202
207
  end
203
208
 
204
- def archives
205
- posted.reverse_chronological.select([:url_title, :title, :posted_at]).all
209
+ def archives(preview = false)
210
+ context = BlogPost
211
+ context = posted unless preview
212
+ context.reverse_chronological.select([:url_title, :title, :posted_at]).all
206
213
  end
207
214
 
208
215
  def feed
@@ -3,8 +3,8 @@
3
3
  <ul>
4
4
  <% @posts.each do |post| %>
5
5
  <li>
6
- <%= post.posted_at.localtime.strftime "%m/%d/%Y" %>:
7
- <a href="/blog/<%= post.url_title %>"><%= post.title %></a>
6
+ <%= post.formatted_posted_at "Not Posted", :format => "%m/%d/%Y" %>:
7
+ <a href="<%= post.entity_relative_previewable_url preview? %>"><%= post.title %></a>
8
8
  </li>
9
9
  <% end %>
10
10
  </ul>
@@ -12,6 +12,11 @@
12
12
  <% end %>
13
13
 
14
14
  <% content_for :content do %>
15
+ <% Cartoonist::Entity.hooks_with(:show_entity_before_partial).each do |hook| %>
16
+ <%= render :partial => hook.show_entity_before_partial, :locals => { :entity => @post } %>
17
+ <hr />
18
+ <% end %>
19
+
15
20
  <div class="blog-page">
16
21
  <div class="nav-container">
17
22
  <div class="nav">
@@ -22,7 +27,7 @@
22
27
  <a class="first" href="<%= blog_post_url yield(:first) %>">first</a>
23
28
  <a class="prev" href="<%= blog_post_url yield(:prev) %>">prev</a>
24
29
  <% end %>
25
- <a class="archives" href="/blog/archives">archives</a>
30
+ <a class="archives" href="<%= blog_archives_url %>">archives</a>
26
31
  <% if @disabled_next %>
27
32
  <a class="next-disabled">next</a>
28
33
  <a class="last-disabled">last</a>
@@ -44,7 +49,7 @@
44
49
  <a class="first" href="<%= blog_post_url yield(:first) %>">first</a>
45
50
  <a class="prev" href="<%= blog_post_url yield(:prev) %>">prev</a>
46
51
  <% end %>
47
- <a class="archives" href="/blog/archives">archives</a>
52
+ <a class="archives" href="<%= blog_archives_url %>">archives</a>
48
53
  <% if @disabled_next %>
49
54
  <a class="next-disabled">next</a>
50
55
  <a class="last-disabled">last</a>
@@ -55,6 +60,11 @@
55
60
  </div>
56
61
  </div>
57
62
  </div>
63
+
64
+ <% Cartoonist::Entity.hooks_with(:show_entity_after_partial).each do |hook| %>
65
+ <%= render :partial => hook.show_entity_after_partial, :locals => { :entity => @post } %>
66
+ <hr />
67
+ <% end %>
58
68
  <% end %>
59
69
 
60
70
  <% content_for :post_date_content do %>
@@ -42,6 +42,7 @@ module CartoonistBlog
42
42
  end
43
43
 
44
44
  collection do
45
+ get "archives"
45
46
  get "preview"
46
47
  post "preview_content"
47
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartoonist-blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,19 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-24 00:00:00.000000000 Z
12
+ date: 2012-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cartoonist
16
- requirement: &16264880 !ruby/object:Gem::Requirement
16
+ requirement: &21093000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
20
20
  - !ruby/object:Gem::Version
21
- version: 0.0.10
21
+ version: 0.0.11
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16264880
24
+ version_requirements: *21093000
25
25
  description: This core plugin for Cartoonist adds a simple blog.
26
26
  email: reasonnumber@gmail.com
27
27
  executables: []