drg_blog_news_forum 0.0.3
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +65 -0
- data/Rakefile +34 -0
- data/app/assets/stylesheets/drg_blog_news_forum.css +162 -0
- data/app/controllers/drgcms_controls/dc_blog_dc_reply_control.rb +50 -0
- data/app/controllers/drgcms_controls/dc_forum_topic_control.rb +50 -0
- data/app/controllers/drgcms_controls/dc_forum_topic_dc_reply_control.rb +61 -0
- data/app/forms/cms_menu.yml +33 -0
- data/app/forms/dc_blog.yml +42 -0
- data/app/forms/dc_forum.yml +59 -0
- data/app/forms/dc_forum_policy_rule.yml +4 -0
- data/app/forms/dc_forum_topic.yml +30 -0
- data/app/forms/dc_reply.yml +25 -0
- data/app/helpers/dc_blog_renderer.rb +75 -0
- data/app/helpers/dc_forum_helper.rb +39 -0
- data/app/helpers/dc_forum_renderer.rb +79 -0
- data/app/models/dc_blog.rb +83 -0
- data/app/models/dc_forum.rb +45 -0
- data/app/models/dc_forum_policy_rule.rb +30 -0
- data/app/models/dc_forum_topic.rb +47 -0
- data/app/models/dc_news.rb +42 -0
- data/app/models/dc_reply.rb +39 -0
- data/app/models/dc_reply_concern.rb +45 -0
- data/app/views/dc_blog/_blog.html.erb +24 -0
- data/app/views/dc_blog/_blogers.html.erb +9 -0
- data/app/views/dc_blog/_entries.html.erb +13 -0
- data/app/views/dc_blog/_entry.html.erb +18 -0
- data/app/views/dc_forum/_forums.html.erb +33 -0
- data/app/views/dc_forum/_topic.html.erb +51 -0
- data/app/views/dc_forum/_topics.html.erb +44 -0
- data/app/views/dc_replay/_reply.html.erb +24 -0
- data/config/locales/dc_forum_en.yml +44 -0
- data/config/locales/dc_forum_sl.yml +45 -0
- data/config/locales/models_en.yml +118 -0
- data/config/locales/models_sl.yml +101 -0
- data/lib/drg_blog_news_forum/engine.rb +4 -0
- data/lib/drg_blog_news_forum/version.rb +3 -0
- data/lib/drg_blog_news_forum.rb +6 -0
- data/lib/tasks/drg_blog_news_forum_tasks.rake +44 -0
- data/test/drg_blog_news_forum_test.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +118 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
#
|
26
|
+
########################################################################
|
27
|
+
class DcBlogRenderer < DcRenderer
|
28
|
+
include DcApplicationHelper
|
29
|
+
|
30
|
+
########################################################################
|
31
|
+
# Show one blog entry
|
32
|
+
########################################################################
|
33
|
+
def show_entry
|
34
|
+
# blog = @parent.params[:blog_id] ? DcBlog.find(@parent.params[:blog_id]) : DcBlog.last
|
35
|
+
entry = DcBlog.find_by(created_by_name: @parent.params[:name], link: @parent.params[:link])
|
36
|
+
return t('dc_blog.entry_not_found') if entry.nil?
|
37
|
+
|
38
|
+
replies = entry.dc_replies.where(active: true).order(created_at: 1).
|
39
|
+
page(@parent.params[:page]).per(5)
|
40
|
+
@parent.render partial: 'dc_blog/entry', formats: [:html],
|
41
|
+
locals: { entry: entry, replies: replies, opts: @opts }
|
42
|
+
end
|
43
|
+
|
44
|
+
########################################################################
|
45
|
+
# List all blogs from one bloger
|
46
|
+
########################################################################
|
47
|
+
def list_all
|
48
|
+
entries = DcBlog.only(:created_by_name, :link, :subject, :created_at)
|
49
|
+
.where(created_by_name: @parent.params[:name]).order_by(created_at: -1)
|
50
|
+
.page(@parent.params[:page]).per(10)
|
51
|
+
@parent.render partial: 'dc_blog/entries', formats: [:html], locals: { entries: entries }
|
52
|
+
end
|
53
|
+
|
54
|
+
########################################################################
|
55
|
+
# List all blogers
|
56
|
+
########################################################################
|
57
|
+
def list_blogers
|
58
|
+
blogers = DcBlog.all.distinct(:created_by_name)
|
59
|
+
@parent.render partial: 'dc_blog/blogers', formats: [:html], locals: { blogers: blogers }
|
60
|
+
end
|
61
|
+
|
62
|
+
########################################################################
|
63
|
+
# Default method will dispatch to proper method.
|
64
|
+
########################################################################
|
65
|
+
def default
|
66
|
+
if @parent.params[:name].nil?
|
67
|
+
list_blogers
|
68
|
+
elsif @parent.params[:link].nil? or @parent.params[:link] == 'all'
|
69
|
+
list_all
|
70
|
+
else
|
71
|
+
show_entry
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module DcForumHelper
|
25
|
+
#include DcApplicationHelper
|
26
|
+
|
27
|
+
########################################################################
|
28
|
+
#
|
29
|
+
########################################################################
|
30
|
+
def dc_pretty_date(time)
|
31
|
+
case
|
32
|
+
when time < 11.months.ago then I18n.localize(time.to_date, format: :long)
|
33
|
+
when time < 6.days.ago then I18n.localize(time.to_date, format: :short)
|
34
|
+
when time < 14.hours.ago then I18n.localize(time, format: :short)
|
35
|
+
else time.strftime('%H:%M')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
#
|
26
|
+
########################################################################
|
27
|
+
class DcForumRenderer < DcRenderer
|
28
|
+
include DcApplicationHelper
|
29
|
+
|
30
|
+
########################################################################
|
31
|
+
#
|
32
|
+
########################################################################
|
33
|
+
#def pretty_date(time)
|
34
|
+
# case
|
35
|
+
# when time < 11.months.ago then I18n.localize(time.to_date, format: :long)
|
36
|
+
# when time < 6.days.ago then I18n.localize(time.to_date, format: :short)
|
37
|
+
# when time < 14.hours.ago then I18n.localize(time, format: :short)
|
38
|
+
# else time.strftime('%H:%M')
|
39
|
+
# end
|
40
|
+
#end
|
41
|
+
|
42
|
+
########################################################################
|
43
|
+
# Topic method lists topic and its replays.
|
44
|
+
#
|
45
|
+
# Same as code above but with usage of view partial.
|
46
|
+
########################################################################
|
47
|
+
def topic
|
48
|
+
forum = DcForum.find(@parent.params[:forum])
|
49
|
+
topic = DcForumTopic.find(@parent.params[:topic])
|
50
|
+
replies = topic.dc_replies.where(active: true).order(created_at: 1).page(@parent.params[:page]).per(5)
|
51
|
+
@parent.render partial: 'dc_forum/topic', formats: [:html],
|
52
|
+
locals: { forum: forum, topic: topic, replies: replies }
|
53
|
+
end
|
54
|
+
|
55
|
+
########################################################################
|
56
|
+
# Topic method lists topic and its replays.
|
57
|
+
#
|
58
|
+
# Same as code above but with usage of view partial.
|
59
|
+
########################################################################
|
60
|
+
def topics
|
61
|
+
forum = DcForum.find(@parent.params[:forum])
|
62
|
+
topics = DcForumTopic.only(:id, :created_by_name, :updated_by_name, :subject, :created_at, :updated_at, :replies)
|
63
|
+
.where(dc_forum_id: forum._id, active: true).order(updated_at: -1)
|
64
|
+
.page(@parent.params[:page]).per(10)
|
65
|
+
@parent.render partial: 'dc_forum/topics', formats: [:html], locals: { forum: forum, topics: topics }
|
66
|
+
end
|
67
|
+
|
68
|
+
########################################################################
|
69
|
+
# Default method will list all available forums
|
70
|
+
########################################################################
|
71
|
+
def default
|
72
|
+
return topic if @parent.params[:topic]
|
73
|
+
return topics if @parent.params[:forum]
|
74
|
+
#
|
75
|
+
forums = DcForum.where(:site_id.in => [nil, dc_get_site._id], active: true).order(order: 1).each
|
76
|
+
@parent.render partial: 'dc_forum/forums', formats: [:html], locals: { forums: forums, opts: @opts }
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# ActiveSupport::Concern definition for DcBlog class.
|
26
|
+
#########################################################################
|
27
|
+
module DcBlogConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
included do
|
30
|
+
|
31
|
+
include Mongoid::Document
|
32
|
+
include Mongoid::Timestamps
|
33
|
+
|
34
|
+
field :subject, type: String, default: ''
|
35
|
+
field :body, type: String, default: ''
|
36
|
+
field :active, type: Boolean, default: true
|
37
|
+
field :link, type: String
|
38
|
+
|
39
|
+
field :created_by, type: BSON::ObjectId
|
40
|
+
field :created_by_name, type: String
|
41
|
+
|
42
|
+
embeds_many :dc_replies, as: :replies
|
43
|
+
|
44
|
+
index({created_by_name: 1, link: 1})
|
45
|
+
|
46
|
+
validates_length_of :subject, minimum: 4
|
47
|
+
validates_length_of :body, minimum: 10
|
48
|
+
|
49
|
+
before_save :do_before_save
|
50
|
+
|
51
|
+
########################################################################
|
52
|
+
# Update link if if field is left blank.
|
53
|
+
########################################################################
|
54
|
+
def do_before_save
|
55
|
+
if self.link.size < 5
|
56
|
+
self.link = self.created_at.strftime('%Y-%m-%d-') + UnicodeUtils.downcase(self.subject)
|
57
|
+
end
|
58
|
+
if self.created_by_name.nil?
|
59
|
+
self.created_by_name = DcUser.find(self.created_by).name
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
########################################################################
|
64
|
+
# Method returns all users having bloger system role.
|
65
|
+
########################################################################
|
66
|
+
def blogers
|
67
|
+
blogers_role = DcRole.only(:id).find_by(sytem_name: 'bloger')
|
68
|
+
return [] unless blogers_role
|
69
|
+
#
|
70
|
+
DcUser.where('dc_user_roles.dc_policy_role_id' => blogers_role.id).order_by(name: 1)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
########################################################################
|
77
|
+
# Mongoid::Document model for dc_blogs documents.
|
78
|
+
#
|
79
|
+
# dc_blog class is used for creating simple blog site.
|
80
|
+
########################################################################
|
81
|
+
class DcBlog
|
82
|
+
include DcBlogConcern
|
83
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcForum
|
25
|
+
include Mongoid::Document
|
26
|
+
include Mongoid::Timestamps
|
27
|
+
|
28
|
+
field :name, type: String, default: ''
|
29
|
+
field :description, type: String, default: ''
|
30
|
+
field :site_id, type: BSON::ObjectId
|
31
|
+
field :order, type: Integer, default: 10
|
32
|
+
field :topics, type: Integer, default: 0
|
33
|
+
field :replies, type: Integer, default: 0
|
34
|
+
field :forum_groups,type: Array
|
35
|
+
|
36
|
+
field :active, type: Boolean, default: true
|
37
|
+
field :created_by, type: BSON::ObjectId
|
38
|
+
field :updated_by, type: BSON::ObjectId
|
39
|
+
field :created_by_name, type: String
|
40
|
+
field :updated_by_name, type: String
|
41
|
+
|
42
|
+
embeds_many :dc_policy_rules, as: :policy_rules
|
43
|
+
|
44
|
+
index( { name: 1 } )
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require_dependency DrgCms.model 'dc_policy_rule'
|
25
|
+
|
26
|
+
class DcForumPolicyRule
|
27
|
+
include DcPolicyRuleConcern
|
28
|
+
|
29
|
+
embedded_in :dc_forum
|
30
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcForumTopic
|
25
|
+
include Mongoid::Document
|
26
|
+
include Mongoid::Timestamps
|
27
|
+
|
28
|
+
field :subject, type: String, default: ''
|
29
|
+
field :body, type: String, default: ''
|
30
|
+
field :replies, type: Integer, default: 0
|
31
|
+
field :views, type: Integer, default: 0
|
32
|
+
|
33
|
+
belongs_to :dc_forum
|
34
|
+
embeds_many :dc_replies, as: :replies
|
35
|
+
|
36
|
+
field :active, type: Boolean, default: true
|
37
|
+
field :created_by, type: BSON::ObjectId
|
38
|
+
field :updated_by, type: BSON::ObjectId
|
39
|
+
field :created_by_name, type: String
|
40
|
+
field :updated_by_name, type: String
|
41
|
+
|
42
|
+
|
43
|
+
index( { dc_forum_id: 1 } )
|
44
|
+
|
45
|
+
validates_length_of :subject, minimum: 4
|
46
|
+
validates_length_of :body, minimum: 10
|
47
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcNews
|
25
|
+
include Mongoid::Document
|
26
|
+
include Mongoid::Timestamps
|
27
|
+
|
28
|
+
field :subject, type: String, default: ''
|
29
|
+
field :body, type: String, default: ''
|
30
|
+
field :active, type: Boolean, default: true
|
31
|
+
field :valid_from, type: Date
|
32
|
+
field :valid_to, type: Date
|
33
|
+
field :categories, type: Array
|
34
|
+
|
35
|
+
field :created_by, type: BSON::ObjectId
|
36
|
+
field :created_by_name, type: String
|
37
|
+
|
38
|
+
embeds_many :replies
|
39
|
+
|
40
|
+
validates_length_of :subject, minimum: 4
|
41
|
+
validates_length_of :body, minimum: 10
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
class DcReply
|
25
|
+
include Mongoid::Document
|
26
|
+
include Mongoid::Timestamps
|
27
|
+
|
28
|
+
field :subject, type: String, default: ''
|
29
|
+
field :body, type: String, default: ''
|
30
|
+
field :active, type: Boolean, default: true
|
31
|
+
|
32
|
+
field :created_by, type: BSON::ObjectId
|
33
|
+
field :created_by_name, type: String
|
34
|
+
|
35
|
+
embedded_in :replies, polymorphic: true
|
36
|
+
|
37
|
+
validates_length_of :subject, minimum: 4
|
38
|
+
validates_length_of :body, minimum: 10
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module DcReplyConcern
|
25
|
+
extend ActiveSupport::Concern
|
26
|
+
included do
|
27
|
+
|
28
|
+
include Mongoid::Document
|
29
|
+
include Mongoid::Timestamps
|
30
|
+
|
31
|
+
field :subject, type: String, default: ''
|
32
|
+
field :body, type: String, default: ''
|
33
|
+
field :active, type: Boolean, default: true
|
34
|
+
|
35
|
+
field :created_by, type: BSON::ObjectId
|
36
|
+
|
37
|
+
embedded_in :dc_forum_topic
|
38
|
+
|
39
|
+
index( { dc_forum_topic_id: 1 } )
|
40
|
+
|
41
|
+
validates_length_of :subject, minimum: 4
|
42
|
+
validates_length_of :body, minimum: 10
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="blog-title">
|
2
|
+
<%= title %>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<%= if opts[:edit_mode] > 1
|
6
|
+
dc_link_for_create(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.new_entry' )
|
7
|
+
end %>
|
8
|
+
|
9
|
+
<% if blog %>
|
10
|
+
<div class="blog-date"><%= dc_pretty_date(blog.created_at) %></div>
|
11
|
+
<div class="blog-subject"><%= blog.subject %></div>
|
12
|
+
<div style="clear:both;"></div>
|
13
|
+
|
14
|
+
<div class="blog-body"><%= blog.body%></div>
|
15
|
+
|
16
|
+
<div class="blog-replies">
|
17
|
+
<%= render partial: 'dc_reply/reply', formats: [:html],
|
18
|
+
locals: { replies: replies, parent_id: blog.id } %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<iframe id="iframe_edit" name="iframe_edit" scrolling="no"></iframe>
|
22
|
+
<% else %>
|
23
|
+
<br><br><br>This blog has no posts. Yet ;-)
|
24
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="blog-title">
|
2
|
+
<h1><%= params[:name] %>, <%= t('dc_blog.my_blog') %></h1>
|
3
|
+
</div>
|
4
|
+
<% for entry in entries %>
|
5
|
+
|
6
|
+
<div class="blog-entry">
|
7
|
+
|
8
|
+
<%= link_to( entry.subject,
|
9
|
+
{ path: 'blog', name: params[:name], link: entry.link } )%>
|
10
|
+
|
11
|
+
<div class="blog-date"><h3><%= dc_pretty_date(entry.created_at) %></h3></div>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
<% if opts[:edit_mode] > 1 %>
|
3
|
+
<%= dc_link_for_create(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.new_entry' ) %>
|
4
|
+
<br><br>
|
5
|
+
<%= dc_link_for_edit(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.edit_entry', id: entry.id ) %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<div class="blog-subject"><h1><%= entry.subject %></h1></div>
|
9
|
+
<div class="blog-date"><h3><%= t('dc_blog.published') + ' ' + dc_pretty_date(entry.created_at) %></h3></div>
|
10
|
+
|
11
|
+
<div class="blog-body"><%= entry.body.html_safe %></div>
|
12
|
+
|
13
|
+
<div class="blog-replies">
|
14
|
+
<%= render partial: 'dc_replay/reply', formats: [:html],
|
15
|
+
locals: { replies: replies, parent_id: entry.id, parent_document: 'dc_blog' } %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<iframe id="iframe_edit" name="iframe_edit" scrolling="no"></iframe>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= if opts[:edit_mode] > 1
|
2
|
+
dc_link_for_create(controller: 'cmsedit', table: 'dc_forum', title: 'dc_forum.add_new_forum' )
|
3
|
+
end %>
|
4
|
+
|
5
|
+
<div class="forum-topics">
|
6
|
+
<div class="forum-title">
|
7
|
+
<h1><%= t 'dc_forum.forums_list' %></h1>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<% for forum in forums %>
|
11
|
+
<div class="topic-<%= cycle("odd", "even") %>">
|
12
|
+
<%= if opts[:edit_mode] > 1 then
|
13
|
+
dc_link_for_edit(controller: 'cmsedit', table: 'dc_forum', id: forum._id, title: 'dc_forum.edit_forum' ); end %>
|
14
|
+
<div class="name">
|
15
|
+
<%= link_to(forum.name,{ path: params[:path], forum: forum.id} ) %>
|
16
|
+
</div>
|
17
|
+
<div class='description'>
|
18
|
+
<%= forum.description %><hr>
|
19
|
+
<b><%= t('dc_forum.topics') %>:</b>
|
20
|
+
<%= forum.topics %> |
|
21
|
+
|
22
|
+
<b><%= t('dc_forum.replies') %>:</b>
|
23
|
+
<%= forum.replies %> |
|
24
|
+
|
25
|
+
<b><%= t('dc_forum.last') %>:</b>
|
26
|
+
<%= forum.updated_by_name %>
|
27
|
+
<%= dc_pretty_date(forum.updated_at) %>
|
28
|
+
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
|