comfy_blog 0.0.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.
Files changed (78) hide show
  1. data/Gemfile +11 -0
  2. data/LICENSE +20 -0
  3. data/README.md +23 -0
  4. data/Rakefile +21 -0
  5. data/VERSION +1 -0
  6. data/app/assets/images/rails.png +0 -0
  7. data/app/assets/javascripts/application.js +8 -0
  8. data/app/assets/stylesheets/comfy_blog/admin.css +57 -0
  9. data/app/assets/stylesheets/comfy_blog/application.css +73 -0
  10. data/app/assets/stylesheets/comfy_blog/reset.css +1 -0
  11. data/app/controllers/application_controller.rb +5 -0
  12. data/app/controllers/blog/admin/base_controller.rb +3 -0
  13. data/app/controllers/blog/admin/comments_controller.rb +34 -0
  14. data/app/controllers/blog/admin/posts_controller.rb +57 -0
  15. data/app/controllers/blog/posts_controller.rb +33 -0
  16. data/app/helpers/blog/application_helper.rb +16 -0
  17. data/app/models/.gitkeep +0 -0
  18. data/app/models/blog/comment.rb +21 -0
  19. data/app/models/blog/post.rb +81 -0
  20. data/app/models/blog/tag.rb +25 -0
  21. data/app/models/blog/tagging.rb +22 -0
  22. data/app/views/blog/admin/_html_head.html.erb +1 -0
  23. data/app/views/blog/admin/_navigation.html.erb +1 -0
  24. data/app/views/blog/admin/comments/_comment.html.erb +22 -0
  25. data/app/views/blog/admin/comments/destroy.js.erb +3 -0
  26. data/app/views/blog/admin/comments/index.html.erb +10 -0
  27. data/app/views/blog/admin/comments/publish.js.erb +1 -0
  28. data/app/views/blog/admin/posts/_form.html.erb +24 -0
  29. data/app/views/blog/admin/posts/_post.html.erb +21 -0
  30. data/app/views/blog/admin/posts/edit.html.erb +5 -0
  31. data/app/views/blog/admin/posts/index.html.erb +9 -0
  32. data/app/views/blog/admin/posts/new.html.erb +5 -0
  33. data/app/views/blog/posts/_post.html.erb +18 -0
  34. data/app/views/blog/posts/index.html.erb +5 -0
  35. data/app/views/blog/posts/show.html.erb +1 -0
  36. data/app/views/layouts/application.html.erb +17 -0
  37. data/comfy_blog.gemspec +125 -0
  38. data/config.ru +4 -0
  39. data/config/application.rb +48 -0
  40. data/config/boot.rb +6 -0
  41. data/config/database.yml +25 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +33 -0
  44. data/config/environments/production.rb +51 -0
  45. data/config/environments/test.rb +42 -0
  46. data/config/initializers/comfy_blog.rb +18 -0
  47. data/config/initializers/secret_token.rb +3 -0
  48. data/config/initializers/wrap_parameters.rb +14 -0
  49. data/config/locales/en.yml +5 -0
  50. data/config/routes.rb +29 -0
  51. data/db/migrate/01_create_comfy_blog.rb +55 -0
  52. data/db/schema.rb +63 -0
  53. data/db/seeds.rb +7 -0
  54. data/lib/comfy_blog.rb +26 -0
  55. data/lib/comfy_blog/configuration.rb +33 -0
  56. data/lib/comfy_blog/core_ext/string.rb +8 -0
  57. data/lib/comfy_blog/engine.rb +20 -0
  58. data/lib/comfy_blog/form_builder.rb +50 -0
  59. data/lib/generators/README +10 -0
  60. data/lib/generators/blog_generator.rb +31 -0
  61. data/script/rails +6 -0
  62. data/test/fixtures/.gitkeep +0 -0
  63. data/test/fixtures/blog/comments.yml +6 -0
  64. data/test/fixtures/blog/posts.yml +8 -0
  65. data/test/fixtures/blog/taggings.yml +7 -0
  66. data/test/fixtures/blog/tags.yml +9 -0
  67. data/test/functional/.gitkeep +0 -0
  68. data/test/functional/blog/admin/comments_controller_test.rb +38 -0
  69. data/test/functional/blog/admin/posts_controller_test.rb +100 -0
  70. data/test/functional/blog/posts_controller_test.rb +93 -0
  71. data/test/test_helper.rb +40 -0
  72. data/test/unit/.gitkeep +0 -0
  73. data/test/unit/comment_test.rb +34 -0
  74. data/test/unit/configuration_test.rb +19 -0
  75. data/test/unit/post_test.rb +121 -0
  76. data/test/unit/tag_test.rb +44 -0
  77. data/test/unit/tagging_test.rb +30 -0
  78. metadata +172 -0
@@ -0,0 +1,25 @@
1
+ class Blog::Tag < ActiveRecord::Base
2
+
3
+ set_table_name :blog_tags
4
+
5
+ # -- Relationships --------------------------------------------------------
6
+ has_many :taggings, :dependent => :destroy
7
+ has_many :posts, :through => :taggings
8
+
9
+ # -- Validations ----------------------------------------------------------
10
+ validates_uniqueness_of :name
11
+
12
+ # -- Callbacks ------------------------------------------------------------
13
+ before_validation :strip_name
14
+
15
+ # -- Scopes ---------------------------------------------------------------
16
+ scope :categories, where(:is_category => true)
17
+ scope :tags, where(:is_category => false)
18
+
19
+ protected
20
+
21
+ def strip_name
22
+ self.name.strip!
23
+ end
24
+
25
+ end
@@ -0,0 +1,22 @@
1
+ class Blog::Tagging < ActiveRecord::Base
2
+
3
+ set_table_name :blog_taggings
4
+
5
+ # -- Relationships --------------------------------------------------------
6
+ belongs_to :post
7
+ belongs_to :tag, :counter_cache => true
8
+
9
+ # -- Callbacks ------------------------------------------------------------
10
+ after_destroy :destroy_tag
11
+
12
+ # -- Scopes ---------------------------------------------------------------
13
+ scope :for_tags, includes(:tag).where('blog_tags.is_category' => false)
14
+ scope :for_categories, includes(:tag).where('blog_tags.is_category' => true)
15
+
16
+ protected
17
+
18
+ def destroy_tag
19
+ self.tag.destroy if !self.tag.is_category? && self.tag.taggings.count == 0
20
+ end
21
+
22
+ end
@@ -0,0 +1 @@
1
+ <%= stylesheet_link_tag 'comfy_blog/admin' %>
@@ -0,0 +1 @@
1
+ <li><%= active_link_to 'Blog posts', admin_posts_path %></li>
@@ -0,0 +1,22 @@
1
+ <li id='<%= dom_id(comment) %>'>
2
+ <div class='item'>
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
+ <div class='action_links'>
5
+ <% unless comment.is_published? %>
6
+ <%= link_to 'Publish', publish_admin_comment_path(comment), :remote => true, :method => :put %>
7
+ <% end %>
8
+ <%= link_to 'Delete', admin_comment_path(comment), :method => 'delete', :confirm => 'Are you sure?' %>
9
+ </div>
10
+ <div class='label'>
11
+ <div class='sublabel'>
12
+ <em>
13
+ <%= time_ago_in_words(comment.created_at) %> ago
14
+ <strong><%= mail_to(comment.email, comment.author) %></strong> wrote
15
+ </em>
16
+ </div>
17
+ </div>
18
+ <div class='content'>
19
+ <%= simple_format(auto_link(comment.content)) %>
20
+ </div>
21
+ </div>
22
+ </li>
@@ -0,0 +1,3 @@
1
+ $('li#<%= dom_id(@comment) %>').fadeOut('slow', function(){
2
+ $(this).remove();
3
+ })
@@ -0,0 +1,10 @@
1
+ <h1>
2
+ Comments
3
+ <% if @post %>
4
+ for <%= @post.title %>
5
+ <% end %>
6
+ </h1>
7
+
8
+ <ul class='list comments'>
9
+ <%= render @comments %>
10
+ </ul>
@@ -0,0 +1 @@
1
+ $('li#<%= dom_id(@comment) %>').replaceWith('<%= escape_javascript(render(:partial => "comment", :object => @comment)) %>')
@@ -0,0 +1,24 @@
1
+ <%= form.text_field :title %>
2
+ <%= form.text_field :author %>
3
+ <%= form.text_field :tag_names, :label => 'Tags' %>
4
+ <%= form.text_area :content, :class => 'rich_text' %>
5
+ <%= form.text_field :excerpt %>
6
+
7
+ <% if defined?(ComfortableMexicanSofa) %>
8
+ <% content_for :right_column do %>
9
+ <%= render :partial => 'cms_admin/files/index' %>
10
+ <% end %>
11
+
12
+ <%= cms_hook :blog_post, :locals => { :form => form } %>
13
+
14
+ <%= form.simple_field nil, nil, :class => 'submit_element' do %>
15
+ <%= form.check_box :is_published, :disable_builder => true %>
16
+ <%= form.label_for :is_published %>
17
+ <%= form.submit (@post.new_record? ? 'Create post' : 'Update post'), :disable_builder => true %>
18
+ <% end %>
19
+
20
+ <% else %>
21
+ <%= form.check_box :is_published %>
22
+ <%= form.submit (@post.new_record? ? 'Create post' : 'Update post') %>
23
+ <% end %>
24
+
@@ -0,0 +1,21 @@
1
+ <li>
2
+ <div class='item'>
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?' %>
7
+ </div>
8
+ <div class='label'>
9
+ <%= link_to post.title.titleize, edit_admin_post_path(post) %>
10
+ <div class='sublabel'>
11
+ Published <%= time_ago_in_words(post.updated_at) %> ago
12
+ by <strong><%= post.author %></strong>
13
+ <%= '[DRAFT]' if !post.is_published? %>
14
+ <% post.tags.each do |tag| %>
15
+ <span class="tag"><%= tag.name %></span>
16
+ <% end %>
17
+
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </li>
@@ -0,0 +1,5 @@
1
+ <h1>Editing <%= @post.title.titleize %></h1>
2
+
3
+ <%= comfy_blog_form_for @post, :as => :post, :url => {:action => :update} do |form| %>
4
+ <%= render :partial => form %>
5
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <%= link_to 'Add new blog post', new_admin_post_path, :class => 'big button' %>
2
+
3
+ <h1>Blog Posts</h1>
4
+
5
+ <ul class='list posts'>
6
+ <%= render :partial => @posts %>
7
+ </ul>
8
+
9
+ <%= will_paginate @posts %>
@@ -0,0 +1,5 @@
1
+ <h1>New Blog Post</h1>
2
+
3
+ <%= comfy_blog_form_for @post, :as => :post, :url => {:action => :create} do |form| %>
4
+ <%= render :partial => form %>
5
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div class='post'>
2
+ <h1><%= post.title %></h1>
3
+ <div class='author'><%= post.author %></div>
4
+ <div class='date'><%= post.created_at %></div>
5
+ <div class='content'>
6
+ <%= post.content.html_safe %>
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 %>
@@ -0,0 +1,5 @@
1
+ <% @posts.each do |post| %>
2
+ <%= render :partial => 'post', :object => post %>
3
+ <% end %>
4
+
5
+ <%= will_paginate @posts, :previous_label => '« Older Posts', :next_label => 'Newer Posts »', :page_links => false %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'post', :object => @post %>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html;charset=utf-8' http-equiv='Content-Type'>
5
+ <title>ComfyBlog</title>
6
+ <%= javascript_include_tag 'application' %>
7
+ <%= stylesheet_link_tag 'comfy_blog/application' %>
8
+ <%= yield :head %>
9
+ <%= csrf_meta_tags %>
10
+ </head>
11
+ <body>
12
+ <% flash.each do |type, message| %>
13
+ <div class='flash <%= type %>'><%= message %></div>
14
+ <% end %>
15
+ <%= yield %>
16
+ </body>
17
+ </html>
@@ -0,0 +1,125 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "comfy_blog"
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Oleg Khabarov", "The Working Group Inc."]
12
+ s.date = "2012-01-18"
13
+ s.description = ""
14
+ s.email = "oleg@twg.ca"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "app/assets/images/rails.png",
26
+ "app/assets/javascripts/application.js",
27
+ "app/assets/stylesheets/comfy_blog/admin.css",
28
+ "app/assets/stylesheets/comfy_blog/application.css",
29
+ "app/assets/stylesheets/comfy_blog/reset.css",
30
+ "app/controllers/application_controller.rb",
31
+ "app/controllers/blog/admin/base_controller.rb",
32
+ "app/controllers/blog/admin/comments_controller.rb",
33
+ "app/controllers/blog/admin/posts_controller.rb",
34
+ "app/controllers/blog/posts_controller.rb",
35
+ "app/helpers/blog/application_helper.rb",
36
+ "app/models/.gitkeep",
37
+ "app/models/blog/comment.rb",
38
+ "app/models/blog/post.rb",
39
+ "app/models/blog/tag.rb",
40
+ "app/models/blog/tagging.rb",
41
+ "app/views/blog/admin/_html_head.html.erb",
42
+ "app/views/blog/admin/_navigation.html.erb",
43
+ "app/views/blog/admin/comments/_comment.html.erb",
44
+ "app/views/blog/admin/comments/destroy.js.erb",
45
+ "app/views/blog/admin/comments/index.html.erb",
46
+ "app/views/blog/admin/comments/publish.js.erb",
47
+ "app/views/blog/admin/posts/_form.html.erb",
48
+ "app/views/blog/admin/posts/_post.html.erb",
49
+ "app/views/blog/admin/posts/edit.html.erb",
50
+ "app/views/blog/admin/posts/index.html.erb",
51
+ "app/views/blog/admin/posts/new.html.erb",
52
+ "app/views/blog/posts/_post.html.erb",
53
+ "app/views/blog/posts/index.html.erb",
54
+ "app/views/blog/posts/show.html.erb",
55
+ "app/views/layouts/application.html.erb",
56
+ "comfy_blog.gemspec",
57
+ "config.ru",
58
+ "config/application.rb",
59
+ "config/boot.rb",
60
+ "config/database.yml",
61
+ "config/environment.rb",
62
+ "config/environments/development.rb",
63
+ "config/environments/production.rb",
64
+ "config/environments/test.rb",
65
+ "config/initializers/comfy_blog.rb",
66
+ "config/initializers/secret_token.rb",
67
+ "config/initializers/wrap_parameters.rb",
68
+ "config/locales/en.yml",
69
+ "config/routes.rb",
70
+ "db/migrate/01_create_comfy_blog.rb",
71
+ "db/schema.rb",
72
+ "db/seeds.rb",
73
+ "lib/comfy_blog.rb",
74
+ "lib/comfy_blog/configuration.rb",
75
+ "lib/comfy_blog/core_ext/string.rb",
76
+ "lib/comfy_blog/engine.rb",
77
+ "lib/comfy_blog/form_builder.rb",
78
+ "lib/generators/README",
79
+ "lib/generators/blog_generator.rb",
80
+ "script/rails",
81
+ "test/fixtures/.gitkeep",
82
+ "test/fixtures/blog/comments.yml",
83
+ "test/fixtures/blog/posts.yml",
84
+ "test/fixtures/blog/taggings.yml",
85
+ "test/fixtures/blog/tags.yml",
86
+ "test/functional/.gitkeep",
87
+ "test/functional/blog/admin/comments_controller_test.rb",
88
+ "test/functional/blog/admin/posts_controller_test.rb",
89
+ "test/functional/blog/posts_controller_test.rb",
90
+ "test/test_helper.rb",
91
+ "test/unit/.gitkeep",
92
+ "test/unit/comment_test.rb",
93
+ "test/unit/configuration_test.rb",
94
+ "test/unit/post_test.rb",
95
+ "test/unit/tag_test.rb",
96
+ "test/unit/tagging_test.rb"
97
+ ]
98
+ s.homepage = "http://github.com/comfy/comfy-blog"
99
+ s.licenses = ["MIT"]
100
+ s.require_paths = ["lib"]
101
+ s.rubygems_version = "1.8.10"
102
+ s.summary = "ComfyBlog is a blog engine for Rails 3.1 apps (and ComfortableMexicanSofa)"
103
+
104
+ if s.respond_to? :specification_version then
105
+ s.specification_version = 3
106
+
107
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
108
+ s.add_runtime_dependency(%q<rails>, [">= 3.1.0"])
109
+ s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.2"])
110
+ s.add_runtime_dependency(%q<rails_autolink>, ["~> 1.0.4"])
111
+ s.add_runtime_dependency(%q<jquery-rails>, [">= 1.0.0"])
112
+ else
113
+ s.add_dependency(%q<rails>, [">= 3.1.0"])
114
+ s.add_dependency(%q<will_paginate>, ["~> 3.0.2"])
115
+ s.add_dependency(%q<rails_autolink>, ["~> 1.0.4"])
116
+ s.add_dependency(%q<jquery-rails>, [">= 1.0.0"])
117
+ end
118
+ else
119
+ s.add_dependency(%q<rails>, [">= 3.1.0"])
120
+ s.add_dependency(%q<will_paginate>, ["~> 3.0.2"])
121
+ s.add_dependency(%q<rails_autolink>, ["~> 1.0.4"])
122
+ s.add_dependency(%q<jquery-rails>, [">= 1.0.0"])
123
+ end
124
+ end
125
+
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run ComfyBlog::Application
@@ -0,0 +1,48 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ if defined?(Bundler)
6
+ # If you precompile assets before deploying to production, use this line
7
+ Bundler.require *Rails.groups(:assets => %w(development test))
8
+ # If you want your assets lazily compiled in production, use this line
9
+ # Bundler.require(:default, :assets, Rails.env)
10
+ end
11
+
12
+ module ComfyBlog
13
+ class Application < Rails::Application
14
+
15
+ require 'comfy_blog'
16
+
17
+ # Settings in config/environments/* take precedence over those specified here.
18
+ # Application configuration should go into files in config/initializers
19
+ # -- all .rb files in that directory are automatically loaded.
20
+
21
+ # Custom directories with classes and modules you want to be autoloadable.
22
+ # config.autoload_paths += %W(#{config.root}/extras)
23
+
24
+ # Only load the plugins named here, in the order given (default is alphabetical).
25
+ # :all can be used as a placeholder for all plugins not explicitly named.
26
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
27
+
28
+ # Activate observers that should always be running.
29
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
30
+
31
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
32
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
33
+ # config.time_zone = 'Central Time (US & Canada)'
34
+
35
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
36
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
37
+ # config.i18n.default_locale = :de
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+
45
+ # Enable the asset pipeline
46
+ config.assets.enabled = true
47
+ end
48
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ ComfyBlog::Application.initialize!
@@ -0,0 +1,33 @@
1
+ defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
29
+ config.assets.allow_debugging = true
30
+
31
+ # Expands the lines which load the assets
32
+ config.assets.debug = true
33
+ end