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,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
File without changes
@@ -0,0 +1,5 @@
1
+ FIRST NAME,LAST NAME,EMAIL,GROUPS,BIO,test_column
2
+ Abdul,Rauf,test@test.com,Developer,Abdul Rauf is a web and mobile programmer.,
3
+ David,Walker,test2@test.com,Admin;Developer,,test value
4
+ Nick,Crowther,test1@test.com,,"",
5
+ test,test,,,"",
@@ -0,0 +1,4 @@
1
+ name,face_id,handwritting_id,bio,published_at,updated_at
2
+ Abdul,5,9,Abdul Rauf is a web and mobile programmer.,07/08/2013 03:30 AM,07/08/2013 03:30 AM
3
+ David,5,9,David Walker,,07/08/2013 03:30 AM
4
+ Nick,5,9,Nick Crowther,,07/08/2013 03:30 AM
@@ -0,0 +1,213 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module Gluttonberg
6
+ module Blog
7
+ describe Public do
8
+ before :all do
9
+ Gluttonberg::Setting.generate_common_settings
10
+ @locale = Gluttonberg::Locale.generate_default_locale
11
+ @user = User.new({
12
+ :first_name => "First",
13
+ :email => "valid_user@test.com",
14
+ :password => "password1",
15
+ :password_confirmation => "password1"
16
+ })
17
+ @user.role = "super_admin"
18
+ @user.save
19
+ @_blog = Weblog.create({
20
+ :name => "The Futurist",
21
+ :description => "Freerange Blog",
22
+ :user => @user
23
+ })
24
+ @_article = create_article(@_blog)
25
+ create_image_assets
26
+ end
27
+
28
+ after :all do
29
+ clean_all_data
30
+ end
31
+
32
+
33
+ it "Blog title" do
34
+ assign(:blog, @_blog)
35
+ helper.page_title.should eql("The Futurist")
36
+ end
37
+
38
+ it "Article title" do
39
+ assign(:article, @_article)
40
+ helper.page_title.should eql("Article Title")
41
+ end
42
+
43
+ it "Blog keywords" do
44
+ assign(:blog, @_blog)
45
+ helper.page_keywords.should be_nil
46
+
47
+ @_blog.seo_keywords = "blog, keywords"
48
+ @_blog.save
49
+
50
+ assign(:blog, @_blog)
51
+ helper.page_keywords.should eql("blog, keywords")
52
+
53
+ @_blog.seo_keywords = nil
54
+ @_blog.save
55
+
56
+ assign(:blog, @_blog)
57
+ helper.page_keywords.should be_nil
58
+ end
59
+
60
+ it "Article keywords" do
61
+ assign(:article, @_article)
62
+ helper.page_keywords.should be_nil
63
+
64
+ @_article.current_localization.seo_keywords = "article, keywords"
65
+ @_article.save
66
+
67
+ assign(:article, @_article)
68
+ helper.page_keywords.should eql("article, keywords")
69
+
70
+ @_article.current_localization.seo_keywords = nil
71
+ @_article.save
72
+
73
+ assign(:article, @_article)
74
+ helper.page_keywords.should be_nil
75
+ end
76
+
77
+
78
+ it "Blog description" do
79
+ assign(:blog, @_blog)
80
+ helper.page_description.should eql("")
81
+
82
+ @_blog.seo_description = "blog description"
83
+ @_blog.save
84
+
85
+ assign(:blog, @_blog)
86
+ helper.page_description.should eql("blog description")
87
+
88
+ @_blog.seo_description = nil
89
+ @_blog.save
90
+
91
+ assign(:blog, @_blog)
92
+ helper.page_description.should eql("")
93
+ end
94
+
95
+ it "Article description" do
96
+ assign(:article, @_article)
97
+ helper.page_description.should eql("")
98
+
99
+ @_article.current_localization.seo_description = "article description"
100
+ @_article.save
101
+
102
+ assign(:article, @_article)
103
+ helper.page_description.should eql("article description")
104
+
105
+ @_article.current_localization.seo_description = nil
106
+ @_article.save
107
+
108
+ assign(:article, @_article)
109
+ helper.page_description.should eql("")
110
+ end
111
+
112
+
113
+ it "Blog fb_icon" do
114
+ assign(:blog, @_blog)
115
+ helper.page_fb_icon_path.should be_nil
116
+
117
+ @_blog.fb_icon_id = @asset2.id
118
+ @_blog.save
119
+
120
+ assign(:blog, @_blog)
121
+ helper.page_fb_icon_path.should eql("http://test.host" + @asset2.url)
122
+
123
+ @_blog.fb_icon_id = nil
124
+ @_blog.save
125
+
126
+ assign(:blog, @_blog)
127
+ helper.page_fb_icon_path.should be_nil
128
+ end
129
+
130
+ it "Article fb_icon" do
131
+ assign(:article, @_article)
132
+ helper.page_fb_icon_path.should be_nil
133
+
134
+ @_article.current_localization.fb_icon_id = @asset2.id
135
+ @_article.save
136
+
137
+ assign(:article, @_article)
138
+ helper.page_fb_icon_path.should eql("http://test.host" + @asset2.url)
139
+
140
+ @_article.current_localization.fb_icon_id = nil
141
+ @_article.save
142
+
143
+ assign(:article, @_article)
144
+ helper.page_fb_icon_path.should be_nil
145
+ end
146
+
147
+ it "Blog classes" do
148
+ assign(:blog, @_blog)
149
+ helper.body_class.should eql("weblog #{@_blog.slug}")
150
+ end
151
+
152
+ it "Article classes" do
153
+ assign(:article, @_article)
154
+ helper.body_class.should eql("post #{@_article.slug}")
155
+ end
156
+
157
+ private
158
+ def create_article(blog)
159
+ @article_params = {
160
+ :name => "Article Title",
161
+ :author => @user,
162
+ :user => @user,
163
+ :blog => blog
164
+ }
165
+ @article_loc_params = {
166
+ :title => "Article Title",
167
+ :excerpt => "intro",
168
+ :body => "Introduction",
169
+ }
170
+ article = Article.new(@article_params)
171
+ article.save
172
+ article.create_localizations(@article_loc_params)
173
+ article
174
+ end
175
+
176
+ def create_image_assets
177
+ @file = GbFile.new(File.join(RSpec.configuration.fixture_path, "assets/gb_banner.jpg"))
178
+ @file.original_filename = "gluttonberg_banner.jpg"
179
+ @file.content_type = "image/jpeg"
180
+ @file.size = 300
181
+
182
+ @param = {
183
+ :name=>"temp file",
184
+ :file=> @file,
185
+ :description=>"<p>test</p>"
186
+ }
187
+
188
+ Gluttonberg::Library.bootstrap
189
+
190
+ @asset = Asset.new( @param )
191
+ @asset.save.should == true
192
+
193
+ @file2 = GbFile.new(File.join(RSpec.configuration.fixture_path, "assets/gb_logo.png"))
194
+ @file2.original_filename = "gluttonberg_logo.png"
195
+ @file2.content_type = "image/png"
196
+ @file2.size = 300
197
+
198
+ @param = {
199
+ :name=>"temp file",
200
+ :file=> @file2,
201
+ :description=>"<p>test</p>"
202
+ }
203
+
204
+ Gluttonberg::Library.bootstrap
205
+
206
+ @asset2 = Asset.new( @param )
207
+ @asset2.save.should == true
208
+ end
209
+
210
+
211
+ end #member
212
+ end
213
+ end
@@ -0,0 +1,127 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe BlogNotifier do
5
+
6
+ before(:each) do
7
+ @locale = Gluttonberg::Locale.generate_default_locale
8
+ Gluttonberg::Setting.generate_common_settings
9
+ end
10
+
11
+ before(:all) do
12
+ @params = {
13
+ :first_name => "First",
14
+ :email => "valid_user@test.com",
15
+ :password => "password1",
16
+ :password_confirmation => "password1"
17
+ }
18
+ @user = User.new(@params)
19
+ @user.role = "super_admin"
20
+ @user.save
21
+ @user.id.should_not be_nil
22
+ end
23
+
24
+ after :all do
25
+ clean_all_data
26
+ end
27
+
28
+
29
+ it "comment_notification" do
30
+ set_site_title
31
+ set_from_email_setting
32
+ @blog = Gluttonberg::Blog::Weblog.create({
33
+ :name => "The Futurist",
34
+ :description => "Freerange Blog",
35
+ :user => @user
36
+ })
37
+ create_member
38
+ @article = create_article
39
+ comment = create_comment
40
+ comment
41
+
42
+ subscription = Gluttonberg::Blog::CommentSubscription.create( {
43
+ :article_id => @article.id,
44
+ :author_email => comment.writer_email,
45
+ :author_name => comment.writer_name
46
+ })
47
+
48
+ mail_object = BlogNotifier.comment_notification(subscription , @article , comment)
49
+ mail_object.to.should eql(["author@test.com"])
50
+ mail_object.subject.should eql("Re: [Gluttonberg Test] Article")
51
+ mail_object.from.should eql(["from@test.com"])
52
+ message_object = mail_object.deliver
53
+ message_object.class.should == Mail::Message
54
+
55
+
56
+ mail_object = BlogNotifier.comment_notification_for_admin(@user , @article , comment)
57
+ mail_object.to.should eql([@user.email])
58
+ mail_object.subject.should eql("Re: [Gluttonberg Test] Article")
59
+ mail_object.from.should eql(["from@test.com"])
60
+ message_object = mail_object.deliver
61
+ message_object.class.should == Mail::Message
62
+
63
+ Gluttonberg::Blog::CommentSubscription.notify_subscribers_of(@article , comment)
64
+
65
+ reset_site_title
66
+ reset_from_email_setting
67
+ end
68
+
69
+
70
+ private
71
+ def set_from_email_setting
72
+ Gluttonberg::Setting.update_settings({"from_email" => "from@test.com"})
73
+ end
74
+
75
+ def reset_from_email_setting
76
+ Gluttonberg::Setting.update_settings({"from_email" => ""})
77
+ end
78
+
79
+ def set_site_title
80
+ Gluttonberg::Setting.update_settings({"title" => "Gluttonberg Test"})
81
+ end
82
+
83
+ def reset_site_title
84
+ Gluttonberg::Setting.update_settings({"title" => ""})
85
+ end
86
+
87
+ def create_article
88
+ @article_params = {
89
+ :name => "Article",
90
+ :author => @user,
91
+ :user => @user,
92
+ :blog => @blog
93
+ }
94
+ @article_loc_params = {
95
+ :title => "Article",
96
+ :excerpt => "intro",
97
+ :body => "Introduction",
98
+ }
99
+ article = Gluttonberg::Blog::Article.new(@article_params)
100
+ article.save
101
+ article.create_localizations(@article_loc_params)
102
+ article
103
+ end
104
+
105
+ def create_member
106
+ member_params = {
107
+ :first_name => "First",
108
+ :email => "valid_user@test.com",
109
+ :password => "password1",
110
+ :password_confirmation => "password1"
111
+ }
112
+ @member = Gluttonberg::Member.create(member_params)
113
+ end
114
+
115
+ def create_comment
116
+ params = {
117
+ :author_name => "Author Name",
118
+ :author_email => "author@test.com",
119
+ :author_website => "Author Website",
120
+ :commentable => @article,
121
+ :body => "Test comment"
122
+ }
123
+ comment = Gluttonberg::Blog::Comment.create(params)
124
+ end
125
+
126
+
127
+ end