gluttonberg-blog 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +3 -0
  4. data/Rakefile +38 -0
  5. data/app/assets/javascripts/blog/application.js +15 -0
  6. data/app/assets/stylesheets/blog/application.css +13 -0
  7. data/app/controllers/gluttonberg/admin/blog/application_controller.rb +6 -0
  8. data/app/controllers/gluttonberg/admin/blog/articles_controller.rb +168 -0
  9. data/app/controllers/gluttonberg/admin/blog/blogs_controller.rb +95 -0
  10. data/app/controllers/gluttonberg/admin/blog/comments_controller.rb +117 -0
  11. data/app/controllers/gluttonberg/public/blog/articles_controller.rb +88 -0
  12. data/app/controllers/gluttonberg/public/blog/blogs_controller.rb +47 -0
  13. data/app/controllers/gluttonberg/public/blog/comments_controller.rb +54 -0
  14. data/app/helpers/gluttonberg/blog/application_helper.rb +6 -0
  15. data/app/mailers/blog_notifier.rb +26 -0
  16. data/app/models/gluttonberg/blog/article.rb +120 -0
  17. data/app/models/gluttonberg/blog/comment.rb +152 -0
  18. data/app/models/gluttonberg/blog/comment_subscription.rb +31 -0
  19. data/app/models/gluttonberg/blog/weblog.rb +25 -0
  20. data/app/views/blog_notifier/comment_notification.html.haml +17 -0
  21. data/app/views/blog_notifier/comment_notification_for_admin.html.haml +19 -0
  22. data/app/views/gluttonberg/admin/blog/articles/_form.html.haml +106 -0
  23. data/app/views/gluttonberg/admin/blog/articles/edit.html.haml +12 -0
  24. data/app/views/gluttonberg/admin/blog/articles/import.html.haml +36 -0
  25. data/app/views/gluttonberg/admin/blog/articles/index.html.haml +82 -0
  26. data/app/views/gluttonberg/admin/blog/articles/new.html.haml +11 -0
  27. data/app/views/gluttonberg/admin/blog/blogs/_form.html.haml +53 -0
  28. data/app/views/gluttonberg/admin/blog/blogs/edit.html.haml +10 -0
  29. data/app/views/gluttonberg/admin/blog/blogs/index.html.haml +35 -0
  30. data/app/views/gluttonberg/admin/blog/blogs/new.html.haml +10 -0
  31. data/app/views/gluttonberg/admin/blog/comments/index.html.haml +66 -0
  32. data/app/views/gluttonberg/public/blog/articles/index.rss.builder +21 -0
  33. data/app/views/gluttonberg/public/blog/blogs/show.rss.builder +21 -0
  34. data/app/views/layouts/blog/application.html.erb +14 -0
  35. data/config/routes.rb +53 -0
  36. data/lib/generators/gluttonberg/blog/blog_generator.rb +42 -0
  37. data/lib/generators/gluttonberg/blog/templates/articles_index.html.haml +18 -0
  38. data/lib/generators/gluttonberg/blog/templates/articles_show.html.haml +63 -0
  39. data/lib/generators/gluttonberg/blog/templates/articles_tag.html.haml +25 -0
  40. data/lib/generators/gluttonberg/blog/templates/blog_migration.rb +94 -0
  41. data/lib/generators/gluttonberg/blog/templates/blogs_index.html.haml +15 -0
  42. data/lib/generators/gluttonberg/blog/templates/blogs_show.html.haml +26 -0
  43. data/lib/gluttonberg/blog.rb +9 -0
  44. data/lib/gluttonberg/blog/engine.rb +22 -0
  45. data/lib/gluttonberg/blog/tasks/blog_tasks.rake +12 -0
  46. data/lib/gluttonberg/blog/version.rb +5 -0
  47. data/spec/dummy/README.rdoc +261 -0
  48. data/spec/dummy/Rakefile +7 -0
  49. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  50. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  51. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  52. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  53. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  54. data/spec/dummy/config.ru +4 -0
  55. data/spec/dummy/config/application.rb +59 -0
  56. data/spec/dummy/config/boot.rb +10 -0
  57. data/spec/dummy/config/database.yml +8 -0
  58. data/spec/dummy/config/environment.rb +5 -0
  59. data/spec/dummy/config/environments/development.rb +37 -0
  60. data/spec/dummy/config/environments/production.rb +67 -0
  61. data/spec/dummy/config/environments/test.rb +37 -0
  62. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/dummy/config/initializers/inflections.rb +15 -0
  64. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  65. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  66. data/spec/dummy/config/initializers/session_store.rb +8 -0
  67. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  68. data/spec/dummy/config/locales/en.yml +5 -0
  69. data/spec/dummy/config/routes.rb +3 -0
  70. data/spec/dummy/db/schema.rb +476 -0
  71. data/spec/dummy/public/404.html +26 -0
  72. data/spec/dummy/public/422.html +26 -0
  73. data/spec/dummy/public/500.html +25 -0
  74. data/spec/dummy/public/favicon.ico +0 -0
  75. data/spec/dummy/script/rails +6 -0
  76. data/spec/fixtures/assets/gb_banner.jpg +0 -0
  77. data/spec/fixtures/assets/gb_logo.png +0 -0
  78. data/spec/fixtures/assets/high_res_photo.jpg +0 -0
  79. data/spec/fixtures/assets/untitled +0 -0
  80. data/spec/fixtures/members.csv +5 -0
  81. data/spec/fixtures/staff_profiles.csv +4 -0
  82. data/spec/helpers/page_info_spec.rb +213 -0
  83. data/spec/mailers/blog_notifier_spec.rb +127 -0
  84. data/spec/models/article_spec.rb +213 -0
  85. data/spec/spec_helper.rb +67 -0
  86. metadata +203 -0
@@ -0,0 +1,10 @@
1
+ - @page_title = "#{link_to "Blogs", admin_blogs_path} > Add New Blog"
2
+
3
+ .row-fluid
4
+ = render :partial => "/gluttonberg/admin/content/main/sidebar"
5
+
6
+ .span9
7
+ .page-header
8
+ %h1
9
+ = @page_title.html_safe
10
+ = render :partial => "form", :locals => {:url => admin_blogs_path}
@@ -0,0 +1,66 @@
1
+ - @page_title = "Comments"
2
+
3
+ .row-fluid
4
+ = render :partial => "/gluttonberg/admin/content/main/sidebar"
5
+ .span9
6
+ .row-fluid
7
+ .page-header
8
+ %h1
9
+ = @page_title
10
+ .subnav
11
+ - if action_name != "index"
12
+ = sub_nav do
13
+ = nav_link("Pending (#{Gluttonberg::Blog::Comment.all_pending.count})", admin_comments_pending_path)
14
+ = nav_link("Approved (#{Gluttonberg::Blog::Comment.all_approved.count})", admin_comments_approved_path)
15
+ = nav_link("Rejected (#{Gluttonberg::Blog::Comment.all_rejected.count})", admin_comments_rejected_path)
16
+ = nav_link("Spam (#{Gluttonberg::Blog::Comment.all_spam.count})", admin_comments_spam_path)
17
+
18
+
19
+ - if @comments.empty?
20
+ %p.empty No Comments
21
+ - else
22
+ %table{:cellpadding => 0, :cellspacing => 0, :summary => "Articles" , :class => "table table-bordered "}
23
+ %thead
24
+ %tr
25
+ %th
26
+ Author
27
+ %th
28
+ Comment
29
+ %th
30
+ Date Commented
31
+ %th.controls
32
+ Controls
33
+ %tbody
34
+ - @comments.each do |comment|
35
+ %tr
36
+ %td{:style => "width:15%;"}
37
+ = comment.author_name
38
+ %td{:style => "width:50%;"}
39
+ = simple_format(comment.body)
40
+ %td{:style => "width:10%;"}
41
+ = comment.created_at
42
+ %td.controls{:style => "width:20%;"}
43
+ .btn-group
44
+ %a{ :class => "btn dropdown-toggle" , "data-toggle" => "dropdown" , :href => "#"}
45
+ Actions
46
+ %span.caret
47
+ %ul.dropdown-menu
48
+
49
+ - if comment.moderation_required && can?(:moderate , Gluttonberg::Blog::Comment)
50
+ %li= link_to("Approve", admin_comments_moderation_path(comment, :moderation => "approve"), :class => "")
51
+ %li= link_to( "Reject", admin_comments_moderation_path(comment, :moderation => "disapprove") , :class => "")
52
+ %li= link_to( "Block comments from this author", admin_comments_block_author_path(comment) , :class => "")
53
+ - elsif can?(:moderate , Gluttonberg::Blog::Comment)
54
+ - if comment.approved == true
55
+ %li= link_to( "Reject", admin_comments_moderation_path(comment, :moderation => "disapprove") , :class => "")
56
+ - else
57
+ %li= link_to("Approve", admin_comments_moderation_path(comment, :moderation => "approve"), :class => "")
58
+ %li.divider
59
+ %li.danger= link_to("Delete", admin_comments_delete_path(comment), :class => "")
60
+ = will_paginate(@comments)
61
+
62
+ - if action_name == "pending"
63
+ %p
64
+ If you have recently updated spam settings then please click on following link for re-assessing all pending comments with new spam settings.
65
+
66
+ = link_to "Detect spam in all pending comments" , admin_comments_spam_detection_for_all_pending_path , :class => "btn btn-info"
@@ -0,0 +1,21 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title @blog.name
5
+ xml.description @blog.description
6
+ xml.link blog_url(@blog.slug)
7
+
8
+ for article in @articles
9
+ xml.item do
10
+ xml.title article.title
11
+ xml.description article.excerpt || article.body
12
+ xml.pubDate article.created_at.to_s(:rfc822)
13
+ unless article.featured_image.blank?
14
+ xml.image (article.featured_image.url)
15
+ end
16
+ xml.link blog_article_path(:blog_id => @blog.slug, :id => article.slug)
17
+ xml.guid blog_article_path(:blog_id => @blog.slug, :id => article.slug)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title @blog.name
5
+ xml.description @blog.description
6
+ xml.link blog_url(@blog.slug)
7
+
8
+ for article in @articles
9
+ xml.item do
10
+ xml.title article.title
11
+ xml.description article.excerpt || article.body
12
+ xml.pubDate article.created_at.to_s(:rfc822)
13
+ unless article.featured_image.blank?
14
+ xml.image (article.featured_image.url)
15
+ end
16
+ xml.link blog_article_url(:blog_id => @blog.slug, :id => article.slug)
17
+ xml.guid blog_article_url(:blog_id => @blog.slug, :id => article.slug)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Blog</title>
5
+ <%= stylesheet_link_tag "blog/application", :media => "all" %>
6
+ <%= javascript_include_tag "blog/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,53 @@
1
+ Rails.application.routes.draw do
2
+ scope :module => 'gluttonberg' do
3
+ namespace :admin do
4
+ scope :module => 'blog' do
5
+ scope 'comments', :controller => :comments, :as => :comments do
6
+ get 'spam_detection_for_all_pending' , :as => :spam_detection_for_all_pending
7
+ get 'pending', :as => :pending
8
+ get 'spam' , :as => :spam
9
+ get 'approved' , :as => :approved
10
+ get 'rejected' => :rejected , :as => :rejected
11
+ get '/moderation/:id/:moderation' => :moderation , :as => :moderation
12
+ get '/delete/:id' => :delete , :as => :delete
13
+ delete '/destroy/:id' => :destroy , :as => :destroy
14
+ get '/block_author/:id' => :block_author , :as => :block_author
15
+ end
16
+
17
+ resources :blogs do
18
+ get 'delete', :on => :member
19
+ resources :articles do
20
+ member do
21
+ get 'delete'
22
+ get 'duplicate'
23
+ end
24
+ collection do
25
+ match 'import'
26
+ get 'export'
27
+ end
28
+ resources :comments do
29
+ member do
30
+ get 'delete'
31
+ end
32
+ end
33
+ end
34
+ end # blogs
35
+ end #blog module
36
+ end #admin
37
+ scope :module => 'public' do
38
+ # Blog Stuff
39
+ scope :module => 'blog' do
40
+ get "/articles/tag/:tag" => "articles#tag" , :as => :articles_by_tag
41
+ get "/articles/unsubscribe/:reference" => "articles#unsubscribe" , :as => :unsubscribe_article_comments
42
+ scope "(/:locale)" do
43
+ resources :blogs do
44
+ resources :articles do
45
+ resources :comments
46
+ get "preview"
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end#public
52
+ end #gluttonberg
53
+ end
@@ -0,0 +1,42 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class Gluttonberg::BlogGenerator < Rails::Generators::Base
5
+ include Rails::Generators::Migration
6
+
7
+ def self.source_root
8
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
9
+ end
10
+
11
+ def self.next_migration_number(dirname)
12
+ Gluttonberg.next_migration_number(dirname)
13
+ end
14
+
15
+ def create_migration_file
16
+ migration_template 'blog_migration.rb', 'db/migrate/blog_migration.rb'
17
+ end
18
+
19
+ def generate_views
20
+ build_views
21
+ end
22
+
23
+ protected
24
+
25
+ def build_views
26
+ views = {
27
+ 'blogs_index.html.haml' => File.join('app/views/gluttonberg/public/blog/blogs', "index.html.haml"),
28
+ 'blogs_show.html.haml' => File.join('app/views/gluttonberg/public/blog/blogs', "show.html.haml"),
29
+ 'articles_index.html.haml' => File.join('app/views/gluttonberg/public/blog/articles', "index.html.haml"),
30
+ 'articles_show.html.haml' => File.join('app/views/gluttonberg/public/blog/articles', "show.html.haml"),
31
+ 'articles_tag.html.haml' => File.join('app/views/gluttonberg/public/blog/articles', "tag.html.haml")
32
+ }
33
+ copy_views(views)
34
+ end
35
+
36
+ def copy_views(views)
37
+ views.each do |template_name, output_path|
38
+ template template_name, output_path
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,18 @@
1
+ %h1
2
+ = @blog.name
3
+
4
+ #articles
5
+ - @articles.each do |article|
6
+ .article
7
+ %h2
8
+ - if Gluttonberg.localized?
9
+ = link_to article.title, blog_article_path(current_localization_slug ,@blog.slug, article.slug)
10
+ - else
11
+ = link_to article.title, blog_article_path(:blog_id => @blog.slug, :id => article.slug)
12
+ by
13
+ = article.author.full_name
14
+ %p
15
+ = asset_tag(article.featured_image , :small_thumb)
16
+ = article.excerpt.html_safe
17
+
18
+
@@ -0,0 +1,63 @@
1
+ %h1
2
+ = @blog.name
3
+
4
+ #articles
5
+ .article
6
+ %h2
7
+ = @article.title
8
+ by
9
+ = @article.author.full_name
10
+ = asset_tag(@article.featured_image , :small_thumb)
11
+ %p
12
+ = @article.body.html_safe
13
+ - unless @article.commenting_disabled?
14
+ #comments
15
+ %h3
16
+ Comments
17
+
18
+ - if @comments.blank?
19
+ %p
20
+ There are no comments.
21
+ - else
22
+ - @comments.each do |comment|
23
+ .comment
24
+ .content
25
+ = comment.body
26
+ .author
27
+ - if comment.author.blank?
28
+ Anonymous
29
+ - else
30
+ = comment.author.full_name
31
+ .time
32
+ = time_ago_in_words(comment.created_at)
33
+ ago
34
+ %br
35
+
36
+ #new_comment
37
+ = form_for(:comment, :url => blog_article_comments_path(current_localization_slug , @blog.slug, @article.slug)) do |f|
38
+ %p
39
+ = f.label :name
40
+ %br
41
+ = f.text_field :author_name
42
+ %p
43
+ = f.label :email
44
+ %br
45
+ = f.text_field :author_email
46
+ %p
47
+ = f.label :website
48
+ %br
49
+ = f.text_field :author_website
50
+ %p
51
+ = f.label :body , "Comment"
52
+ %br
53
+ = f.text_area :body
54
+ %p
55
+ = f.label :subscribe_to_comments
56
+ %br
57
+ = f.check_box :subscribe_to_comments
58
+
59
+
60
+ = honeypot_field_tag
61
+
62
+ %p
63
+ = f.submit
@@ -0,0 +1,25 @@
1
+ %h1
2
+ = params[:tag]
3
+
4
+ #articles
5
+ - @articles.each do |article|
6
+ .article
7
+ %h2
8
+ - if Gluttonberg.localized?
9
+ = link_to article.title, blog_article_path(current_localization_slug , article.blog.slug, article.slug)
10
+ - else
11
+ = link_to article.title, blog_article_path(:blog_id => @blog.slug, :id => article.slug)
12
+ by
13
+ = article.author.full_name
14
+ - unless article.excerpt.blank?
15
+ %p
16
+ = article.excerpt.html_safe
17
+
18
+ .tags_cloud
19
+ - tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class|
20
+
21
+ - if Gluttonberg.localized?
22
+ = link_to tag.name, articles_by_tag_path(current_localization_slug ,tag.name), :class => css_class
23
+ - else
24
+ = link_to tag.name, articles_by_tag_path(:tag => tag.name), :class => css_class
25
+
@@ -0,0 +1,94 @@
1
+ class BlogMigration < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :gb_weblogs do |t|
4
+ t.string :name, :null => false
5
+ t.string :slug, :null => false
6
+ t.text :description
7
+ t.integer :user_id, :null => false
8
+ t.column :state , :string
9
+ t.boolean :moderation_required, :default => true
10
+ t.string :seo_title
11
+ t.text :seo_keywords
12
+ t.text :seo_description
13
+ t.integer :fb_icon_id
14
+ t.string :previous_slug
15
+ t.datetime :published_at
16
+ t.timestamps
17
+ end
18
+
19
+ create_table :gb_articles do |t|
20
+ t.string :slug, :null => false
21
+ t.integer :blog_id, :null => false
22
+ t.integer :user_id, :null => false
23
+ t.integer :author_id, :null => false
24
+ t.column :state , :string #use for publishing
25
+ t.column :disable_comments , :boolean , :default => false
26
+ t.datetime :published_at
27
+ t.string :previous_slug
28
+ t.integer :comments_count, :default => 0
29
+ t.timestamps
30
+ end
31
+
32
+ create_table :gb_comments do |t|
33
+ t.text :body
34
+ t.string :author_name
35
+ t.string :author_email
36
+ t.string :author_website
37
+ t.references :commentable, :polymorphic => true
38
+ t.integer :author_id
39
+ t.boolean :moderation_required, :default => true
40
+ t.boolean :approved, :default => false
41
+ t.datetime :notification_sent_at
42
+ t.boolean :spam , :default => false
43
+ t.float :spam_score
44
+ t.timestamps
45
+ end
46
+
47
+ create_table :gb_comment_subscriptions do |t|
48
+ t.integer :article_id
49
+ t.string :author_name
50
+ t.string :author_email
51
+ t.string :reference_hash
52
+ t.timestamps
53
+ end
54
+
55
+ create_table :gb_article_localizations do |t|
56
+ t.string :title, :null => false
57
+ t.text :excerpt
58
+ t.text :body
59
+ t.integer :featured_image_id
60
+ t.column :article_id, :integer
61
+ t.column :locale_id, :integer
62
+ t.column :version, :integer
63
+ t.string :seo_title
64
+ t.text :seo_keywords
65
+ t.text :seo_description
66
+ t.integer :fb_icon_id
67
+ t.timestamps
68
+ end
69
+
70
+ begin
71
+ Gluttonberg::Blog::Weblog.create_versioned_table
72
+ rescue => e
73
+ puts e
74
+ end
75
+
76
+ begin
77
+ Gluttonberg::Blog::Article # make sure article model is loaded.
78
+ Gluttonberg::Blog::ArticleLocalization.create_versioned_table
79
+ rescue => e
80
+ puts e
81
+ end
82
+
83
+ end
84
+
85
+ def self.down
86
+ drop_table :gb_comments
87
+ drop_table :gb_articles
88
+ drop_table :gb_article_localizations
89
+ drop_table :gb_blogs
90
+ drop_table :gb_comment_subscriptions
91
+ Gluttonberg::Blog::Article # make sure article model is loaded.
92
+ Gluttonberg::Blog::ArticleLocalization.drop_versioned_table
93
+ end
94
+ end
@@ -0,0 +1,15 @@
1
+ %h1
2
+ Available Blogs
3
+
4
+ #blogs
5
+ - if @blogs.blank?
6
+ %p
7
+ There are no blogs yet.
8
+ - else
9
+ - @blogs.each do |blog|
10
+ .blog
11
+ - if Gluttonberg.localized?
12
+ = link_to blog.name, blog_path(current_localization_slug , blog.slug)
13
+ - else
14
+ = link_to blog.name, blog_path(:id => blog.slug)
15
+