sofa_blog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.DS_Store +0 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +83 -0
  4. data/LICENSE +20 -0
  5. data/README.md +66 -0
  6. data/Rakefile +19 -0
  7. data/VERSION +1 -0
  8. data/app/.DS_Store +0 -0
  9. data/app/controllers/cms_admin/blog_comments_controller.rb +66 -0
  10. data/app/controllers/cms_admin/blog_posts_controller.rb +48 -0
  11. data/app/models/blog_comment.rb +45 -0
  12. data/app/models/blog_post.rb +62 -0
  13. data/app/models/blog_tag.rb +22 -0
  14. data/app/models/blog_tagging.rb +8 -0
  15. data/app/views/.DS_Store +0 -0
  16. data/app/views/cms_admin/blog_comments/_blog_comment.html.erb +22 -0
  17. data/app/views/cms_admin/blog_comments/_form.html.erb +24 -0
  18. data/app/views/cms_admin/blog_comments/_status.html.erb +7 -0
  19. data/app/views/cms_admin/blog_comments/approve.rjs +1 -0
  20. data/app/views/cms_admin/blog_comments/disapprove.rjs +1 -0
  21. data/app/views/cms_admin/blog_comments/edit.html.erb +7 -0
  22. data/app/views/cms_admin/blog_comments/index.html.erb +7 -0
  23. data/app/views/cms_admin/blog_comments/new.html.erb +6 -0
  24. data/app/views/cms_admin/blog_posts/_blog_post.html.erb +21 -0
  25. data/app/views/cms_admin/blog_posts/_form.html.erb +33 -0
  26. data/app/views/cms_admin/blog_posts/edit.html.erb +7 -0
  27. data/app/views/cms_admin/blog_posts/index.html.erb +8 -0
  28. data/app/views/cms_admin/blog_posts/new.html.erb +5 -0
  29. data/app/views/sofa_blog/_head.html.erb +1 -0
  30. data/app/views/sofa_blog/_nav.html.erb +1 -0
  31. data/config/.DS_Store +0 -0
  32. data/config/routes.rb +14 -0
  33. data/db/migrate/01_create_sofa_blog.rb +50 -0
  34. data/doc/sofa.png +0 -0
  35. data/lib/generators/README +12 -0
  36. data/lib/generators/blog_generator.rb +33 -0
  37. data/lib/sofa_blog/engine.rb +17 -0
  38. data/lib/sofa_blog.rb +3 -0
  39. data/public/javascripts/jquery.autocomplete.pack.js +12 -0
  40. data/public/stylesheets/content.css +53 -0
  41. data/sofa_blog.gemspec +88 -0
  42. data/tmp/application.rb +15 -0
  43. data/tmp/boot.rb +13 -0
  44. data/tmp/environment.rb +6 -0
  45. data/tmp/initializers/formatted_form_builder.rb +141 -0
  46. data/tmp/initializers/wristband.rb +1 -0
  47. metadata +145 -0
data/.DS_Store ADDED
Binary file
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'comfortable_mexican_sofa', '>=1.0.46'
data/Gemfile.lock ADDED
@@ -0,0 +1,83 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.4)
6
+ actionpack (= 3.0.4)
7
+ mail (~> 2.2.15)
8
+ actionpack (3.0.4)
9
+ activemodel (= 3.0.4)
10
+ activesupport (= 3.0.4)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.7)
17
+ tzinfo (~> 0.3.23)
18
+ active_link_to (0.0.6)
19
+ activemodel (3.0.4)
20
+ activesupport (= 3.0.4)
21
+ builder (~> 2.1.2)
22
+ i18n (~> 0.4)
23
+ activerecord (3.0.4)
24
+ activemodel (= 3.0.4)
25
+ activesupport (= 3.0.4)
26
+ arel (~> 2.0.2)
27
+ tzinfo (~> 0.3.23)
28
+ activeresource (3.0.4)
29
+ activemodel (= 3.0.4)
30
+ activesupport (= 3.0.4)
31
+ activesupport (3.0.4)
32
+ arel (2.0.9)
33
+ builder (2.1.2)
34
+ comfortable_mexican_sofa (1.0.46)
35
+ active_link_to (>= 0.0.6)
36
+ active_link_to (>= 0.0.6)
37
+ mime-types
38
+ paperclip (>= 2.3.8)
39
+ paperclip (>= 2.3.8)
40
+ rails (>= 3.0.3)
41
+ rails (>= 3.0.3)
42
+ erubis (2.6.6)
43
+ abstract (>= 1.0.0)
44
+ i18n (0.5.0)
45
+ mail (2.2.15)
46
+ activesupport (>= 2.3.6)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.16)
51
+ paperclip (2.3.8)
52
+ activerecord
53
+ activesupport
54
+ polyglot (0.3.1)
55
+ rack (1.2.1)
56
+ rack-mount (0.6.13)
57
+ rack (>= 1.0.0)
58
+ rack-test (0.5.7)
59
+ rack (>= 1.0)
60
+ rails (3.0.4)
61
+ actionmailer (= 3.0.4)
62
+ actionpack (= 3.0.4)
63
+ activerecord (= 3.0.4)
64
+ activeresource (= 3.0.4)
65
+ activesupport (= 3.0.4)
66
+ bundler (~> 1.0)
67
+ railties (= 3.0.4)
68
+ railties (3.0.4)
69
+ actionpack (= 3.0.4)
70
+ activesupport (= 3.0.4)
71
+ rake (>= 0.8.7)
72
+ thor (~> 0.14.4)
73
+ rake (0.8.7)
74
+ thor (0.14.6)
75
+ treetop (1.4.9)
76
+ polyglot (>= 0.3.1)
77
+ tzinfo (0.3.24)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ comfortable_mexican_sofa (>= 1.0.46)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jack Neto, The Working Group Inc
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Sofa Blog
2
+
3
+ Sofa Blog is an extension for [ComfortableMexicanSofa](https://github.com/twg/comfortable-mexican-sofa) (CMS) that allows management of blog posts and comments.
4
+
5
+ ## Installation
6
+
7
+ Add gem definition to your Gemfile:
8
+
9
+ gem 'sofa_blog'
10
+
11
+ Then from the Rails project's root run:
12
+
13
+ bundle install
14
+ rails g blog
15
+ rake db:migrate
16
+
17
+ ## Usage
18
+
19
+ After finishing installation you should be able to navigate to the CMS admin area (http://yoursite/cms-admin by default) and see a Blog Posts tab on the main navigation.
20
+
21
+ ### The Blog Post
22
+
23
+ @post = BlogPost.first # Grab the first post
24
+ @post.title # The title of the post
25
+ @post.author # The name of the author
26
+ @post.content # The content of the post
27
+ @post.published? # Returns true if the post has been published
28
+ @post.created_at # Created at
29
+ @post.updated_at # Updated at
30
+ @post.comments_count # The total number of comments
31
+ @post.approved_comments_count # The number of approved comments
32
+
33
+ A blog post can be tagged with a comma separared list of words.
34
+
35
+ @post.blog_tags.collect(&:name).join(', ') # Returns a comma-separated list of tags in the post
36
+
37
+
38
+ A few scopes are also available for your convenience:
39
+
40
+ BlogPost.published # All the published posts
41
+ BlogPost.tagged_with(params[:tag_id].to_i) # All the posts tagged with a specific tag_id
42
+ BlogPost.published.tagged_with(params[:tag_id].to_i) # All the published posts tagged with a specific tag_id
43
+
44
+ ### The Comments
45
+
46
+ @comment = @post.blog_comments.first # Grab the first comment
47
+ @comment.name # The name of the author
48
+ @comment.email # The email of the author
49
+ @comment.content # The comment
50
+ @comment.created_at # Created at
51
+ @comment.updated_at # Updated at
52
+
53
+
54
+ ## Dependencies
55
+
56
+ Sofa Blog depends on:
57
+
58
+ * **[ComfortableMexicanSofa](https://github.com/twg/comfortable-mexican-sofa)** - A tiny and powerful micro CMS for your Rails 3 application
59
+
60
+ * * *
61
+
62
+ ![Looks pretty comfortable to me. No idea what makes it Mexican.](https://github.com/twg/sofa-blog/raw/master/doc/sofa.png)
63
+
64
+ Sofa Blog is released under the [MIT license](https://github.com/twg/sofa-blog/raw/master/LICENSE)
65
+
66
+ Copyright 2011 Jack Neto, [The Working Group Inc](http://www.twg.ca)
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = 'sofa_blog'
9
+ gem.summary = 'A blog extension for Comfortable Mexican Sofa'
10
+ gem.description = ''
11
+ gem.email = 'jack@theworkinggroup.ca'
12
+ gem.homepage = 'http://github.com/twg/sofa-blog'
13
+ gem.authors = ['Jack Neto', 'The Working Group Inc']
14
+ gem.add_dependency('comfortable_mexican_sofa', '>=1.0.46')
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/app/.DS_Store ADDED
Binary file
@@ -0,0 +1,66 @@
1
+ class CmsAdmin::BlogCommentsController < CmsAdmin::BaseController
2
+ before_filter :load_blog_post
3
+ before_filter :build_blog_comment, :only => [:new, :create]
4
+ before_filter :load_blog_comment, :only => [:show, :edit, :update, :destroy, :approve, :disapprove]
5
+
6
+ def index
7
+ @blog_comments = BlogComment.order('created_at DESC')
8
+ end
9
+
10
+ def show
11
+ # ...
12
+ end
13
+
14
+ def new
15
+ # ...
16
+ end
17
+
18
+ def create
19
+ @blog_comment.save!
20
+ flash[:notice] = 'Comment created'
21
+ redirect_to :action => :edit, :id => @blog_post
22
+ rescue ActiveRecord::RecordInvalid
23
+ render :action => :new
24
+ end
25
+
26
+ def edit
27
+ # ...
28
+ end
29
+
30
+ def update
31
+ if @blog_comment.update_attributes(params[:blog_comment])
32
+ flash[:notice] = 'Comment updated'
33
+ redirect_to :action => :index, :id => @blog_comment
34
+ else
35
+ render :action => :edit
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @blog_comment.destroy
41
+
42
+ flash[:notice] = 'Comment removed'
43
+ redirect_to :action => :index
44
+ end
45
+
46
+ def approve
47
+ @blog_comment.approve!
48
+ end
49
+
50
+ def disapprove
51
+ @blog_comment.disapprove!
52
+ end
53
+
54
+ protected
55
+ def load_blog_post
56
+ @blog_post = BlogPost.find(params[:blog_post_id])
57
+ end
58
+
59
+ def load_blog_comment
60
+ @blog_comment = BlogComment.find(params[:id])
61
+ end
62
+
63
+ def build_blog_comment
64
+ @blog_comment = @blog_post.blog_comments.build(params[:blog_comment])
65
+ end
66
+ end
@@ -0,0 +1,48 @@
1
+ class CmsAdmin::BlogPostsController < CmsAdmin::BaseController
2
+ before_filter :build_blog_post, :only => [:new, :create]
3
+ before_filter :load_blog_post, :only => [:edit, :update, :destroy]
4
+
5
+ def index
6
+ @blog_posts = BlogPost.order('created_at DESC')
7
+ end
8
+
9
+ def new
10
+ @blog_post.published ||= true
11
+ end
12
+
13
+ def create
14
+ @blog_post.save!
15
+ flash[:notice] = 'Blog post created'
16
+ redirect_to :action => :edit, :id => @blog_post
17
+ rescue ActiveRecord::RecordInvalid
18
+ render :action => :new
19
+ end
20
+
21
+ def edit
22
+ # ...
23
+ end
24
+
25
+ def update
26
+ @blog_post.update_attributes!(params[:blog_post])
27
+ flash[:notice] = 'Post updated'
28
+ redirect_to :action => :edit, :id => @blog_post
29
+ rescue ActiveRecord::RecordInvalid
30
+ render :action => :edit
31
+ end
32
+
33
+ def destroy
34
+ @blog_post.destroy
35
+
36
+ flash[:notice] = 'Post removed'
37
+ redirect_to :action => :index
38
+ end
39
+
40
+ protected
41
+ def build_blog_post
42
+ @blog_post = BlogPost.new(params[:blog_post])
43
+ end
44
+
45
+ def load_blog_post
46
+ @blog_post = BlogPost.find_by_id(params[:id].to_i)
47
+ end
48
+ end
@@ -0,0 +1,45 @@
1
+ class BlogComment < ActiveRecord::Base
2
+
3
+ # -- Relationships --------------------------------------------------------
4
+
5
+ belongs_to :blog_post, :counter_cache => :comments_count
6
+
7
+ # -- Validations ----------------------------------------------------------
8
+
9
+ validates_presence_of :content
10
+ validates_length_of :email,
11
+ :in => 6..100,
12
+ :too_short => 'Your email address needs to be at least 6 characters long.'
13
+ validates_format_of :email,
14
+ :message => 'The email you entered is not valid.',
15
+ :with => /^([\w.%-+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
16
+
17
+ # -- Scopes ----------------------------------------------------------
18
+
19
+ scope :approved, where(:approved => true)
20
+
21
+ # -- AR Callbacks ---------------------------------------------------------
22
+
23
+ after_save :update_approved_comments_counter, :update_comments_counter
24
+ after_destroy :update_approved_comments_counter, :update_comments_counter
25
+
26
+ # -- Instance Methods --------------------------------------------------------
27
+
28
+ def approve!
29
+ update_attribute(:approved, true)
30
+ end
31
+
32
+ def disapprove!
33
+ update_attribute(:approved, false)
34
+ end
35
+
36
+
37
+ protected
38
+ def update_approved_comments_counter
39
+ self.connection.execute("UPDATE blog_posts SET approved_comments_count = #{blog_post.blog_comments.approved.count} WHERE id = #{blog_post.id}")
40
+ end
41
+
42
+ def update_comments_counter
43
+ self.connection.execute("UPDATE blog_posts SET comments_count = #{blog_post.blog_comments.count} WHERE id = #{blog_post.id}")
44
+ end
45
+ end
@@ -0,0 +1,62 @@
1
+ class BlogPost < ActiveRecord::Base
2
+
3
+ attr_accessor :tag_names
4
+
5
+ # -- Relationships --------------------------------------------------------
6
+
7
+ has_many :blog_comments, :dependent => :destroy
8
+ has_many :blog_taggings, :dependent => :destroy
9
+ has_many :blog_tags, :through => :blog_taggings
10
+
11
+ # -- Validations ----------------------------------------------------------
12
+
13
+ validates :content, :presence => {:message => 'Please enter some content for this post'}
14
+ validates :title, :presence => {:message => 'Please enter a title for this post'}
15
+
16
+ # -- Scopes ----------------------------------------------------------
17
+
18
+ scope :published, where(:published => true).order('created_at DESC')
19
+ scope :tagged_with, lambda { |tag_id|
20
+ joins(:blog_taggings).where('blog_taggings.blog_tag_id' => tag_id)
21
+ }
22
+
23
+ # -- AR Callbacks ---------------------------------------------------------
24
+
25
+ before_save :assign_tags
26
+ after_save :delete_unused_tags
27
+
28
+ # -- Instance Methods --------------------------------------------------------
29
+
30
+ def to_param
31
+ "#{self.id}-#{title.downcase.gsub(/\W|_/, ' ').strip.squeeze(' ').gsub(/\s/, '-')}"
32
+ end
33
+
34
+ def tag_names
35
+ @tag_names ||= self.blog_tags.collect(&:name).join(', ')
36
+ end
37
+
38
+
39
+ protected
40
+ def self.collect_tags(query)
41
+ return [] if query.blank?
42
+ query.split(',').collect{|t| t.strip.downcase}.delete_if{|s|s.blank?}.uniq
43
+ end
44
+
45
+ def assign_tags
46
+ self.tag_names # IMPORTANT: populating @tag_names so we can rebuild existing taggings
47
+ self.blog_taggings.delete_all
48
+
49
+ BlogPost.collect_tags(self.tag_names).each do |tag_name|
50
+ if existing_tag = BlogTag.find_by_name(tag_name)
51
+ self.blog_tags << existing_tag
52
+ else
53
+ self.blog_tags.new(:name => tag_name)
54
+ end
55
+ end
56
+ @tag_names = nil # reloading the reader
57
+ end
58
+
59
+ def delete_unused_tags
60
+ BlogTag.destroy_all('blog_taggings_count = 0')
61
+ end
62
+ end
@@ -0,0 +1,22 @@
1
+ class BlogTag < ActiveRecord::Base
2
+
3
+ # -- AR Callbacks ---------------------------------------------------------
4
+
5
+ before_validation :downcase_name
6
+
7
+ # -- Validations ----------------------------------------------------------
8
+
9
+ validates_uniqueness_of :name
10
+
11
+ # -- Relationships --------------------------------------------------------
12
+
13
+ has_many :blog_taggings, :dependent => :destroy
14
+ has_many :blog_posts, :through => :blog_taggings
15
+
16
+ protected
17
+
18
+ def downcase_name
19
+ self.name = self.name.downcase unless self.name.blank?
20
+ end
21
+
22
+ end
@@ -0,0 +1,8 @@
1
+ class BlogTagging < ActiveRecord::Base
2
+
3
+ # -- Relationships --------------------------------------------------------
4
+
5
+ belongs_to :blog_post
6
+ belongs_to :blog_tag, :counter_cache => true
7
+
8
+ end
Binary file
@@ -0,0 +1,22 @@
1
+ <li>
2
+ <div class='item'>
3
+ <div class='icon' style="background-image:url(http://www.gravatar.com/avatar/<%=Digest::MD5.hexdigest(blog_comment.email.downcase)%>?s=28&d=identicon)"></div>
4
+ <div class='action_links'>
5
+ <%= render :partial => 'status', :locals => {:blog_comment => blog_comment} %>
6
+ <%= link_to 'Edit', edit_cms_admin_blog_post_blog_comment_path(@blog_post, blog_comment) %>
7
+ <%= link_to 'Delete', cms_admin_blog_post_blog_comment_path(@blog_post, blog_comment), :method => 'delete', :confirm => 'Are you sure?' %>
8
+ </div>
9
+ <div class='label'>
10
+ <div class='sublabel'>
11
+ <em>
12
+ <%= time_ago_in_words(blog_comment.updated_at) %> ago
13
+ <strong><%= mail_to(blog_comment.email, blog_comment.name) %></strong> wrote
14
+ <% if !blog_comment.approved? %>[Waiting approval]<% end %>
15
+ </em>
16
+ </div>
17
+ </div>
18
+ <div class='content'>
19
+ <%= simple_format(auto_link(blog_comment.content)) %>
20
+ </div>
21
+ </div>
22
+ </li>
@@ -0,0 +1,24 @@
1
+ <%= content_for :head do %>
2
+ <script type="text/javascript">
3
+ $(document).ready(function() {
4
+ $('#blog_comment_content').focus();
5
+ })
6
+ </script>
7
+ <% end %>
8
+
9
+ <div id='form_blocks'>
10
+ <%= form.text_field :name %>
11
+ <%= form.text_field :email %>
12
+ <%= form.text_area :content %>
13
+ </div>
14
+
15
+
16
+ <%= form.simple_field nil, nil, :class => 'submit_element' do %>
17
+ <%= form.check_box :approved, :disable_builder => true %>
18
+ <%= form.label_for :approved, :label => 'Approved' %>
19
+ <%= form.submit @blog_post.new_record?? 'Create comment' : 'Update comment', :disable_builder => true %>
20
+ or
21
+ <%= link_to 'cancel', :back%>
22
+ <% end %>
23
+
24
+
@@ -0,0 +1,7 @@
1
+ <span id="<%= dom_id(blog_comment, :status) %>">
2
+ <% if blog_comment.approved? %>
3
+ <%= link_to 'Disapprove', disapprove_cms_admin_blog_post_blog_comment_path(@blog_post, blog_comment), :remote => true, :method => :put, :before => "$('##{dom_id(blog_comment, :status)}').html('disapproving ...')", :update => dom_id(blog_comment, :status) %>
4
+ <% else %>
5
+ <%= link_to 'Approve', approve_cms_admin_blog_post_blog_comment_path(@blog_post, blog_comment), :remote => true, :method => :put, :before => "$('##{dom_id(blog_comment, :status)}').html('approving ...')", :update => dom_id(blog_comment, :status) %>
6
+ <% end %>
7
+ </span>
@@ -0,0 +1 @@
1
+ page << "$('##{dom_id(@blog_comment, :status)}').html('#{escape_javascript(render(:partial => 'status', :locals => {:blog_comment => @blog_comment}))}')"
@@ -0,0 +1 @@
1
+ page << "$('##{dom_id(@blog_comment, :status)}').html('#{escape_javascript(render(:partial => 'status', :locals => {:blog_comment => @blog_comment}))}')"
@@ -0,0 +1,7 @@
1
+ <%= link_to span_tag('Create New Comment'), new_cms_admin_blog_post_path, :class => 'big button' %>
2
+
3
+ <h1>Edit comment</h1>
4
+
5
+ <%= cms_form_for @blog_comment, :url => {:action => :update} do |form| %>
6
+ <%= render :partial => form %>
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= link_to span_tag('Create New Comment'), new_cms_admin_blog_post_blog_comment_path(@blog_post), :class => 'big button' %>
2
+
3
+ <h1><%= truncate(@blog_post.title) %></h1>
4
+
5
+ <ul class='list'>
6
+ <%= render @blog_comments %>
7
+ </ul>
@@ -0,0 +1,6 @@
1
+ <h1>New comment</h1>
2
+
3
+ <%= cms_form_for @blog_comment, :url => {:action => :create} do |form| %>
4
+ <%= render :partial => form %>
5
+ <% end %>
6
+
@@ -0,0 +1,21 @@
1
+ <li>
2
+ <div class='item'>
3
+ <div class='icon'></div>
4
+ <div class='action_links'>
5
+ <%= link_to pluralize(blog_post.comments_count, 'comment'), cms_admin_blog_post_blog_comments_path(blog_post) %>
6
+ <%= link_to 'Edit', edit_cms_admin_blog_post_path(blog_post) %>
7
+ <%= link_to 'Delete', cms_admin_blog_post_path(blog_post), :method => 'delete', :confirm => 'Are you sure?' %>
8
+ </div>
9
+ <div class='label'>
10
+ <%= link_to blog_post.title.titleize, edit_cms_admin_blog_post_path(blog_post)%>
11
+ <div class='sublabel'>
12
+ Published <%= time_ago_in_words(blog_post.updated_at) %> ago
13
+ by <strong><%= blog_post.author %></strong>
14
+ <% if !blog_post.published? %>[DRAFT]<% end %>
15
+ <% blog_post.blog_tags.each do |tag| %>
16
+ <span class="tag"><%= tag.name %></span>
17
+ <% end %>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </li>
@@ -0,0 +1,33 @@
1
+ <% content_for :head do %>
2
+ <%= javascript_include_tag 'comfortable_mexican_sofa/blog/jquery.autocomplete.pack' %>
3
+ <script type="text/javascript">
4
+ $(document).ready(function() {
5
+ $('#blog_post_title').focus();
6
+ $("#blog_post_tag_names").autocomplete(<%= BlogTag.all.collect(&:name).to_json.html_safe %>, {
7
+ multiple: true,
8
+ selectFirst: false
9
+ });
10
+ })
11
+ </script>
12
+ <% end %>
13
+
14
+ <% content_for :right_column do %>
15
+ <%= render :partial => 'cms_admin/uploads/index' %>
16
+ <% end %>
17
+
18
+ <div id='form_blocks'>
19
+ <%= form.text_field :title %>
20
+ <%= form.text_field :author %>
21
+ <%= form.text_field :tag_names, :label => 'Tags' %>
22
+ <%= form.text_area :content, :class=> 'rich_text' %>
23
+ </div>
24
+
25
+ <%= form.simple_field nil, nil, :class => 'submit_element' do %>
26
+ <%= form.check_box :published, :disable_builder => true %>
27
+ <%= form.label_for :published, :label => 'Published' %>
28
+ <%= form.submit @blog_post.new_record?? 'Create post' : 'Update post', :disable_builder => true %>
29
+ or
30
+ <%= link_to 'cancel', :back%>
31
+ <% end %>
32
+
33
+
@@ -0,0 +1,7 @@
1
+ <%= link_to span_tag('Create New Blog Post'), new_cms_admin_blog_post_path, :class => 'big button' %>
2
+
3
+ <h1> Edit blog post </h1>
4
+
5
+ <%= cms_form_for @blog_post, :url => {:action => :update} do |form| %>
6
+ <%= render :partial => form %>
7
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%= link_to span_tag('Create New Blog Post'), new_cms_admin_blog_post_path, :class => 'big button' %>
2
+
3
+ <h1>Blog posts</h1>
4
+
5
+ <ul class='list'>
6
+ <%= render @blog_posts %>
7
+ </ul>
8
+
@@ -0,0 +1,5 @@
1
+ <h1>New Blog Post</h1>
2
+
3
+ <%= cms_form_for @blog_post, :url => {:action => :create} do |form| %>
4
+ <%= render :partial => form %>
5
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= stylesheet_link_tag :blog, :cache => ('_blog' if ComfortableMexicanSofa.config.enable_caching) %>
@@ -0,0 +1 @@
1
+ <%= active_link_to 'Blog posts', cms_admin_blog_posts_path %>
data/config/.DS_Store ADDED
Binary file
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Rails.application.routes.draw do
2
+
3
+ namespace :cms_admin, :path => ComfortableMexicanSofa.config.admin_route_prefix do
4
+ resources :blog_posts do
5
+ resources :blog_comments do
6
+ member do
7
+ put :approve
8
+ put :disapprove
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ end