spud_blog 0.5.1 → 0.6.0

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.
@@ -11,7 +11,7 @@ Spud.Admin.Posts = new function(){
11
11
  this.edit = function(){
12
12
  $('input[type=submit],.close_dialog').button();
13
13
  initDatePicker();
14
- initWysiwym();
14
+ initTinyMCE();
15
15
  $('#spud_post_new_category_form button').live('click', self.didSubmitCategory);
16
16
  };
17
17
 
@@ -1,9 +1,17 @@
1
1
  class BlogController < ApplicationController
2
2
 
3
- respond_to :html, :xml, :json
4
- before_filter :find_post, :only => [:show]
3
+
4
+ respond_to :html, :xml, :json,:rss
5
+
5
6
  layout Spud::Blog.base_layout
6
7
 
8
+ caches_action :show, :index,
9
+ :layout => false,
10
+ :expires => Spud::Blog.config.caching_expires_in,
11
+ :if => Proc.new{ |c|
12
+ Spud::Blog.config.caching_enabled && !(c.params[:page] && c.params[:page].to_i > 1)
13
+ }
14
+
7
15
  def index
8
16
  @posts = SpudPost.public_blog_posts(params[:page], Spud::Blog.config.posts_per_page)
9
17
  respond_with @posts
@@ -42,6 +50,7 @@ class BlogController < ApplicationController
42
50
  end
43
51
 
44
52
  def show
53
+ find_post
45
54
  if @post.comments_enabled
46
55
  @comment = SpudPostComment.new(:spud_post_id => params[:id])
47
56
  end
@@ -56,7 +65,11 @@ class BlogController < ApplicationController
56
65
  redirect_to blog_path and return false
57
66
  end
58
67
  @comment = @post.comments.new(params[:spud_post_comment])
59
- flash[:notice] = 'Your comment has been posted, however it will not appear until it is approved.' if @comment.save
68
+ @comment.approved = true
69
+ if @comment.save
70
+ flash[:notice] = 'Your comment has been posted, however it will not appear until it is approved.'
71
+ expire_action blog_post_url(@post.url_name)
72
+ end
60
73
  respond_with @comment do |format|
61
74
  format.html { redirect_to blog_post_path(@post.url_name, :anchor => 'spud_post_comment_form') }
62
75
  end
@@ -1,8 +1,15 @@
1
1
  class NewsController < ApplicationController
2
2
 
3
- respond_to :html, :xml, :json
3
+ respond_to :html, :xml, :json,:rss
4
4
  layout Spud::Blog.news_layout
5
5
 
6
+ caches_action :show, :index,
7
+ :layout => false,
8
+ :expires => Spud::Blog.config.caching_expires_in,
9
+ :if => Proc.new{ |c|
10
+ Spud::Blog.config.caching_enabled && !(c.params[:page] && c.params[:page].to_i > 1)
11
+ }
12
+
6
13
  def index
7
14
  @posts = SpudPost.public_news_posts(params[:page], Spud::Blog.config.posts_per_page)
8
15
  respond_with @posts
@@ -19,7 +19,10 @@ class Spud::Admin::NewsPostsController < Spud::Admin::ApplicationController
19
19
 
20
20
  def update
21
21
  @categories = SpudPostCategory.grouped
22
- flash[:notice] = 'News Post was successfully updated.' if @post.update_attributes(params[:spud_post])
22
+ if @post.update_attributes(params[:spud_post])
23
+ flash[:notice] = 'News Post was successfully updated.'
24
+ expire_news_actions(@post)
25
+ end
23
26
  respond_with @post, :location => spud_admin_news_posts_path
24
27
  end
25
28
 
@@ -32,12 +35,18 @@ class Spud::Admin::NewsPostsController < Spud::Admin::ApplicationController
32
35
  def create
33
36
  @categories = SpudPostCategory.grouped
34
37
  @post = SpudPost.new(params[:spud_post])
35
- flash[:notice] = 'News Post was successfully created.' if @post.save
38
+ if @post.save
39
+ flash[:notice] = 'News Post was successfully created.'
40
+ expire_news_actions
41
+ end
36
42
  respond_with @post, :location => spud_admin_news_posts_path
37
43
  end
38
44
 
39
45
  def destroy
40
- flash[:notice] = 'News Post was successfully deleted.' if @post.destroy
46
+ if @post.destroy
47
+ flash[:notice] = 'News Post was successfully deleted.'
48
+ expire_news_actions(@post)
49
+ end
41
50
  respond_with @post, :location => spud_admin_news_posts_path
42
51
  end
43
52
 
@@ -51,4 +60,9 @@ class Spud::Admin::NewsPostsController < Spud::Admin::ApplicationController
51
60
  end
52
61
  end
53
62
 
63
+ def expire_news_actions
64
+ expire_action news_url
65
+ expire_action news_post_url(@post.url_name) unless @post.nil?
66
+ end
67
+
54
68
  end
@@ -17,7 +17,10 @@ class Spud::Admin::PostCategoriesController < Spud::Admin::ApplicationController
17
17
  end
18
18
 
19
19
  def update
20
- flash[:notice] = 'Post Category was successfully updated' if @post_category.update_attributes(params[:spud_post_category])
20
+ if @post_category.update_attributes(params[:spud_post_category])
21
+ flash[:notice] = 'Post Category was successfully updated'
22
+ expire_post_actions
23
+ end
21
24
  respond_with @post_category, :location => spud_admin_post_categories_path
22
25
  end
23
26
 
@@ -28,12 +31,18 @@ class Spud::Admin::PostCategoriesController < Spud::Admin::ApplicationController
28
31
 
29
32
  def create
30
33
  @post_category = SpudPostCategory.new(params[:spud_post_category])
31
- flash[:notice] = 'Post Category was successfully created' if @post_category.save
34
+ if @post_category.save
35
+ flash[:notice] = 'Post Category was successfully created'
36
+ expire_post_actions
37
+ end
32
38
  respond_with @post_category, :location => spud_admin_post_categories_path
33
39
  end
34
40
 
35
41
  def destroy
36
- flash[:notice] = 'Post Category was successfully deleted' if @post_category.destroy
42
+ if @post_category.destroy
43
+ flash[:notice] = 'Post Category was successfully deleted'
44
+ expire_post_actions
45
+ end
37
46
  respond_with @post_category, :location => spud_admin_post_categories_path
38
47
  end
39
48
 
@@ -43,4 +52,9 @@ class Spud::Admin::PostCategoriesController < Spud::Admin::ApplicationController
43
52
  @post_category = SpudPostCategory.find(params[:id])
44
53
  end
45
54
 
55
+ def expire_post_actions
56
+ expire_action news_url
57
+ expire_action blog_url
58
+ end
59
+
46
60
  end
@@ -8,7 +8,7 @@ class Spud::Admin::PostsController < Spud::Admin::ApplicationController
8
8
  belongs_to_spud_app :blog_posts
9
9
 
10
10
  def index
11
- @posts = SpudPost.where(:is_news => false).order('published_at desc').includes(:comments).paginate(:page => params[:page], :per_page => 15)
11
+ @posts = SpudPost.where(:is_news => false).order('published_at desc').includes(:comments, :author).paginate(:page => params[:page], :per_page => 15)
12
12
  respond_with @posts
13
13
  end
14
14
 
@@ -19,7 +19,10 @@ class Spud::Admin::PostsController < Spud::Admin::ApplicationController
19
19
 
20
20
  def update
21
21
  @categories = SpudPostCategory.grouped
22
- flash[:notice] = 'Post was successfully updated.' if @post.update_attributes(params[:spud_post])
22
+ if @post.update_attributes(params[:spud_post])
23
+ flash[:notice] = 'Post was successfully updated.'
24
+ expire_blog_actions
25
+ end
23
26
  respond_with @post, :location => spud_admin_posts_path
24
27
  end
25
28
 
@@ -32,12 +35,18 @@ class Spud::Admin::PostsController < Spud::Admin::ApplicationController
32
35
  def create
33
36
  @categories = SpudPostCategory.grouped
34
37
  @post = SpudPost.new(params[:spud_post])
35
- flash[:notice] = 'Post was successfully created.' if @post.save
38
+ if @post.save
39
+ flash[:notice] = 'Post was successfully created.'
40
+ expire_blog_actions
41
+ end
36
42
  respond_with @post, :location => spud_admin_posts_path
37
43
  end
38
44
 
39
45
  def destroy
40
- flash[:notice] = 'Post was successfully deleted.' if @post.destroy
46
+ if @post.destroy
47
+ flash[:notice] = 'Post was successfully deleted.'
48
+ expire_blog_actions
49
+ end
41
50
  respond_with @post, :location => spud_admin_posts_path
42
51
  end
43
52
 
@@ -51,4 +60,9 @@ class Spud::Admin::PostsController < Spud::Admin::ApplicationController
51
60
  end
52
61
  end
53
62
 
63
+ def expire_blog_actions
64
+ expire_action blog_url
65
+ expire_action blog_post_url(@post.url_name) unless @post.nil?
66
+ end
67
+
54
68
  end
@@ -1,6 +1,6 @@
1
1
  class Spud::Blog::SitemapsController < Spud::ApplicationController
2
2
  respond_to :xml
3
- caches_page :show,:expires_in => 1.day
3
+ caches_action :show, :expires_in => 1.day
4
4
  def show
5
5
  @posts = SpudPost.publicly.all
6
6
  respond_with @pages
@@ -1,3 +1,6 @@
1
+ <%=content_for :head do%>
2
+ <link rel="alternate" type="application/rss+xml" title="<%=Spud::Core.site_name%> Blog RSS" href="<%=blog_url()%>" />
3
+ <%end%>
1
4
  <div id="spud_blog_filters">
2
5
  <%= form_tag blog_path, :class => 'spud_blog_filter_form' do %>
3
6
  <label>Category:</label>
@@ -0,0 +1,18 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title "#{Spud::Core.site_name} Blog Articles"
5
+ xml.description "Blog articles for #{Spud::Core.site_name}"
6
+ xml.link news_url(:format => :rss)
7
+
8
+ for article in @posts
9
+ xml.item do
10
+ xml.title article.title
11
+ xml.description article.content
12
+ xml.pubDate article.created_at.to_s(:rfc822)
13
+ xml.link news_post_url(article.url_name)
14
+ xml.guid news_post_url(article.url_name)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,6 @@
1
+ <%=content_for :head do%>
2
+ <link rel="alternate" type="application/rss+xml" title="<%=Spud::Core.site_name%> News RSS" href="<%=news_url()%>" />
3
+ <%end%>
1
4
  <div id="spud_news_filters">
2
5
  <%= form_tag news_path, :class => 'spud_blog_filter_form' do %>
3
6
  <label>Category:</label>
@@ -0,0 +1,18 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title "#{Spud::Core.site_name} News"
5
+ xml.description "News articles for #{Spud::Core.site_name}"
6
+ xml.link news_url(:format => :rss)
7
+
8
+ for article in @posts
9
+ xml.item do
10
+ xml.title article.title
11
+ xml.description article.content
12
+ xml.pubDate article.created_at.to_s(:rfc822)
13
+ xml.link news_post_url(article.url_name)
14
+ xml.guid news_post_url(article.url_name)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -17,7 +17,7 @@
17
17
  <tr>
18
18
  <td><%= link_to post.title, edit_spud_admin_news_post_path(post) %></td>
19
19
  <td><%= post.author.full_name %></td>
20
- <td><%= post.published_at.strftime('%m/%d/%Y') %></td>
20
+ <td><%= link_to(post.published_at.strftime('%m/%d/%Y'), news_post_path(post.url_name)) %></td>
21
21
  <td align="right">
22
22
  <%= link_to 'Delete', spud_admin_news_post_path(post), :method => :delete, :confirm => 'Are you sure you want to delete this post?', :class => 'spud_admin_button_delete' %>
23
23
  </td>
@@ -1,3 +1,3 @@
1
- <%= form_for @post, :url => spud_admin_news_post_path, :html => {:class => 'right_aligned_form'} do |f| %>
1
+ <%= form_for @post, :url => spud_admin_news_posts_path, :html => {:class => 'right_aligned_form'} do |f| %>
2
2
  <%= render :partial => '/spud/admin/posts/form', :locals => {:f => f} %>
3
3
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= form_for @post_category, :url => spud_admin_post_category_path(@post_category), :html => {:class => 'right_aligned_form'} do |f| %>
1
+ <%= form_for @post_category, :url => path, :html => {:class => 'right_aligned_form'} do |f| %>
2
2
 
3
3
  <% if @post_category.errors.any? %>
4
4
  <div class="spud_admin_form_error_list">
@@ -1 +1 @@
1
- <%= render 'form' %>
1
+ <%= render :partial => 'form', :locals => {:path => spud_admin_post_category_path(@post_category)} %>
@@ -1 +1 @@
1
- <%= render 'form' %>
1
+ <%= render :partial => 'form', :locals => {:path => spud_admin_post_categories_path} %>
@@ -18,7 +18,7 @@
18
18
 
19
19
  <div>
20
20
  <%= f.label :content %>
21
- <%= f.text_area :content, :class => 'wysiwym' %>
21
+ <%= f.text_area :content, :class => 'wysiwym tinymce' %>
22
22
  </div>
23
23
 
24
24
  <fieldset>
@@ -28,6 +28,15 @@
28
28
  </ul>
29
29
  </fieldset>
30
30
 
31
+ <% if Spud::Blog.config.has_custom_fields %>
32
+ <fieldset>
33
+ <legend>Custom Fields</legend>
34
+ <ol>
35
+ <%= render :partial => '/spud/admin/posts/custom_fields', :locals => {:f => f} %>
36
+ </ol>
37
+ </fieldset>
38
+ <% end %>
39
+
31
40
  <fieldset>
32
41
  <legend>Advanced</legend>
33
42
  <ol>
@@ -18,7 +18,7 @@
18
18
  <tr>
19
19
  <td><%= link_to post.title, edit_spud_admin_post_path(post) %></td>
20
20
  <td><%= post.author.full_name %></td>
21
- <td><%= post.published_at.strftime('%m/%d/%Y') %></td>
21
+ <td><%= link_to(post.published_at.strftime('%m/%d/%Y'), blog_post_path(post.url_name)) %></td>
22
22
  <td><%= post.comments.size %></td>
23
23
  <td align="right">
24
24
  <%= link_to 'Delete', spud_admin_post_path(post), :method => :delete, :confirm => 'Are you sure you want to delete this post?', :class => 'spud_admin_button_delete' %>
@@ -1,3 +1,3 @@
1
- <%= form_for @post, :url => spud_admin_post_path, :html => {:class => 'right_aligned_form'} do |f| %>
1
+ <%= form_for @post, :url => spud_admin_posts_path, :html => {:class => 'right_aligned_form'} do |f| %>
2
2
  <%= render :partial => 'form', :locals => {:f => f} %>
3
3
  <% end %>
@@ -1,8 +1,7 @@
1
1
  module Spud
2
2
  module Blog
3
3
  include ActiveSupport::Configurable
4
- config_accessor :base_layout,:news_layout, :blog_enabled, :news_enabled, :posts_per_page, :blog_path, :news_path,:enable_sitemap
5
-
4
+ config_accessor :base_layout,:news_layout, :blog_enabled, :news_enabled, :posts_per_page, :blog_path, :news_path, :enable_sitemap, :has_custom_fields, :caching_enabled, :caching_expires_in
6
5
  self.base_layout = 'application'
7
6
  self.news_layout = nil
8
7
  self.news_enabled = false
@@ -11,5 +10,8 @@ module Spud
11
10
  self.blog_path = 'blog'
12
11
  self.news_path = 'news'
13
12
  self.enable_sitemap = true
13
+ self.has_custom_fields = false
14
+ self.caching_enabled = true
15
+ self.caching_expires_in = 1.hour
14
16
  end
15
- end
17
+ end
@@ -24,7 +24,7 @@ module Spud
24
24
  if Spud::Blog.config.news_enabled
25
25
  Spud::Core.config.admin_applications += [{
26
26
  :name => 'News Posts',
27
- :thumbnail => 'spud/admin/posts_thumb.png',
27
+ :thumbnail => 'spud/admin/news_thumb.png',
28
28
  :url => '/spud/admin/news_posts',
29
29
  :order => 2
30
30
  }]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spud_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,36 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000 Z
12
+ date: 2012-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spud_core
16
- requirement: &70274549294540 !ruby/object:Gem::Requirement
16
+ requirement: &70347903377340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.5.2
21
+ version: 0.6.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70274549294540
25
- - !ruby/object:Gem::Dependency
26
- name: will_paginate
27
- requirement: &70274549294060 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70274549294060
24
+ version_requirements: *70347903377340
36
25
  description:
37
26
  email: greg@westlakedesign.com
38
27
  executables: []
39
28
  extensions: []
40
29
  extra_rdoc_files: []
41
30
  files:
31
+ - app/assets/images/spud/admin/news_thumb.png
32
+ - app/assets/images/spud/admin/posts_thumb.png
42
33
  - app/assets/javascripts/spud/admin/news_posts.js
43
34
  - app/assets/javascripts/spud/admin/post_categories.js
44
35
  - app/assets/javascripts/spud/admin/post_comments.js
@@ -71,9 +62,11 @@ files:
71
62
  - app/views/blog/_comment.html.erb
72
63
  - app/views/blog/_comment_form.html.erb
73
64
  - app/views/blog/index.html.erb
65
+ - app/views/blog/index.rss.builder
74
66
  - app/views/blog/show.html.erb
75
67
  - app/views/layouts/spud/admin/post.html.erb
76
68
  - app/views/news/index.html.erb
69
+ - app/views/news/index.rss.builder
77
70
  - app/views/news/show.html.erb
78
71
  - app/views/spud/admin/news_posts/edit.html.erb
79
72
  - app/views/spud/admin/news_posts/index.html.erb