mcms_blog 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/images/icons/accept.png +0 -0
- data/app/assets/images/icons/add.png +0 -0
- data/app/assets/images/icons/ajax-loader.gif +0 -0
- data/app/assets/images/icons/application_edit.png +0 -0
- data/app/assets/images/icons/application_go.png +0 -0
- data/app/assets/images/icons/arrow_left.png +0 -0
- data/app/assets/images/icons/arrow_switch.png +0 -0
- data/app/assets/images/icons/arrow_up.png +0 -0
- data/app/assets/images/icons/bin.png +0 -0
- data/app/assets/images/icons/bin_closed.png +0 -0
- data/app/assets/images/icons/cancel.png +0 -0
- data/app/assets/images/icons/cog_add.png +0 -0
- data/app/assets/images/icons/cog_edit.png +0 -0
- data/app/assets/images/icons/cross.png +0 -0
- data/app/assets/images/icons/delete.png +0 -0
- data/app/assets/images/icons/doc.png +0 -0
- data/app/assets/images/icons/down.gif +0 -0
- data/app/assets/images/icons/edit.png +0 -0
- data/app/assets/images/icons/email.png +0 -0
- data/app/assets/images/icons/email_edit.png +0 -0
- data/app/assets/images/icons/email_go.png +0 -0
- data/app/assets/images/icons/email_open.png +0 -0
- data/app/assets/images/icons/eye.png +0 -0
- data/app/assets/images/icons/folder_page_white.png +0 -0
- data/app/assets/images/icons/image_add.png +0 -0
- data/app/assets/images/icons/image_edit.png +0 -0
- data/app/assets/images/icons/img.png +0 -0
- data/app/assets/images/icons/information.png +0 -0
- data/app/assets/images/icons/layout_add.png +0 -0
- data/app/assets/images/icons/layout_edit.png +0 -0
- data/app/assets/images/icons/music.png +0 -0
- data/app/assets/images/icons/page_add.png +0 -0
- data/app/assets/images/icons/page_edit.png +0 -0
- data/app/assets/images/icons/page_white_edit.png +0 -0
- data/app/assets/images/icons/page_white_gear.png +0 -0
- data/app/assets/images/icons/page_white_put.png +0 -0
- data/app/assets/images/icons/pdf.png +0 -0
- data/app/assets/images/icons/ppt.png +0 -0
- data/app/assets/images/icons/star.png +0 -0
- data/app/assets/images/icons/tick.png +0 -0
- data/app/assets/images/icons/up.gif +0 -0
- data/app/assets/images/icons/user_add.png +0 -0
- data/app/assets/images/icons/user_comment.png +0 -0
- data/app/assets/images/icons/user_edit.png +0 -0
- data/app/assets/images/icons/xls.png +0 -0
- data/app/assets/images/icons/zip.png +0 -0
- data/app/assets/images/icons/zoom.png +0 -0
- data/app/assets/images/page_bg.png +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/admin/blog/mcms-blog-submenu.js +50 -0
- data/app/assets/javascripts/contrib/ui.core.js +519 -0
- data/app/assets/javascripts/contrib/ui.tabs.js +688 -0
- data/app/assets/javascripts/posts.js +3 -0
- data/app/assets/stylesheets/blog_global.css +1587 -0
- data/app/assets/stylesheets/blog_home.css +1432 -0
- data/app/assets/stylesheets/home.css +1429 -0
- data/app/assets/stylesheets/images/back_ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/app/assets/stylesheets/images/spellayt.gif +0 -0
- data/app/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_green.png +1 -0
- data/app/assets/stylesheets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/app/assets/stylesheets/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_217bc0_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_469bdd_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_6da8d5_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/app/assets/stylesheets/images/ui-icons_f9bd01_256x240.png +0 -0
- data/app/assets/stylesheets/jquery-ui-1.8.6.custom.css +572 -0
- data/app/assets/stylesheets/submenu.css.scss +32 -0
- data/app/controllers/admin/blog/categories_controller.rb +47 -0
- data/app/controllers/admin/blog/comments_controller.rb +64 -0
- data/app/controllers/admin/blog/posts_controller.rb +80 -0
- data/app/controllers/admin/blog/settings_controller.rb +67 -0
- data/app/controllers/application_controller.rb +29 -0
- data/app/controllers/blog/categories_controller.rb +34 -0
- data/app/controllers/blog/comments_controller.rb +34 -0
- data/app/controllers/blog/posts_controller.rb +123 -0
- data/app/controllers/blog_controller.rb +31 -0
- data/app/helpers/application_helper.rb +5 -0
- data/app/helpers/blog_helper.rb +66 -0
- data/app/helpers/notification_hepler.rb +5 -0
- data/app/helpers/settings_helper.rb +38 -0
- data/app/mailers/blog/comment_mailer.rb +12 -0
- data/app/models/blog_category.rb +29 -0
- data/app/models/blog_comment.rb +109 -0
- data/app/models/blog_post.rb +121 -0
- data/app/models/categorization.rb +16 -0
- data/app/models/ckeditor/asset.rb +6 -0
- data/app/models/ckeditor/attachment_file.rb +12 -0
- data/app/models/ckeditor/picture.rb +13 -0
- data/app/models/setting.rb +59 -0
- data/app/views/admin/blog/_submenu.html.erb +89 -0
- data/app/views/admin/blog/categories/_category.html.erb +20 -0
- data/app/views/admin/blog/categories/_form.html.erb +21 -0
- data/app/views/admin/blog/categories/_sortable_list.html.erb +3 -0
- data/app/views/admin/blog/categories/edit.html.erb +1 -0
- data/app/views/admin/blog/categories/index.html.erb +23 -0
- data/app/views/admin/blog/categories/new.html.erb +2 -0
- data/app/views/admin/blog/comments/_comment.html.erb +27 -0
- data/app/views/admin/blog/comments/_sortable_list.html.erb +11 -0
- data/app/views/admin/blog/comments/index.html.erb +12 -0
- data/app/views/admin/blog/comments/show.html.erb +70 -0
- data/app/views/admin/blog/posts/_form.css.erb +22 -0
- data/app/views/admin/blog/posts/_form.html.erb +92 -0
- data/app/views/admin/blog/posts/_form.js.erb +34 -0
- data/app/views/admin/blog/posts/_form_part.html.erb +10 -0
- data/app/views/admin/blog/posts/_post.html.erb +26 -0
- data/app/views/admin/blog/posts/_sortable_list.html.erb +3 -0
- data/app/views/admin/blog/posts/_teaser_part.html.erb +11 -0
- data/app/views/admin/blog/posts/edit.html.erb +1 -0
- data/app/views/admin/blog/posts/index.html.erb +29 -0
- data/app/views/admin/blog/posts/new.html.erb +13 -0
- data/app/views/admin/blog/settings/notification_recipients.html.erb +23 -0
- data/app/views/blog/categories/show.html.erb +17 -0
- data/app/views/blog/posts/_comment.html.erb +17 -0
- data/app/views/blog/posts/_nav.html.erb +18 -0
- data/app/views/blog/posts/_post.html.erb +25 -0
- data/app/views/blog/posts/archive.html.erb +17 -0
- data/app/views/blog/posts/index.html.erb +15 -0
- data/app/views/blog/posts/show.html.erb +64 -0
- data/app/views/blog/posts/tagged.html.erb +20 -0
- data/app/views/blog/shared/_categories.html.erb +19 -0
- data/app/views/blog/shared/_post.html.erb +34 -0
- data/app/views/blog/shared/_posts.html.erb +17 -0
- data/app/views/blog/shared/_rss_feed.html.erb +2 -0
- data/app/views/blog/shared/_tags.html.erb +17 -0
- data/app/views/layouts/_javascript.html.erb +3 -0
- data/app/views/layouts/_scripts.html.erb +6 -0
- data/app/views/layouts/_stylesheets.html.erb +6 -0
- data/app/views/layouts/admin.html.erb +25 -0
- data/app/views/layouts/application.html.erb +38 -0
- data/app/views/layouts/home.html.erb +38 -0
- data/app/views/shared/_footer.html.erb +3 -0
- data/app/views/shared/_head.html.erb +4 -0
- data/app/views/shared/_header.html.erb +7 -0
- data/app/views/shared/_javascripts.html.erb +3 -0
- data/app/views/shared/_menu.html.erb +9 -0
- data/app/views/shared/_stylesheets.html.erb +6 -0
- data/app/views/shared/admin/_error_messages.html.erb +16 -0
- data/app/views/shared/admin/_form_actions.html.erb +34 -0
- data/config/locales/en.yml +192 -0
- data/config/routes.rb +65 -0
- data/db/migrate/20120606150655_create_mcms_assets.rb +26 -0
- data/db/migrate/20120608071959_create_blog_categories.rb +9 -0
- data/db/migrate/20120608072013_create_blog_comments.rb +14 -0
- data/db/migrate/20120608072027_create_blog_posts.rb +16 -0
- data/db/migrate/20120612055745_create_categorizations.rb +9 -0
- data/db/migrate/20120618104134_add_index_in_blog_comments.rb +5 -0
- data/db/migrate/20120618105246_add_custom_index_in_mcms_blog_comments.rb +5 -0
- data/db/migrate/20120618105511_add_custom_index_in_mcms_blog_posts.rb +5 -0
- data/db/migrate/20120619094143_create_settings.rb +12 -0
- data/db/migrate/20120627063009_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/20120629065434_add_slug_to_blog_post.rb +6 -0
- data/db/migrate/20120629113457_add_slug_to_mcms_blog_category.rb +6 -0
- data/db/seeds.rb +26 -0
- data/lib/generators/mcms_blog/USAGE +8 -0
- data/lib/generators/mcms_blog/mcms_blog_generator.rb +60 -0
- data/lib/generators/mcms_blog/templates/asset_manager.rb +107 -0
- data/lib/generators/mcms_blog/templates/ckeditor.rb +18 -0
- data/lib/mcms_blog/engine.rb +18 -0
- data/lib/mcms_blog/version.rb +3 -0
- data/lib/mcms_blog.rb +4 -0
- data/lib/tasks/mcms_blog_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/mcms_blog_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +403 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
=begin
|
2
|
+
@Name :BlogCategory model
|
3
|
+
@Created at :12-06-2012
|
4
|
+
@Updated at :12-06-2012
|
5
|
+
@Purpose :Needed for initailizing activerecord for blog_categories table in rails
|
6
|
+
@Company : Mindfire Solutions
|
7
|
+
=end
|
8
|
+
class BlogCategory < ActiveRecord::Base
|
9
|
+
extend FriendlyId
|
10
|
+
friendly_id :title, use: :slugged
|
11
|
+
|
12
|
+
#set table name prefix as mcms_
|
13
|
+
self.table_name = 'mcms_blog_categories'
|
14
|
+
|
15
|
+
#attribute accessibles
|
16
|
+
attr_accessible :title
|
17
|
+
|
18
|
+
#validation rules
|
19
|
+
validates :title, :presence => true
|
20
|
+
|
21
|
+
|
22
|
+
#model association rules
|
23
|
+
has_many :categorizations
|
24
|
+
has_many :posts, :through => :categorizations, :source => :blog_post
|
25
|
+
|
26
|
+
def post_count
|
27
|
+
posts.select(&:live?).count
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
=begin
|
2
|
+
@Name :BlogComment model
|
3
|
+
@Created at :12-06-2012
|
4
|
+
@Updated at :12-06-2012
|
5
|
+
@Purpose :Needed for initailizing activerecord for blog_comments table in rails
|
6
|
+
@Company :Mindfire Solutions
|
7
|
+
=end
|
8
|
+
class BlogComment < ActiveRecord::Base
|
9
|
+
|
10
|
+
#set a table name prefix
|
11
|
+
self.table_name = 'mcms_blog_comments'
|
12
|
+
|
13
|
+
#including NotificationHelper for notification helper methods
|
14
|
+
include ApplicationHelper
|
15
|
+
|
16
|
+
#attribute accessibles
|
17
|
+
attr_accessible :name, :email, :body, :blog_post_id, :state
|
18
|
+
|
19
|
+
#defining model associations
|
20
|
+
belongs_to :post, :class_name => 'BlogPost', :foreign_key => 'blog_post_id'
|
21
|
+
|
22
|
+
#validation rules
|
23
|
+
validates :name, :body, :presence => true
|
24
|
+
validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
|
25
|
+
|
26
|
+
#defining some scopes for lambda call
|
27
|
+
scope :unmoderated, :conditions => {:state=> nil}
|
28
|
+
scope :approved, :conditions => {:state => 'approved'}
|
29
|
+
scope :rejected, :conditions => {:state => 'rejected'}
|
30
|
+
|
31
|
+
|
32
|
+
#Set the approved state for the comment
|
33
|
+
def approve!
|
34
|
+
self.update_attribute(:state, 'approved')
|
35
|
+
end
|
36
|
+
|
37
|
+
#Set the reject state for the comment
|
38
|
+
def reject!
|
39
|
+
self.update_attribute(:state, 'rejected')
|
40
|
+
end
|
41
|
+
|
42
|
+
#Findout whether the comment is rejected or not
|
43
|
+
def is_rejected?
|
44
|
+
self.state == 'rejected'
|
45
|
+
end
|
46
|
+
|
47
|
+
#Findout whether the comment is approved or not
|
48
|
+
def is_approved?
|
49
|
+
self.state == 'approved'
|
50
|
+
end
|
51
|
+
|
52
|
+
#Findout whether the comment is unmoderated or not
|
53
|
+
def is_unmoderated?
|
54
|
+
self.state.nil?
|
55
|
+
end
|
56
|
+
|
57
|
+
#Notification module related to comment notifications
|
58
|
+
module Notification
|
59
|
+
|
60
|
+
class << self
|
61
|
+
#recipients method setting or finding a perticular recipient for mcms
|
62
|
+
def recipients
|
63
|
+
#notify_me
|
64
|
+
end
|
65
|
+
|
66
|
+
def recipients=(emails)
|
67
|
+
Setting.set_notification_recipient(emails)
|
68
|
+
end
|
69
|
+
|
70
|
+
def subject
|
71
|
+
"New inquiry from your website"
|
72
|
+
end
|
73
|
+
|
74
|
+
def find_notification_recipient
|
75
|
+
Setting.find_notification_recipient
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#Moderation module for comments
|
82
|
+
module Moderation
|
83
|
+
class << self
|
84
|
+
def enabled?
|
85
|
+
value = Setting.find_by_name('comment_moderation').value
|
86
|
+
if value.to_i == 1
|
87
|
+
return true
|
88
|
+
else
|
89
|
+
return false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def toggle!
|
94
|
+
new_value = {
|
95
|
+
:value => !BlogComment::Moderation.enabled?,
|
96
|
+
:scoping => 'blog',
|
97
|
+
:restricted => false
|
98
|
+
}
|
99
|
+
if RefinerySetting.respond_to?(:set)
|
100
|
+
RefinerySetting.set(:comment_moderation, new_value)
|
101
|
+
else
|
102
|
+
RefinerySetting[:comment_moderation] = new_value
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
=begin
|
2
|
+
@Name :BlogPost model
|
3
|
+
@Created at :12-06-2012
|
4
|
+
@Updated at :12-06-2012
|
5
|
+
@Purpose :Needed for initailizing activerecord for blog_posts table in rails
|
6
|
+
@Company : Mindfire Solutions
|
7
|
+
=end
|
8
|
+
|
9
|
+
class BlogPost < ActiveRecord::Base
|
10
|
+
extend FriendlyId
|
11
|
+
friendly_id :title, use: :slugged
|
12
|
+
|
13
|
+
#setting a table name prefix with mcms_
|
14
|
+
self.table_name = 'mcms_blog_posts'
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
#attribute accessibles
|
20
|
+
attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids, :custom_url, :custom_teaser,
|
21
|
+
:cached_slug
|
22
|
+
|
23
|
+
#Defining model associations
|
24
|
+
belongs_to :author, :class_name => 'User', :foreign_key => :user_id
|
25
|
+
has_many :comments, :class_name => 'BlogComment', :dependent => :destroy
|
26
|
+
has_many :categorizations
|
27
|
+
has_many :categories, :through => :categorizations, :source => :blog_category
|
28
|
+
|
29
|
+
#validation rules
|
30
|
+
validates :title, :presence => true
|
31
|
+
validates :body, :presence => true
|
32
|
+
|
33
|
+
#acts_as_taggable for blog posts
|
34
|
+
acts_as_taggable
|
35
|
+
|
36
|
+
#setting a default scope for all records
|
37
|
+
default_scope :order => 'published_at DESC'
|
38
|
+
|
39
|
+
#defining scope for user-defined functionality
|
40
|
+
scope :live, lambda { where( "published_at <= ? and draft = ?", Time.now, false) }
|
41
|
+
scope :all_previous, lambda { where(['published_at <= ?', Time.now.beginning_of_month]) }
|
42
|
+
scope :by_archive, lambda { |archive_date|
|
43
|
+
where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month])
|
44
|
+
}
|
45
|
+
|
46
|
+
scope :by_year, lambda { |archive_year|
|
47
|
+
where(['published_at between ? and ?', archive_year.beginning_of_year, archive_year.end_of_year])
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
def live?
|
52
|
+
!draft and published_at <= Time.now
|
53
|
+
end
|
54
|
+
|
55
|
+
#class methods started here
|
56
|
+
class << self
|
57
|
+
def next current_record
|
58
|
+
self.send(:with_exclusive_scope) do
|
59
|
+
where(["published_at > ? and draft = ?", current_record.published_at, false]).order("published_at ASC")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def comments_allowed?
|
64
|
+
# RefinerySetting.find_or_set(:comments_allowed, true, {
|
65
|
+
# :scoping => 'blog'
|
66
|
+
# })
|
67
|
+
end
|
68
|
+
|
69
|
+
def uncategorized
|
70
|
+
BlogPost.live.reject { |p| p.categories.any? }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#Added module for settings
|
75
|
+
module CommentSetting
|
76
|
+
class << self
|
77
|
+
|
78
|
+
#this method returns true if comments_allowed value is true or 1 neither false in settings table
|
79
|
+
def is_comments_allowed?
|
80
|
+
value = Setting.find_by_name('comment_allowed').value
|
81
|
+
if value.to_i == 1
|
82
|
+
return true
|
83
|
+
else
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#this method returns true if comments_moderated value is true or 1 neither false in settings table
|
89
|
+
def is_comments_moderated?
|
90
|
+
value = Setting.find_by_name('comment_moderation').value
|
91
|
+
if value.to_i == 1
|
92
|
+
true
|
93
|
+
else
|
94
|
+
false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
#this method update the comments_allowed value to false
|
99
|
+
def do_uncommentable
|
100
|
+
Setting.blog_uncommentable_setting
|
101
|
+
end
|
102
|
+
|
103
|
+
#this method update the comments_allowed value to true
|
104
|
+
def do_commentable
|
105
|
+
Setting.blog_commentable_setting
|
106
|
+
end
|
107
|
+
|
108
|
+
#this method update the comments_allowed value to false
|
109
|
+
def do_unmoderatable
|
110
|
+
Setting.blog_unmoderatable_setting
|
111
|
+
end
|
112
|
+
|
113
|
+
#this method update the comments_allowed value to true
|
114
|
+
def do_moderatable
|
115
|
+
Setting.blog_moderatable_setting
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
=begin
|
2
|
+
@Name Categorization model
|
3
|
+
@Created at :12-06-2012
|
4
|
+
@Updated at :12-06-2012
|
5
|
+
@Purpose :Needed for initailizing activerecord for blog_categories_blog_posts table in rails
|
6
|
+
@Company : Mindfire Solutions
|
7
|
+
=end
|
8
|
+
class Categorization < ActiveRecord::Base
|
9
|
+
|
10
|
+
#Setting table name
|
11
|
+
self.table_name = 'mcms_blog_categories_blog_posts'
|
12
|
+
|
13
|
+
#Defining model associations
|
14
|
+
belongs_to :blog_post
|
15
|
+
belongs_to :blog_category
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Ckeditor::AttachmentFile < Ckeditor::Asset
|
2
|
+
has_attached_file :data,
|
3
|
+
:url => "/ckeditor_assets/attachments/:id/:filename",
|
4
|
+
:path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
|
5
|
+
|
6
|
+
validates_attachment_size :data, :less_than => 100.megabytes
|
7
|
+
validates_attachment_presence :data
|
8
|
+
|
9
|
+
def url_thumb
|
10
|
+
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Ckeditor::Picture < Ckeditor::Asset
|
2
|
+
has_attached_file :data,
|
3
|
+
:url => "/ckeditor_assets/pictures/:id/:style_:basename.:extension",
|
4
|
+
:path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",
|
5
|
+
:styles => { :content => '800>', :thumb => '118x100#' }
|
6
|
+
|
7
|
+
validates_attachment_size :data, :less_than => 2.megabytes
|
8
|
+
validates_attachment_presence :data
|
9
|
+
|
10
|
+
def url_content
|
11
|
+
url(:content)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
=begin
|
2
|
+
@Name :Setting model
|
3
|
+
@Created at :19-06-2012
|
4
|
+
@Updated at :20-06-2012
|
5
|
+
@Purpose :Needed for initailizing activerecord for mcms_settings table in rails
|
6
|
+
@Company :Mindfire Solutions
|
7
|
+
=end
|
8
|
+
class Setting < ActiveRecord::Base
|
9
|
+
|
10
|
+
#setting a table name prefix with mcms_
|
11
|
+
self.table_name = 'mcms_settings'
|
12
|
+
|
13
|
+
#including SettingsHelper to call helper methods here
|
14
|
+
include SettingsHelper
|
15
|
+
|
16
|
+
#attr_accessibles
|
17
|
+
attr_accessible :name, :value, :destroyable
|
18
|
+
|
19
|
+
#make settings for blogs to be uncommentable by updating attribute value to 0
|
20
|
+
def self.blog_uncommentable_setting
|
21
|
+
self.find_by_name('comment_allowed').update_attribute(:value, SettingsHelper.uncommentable)
|
22
|
+
end
|
23
|
+
|
24
|
+
#make settings for blogs to be commentable by updating attribute value to 1
|
25
|
+
def self.blog_commentable_setting
|
26
|
+
self.find_by_name('comment_allowed').update_attribute(:value, SettingsHelper.commentable)
|
27
|
+
end
|
28
|
+
|
29
|
+
#make settings for blogs to be unmoderatable by updating attribute value to 0
|
30
|
+
def self.blog_unmoderatable_setting
|
31
|
+
self.find_by_name('comment_moderation').update_attributes(:value => SettingsHelper.unmoderatable)
|
32
|
+
end
|
33
|
+
|
34
|
+
#make settings for blogs to be moderatable by updating attribute value to 1
|
35
|
+
def self.blog_moderatable_setting
|
36
|
+
self.find_by_name('comment_moderation').update_attributes(:value => SettingsHelper.moderatable)
|
37
|
+
end
|
38
|
+
|
39
|
+
#retrieve notification_recipient email
|
40
|
+
def self.notification_recipient
|
41
|
+
email_id = self.find_by_name('notication_recipient').email
|
42
|
+
if email_id.present?
|
43
|
+
return email_id
|
44
|
+
else
|
45
|
+
return User.first.email
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#Setting notification recipients emails.
|
50
|
+
def self.set_notification_recipient(emails)
|
51
|
+
self.find_by_name('notification_recipient').update_attributes(:value => emails)
|
52
|
+
end
|
53
|
+
|
54
|
+
#Finding notification recipients emails.
|
55
|
+
def self.find_notification_recipient
|
56
|
+
self.find_by_name('notification_recipient').value
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/_submenu.html.erb
|
3
|
+
@Use: This is a page for displaying menu parts in admin side
|
4
|
+
@Created date: 13-06-2012
|
5
|
+
@Modified Date: 13-06-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<nav id='actions' class='multilist'>
|
9
|
+
|
10
|
+
<ul class='collapsible-menu'>
|
11
|
+
<li class='not-a-link'>
|
12
|
+
<%= link_to t('.posts.title'), '#',
|
13
|
+
:class => 'page-copy-icon' %>
|
14
|
+
</li>
|
15
|
+
<li>
|
16
|
+
<%= link_to t('.posts.manage'), admin_blog_posts_path,
|
17
|
+
:class => 'page-icon' %>
|
18
|
+
</li>
|
19
|
+
<li>
|
20
|
+
<%= link_to t('.posts.uncategorized'), uncategorized_admin_blog_posts_url,
|
21
|
+
:class => 'page-icon' %>
|
22
|
+
</li>
|
23
|
+
<li>
|
24
|
+
<%= link_to t('.posts.new'), new_admin_blog_post_url,
|
25
|
+
:class => 'page-add-icon' %>
|
26
|
+
</li>
|
27
|
+
</ul>
|
28
|
+
|
29
|
+
|
30
|
+
<ul class='collapsible-menu'>
|
31
|
+
<li class='not-a-link'>
|
32
|
+
<%= link_to t('.categories.title'), '#',
|
33
|
+
:class => 'folder-icon' %>
|
34
|
+
</li>
|
35
|
+
<li>
|
36
|
+
<%= link_to t('.categories.manage'), admin_blog_categories_url,
|
37
|
+
:class => 'folder-edit-icon' %>
|
38
|
+
</li>
|
39
|
+
<li>
|
40
|
+
<%= link_to t('.categories.new'), new_admin_blog_category_url,
|
41
|
+
:class => 'folder-add-icon' %>
|
42
|
+
</li>
|
43
|
+
</ul>
|
44
|
+
|
45
|
+
<% if BlogPost::CommentSetting.is_comments_allowed? %>
|
46
|
+
<ul class='collapsible-menu'>
|
47
|
+
<li class='not-a-link'>
|
48
|
+
|
49
|
+
<%= link_to 'Comments', '#',
|
50
|
+
:class => 'comments-icon' %>
|
51
|
+
</li>
|
52
|
+
<li>
|
53
|
+
<%= link_to t('.comments.new'), admin_blog_comments_path,
|
54
|
+
:class => 'comment-icon' %>
|
55
|
+
</li>
|
56
|
+
<li>
|
57
|
+
<%= link_to t('.comments.approved'), approved_admin_blog_comments_path,
|
58
|
+
:class => 'comment-tick-icon' %>
|
59
|
+
</li>
|
60
|
+
<li>
|
61
|
+
<%= link_to t('.comments.rejected'), rejected_admin_blog_comments_path,
|
62
|
+
:class => 'comment-cross-icon' %>
|
63
|
+
</li>
|
64
|
+
</ul>
|
65
|
+
<% end %>
|
66
|
+
|
67
|
+
<ul class='collapsible-menu'>
|
68
|
+
<li class='not-a-link'>
|
69
|
+
<%= link_to t('.settings.title'), admin_blog_settings_path,
|
70
|
+
:class => 'settings-icon' %>
|
71
|
+
</li>
|
72
|
+
<li>
|
73
|
+
<%= link_to t('.settings.comments'), comments_admin_blog_settings_url,
|
74
|
+
:class => "#{BlogPost::CommentSetting.is_comments_allowed? ? 'success' : 'failure'}-icon" %>
|
75
|
+
</li>
|
76
|
+
<li>
|
77
|
+
<%= link_to t('.settings.moderation'), moderation_admin_blog_settings_url,
|
78
|
+
:class => "#{BlogPost::CommentSetting.is_comments_moderated? ? 'success' : 'failure'}-icon" %>
|
79
|
+
</li>
|
80
|
+
<li>
|
81
|
+
<%= link_to t('.settings.update_notified'),
|
82
|
+
notification_recipients_admin_blog_settings_url,
|
83
|
+
:class => 'user-comment-icon' %>
|
84
|
+
</li>
|
85
|
+
</ul>
|
86
|
+
|
87
|
+
</nav>
|
88
|
+
|
89
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(category) -%>">
|
2
|
+
<span class='title'>
|
3
|
+
<%= category.title %>
|
4
|
+
<span class="preview"> </span>
|
5
|
+
</span>
|
6
|
+
|
7
|
+
<span class='actions'>
|
8
|
+
|
9
|
+
<%= link_to image_tag("icons/application_edit.png"), edit_admin_blog_category_path(category),
|
10
|
+
:title => 'Edit' %>
|
11
|
+
<%= link_to image_tag("icons/delete.png"), admin_blog_category_path(category),
|
12
|
+
:class => "cancel confirm-delete",
|
13
|
+
:title => 'Delete',
|
14
|
+
:method => :delete,
|
15
|
+
:confirm => "Are you sure to delete ?" %>
|
16
|
+
<%= link_to image_tag("icons/application_go.png"), blog_category_path(category),
|
17
|
+
:title => 'Show' %>
|
18
|
+
</span>
|
19
|
+
|
20
|
+
</li>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/categories/_form.html.erb
|
3
|
+
@Use: This is a partial for opening form for input categories records
|
4
|
+
@Created date: 13-06-2012
|
5
|
+
@Modified Date: 05-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<%= form_for [:admin, @blog_category] do |f| %>
|
9
|
+
<%= render :partial => "/shared/admin/error_messages",
|
10
|
+
:locals => {
|
11
|
+
:object => f.object,
|
12
|
+
:include_object_name => true
|
13
|
+
} %>
|
14
|
+
|
15
|
+
<div class='field'>
|
16
|
+
<%= f.label :title -%>
|
17
|
+
<%= f.text_field :title, :class => 'larger widest' -%>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<%= render :partial => "/shared/admin/form_actions", :locals => { :f => f } %>
|
21
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/categories/index.html.erb
|
3
|
+
@Use: This is a page for displaying categories records
|
4
|
+
@Created date: 13-06-2012
|
5
|
+
@Modified Date: 13-06-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<%=render :partial=>'/admin/blog/submenu' %>
|
9
|
+
<div id='records'>
|
10
|
+
<% if @blog_categories.any? %>
|
11
|
+
<%= will_paginate @blog_categories %>
|
12
|
+
|
13
|
+
<%= render :partial => "sortable_list" %>
|
14
|
+
|
15
|
+
<%= will_paginate @blog_categories %>
|
16
|
+
<% else %>
|
17
|
+
<p>
|
18
|
+
<strong>
|
19
|
+
<%= t('.no_items_yet', :create => t('admin.blog.submenu.categories.new')) %>
|
20
|
+
</strong>
|
21
|
+
</p>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/comments/_comment.html.erb
|
3
|
+
@Use: This is a page for displaying comments records
|
4
|
+
@Created date: 13-06-2012
|
5
|
+
@Modified Date: 19-06-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= "comment-#{comment.to_param}" -%>">
|
9
|
+
<span class='title'>
|
10
|
+
<%= comment.name %>
|
11
|
+
<span class="preview"> <%= truncate(comment.body, :length => 75) %></span>
|
12
|
+
</span>
|
13
|
+
<span class='actions'>
|
14
|
+
<%= link_to image_tag("icons/application_go.png"),
|
15
|
+
blog_post_url(comment.post, :anchor => "comment-#{comment.to_param}"),
|
16
|
+
:title => t('.view_live_html'),
|
17
|
+
:target => "_blank" unless comment.is_unmoderated? %>
|
18
|
+
<%= link_to image_tag('icons/zoom.png'), admin_blog_comment_path(comment),
|
19
|
+
:title => t('.read') %>
|
20
|
+
<%= link_to image_tag("icons/cross.png"),
|
21
|
+
rejected_admin_blog_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
|
22
|
+
:title => t('.reject') unless comment.is_rejected? %>
|
23
|
+
<%= link_to image_tag("icons/tick.png"),
|
24
|
+
approved_admin_blog_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
|
25
|
+
:title => t('.approve') unless comment.is_approved? %>
|
26
|
+
</span>
|
27
|
+
</li>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/comments/_sortable_list.html.erb
|
3
|
+
@Use: This is a page for displaying blog comments records
|
4
|
+
@Created date: 13-06-2012
|
5
|
+
@Modified Date: 13-06-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<ul id='sortable_list'>
|
9
|
+
<%= render :partial => 'comment', :collection => @blog_comments %>
|
10
|
+
</ul>
|
11
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= render :partial => '/admin/blog/submenu' %>
|
2
|
+
<div id='records'>
|
3
|
+
|
4
|
+
<% if @blog_comments.any? %>
|
5
|
+
<%= render :partial => "sortable_list" %>
|
6
|
+
<% else %>
|
7
|
+
<h3>
|
8
|
+
<%= t('.no_items_yet',
|
9
|
+
:type => t("admin.blog.submenu.comments.#{action_name.gsub('index', 'new')}").downcase) %>
|
10
|
+
</h3>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/comments/show.html.erb
|
3
|
+
@Use: This is a page for displaying comment record by id
|
4
|
+
@Created date: 18-06-2012
|
5
|
+
@Modified Date: 19-06-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<div id='actions'>
|
9
|
+
<h2><%= t('.details')%></h2>
|
10
|
+
<p>
|
11
|
+
<strong><%= t('.age') %>:</strong> <%= time_ago_in_words(@blog_comment.created_at) %>
|
12
|
+
</p>
|
13
|
+
<h2><%= t('.actions') %></h2>
|
14
|
+
<ul>
|
15
|
+
<li>
|
16
|
+
<%= link_to t('.back'), {:action => 'index'}, :class => "back_icon" %>
|
17
|
+
</li>
|
18
|
+
<li>
|
19
|
+
<%= link_to t('.reject'), rejected_admin_blog_comment_path(@blog_comment, :return_to => 'rejected'),
|
20
|
+
:class => 'comment_cross_icon' unless @blog_comment.is_rejected? %>
|
21
|
+
</li>
|
22
|
+
<li>
|
23
|
+
<%= link_to t('.approve'), approved_admin_blog_comment_path(@blog_comment, :return_to => 'approved'),
|
24
|
+
:class => 'comment_tick_icon' unless @blog_comment.is_approved? %>
|
25
|
+
</li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
<div id='records'>
|
29
|
+
<h2><%= t('.comment') %></h2>
|
30
|
+
<table id='inquiry'>
|
31
|
+
<tr>
|
32
|
+
<td>
|
33
|
+
<strong><%= t('.blog_post') %></strong>
|
34
|
+
</td>
|
35
|
+
<td>
|
36
|
+
<%= link_to @blog_comment.post.title,
|
37
|
+
blog_post_url(@blog_comment.post, :anchor => "comment-#{@blog_comment.to_param}"),
|
38
|
+
:target => '_blank' %>
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
<tr>
|
42
|
+
<td>
|
43
|
+
<strong><%= t('.from') %></strong>
|
44
|
+
</td>
|
45
|
+
<td>
|
46
|
+
<%= @blog_comment.name %> [<%= mail_to @blog_comment.email, @blog_comment.email, {:title => t('.click_to_email')} %>]
|
47
|
+
</td>
|
48
|
+
</tr>
|
49
|
+
<tr>
|
50
|
+
<td>
|
51
|
+
<strong><%= t('.date') %></strong>
|
52
|
+
</td>
|
53
|
+
<td>
|
54
|
+
<%= l(Date.parse(@blog_comment.created_at.to_s), :format => :long) %>
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr>
|
58
|
+
<td valign='top'>
|
59
|
+
<strong><%= t('.message') %></strong>
|
60
|
+
</td>
|
61
|
+
<td>
|
62
|
+
<p style='margin-top: 0px'>
|
63
|
+
<%= @blog_comment.body.gsub("\r\n\r\n", "\r\n").gsub("\r\n", "</p><p>") %>
|
64
|
+
</p>
|
65
|
+
</td>
|
66
|
+
</tr>
|
67
|
+
</table>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
|