comfy_blog 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/README.md +48 -6
  2. data/VERSION +1 -1
  3. data/app/controllers/admin/blog/base_controller.rb +3 -0
  4. data/app/controllers/{blog/admin → admin/blog}/comments_controller.rb +1 -1
  5. data/app/controllers/{blog/admin → admin/blog}/posts_controller.rb +7 -7
  6. data/app/controllers/admin/blog/tags_controller.rb +56 -0
  7. data/app/controllers/blog/comments_controller.rb +35 -0
  8. data/app/controllers/blog/posts_controller.rb +8 -1
  9. data/app/helpers/blog/application_helper.rb +5 -2
  10. data/app/models/blog/comment.rb +11 -1
  11. data/app/models/blog/post.rb +8 -4
  12. data/app/models/blog/tag.rb +3 -3
  13. data/app/models/blog/tagging.rb +1 -1
  14. data/app/views/{blog/admin → admin/blog}/_html_head.html.erb +0 -0
  15. data/app/views/admin/blog/_navigation.html.erb +2 -0
  16. data/app/views/{blog/admin → admin/blog}/comments/_comment.html.erb +2 -2
  17. data/app/views/{blog/admin → admin/blog}/comments/destroy.js.erb +0 -0
  18. data/app/views/{blog/admin → admin/blog}/comments/index.html.erb +3 -1
  19. data/app/views/{blog/admin → admin/blog}/comments/publish.js.erb +0 -0
  20. data/app/views/{blog/admin → admin/blog}/posts/_form.html.erb +11 -0
  21. data/app/views/{blog/admin → admin/blog}/posts/_post.html.erb +4 -4
  22. data/app/views/{blog/admin → admin/blog}/posts/edit.html.erb +0 -0
  23. data/app/views/admin/blog/posts/index.html.erb +11 -0
  24. data/app/views/{blog/admin → admin/blog}/posts/new.html.erb +0 -0
  25. data/app/views/admin/blog/tags/_form.html.erb +20 -0
  26. data/app/views/admin/blog/tags/_tag.html.erb +16 -0
  27. data/app/views/admin/blog/tags/edit.html.erb +5 -0
  28. data/app/views/admin/blog/tags/index.html.erb +9 -0
  29. data/app/views/admin/blog/tags/new.html.erb +5 -0
  30. data/app/views/blog/comments/_comment.html.erb +4 -0
  31. data/app/views/blog/comments/_form.html.erb +6 -0
  32. data/app/views/blog/comments/create.js.erb +6 -0
  33. data/app/views/blog/posts/_post.html.erb +2 -12
  34. data/app/views/blog/posts/index.rss.builder +18 -0
  35. data/app/views/blog/posts/show.html.erb +9 -1
  36. data/comfy_blog.gemspec +33 -18
  37. data/config/initializers/comfy_blog.rb +7 -0
  38. data/config/initializers/wrap_parameters.rb +1 -1
  39. data/config/routes.rb +9 -7
  40. data/db/migrate/01_create_comfy_blog.rb +4 -5
  41. data/db/schema.rb +8 -9
  42. data/lib/comfy_blog/configuration.rb +20 -6
  43. data/lib/comfy_blog/engine.rb +6 -6
  44. data/lib/comfy_blog.rb +1 -1
  45. data/lib/generators/README +6 -6
  46. data/lib/generators/blog_generator.rb +3 -3
  47. data/lib/tasks/comfy_blog.rake +4 -0
  48. data/test/fixtures/blog/tags.yml +5 -0
  49. data/test/functional/{blog/admin → admin/blog}/comments_controller_test.rb +1 -1
  50. data/test/functional/{blog/admin → admin/blog}/posts_controller_test.rb +6 -8
  51. data/test/functional/admin/blog/tags_controller_test.rb +88 -0
  52. data/test/functional/blog/comments_controller_test.rb +78 -0
  53. data/test/functional/blog/posts_controller_test.rb +8 -0
  54. data/test/integration/routing_test.rb +26 -0
  55. data/test/test_helper.rb +9 -6
  56. data/test/unit/comment_test.rb +13 -1
  57. data/test/unit/configuration_test.rb +8 -5
  58. data/test/unit/post_test.rb +19 -0
  59. data/test/unit/tag_test.rb +2 -1
  60. metadata +42 -27
  61. data/app/controllers/blog/admin/base_controller.rb +0 -3
  62. data/app/views/blog/admin/_navigation.html.erb +0 -1
  63. data/app/views/blog/admin/posts/index.html.erb +0 -9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # ComfyBlog
1
+ # ComfyBlog [![Build Status](https://secure.travis-ci.org/comfy/comfy-blog.png)](http://travis-ci.org/comfy/comfy-blog) [![Dependency Status](https://gemnasium.com/comfy/comfy-blog.png)](https://gemnasium.com/comfy/comfy-blog)
2
2
 
3
- ComfyBlog is an simple blog management engine for Rails 3.1 apps. As a bonus it integrates seamlessly with [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) CMS Engine
3
+ ComfyBlog is an simple blog management engine for Rails 3.1 apps. It also integrates with [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) CMS Engine
4
4
 
5
5
  ## Installation
6
6
 
@@ -13,11 +13,53 @@ Then from the Rails project's root run:
13
13
  bundle install
14
14
  rails g blog
15
15
  rake db:migrate
16
+
17
+ Now you should be able to go to `/admin/blog/posts` and add new blog posts.
18
+
19
+ ## Configuration
20
+
21
+ First thing you want to do is change title and description of the blog.
22
+ For that you need to adjust `comfy_blog` initializer.
23
+
24
+ config.title = 'ComfyBlog'
25
+ config.description = 'A Simple Blog'
26
+
27
+ You'll notice that you can access blog's admin area without any type of authentication.
28
+ This is because ComfyBlog doesn't deal with users, it only knows how to save and show
29
+ blog posts. You probably want to put blog's admin controllers behind your controller
30
+ that handles authentication.
31
+
32
+ config.admin_controller = 'YourAdminBaseController'
33
+
34
+ If you want blog's controller paths to match your admin path, like `cms-admin`. Change
35
+ the following configuration.
36
+
37
+ config.admin_route_prefix = 'cms-admin'
38
+
39
+ By default blog posts are served from the root. If you want to section off blog content
40
+ to a `/blog` path. Adjust this configuration:
41
+
42
+ config.public_route_prefix = 'blog'
43
+
44
+ Provided views to display blog posts are pretty basic and you'll probably want to change
45
+ them right away. You can change the layout from the default `application` to something else.
46
+
47
+ config.public_layout = 'blog'
48
+
49
+ Since ComfyBlog is an engine, it allows you to completely overwrite views. It's enough to
50
+ create `app/views/blog/posts/index.html.erb` (could be HAML or whatever you want) and structure
51
+ it in any way you want. There's also `show.html.erb` and `_post.html.erb` available.
52
+
53
+ You can control number of posts per page by adjusting this config:
54
+
55
+ config.posts_per_page = 10
56
+
57
+ Posted comments will be sitting in the queue waiting to be published. You can auto publish them
58
+ by setting this to `true`:
16
59
 
17
- ## Usage
60
+ config.auto_publish_comments = true
18
61
 
19
- TODO
20
62
 
21
- Sofa Blog is released under the [MIT license](https://github.com/comfy/comfy-blog/raw/master/LICENSE)
63
+ ComfyBlog is released under the [MIT license](https://github.com/comfy/comfy-blog/raw/master/LICENSE)
22
64
 
23
- Copyright 2011 Oleg Khabarov, [The Working Group Inc](http://www.twg.ca)
65
+ Copyright 2012 Oleg Khabarov, [The Working Group Inc](http://www.twg.ca)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.0
@@ -0,0 +1,3 @@
1
+ class Admin::Blog::BaseController < ComfyBlog.config.admin_controller.to_s.constantize
2
+ # ...
3
+ end
@@ -1,4 +1,4 @@
1
- class Blog::Admin::CommentsController < Blog::Admin::BaseController
1
+ class Admin::Blog::CommentsController < Admin::Blog::BaseController
2
2
 
3
3
  before_filter :load_post, :only => [:index]
4
4
  before_filter :load_comment, :only => [:destroy, :publish]
@@ -1,4 +1,4 @@
1
- class Blog::Admin::PostsController < Blog::Admin::BaseController
1
+ class Admin::Blog::PostsController < Admin::Blog::BaseController
2
2
 
3
3
  before_filter :build_post, :only => [:new, :create]
4
4
  before_filter :load_post, :only => [:edit, :update, :destroy]
@@ -13,11 +13,11 @@ class Blog::Admin::PostsController < Blog::Admin::BaseController
13
13
 
14
14
  def create
15
15
  @post.save!
16
- flash.now[:notice] = 'Blog Post created'
17
- render :action => :new
16
+ flash[:notice] = 'Blog Post created'
17
+ redirect_to :action => :edit, :id => @post
18
18
 
19
19
  rescue ActiveRecord::RecordInvalid
20
- flash.now[:error] = 'Failed to create Blog Post'
20
+ flash[:error] = 'Failed to create Blog Post'
21
21
  render :action => :new
22
22
  end
23
23
 
@@ -27,11 +27,11 @@ class Blog::Admin::PostsController < Blog::Admin::BaseController
27
27
 
28
28
  def update
29
29
  @post.update_attributes!(params[:post])
30
- flash.now[:notice] = 'Blog Post updated'
31
- render :action => :edit
30
+ flash[:notice] = 'Blog Post updated'
31
+ redirect_to :action => :edit, :id => @post
32
32
 
33
33
  rescue ActiveRecord::RecordInvalid
34
- flash.now[:error] = 'Failed to update Blog Post'
34
+ flash[:error] = 'Failed to update Blog Post'
35
35
  render :action => :edit
36
36
  end
37
37
 
@@ -0,0 +1,56 @@
1
+ class Admin::Blog::TagsController < Admin::Blog::BaseController
2
+
3
+ before_filter :build_tag, :only => [:new, :create]
4
+ before_filter :load_tag, :only => [:edit, :update, :destroy]
5
+
6
+ def index
7
+ @tags = Blog::Tag.order('is_category DESC', :name)
8
+ end
9
+
10
+ def edit
11
+ render
12
+ end
13
+
14
+ def new
15
+ render
16
+ end
17
+
18
+ def update
19
+ @tag.update_attributes!(params[:tag])
20
+ flash[:notice] = 'Blog Tag updated'
21
+ redirect_to :action => :index
22
+
23
+ rescue ActiveRecord::RecordInvalid
24
+ flash[:error] = 'Failed to update Blog Tag'
25
+ render :action => :edit
26
+ end
27
+
28
+ def create
29
+ @tag.save!
30
+ flash[:notice] = 'Blog Tag created'
31
+ redirect_to :action => :index
32
+
33
+ rescue ActiveRecord::RecordInvalid
34
+ flash[:error] = 'Failed to create Blog Tag'
35
+ render :action => :new
36
+ end
37
+
38
+ def destroy
39
+ @tag.destroy
40
+ flash[:notice] = 'Blog Tag removed'
41
+ redirect_to :action => :index
42
+ end
43
+
44
+ protected
45
+
46
+ def build_tag
47
+ @tag = Blog::Tag.new(params[:tag])
48
+ end
49
+
50
+ def load_tag
51
+ @tag = Blog::Tag.find(params[:id])
52
+ rescue ActiveRecord::RecordNotFound
53
+ flash[:error] = 'Blog Tag not found'
54
+ redirect_to :action => :index
55
+ end
56
+ end
@@ -0,0 +1,35 @@
1
+ class Blog::CommentsController < ApplicationController
2
+
3
+ def create
4
+ @post = Blog::Post.published.find(params[:post_id])
5
+ @comment = @post.comments.new(params[:comment])
6
+ @comment.save!
7
+
8
+ respond_to do |f|
9
+ f.html do
10
+ flash[:notice] = 'Comment created'
11
+ redirect_to dated_blog_post_path(@post.year, @post.month, @post.slug)
12
+ end
13
+ f.js
14
+ end
15
+
16
+ rescue ActiveRecord::RecordNotFound
17
+ respond_to do |f|
18
+ f.html do
19
+ flash[:error] = 'Blog Post not found'
20
+ redirect_to blog_posts_path
21
+ end
22
+ f.js do
23
+ render :nothing => true, :status => 404
24
+ end
25
+ end
26
+
27
+ rescue ActiveRecord::RecordInvalid
28
+ respond_to do |f|
29
+ f.html do
30
+ render 'blog/posts/show'
31
+ end
32
+ f.js
33
+ end
34
+ end
35
+ end
@@ -14,7 +14,14 @@ class Blog::PostsController < ApplicationController
14
14
  Blog::Post.published
15
15
  end
16
16
 
17
- @posts = scope.paginate :per_page => ComfyBlog.config.posts_per_page, :page => params[:page]
17
+ respond_to do |f|
18
+ f.html do
19
+ @posts = scope.paginate :per_page => ComfyBlog.config.posts_per_page, :page => params[:page]
20
+ end
21
+ f.rss do
22
+ @posts = scope.limit(ComfyBlog.config.posts_per_page)
23
+ end
24
+ end
18
25
  end
19
26
 
20
27
  def show
@@ -9,8 +9,11 @@ module Blog::ApplicationHelper
9
9
  )
10
10
  end
11
11
 
12
- def blog_post_path(post)
13
-
12
+ # URL helpers for blog_post_(path/url)
13
+ %w(path url).each do |type|
14
+ define_method "blog_post_#{type}" do |post|
15
+ send("dated_blog_post_#{type}", post.year, post.month, post.slug)
16
+ end
14
17
  end
15
18
 
16
19
  end
@@ -1,6 +1,6 @@
1
1
  class Blog::Comment < ActiveRecord::Base
2
2
 
3
- set_table_name :blog_comments
3
+ self.table_name = :blog_comments
4
4
 
5
5
  attr_accessible :author,
6
6
  :email,
@@ -8,6 +8,9 @@ class Blog::Comment < ActiveRecord::Base
8
8
 
9
9
  # -- Relationships --------------------------------------------------------
10
10
  belongs_to :post
11
+
12
+ # -- Callbacks ------------------------------------------------------------
13
+ before_create :set_publish
11
14
 
12
15
  # -- Validations ----------------------------------------------------------
13
16
  validates :post_id, :content, :author, :email,
@@ -18,4 +21,11 @@ class Blog::Comment < ActiveRecord::Base
18
21
  # -- Scopes ---------------------------------------------------------------
19
22
  scope :published, where(:is_published => true)
20
23
 
24
+ protected
25
+
26
+ def set_publish
27
+ self.is_published = ComfyBlog.config.auto_publish_comments
28
+ return
29
+ end
30
+
21
31
  end
@@ -1,6 +1,6 @@
1
1
  class Blog::Post < ActiveRecord::Base
2
2
 
3
- set_table_name :blog_posts
3
+ self.table_name = :blog_posts
4
4
 
5
5
  # -- Attributes -----------------------------------------------------------
6
6
  attr_accessor :tag_names,
@@ -46,6 +46,10 @@ class Blog::Post < ActiveRecord::Base
46
46
  @tag_names ||= self.tags.tags.collect(&:name).join(', ')
47
47
  end
48
48
 
49
+ def category_ids
50
+ @category_ids ||= self.tags.categories.inject({}){|h, c| h[c.id.to_s] = '1'; h}
51
+ end
52
+
49
53
  protected
50
54
 
51
55
  def set_slug
@@ -61,16 +65,16 @@ protected
61
65
  return unless tag_names
62
66
  self.taggings.for_tags.destroy_all
63
67
  self.tag_names.split(',').map{ |t| t.strip }.uniq.each do |tag_name|
64
- self.tags << Blog::Tag.find_or_create_by_name(tag_name)
68
+ self.tags << Blog::Tag.find_or_create_by_name(tag_name) rescue nil
65
69
  end
66
70
  end
67
71
 
68
72
  def sync_categories
69
- (self.category_ids || {}).each do |category_id, flag|
73
+ self.category_ids.each do |category_id, flag|
70
74
  case flag.to_i
71
75
  when 1
72
76
  if category = Blog::Tag.categories.find_by_id(category_id)
73
- category.taggings.create(:post => self)
77
+ category.taggings.create(:post => self) rescue nil
74
78
  end
75
79
  when 0
76
80
  self.taggings.for_categories.where(:tag_id => category_id).destroy_all
@@ -1,13 +1,13 @@
1
1
  class Blog::Tag < ActiveRecord::Base
2
2
 
3
- set_table_name :blog_tags
3
+ self.table_name = :blog_tags
4
4
 
5
5
  # -- Relationships --------------------------------------------------------
6
6
  has_many :taggings, :dependent => :destroy
7
7
  has_many :posts, :through => :taggings
8
8
 
9
9
  # -- Validations ----------------------------------------------------------
10
- validates_uniqueness_of :name
10
+ validates_uniqueness_of :name, :case_sensitive => false
11
11
 
12
12
  # -- Callbacks ------------------------------------------------------------
13
13
  before_validation :strip_name
@@ -19,7 +19,7 @@ class Blog::Tag < ActiveRecord::Base
19
19
  protected
20
20
 
21
21
  def strip_name
22
- self.name.strip!
22
+ self.name = self.name.strip if self.name
23
23
  end
24
24
 
25
25
  end
@@ -1,6 +1,6 @@
1
1
  class Blog::Tagging < ActiveRecord::Base
2
2
 
3
- set_table_name :blog_taggings
3
+ self.table_name = :blog_taggings
4
4
 
5
5
  # -- Relationships --------------------------------------------------------
6
6
  belongs_to :post
@@ -0,0 +1,2 @@
1
+ <li><%= active_link_to 'Blog posts', admin_blog_posts_path %></li>
2
+ <li><%= active_link_to 'Blog tags', admin_blog_tags_path %></li>
@@ -3,9 +3,9 @@
3
3
  <div class='icon' style="background-image:url(http://www.gravatar.com/avatar/<%=Digest::MD5.hexdigest(comment.email.downcase)%>?s=28&d=identicon)"></div>
4
4
  <div class='action_links'>
5
5
  <% unless comment.is_published? %>
6
- <%= link_to 'Publish', publish_admin_comment_path(comment), :remote => true, :method => :put %>
6
+ <%= link_to 'Publish', publish_admin_blog_comment_path(comment), :remote => true, :method => :put %>
7
7
  <% end %>
8
- <%= link_to 'Delete', admin_comment_path(comment), :method => 'delete', :confirm => 'Are you sure?' %>
8
+ <%= link_to 'Delete', admin_blog_comment_path(comment), :method => 'delete', :confirm => 'Are you sure?' %>
9
9
  </div>
10
10
  <div class='label'>
11
11
  <div class='sublabel'>
@@ -6,5 +6,7 @@
6
6
  </h1>
7
7
 
8
8
  <ul class='list comments'>
9
- <%= render @comments %>
9
+ <% @comments.each do |comment| %>
10
+ <%= render :partial => 'comment', :object => comment %>
11
+ <% end %>
10
12
  </ul>
@@ -1,5 +1,16 @@
1
1
  <%= form.text_field :title %>
2
2
  <%= form.text_field :author %>
3
+ <% if Blog::Tag.categories.present? %>
4
+ <%= form.simple_field 'Categories' do %>
5
+ <% Blog::Tag.categories.each do |category| %>
6
+ <%= hidden_field_tag "post[category_ids][#{category.id}]", 0, :id => nil %>
7
+ <label>
8
+ <%= check_box_tag "post[category_ids][#{category.id}]", 1, @post.category_ids[category.id.to_s].to_i == 1, :id => nil %>
9
+ <%= category.name %>
10
+ </label>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
3
14
  <%= form.text_field :tag_names, :label => 'Tags' %>
4
15
  <%= form.text_area :content, :class => 'rich_text' %>
5
16
  <%= form.text_field :excerpt %>
@@ -1,12 +1,12 @@
1
1
  <li>
2
2
  <div class='item'>
3
3
  <div class='action_links'>
4
- <%= link_to pluralize(post.comments.count, 'comment'), admin_post_comments_path(post) %>
5
- <%= link_to 'Edit', edit_admin_post_path(post) %>
6
- <%= link_to 'Delete', admin_post_path(post), :method => :delete, :confirm => 'Are you sure?' %>
4
+ <%= link_to pluralize(post.comments.count, 'comment'), admin_blog_post_comments_path(post) %>
5
+ <%= link_to 'Edit', edit_admin_blog_post_path(post) %>
6
+ <%= link_to 'Delete', admin_blog_post_path(post), :method => :delete, :confirm => 'Are you sure?' %>
7
7
  </div>
8
8
  <div class='label'>
9
- <%= link_to post.title.titleize, edit_admin_post_path(post) %>
9
+ <%= link_to post.title.titleize, edit_admin_blog_post_path(post) %>
10
10
  <div class='sublabel'>
11
11
  Published <%= time_ago_in_words(post.updated_at) %> ago
12
12
  by <strong><%= post.author %></strong>
@@ -0,0 +1,11 @@
1
+ <%= link_to 'Add new blog post', new_admin_blog_post_path, :class => 'big button' %>
2
+
3
+ <h1>Blog Posts</h1>
4
+
5
+ <ul class='list posts'>
6
+ <% @posts.each do |post| %>
7
+ <%= render :partial => 'post', :object => post %>
8
+ <% end %>
9
+ </ul>
10
+
11
+ <%= will_paginate @posts %>
@@ -0,0 +1,20 @@
1
+ <%= form.text_field :name %>
2
+ <%= form.check_box :is_category %>
3
+
4
+ <% if defined?(ComfortableMexicanSofa) %>
5
+ <%= form.simple_field nil, nil, :class => 'submit_element' do %>
6
+ <% if @tag.is_category %>
7
+ <%= form.submit @tag.new_record?? 'Create category' : 'Update category', :disable_builder => true %>
8
+ <% else %>
9
+ <%= form.submit @tag.new_record?? 'Create tag' : 'Update tag', :disable_builder => true %>
10
+ <% end %>
11
+ <% end %>
12
+
13
+ <% else %>
14
+ <% if @tag.is_category %>
15
+ <%= form.submit @tag.new_record?? 'Create category' : 'Update category' %>
16
+ <% else %>
17
+ <%= form.submit @tag.new_record?? 'Create tag' : 'Update tag' %>
18
+ <% end %>
19
+ <% end %>
20
+
@@ -0,0 +1,16 @@
1
+ <li>
2
+ <div class='item'>
3
+ <div class='action_links'>
4
+ <%= link_to 'Edit', :action => :edit, :id => tag %>
5
+ <%= link_to 'Delete', {:action => :destroy, :id => tag}, :method => :delete, :confirm => 'Are you sure you want to delete this tag?' %>
6
+ </div>
7
+ <div class='label'>
8
+ <%= link_to tag.name, :action => :edit, :id => tag %>
9
+ <div class='sublabel'>
10
+ <% if tag.is_category? %>
11
+ Category
12
+ <% end %>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ </li>
@@ -0,0 +1,5 @@
1
+ <h1>Editing <%= @tag.name %></h1>
2
+
3
+ <%= comfy_blog_form_for @tag, :as => :tag, :url => {:action => :update} do |form| %>
4
+ <%= render :partial => form %>
5
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <%= link_to 'Add new blog tag', {:action => :new}, :class => 'big button' %>
2
+
3
+ <h1>Blog Tags</h1>
4
+
5
+ <ul class='list categories'>
6
+ <% @tags.each do |tag| %>
7
+ <%= render :partial => 'tag', :object => tag %>
8
+ <% end %>
9
+ </ul>
@@ -0,0 +1,5 @@
1
+ <h1>New Blog Post</h1>
2
+
3
+ <%= comfy_blog_form_for @tag, :as => :tag, :url => {:action => :create} do |form| %>
4
+ <%= render :partial => form %>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <div class='comment' id='<%= dom_id(comment) %>'>
2
+ <div class='author'><%= comment.author %></div>
3
+ <div class='content'><%= comment.content %></div>
4
+ </div>
@@ -0,0 +1,6 @@
1
+ <%= form_for :comment, :remote => true, :url => blog_post_comments_path(@post), :html => { :id => 'comment' } do |form| %>
2
+ <%= form.text_field :author %>
3
+ <%= form.text_field :email %>
4
+ <%= form.text_area :content %>
5
+ <%= form.submit 'Submit' %>
6
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% if @comment.new_record? %>
2
+ $('form#comment').replaceWith('<%= escape_javascript(render(:partial => "form")) %>');
3
+ <% else %>
4
+ $('form#comment')[0].reset();
5
+ $('#comments').append('<%= escape_javascript(render(:partial => "comment", :object => @comment)) %>');
6
+ <% end %>
@@ -1,18 +1,8 @@
1
1
  <div class='post'>
2
- <h1><%= post.title %></h1>
2
+ <h1><%= @post ? post.title : link_to(post.title, blog_post_path(post))%></h1>
3
3
  <div class='author'><%= post.author %></div>
4
4
  <div class='date'><%= post.created_at %></div>
5
5
  <div class='content'>
6
6
  <%= post.content.html_safe %>
7
7
  </div>
8
- <div>
9
-
10
- <% if @post %>
11
- <div class='comments'>
12
- <% @post.comments.each do |comment| %>
13
- <div class='comment'>
14
- <%= comment.content %>
15
- </div>
16
- <% end %>
17
- </div>
18
- <% end %>
8
+ </div>
@@ -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 ComfyBlog.config.title
5
+ xml.description ComfyBlog.config.description
6
+ xml.link request.url
7
+
8
+ @posts.each do |post|
9
+ xml.item do
10
+ xml.title post.title
11
+ xml.description post.content
12
+ xml.pubDate post.created_at.to_s(:rfc822)
13
+ xml.link blog_post_url(post)
14
+ xml.guid blog_post_url(post)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1 +1,9 @@
1
- <%= render :partial => 'post', :object => @post %>
1
+ <%= render :partial => 'blog/posts/post', :object => @post %>
2
+
3
+ <div id='comments'>
4
+ <% @post.comments.each do |comment| %>
5
+ <%= render :partial => 'blog/comments/comment', :object => comment %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <%= render :partial => 'blog/comments/form' %>