drg_blog_news_forum 0.5.51.1 → 0.5.52.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/app/assets/stylesheets/drg_blog_news_forum.css +15 -6
  4. data/app/controllers/drgcms_controls/dc_news_dc_reply_control.rb +4 -2
  5. data/app/controllers/drgcms_controls/reply_control.rb +52 -0
  6. data/app/forms/dc_forum.yml +17 -16
  7. data/app/forms/dc_forum_topic.yml +6 -7
  8. data/app/forms/dc_news.yml +9 -8
  9. data/app/forms/dc_reply.yml +0 -1
  10. data/app/forms/forum_settings.yml +56 -0
  11. data/app/forms/news_settings.yml +91 -0
  12. data/app/forms/reply.yml +15 -0
  13. data/app/helpers/dc_blog_renderer.rb +21 -29
  14. data/app/helpers/{dc_forum_helper.rb → dc_bnf_helper.rb} +18 -1
  15. data/app/helpers/dc_forum_renderer.rb +2 -1
  16. data/app/helpers/dc_news_renderer.rb +45 -28
  17. data/app/models/dc_forum.rb +19 -8
  18. data/app/models/dc_reply.rb +4 -2
  19. data/app/views/dc_blog/_blogers.html.erb +1 -1
  20. data/app/views/dc_blog/_list.html.erb +13 -0
  21. data/app/views/dc_blog/{_entry.html.erb → _show.html.erb} +6 -6
  22. data/app/views/dc_news/_last_news.erb +3 -3
  23. data/app/views/dc_news/_list.html.erb +24 -0
  24. data/app/views/dc_news/_show.html.erb +26 -0
  25. data/app/views/dc_replay/_reply.html.erb +15 -13
  26. data/config/locales/{dc_forum_en.yml → dc_bnf_en.yml} +26 -0
  27. data/config/locales/{dc_forum_sl.yml → dc_bnf_sl.yml} +24 -4
  28. data/lib/drg_blog_news_forum/version.rb +1 -1
  29. metadata +13 -12
  30. data/app/forms/dc_forum_policy_rule.yml +0 -2
  31. data/app/views/dc_blog/_entries.html.erb +0 -19
  32. data/app/views/dc_news/_entries.html.erb +0 -15
  33. data/app/views/dc_news/_entry.html.erb +0 -23
  34. data/app/views/dc_news/_news.html.erb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cd602fc22625d9c548b208a24437d089661603d
4
- data.tar.gz: bd6a9948321595a12e92c020fdfa998c5651f2ca
3
+ metadata.gz: 21376b47f6aebf241e6cd3053fe434b6cc1b430a
4
+ data.tar.gz: f7cbc383f3882a7fa36a385b0dd311d653f1eee4
5
5
  SHA512:
6
- metadata.gz: 9759f43c526f5d5345466df123d11b70313602923538696b51c50cb0ee67db78bdab84cb7d1a5478a06cb9c7d6d0d0faf330b55a6fe66621f613641da251bade
7
- data.tar.gz: ee2cfffa7d0e6a8a68b11e35b1caa03273753cdc880f458020a2e4ad1e0663f173b9aaf8e1a92c037b0a34965d927c97b2891a07af6adae40b869f4f6a0d0ebb
6
+ metadata.gz: 58171ad983f8d78c280f409be0992fef784cf64b7350fdf9e06710900fca5c8f17ce6025632c8e971f4d2162045c81cd75d2511c8ae7a60d399b6d690bf21e0e
7
+ data.tar.gz: 804ccf7bb9b4dded3b05684c8cf26616b52037d55f0e392d98f791a216d472844b107c0f8f22428869d72cd454c7456e15a889f3b761b8ce0828f4aec42bac4a
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 YOURNAME
1
+ Copyright 2014+ Damjan Rems
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -74,10 +74,10 @@ height: 1px;
74
74
 
75
75
  #dc-reply-menu {
76
76
  border: none;
77
- padding: 5px 0px;
77
+ padding: 1em 0px;
78
78
  }
79
79
 
80
- #dc-forum .reply-top-odd, #dc-forum .reply-top-even {
80
+ #dc-forum .reply-top.odd, #dc-forum .reply-top.even {
81
81
  margin-top: 10px;
82
82
  padding: 4px;
83
83
  background: #eee;
@@ -86,7 +86,7 @@ padding: 5px 0px;
86
86
  border-top-right-radius: 3px;
87
87
  }
88
88
 
89
- #dc-forum .reply-body-odd, #dc-forum .reply-body-even {
89
+ #dc-forum .reply-body.odd, #dc-forum .reply-body.even {
90
90
  padding: 4px;
91
91
  background: #f8f8f8;
92
92
  border: 1px solid #ddd;
@@ -135,6 +135,10 @@ border-radius: 2px;
135
135
  }
136
136
 
137
137
  /******* dc_blog *******/
138
+ #blogs .title {
139
+ font-size: 1.4em;
140
+ padding-bottom: 5px;
141
+ }
138
142
  .blog-subject {
139
143
  font-size: 1.4em;
140
144
  font-weight: bold;
@@ -149,16 +153,16 @@ margin-bottom: 20px;
149
153
  }
150
154
  .blog-replies {
151
155
  }
152
- .reply-top-even {
156
+ .reply-top.even {
153
157
  padding:5px;
154
158
  background-color: #fff;
155
159
  }
156
- .reply-top-odd {
160
+ .reply-top.odd {
157
161
  padding:5px;
158
162
  background-color: #eee;
159
163
  }
160
164
 
161
- .reply-body-even p, .reply-body-odd p {
165
+ .reply-body.even p, .reply-body.odd p {
162
166
  margin-top: 0em;
163
167
  margin-bottom: 0em;
164
168
  }
@@ -176,3 +180,8 @@ margin-bottom: 40px;
176
180
  padding-top: 5px;
177
181
  padding-bottom: 5px;
178
182
  }
183
+
184
+ /**** news ****/
185
+ .news.one .author {
186
+ font-size: 1.2em;
187
+ }
@@ -32,8 +32,10 @@ module DrgcmsControls::DcNewsDcReplyControl
32
32
  ######################################################################
33
33
  def dc_new_record()
34
34
  # fill with quote when reply_to is present
35
- if params[:reply_to]
36
- replyto = @record._parent.dc_replies.find(params[:reply_to])
35
+ bla
36
+ if params[:reply_to]
37
+
38
+ replyto = DcReply.find(params[:reply_to])
37
39
  @record.subject = "Re: #{replyto.subject}"
38
40
  @record.body = "<div class='dc-forum-quote'>#{replyto.body}</div><br>"
39
41
  end
@@ -0,0 +1,52 @@
1
+ #encoding: utf-8
2
+ #--
3
+ # Copyright (c) 2014+ Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ ######################################################################
26
+ # DrgcmsControls for DcBlog.DcReply form
27
+ ######################################################################
28
+ module DrgcmsControls::ReplyControl
29
+
30
+ ######################################################################
31
+ # Called when new empty record is created
32
+ ######################################################################
33
+ def dc_new_record()
34
+ # fill with quote when reply_to is present
35
+ if params[:reply_to]
36
+ replyto = DcReply.find(params[:reply_to])
37
+ @record.subject = (replyto.subject.match('Re:') ? '' : 'Re: ') + replyto.subject
38
+ @record.body = "<div class='dc-forum-quote'>#{replyto.body}</div><br>"
39
+ end
40
+ @record.created_by_name = session[:user_name] if session[:user_name]
41
+ end
42
+
43
+ ######################################################################
44
+ # Called before save. Reloads browser.
45
+ ######################################################################
46
+ def dc_before_save()
47
+ params[:return_to] = 'parent.reload'
48
+ # simple automatic robot trap
49
+ return false unless params[:record][:honey].blank?
50
+ end
51
+
52
+ end
@@ -10,10 +10,7 @@ result_set:
10
10
  columns:
11
11
  1:
12
12
  name: name
13
- 2:
14
- name: site_id
15
- eval: dc_name4_id,dc_site,name
16
- 3:
13
+ 2:
17
14
  name: order
18
15
  4:
19
16
  name: active
@@ -28,28 +25,32 @@ form:
28
25
  10:
29
26
  name: name
30
27
  type: text_field
31
- html:
32
- size: 50
28
+ size: 50
33
29
 
34
30
  20:
31
+ name: link
32
+ type: text_field
33
+ size: 50
34
+
35
+ 30:
35
36
  name: description
36
37
  type: text_area
37
- html:
38
- size: 80x10
38
+ size: 80x8
39
39
 
40
- 30:
41
- name: site_id
40
+ 40:
41
+ name: forum_groups
42
42
  type: select
43
- eval: DcSite.choices4_site
43
+ multiple: true
44
+ eval: dc_big_table 'forum-groups'
44
45
  html:
45
- include_blank: true
46
- 40:
46
+ include_blank: true
47
+
48
+ 50:
47
49
  name: order
48
50
  type: text_field
49
- html:
50
- size: 3
51
+ size: 3
51
52
 
52
- 50:
53
+ 60:
53
54
  name: dc_policy_rules
54
55
  type: embedded
55
56
  form_name: dc_policy_rule
@@ -9,12 +9,15 @@ form:
9
9
 
10
10
  fields:
11
11
  10:
12
+ name: created_by_name
13
+ type: readonly
14
+
15
+ 20:
12
16
  name: subject
13
17
  type: text_field
14
- html:
15
- size: 80
18
+ size: 80
16
19
 
17
- 20:
20
+ 30:
18
21
  name: body
19
22
  type: html_field
20
23
  options: "height: 420, toolbar: 'basic'"
@@ -22,7 +25,3 @@ form:
22
25
  100:
23
26
  name: dc_forum_id
24
27
  type: hidden_field
25
- 110:
26
- name: created_by_name
27
- type: hidden_field
28
-
@@ -36,16 +36,17 @@ form:
36
36
  30:
37
37
  name: created_at
38
38
  type: datetime_picker
39
-
39
+
40
40
  40:
41
+ name: categories
42
+ type: select
43
+ multiple: true
44
+ eval: dc_big_table 'news-categories'
45
+ html:
46
+ include_blank: true
47
+
48
+ 50:
41
49
  name: body
42
50
  type: html_field
43
51
  options: 'height: 500'
44
52
 
45
- 50:
46
- name: dc_replies
47
- type: embedded
48
- form_name: dc_reply
49
- table: dc_reply
50
- html:
51
- height: 400
@@ -32,4 +32,3 @@ form:
32
32
  name: body
33
33
  type: html_field
34
34
  options: "height: 420, toolbar: 'basic', allowedContent: false"
35
-
@@ -0,0 +1,56 @@
1
+ ## Form for news settings
2
+ table: dc_memory
3
+ title: dc_forum.settings
4
+ controls: design_element_settings
5
+
6
+ form:
7
+ actions:
8
+ 1: save
9
+
10
+ fields:
11
+
12
+ 10:
13
+ name: forum_groups
14
+ type: select
15
+ multiple: true
16
+ eval: dc_big_table 'forum-groups'
17
+ text: helpers.label.dc_forum.forum_groups
18
+ help: helpers.help.dc_forum.forum_groups
19
+ html:
20
+ include_blank: true
21
+
22
+ 100:
23
+ name: title
24
+ type: text_field
25
+ size: 30
26
+ text: dc_forum.title
27
+ help: dc_forum.title_help
28
+ top-line: 1
29
+
30
+ 110:
31
+ name: clas
32
+ type: text_field
33
+ size: 10
34
+ text: dc_news.clas
35
+ help: dc_news.clas_help
36
+
37
+ 120:
38
+ name: list
39
+ type: text_field
40
+ size: 30
41
+ text: dc_news.list
42
+ help: dc_news.list_help
43
+
44
+ 130:
45
+ name: show
46
+ type: text_field
47
+ size: 30
48
+ text: dc_news.show
49
+ help: dc_news.show_help
50
+
51
+ 140:
52
+ name: link
53
+ type: text_field
54
+ size: 30
55
+ text: dc_news.link
56
+ help: dc_news.link_help
@@ -0,0 +1,91 @@
1
+ ## Form for news settings
2
+ table: dc_memory
3
+ title: dc_news.settings
4
+ controls: design_element_settings
5
+
6
+ form:
7
+ actions:
8
+ 1: save
9
+
10
+ fields:
11
+
12
+ 10:
13
+ name: categories
14
+ type: select
15
+ multiple: true
16
+ eval: dc_big_table 'news-categories'
17
+ text: dc_news.categories
18
+ help: dc_news.categories_help
19
+ html:
20
+ include_blank: true
21
+
22
+ 20:
23
+ name: number
24
+ type: text_field
25
+ size: 3
26
+ text: dc_news.number
27
+ help: dc_news.number_help
28
+
29
+ 30:
30
+ name: paging
31
+ type: check_box
32
+ text: dc_news.paging
33
+ help: dc_news.paging_help
34
+
35
+ 40:
36
+ name: small
37
+ type: text_field
38
+ size: 2
39
+ text: dc_news.small
40
+ help: dc_news.small_help
41
+ group: 3
42
+
43
+ 50:
44
+ name: medium
45
+ type: text_field
46
+ size: 2
47
+ text: dc_news.medium
48
+ help: dc_news.medium_help
49
+
50
+ 60:
51
+ name: large
52
+ type: text_field
53
+ size: 2
54
+ text: dc_news.large
55
+ help: dc_news.large_help
56
+
57
+ 100:
58
+ name: title
59
+ type: text_field
60
+ size: 30
61
+ text: dc_news.title
62
+ help: dc_news.title_help
63
+ top-line: 1
64
+
65
+ 110:
66
+ name: clas
67
+ type: text_field
68
+ size: 10
69
+ text: dc_news.clas
70
+ help: dc_news.clas_help
71
+
72
+ 120:
73
+ name: list
74
+ type: text_field
75
+ size: 30
76
+ text: dc_news.list
77
+ help: dc_news.list_help
78
+
79
+ 130:
80
+ name: show
81
+ type: text_field
82
+ size: 30
83
+ text: dc_news.show
84
+ help: dc_news.show_help
85
+
86
+ 140:
87
+ name: link
88
+ type: text_field
89
+ size: 30
90
+ text: dc_news.link
91
+ help: dc_news.link_help
data/app/forms/reply.yml CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
2
  table: dc_reply
3
+ title: Reply
4
+ controls: reply
3
5
 
4
6
  form:
5
7
  height: 750
@@ -25,3 +27,16 @@ form:
25
27
  type: html_field
26
28
  options: "height: 420, toolbar: 'basic', allowedContent: false"
27
29
 
30
+ 100:
31
+ name: doc_id
32
+ type: hidden_field
33
+
34
+ 110:
35
+ name: doc_class
36
+ type: hidden_field
37
+
38
+ 120:
39
+ name: honey
40
+ type: hidden_field
41
+
42
+
@@ -30,25 +30,23 @@ include DcApplicationHelper
30
30
  ########################################################################
31
31
  # Show one blog entry
32
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])
33
+ def show(link)
34
+ entry = DcBlog.find_by(link: link)
36
35
  return t('dc_blog.entry_not_found') if entry.nil?
37
36
 
38
- replies = entry.dc_replies.where(active: true).order(created_at: 1).
39
- page(@parent.params[:page]).per(20)
40
- @parent.render partial: 'dc_blog/entry', formats: [:html],
41
- locals: { entry: entry, replies: replies, opts: @opts }
37
+ replies = DcReply.where(doc_id: entry.id, active: true).order(created_at: 1)
38
+ @parent.render partial: 'dc_blog/show', formats: [:html],
39
+ locals: { document: entry, replies: replies, opts: @opts }
42
40
  end
43
41
 
44
42
  ########################################################################
45
43
  # List all blogs from one bloger
46
44
  ########################################################################
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)
45
+ def list(bloger)
46
+ documents = DcBlog.only(:created_by_name, :link, :subject, :created_at)
47
+ .where(active: true).order_by(created_at: -1)
50
48
  .page(@parent.params[:page]).per(10)
51
- @parent.render partial: 'dc_blog/entries', formats: [:html], locals: { entries: entries }
49
+ @parent.render partial: 'dc_blog/list', formats: [:html], locals: { documents: documents }
52
50
  end
53
51
 
54
52
  ########################################################################
@@ -65,22 +63,14 @@ end
65
63
  def last_blogs
66
64
  limit = @opts[:limit] || 3
67
65
  entries = DcBlog.only(:created_by_name, :link, :subject, :created_at)
68
- .where(active: true) #, :created_at.gt => 6.months.ago)
66
+ .where(active: true)
69
67
  .order_by(created_at: -1).limit(limit).to_a
70
- =begin
71
- if entries.size > 0
72
- # for document link.
73
- path = @opts[:path] || 'blog'
74
- @parent.render partial: 'dc_blog/last_blogs', formats: [:html], locals: { entries: entries, path: path }
75
- else
76
- ''
77
- end
78
- =end
79
- entries.inject('') do |result, element|
80
- result << @parent.link_to("/blog/#{element.created_by_name}/#{element.link}") do
68
+
69
+ entries.inject('') do |result, document|
70
+ result << @parent.link_to("/blog/#{document.link}") do
81
71
  %Q[
82
- <span class="date">#{@parent.dc_pretty_date(element.created_at)} : </span>
83
- <span class="title">#{element.subject}</span><br><br>
72
+ <span class="date">#{@parent.dc_pretty_date(document.created_at)} : </span>
73
+ <span class="title">#{document.subject}</span><br><br>
84
74
  ].html_safe
85
75
  end
86
76
  end
@@ -92,12 +82,14 @@ end
92
82
  # Default method will dispatch to proper method.
93
83
  ########################################################################
94
84
  def default
95
- if @parent.params[:name].nil?
85
+ document_link = @opts[:path].last
86
+ p @opts[:path]
87
+ if @opts[:path].size == 1 or document_link == 'blogers'
96
88
  list_blogers
97
- elsif @parent.params[:link].nil? or @parent.params[:link] == 'all'
98
- list_all
89
+ elsif @opts[:path].size == 2
90
+ list(document_link)
99
91
  else
100
- show_entry
92
+ show(document_link)
101
93
  end
102
94
  end
103
95
 
@@ -21,7 +21,7 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- module DcForumHelper
24
+ module DcBnfHelper
25
25
  #include DcApplicationHelper
26
26
 
27
27
  ########################################################################
@@ -36,4 +36,21 @@ def dc_pretty_date(time)
36
36
  end
37
37
  end
38
38
 
39
+ ########################################################################
40
+ # Link for editing news settings
41
+ ########################################################################
42
+ def news_settings(opts)
43
+ return '' unless opts[:edit_mode] > 1
44
+ # settings can be saved in dc_site or dc_page document
45
+ table = opts[:table] || @page.class.to_s
46
+ id = (table == 'dc_site') ? @site.id : @page.id
47
+ %Q[<div>
48
+ #{dc_link_for_edit(table: 'dc_memory', title: 'helpers.news.settings',
49
+ form_name: 'news_settings', icon: 'cog lg',
50
+ id: id, location: table, action: 'new',
51
+ element: opts[:element] )}
52
+ #{dc_link_for_create(table: 'dc_news', title: 'helpers.news.create')}
53
+ </div>].html_safe
54
+ end
55
+
39
56
  end
@@ -48,7 +48,8 @@ include DcApplicationHelper
48
48
  def topic
49
49
  forum = DcForum.find(@parent.params[:forum])
50
50
  topic = DcForumTopic.find(@parent.params[:topic])
51
- replies = topic.dc_replies.where(active: true).order(created_at: 1).page(@parent.params[:page]).per(10)
51
+ replies = DcReply.where(doc_id: topic.id, active: true).order(created_at: 1)
52
+ .page(@parent.params[:page]).per(10)
52
53
  @parent.render partial: 'dc_forum/topic', formats: [:html],
53
54
  locals: { forum: forum, topic: topic, replies: replies }
54
55
  end
@@ -28,45 +28,60 @@ class DcNewsRenderer < DcRenderer
28
28
  include DcApplicationHelper
29
29
 
30
30
  ########################################################################
31
- # Show one news entry
31
+ # Collects documents for list
32
32
  ########################################################################
33
- def show_entry
34
- entry = DcNews.find_by(link: @parent.params[:link])
35
- return t('dc_news.entry_not_found') if entry.nil?
33
+ def collect_documents()
34
+ categories = @opts.dig(:settings, @opts[:element], 'categories')
35
+ query = if categories
36
+ categories.map! {|e| (e.class == String and BSON::ObjectId.legal?(e)) ? BSON::ObjectId.from_string(e) : e }
37
+ DcNews.where(:categories.in => categories, active: true)
38
+ else
39
+ DcNews.where(active: true)
40
+ end
41
+ query = query.only(:id, :created_at, :subject, :created_by_name, :link)
42
+ # paging
43
+ if @opts.dig(:settings, @opts[:element], 'paging') == '1'
44
+ per_page = @opts.dig(:settings, @opts[:element], 'docs_per_page') || 15
45
+ query.order_by(created_at: -1).page(@parent.params[:page]).per(per_page)
46
+ else
47
+ query = query.and({"$or" => [{valid_from: nil}, {:valid_from.gt => Time.now.beginning_of_day}]})
48
+
49
+ limit = @opts.dig(:settings, @opts[:element], 'docs_per_view') || 5
50
+ query.order_by(created_at: -1).limit(limit)
51
+ end
52
+ end
53
+
54
+ ########################################################################
55
+ # Show one news document
56
+ ########################################################################
57
+ def show(link)
58
+ document = DcNews.find_by(link: link)
59
+ return t('dc_news.entry_not_found') if document.nil?
36
60
 
37
- replies = entry.dc_replies.where(active: true).order(created_at: 1).
38
- page(@parent.params[:page]).per(10)
39
- @parent.render partial: 'dc_news/entry', formats: [:html],
40
- locals: { entry: entry, replies: replies, opts: @opts }
61
+ replies = DcReply.where(doc_id: document.id, active: true).order(created_at: 1)
62
+ partial = @opts.dig(:settings, @opts[:element], 'show') || 'dc_news/show'
63
+ @parent.render partial: partial,
64
+ locals: { document: document, replies: replies, opts: @opts }
41
65
  end
42
66
 
43
67
  ########################################################################
44
- # List all news
68
+ # List news
45
69
  ########################################################################
46
- def list_all
47
- entries = DcNews.only(:created_by_name, :link, :subject, :created_at)
48
- .where(active: true).order_by(created_at: -1)
49
- .page(@parent.params[:page]).per(10)
50
- @parent.render partial: 'dc_news/entries', formats: [:html], locals: { entries: entries }
70
+ def list
71
+ partial = @opts.dig(:settings, @opts[:element], 'view') || 'dc_news/list'
72
+ documents = collect_documents.to_a
73
+ @parent.render(partial: partial, formats: [:html], locals: { documents: documents, opts: @opts } )
51
74
  end
52
75
 
53
76
  ########################################################################
54
- # List last news on home page. But no more than 3 entries and not older than 2 months.
77
+ # List last 3 news in footer.
55
78
  ########################################################################
56
79
  def last_news
57
80
  limit = @opts[:limit] || 3
58
81
  entries = DcNews.only(:created_by_name, :link, :subject, :created_at)
59
- .where(active: true) #, :created_at.gt => 6.months.ago)
82
+ .where(active: true)
60
83
  .order_by(created_at: -1).limit(limit).to_a
61
- =begin
62
- if entries.size > 0
63
- # for document link.
64
- path = @opts[:path] || 'news'
65
- @parent.render partial: 'dc_news/last_news', formats: [:html], locals: { entries: entries, path: path }
66
- else
67
- ''
68
- end
69
- =end
84
+
70
85
  entries.inject('') do |result, element|
71
86
  result << @parent.link_to("/news/#{element.link}") do
72
87
  %Q[
@@ -81,10 +96,12 @@ end
81
96
  # Default method will dispatch to proper method.
82
97
  ########################################################################
83
98
  def default
84
- if @parent.params[:link].nil?
85
- list_all
99
+ # if last part of url is page link show list otherwise it is document link
100
+ document_link = @opts[:path].last
101
+ if document_link == @parent.page.subject_link or document_link == @parent.site.homepage_link
102
+ list
86
103
  else
87
- show_entry
104
+ show(document_link)
88
105
  end
89
106
  end
90
107
 
@@ -30,17 +30,15 @@
30
30
  # created_at Time created_at
31
31
  # updated_at Time updated_at
32
32
  # name String Forum name (short description)
33
+ # link String Forum link
33
34
  # description String Long description of what is forum about
34
- # site_id BSON::ObjectId Site that forums belongs to
35
35
  # order Integer Order
36
36
  # topics Integer No of topics
37
37
  # replies Integer replies
38
38
  # forum_groups Array forum_groups
39
- # active Mongoid::Boolean active
39
+ # active Boolean Is active
40
40
  # created_by BSON::ObjectId created_by
41
41
  # updated_by BSON::ObjectId updated_by
42
- # created_by_name String created_by_name
43
- # updated_by_name String updated_by_name
44
42
  # dc_policy_rules Embedded:DcPolicyRule dc_policy_rules
45
43
  #########################################################################
46
44
  class DcForum
@@ -48,8 +46,8 @@ class DcForum
48
46
  include Mongoid::Timestamps
49
47
 
50
48
  field :name, type: String, default: ''
49
+ field :link, type: String
51
50
  field :description, type: String, default: ''
52
- field :site_id, type: BSON::ObjectId
53
51
  field :order, type: Integer, default: 10
54
52
  field :topics, type: Integer, default: 0
55
53
  field :replies, type: Integer, default: 0
@@ -58,10 +56,23 @@ class DcForum
58
56
  field :active, type: Boolean, default: true
59
57
  field :created_by, type: BSON::ObjectId
60
58
  field :updated_by, type: BSON::ObjectId
61
- field :created_by_name, type: String
62
- field :updated_by_name, type: String
63
59
 
64
60
  embeds_many :dc_policy_rules, as: :policy_rules
65
61
 
66
- index( { name: 1 } )
62
+ index( { link: 1 } )
63
+
64
+ validates_length_of :name, minimum: 4
65
+
66
+ before_save :do_before_save
67
+
68
+ ########################################################################
69
+ # Update link when left blank.
70
+ ########################################################################
71
+ def do_before_save
72
+ if self.link.size < 5
73
+ self.link = self.name.strip.downcase.gsub(' ','-')
74
+ end
75
+ end
76
+
77
+
67
78
  end
@@ -32,6 +32,8 @@
32
32
  # subject String Subject, short description of reply
33
33
  # body String Body text of reply
34
34
  # active Mongoid::Boolean Reply is active
35
+ # doc_id BSON::ObjectId Replied document id
36
+ # doc_class String Document origin class
35
37
  # created_by BSON::ObjectId Created by
36
38
  # created_by_name String Reply author's name
37
39
  ########################################################################
@@ -42,12 +44,12 @@ class DcReply
42
44
  field :subject, type: String, default: ''
43
45
  field :body, type: String, default: ''
44
46
  field :active, type: Boolean, default: true
47
+ field :doc_id, type: BSON::ObjectId
48
+ field :doc_class, type: String
45
49
 
46
50
  field :created_by, type: BSON::ObjectId
47
51
  field :created_by_name, type: String
48
52
 
49
- embedded_in :replies, polymorphic: true
50
-
51
53
  validates_length_of :subject, minimum: 4
52
54
  validates_length_of :body, minimum: 10
53
55
  validates_length_of :created_by_name, minimum: 5
@@ -8,7 +8,7 @@
8
8
 
9
9
  <% for bloger in blogers %>
10
10
  <div class="blog-entry">
11
- <%= link_to( bloger, { path: 'blog', name: bloger} )%>
11
+ <%= link_to( bloger, { path: "blog/#{bloger}"} )%>
12
12
  </div>
13
13
  <% end %>
14
14
  </div>
@@ -0,0 +1,13 @@
1
+
2
+ <div class="wrap">
3
+ <div id="blogs">
4
+ <h3><%= t('dc_blog.blogs') %></h3>
5
+
6
+ <% for document in documents %>
7
+ <div class="entry">
8
+ <div class="date"><%= dc_pretty_date(document.created_at) %></div>
9
+ <div class="title"><%= link_to( document.subject, path: "#{@page.link}/#{document.created_by_name}/#{document.link}" )%></div>
10
+ </div>
11
+ <% end %>
12
+ </div>
13
+ </div>
@@ -1,20 +1,20 @@
1
1
  <div class="wrap">
2
2
  <% if session[:edit_mode] > 1 %>
3
- <%= dc_link_for_create(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.new_entry' ) %>
3
+ <%= dc_link_for_create(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.new_document' ) %>
4
4
  <br><br>
5
- <%= dc_link_for_edit(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.edit_entry', id: entry.id ) %>
5
+ <%= dc_link_for_edit(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.edit_document', id: document.id ) %>
6
6
  <% end %>
7
7
 
8
- <div class="blog-subject"><h1><%= entry.subject %></h1></div>
9
- <div class="blog-date"><h4><%= t('dc_blog.published') + ' ' + dc_pretty_date(entry.created_at) %></h4></div>
8
+ <div class="blog-subject"><h2><%= document.subject %></h2></div>
9
+ <div class="blog-date"><h4><%= t('dc_blog.published') + ' ' + dc_pretty_date(document.created_at) %></h4></div>
10
10
 
11
- <div class="blog-body"><%= entry.body.html_safe %></div>
11
+ <div class="blog-body"><%= document.body.html_safe %></div>
12
12
  <div class="social-sites"><%= social_sites %></div>
13
13
 
14
14
  <div class="blog-replies">
15
15
  <h2><%= t('dc_blog.comments') %></h2>
16
16
  <%= render partial: 'dc_replay/reply', formats: [:html],
17
- locals: { replies: replies, parent_id: entry.id, parent_document: 'dc_blog' } %>
17
+ locals: { replies: replies, parent_doc: document } %>
18
18
  </div>
19
19
 
20
20
  <iframe id="iframe_edit" name="iframe_edit" scrolling="no"></iframe>
@@ -2,10 +2,10 @@
2
2
  <div id="last-news">
3
3
  <h3><%= t('dc_news.last_news') %></h3>
4
4
 
5
- <% for entry in entries %>
5
+ <% for document in documents %>
6
6
  <div class="entry">
7
- <span class="date"><%= dc_pretty_date(entry.created_at) %></span>
8
- <span class="title"><%= link_to( entry.subject, "/#{path}/#{entry.link}" )%></span>
7
+ <span class="date"><%= dc_pretty_date(document.created_at) %></span>
8
+ <span class="title"><%= link_to( document.subject, "/#{path}/#{document.link}" )%></span>
9
9
  </div>
10
10
  <% end %>
11
11
  </div>
@@ -0,0 +1,24 @@
1
+ <%
2
+ clas = (opts.dig(:settings, opts[:element], 'clas') || 'news') + ' list'
3
+ small = (opts.dig(:settings, opts[:element], 'small') || 1).to_i
4
+ medium = (opts.dig(:settings, opts[:element], 'medium') || small).to_i
5
+ large = (opts.dig(:settings, opts[:element], 'large') || medium).to_i
6
+ paging = opts.dig(:settings, opts[:element], 'paging') == '1'
7
+ link = opts.dig(:settings, opts[:element], 'link') || @page.subject_link
8
+ title = opts.dig(:settings, opts[:element], 'title') || t('dc_news.news')
9
+ %>
10
+
11
+ <div class="<%= clas %>">
12
+ <%= news_settings(opts) %>
13
+ <% unless title == '-' %><h2><%= title %></h2><% end %>
14
+ <%= if opts[:edit_mode] > 1
15
+ dc_link_for_create(controller: 'cmsedit', table: 'dc_news', title: 'dc_blog.new_entry' )
16
+ end %>
17
+
18
+ <% for document in documents %>
19
+ <div class="document">
20
+ <%= dc_pretty_date(document.created_at) %>
21
+ <h4><%= link_to( document.subject, { path: "#{link}/#{document.link}" } )%></h4>
22
+ </div>
23
+ <% end %>
24
+ </div>
@@ -0,0 +1,26 @@
1
+ <%
2
+ clas = (opts.dig(:settings, opts[:element], 'clas') || 'news') + ' one'
3
+ %>
4
+
5
+ <div class="<%= clas %>">
6
+ <% if session[:edit_mode] > 1 %>
7
+ <%= dc_link_for_edit(table: 'dc_news', title: 'dc_news.edit_document', id: document.id ) %>
8
+ <%= dc_link_for_create( table: 'dc_news', title: 'dc_news.new_document' ) %>
9
+ <% end %>
10
+
11
+ <h2><%= document.subject %></h2>
12
+ <div class="author">
13
+ <%= "#{t('dc_blog.author')} #{document.created_by_name}, #{dc_pretty_date(document.created_at)}" %>
14
+ </div><br>
15
+
16
+ <div class="body"><%= document.body.html_safe %></div>
17
+ <div class="social-sites"><%= social_sites %></div>
18
+
19
+ <div class="news-replies">
20
+ <h2><%= t('dc_blog.comments') %></h2>
21
+ <%= render partial: 'dc_replay/reply', formats: [:html],
22
+ locals: { replies: replies, parent_doc: document } %>
23
+ </div>
24
+
25
+ <iframe id="iframe_edit" name="iframe_edit" scrolling="no"></iframe>
26
+ </div>
@@ -1,24 +1,26 @@
1
1
 
2
2
  <% for reply in replies %>
3
3
  <% oddeven = cycle("odd", "even") %>
4
- <div class="reply-top-<%= oddeven %>">
4
+ <div class="reply-top <%= oddeven %>">
5
5
  <span style="float: right; top-margin: 5px;">
6
- <%= link_to( t('dc_forum.new_reply'), { controller: 'cmsedit', table: "#{parent_document};dc_reply",
7
- form_name: 'reply', action: 'new', ids: parent_id,
8
- reply_to: reply.id}, target: 'iframe_edit') %>
6
+ <%= link_to( t('dc_forum.new_reply'), { table: 'dc_reply', form_name: 'reply',
7
+ controller: :cmsedit, action: 'new', reply_to: reply.id,
8
+ p_doc_id: parent_doc.id, p_doc_class: parent_doc.class.to_s },
9
+ target: 'iframe_edit') %>
9
10
  </span>
10
11
  <b><%= reply.subject %></b><br>
11
12
  <%= t('dc_forum.replied_by') %>: <%= reply.created_by_name %>,
12
13
  <%= dc_pretty_date(reply.created_at) %>&nbsp;&nbsp;<br><br>
13
- <div class="reply-body-<%= oddeven %>"><%= reply.body.html_safe %></div>
14
+ <div class="reply-body <%= oddeven %>"><%= reply.body.html_safe %></div>
14
15
  </div>
15
16
  <% end %>
16
17
 
17
- <table id="dc-reply-menu"><tr>
18
- <td class="dc-link dc-animate" style="white-space: nowrap;">
19
- <%= link_to( t('dc_forum.new_reply'), { controller: 'cmsedit', table: "#{parent_document};dc_reply",
20
- form_name: 'reply', action: 'new', ids: parent_id },
21
- target: 'iframe_edit') %>
22
- </td>
23
- <td style="text-align: right; width: 100%;"><%= paginate replies %></td>
24
- </tr></table>
18
+ <div id="dc-reply-menu">
19
+ <div class="dc-link dc-animate" style="float: left;">
20
+ <%= link_to( t('dc_forum.new_reply'), { controller: 'cmsedit', table: "dc_reply",
21
+ form_name: 'reply', action: 'new',
22
+ p_doc_id: parent_doc.id, p_doc_class: parent_doc.class.to_s},
23
+ {target: 'iframe_edit', class: 'dc-animate'}) %>
24
+ </div>
25
+ <%# = paginate replies %>
26
+ </div>
@@ -45,6 +45,7 @@ en:
45
45
  my_blog: my blog
46
46
  comments: Comments
47
47
  last_blogs: Last blogs
48
+ blogs: Blogs
48
49
 
49
50
  dc_news:
50
51
  news: News
@@ -52,3 +53,28 @@ en:
52
53
  edit_entry: Edit news entry
53
54
  entry_not_found: News article not found
54
55
  last_news: Last news
56
+
57
+ settings: News settings
58
+ categories: Categories
59
+ categories_help: Define categories shown by news agregator
60
+ number: Articles number
61
+ number_help: Number of articles shown by news agregator
62
+ paging: Add paging
63
+ paging_help: Add paging links for the agregator
64
+ small: Small
65
+ small_help: Number of articles per line on small screen
66
+ medium: Medium
67
+ medium_help: Number of articles per line on medium screen
68
+ large: Large
69
+ large_help: Number of articles per line on large screen
70
+ title: Title
71
+ title_help: Title displayed on top of news agregator. - for no title.
72
+ clas: CSS Class
73
+ clas_help: CSS Class wrapped around news agregator
74
+ list: List view
75
+ list_help: Rails view used for render news agregator. Default is dc_news/list.
76
+ show: Show view
77
+ show_help: Rails view used for render document. Default is dc_news/show.
78
+ link: Link
79
+ link_help: Link used to show document. Default is current page link.
80
+
@@ -45,6 +45,7 @@ sl:
45
45
  my_blog: moj blog
46
46
  comments: Komentarji
47
47
  last_blogs: Zadnje objave na blogu
48
+ blogs: Blogi
48
49
 
49
50
  dc_news:
50
51
  news: Novice
@@ -53,7 +54,26 @@ sl:
53
54
  entry_not_found: Novica ne obstaja
54
55
  last_news: Zadnje novice
55
56
 
56
-
57
-
58
-
59
-
57
+ settings: Nastavitve za novice
58
+ categories: Kategorije
59
+ categories_help: Določi kategorije za prikaz novic
60
+ number: Število novic
61
+ number_help: Število novic prikazanih na eno strani
62
+ paging: Strani
63
+ paging_help: Dodaj kontrolnik za pomik po straneh
64
+ small: Mali
65
+ small_help: Število documentov v vrstici na malem zaslonu
66
+ medium: Srednji
67
+ medium_help: Število documentov v vrstici na srednjem zaslonu
68
+ large: Velik
69
+ large_help: Število documentov v vrstici na velikem zaslonu
70
+ title: Naslov
71
+ title_help: Naslov prikazan nad seznamom novic. - za brez naslova.
72
+ clas: CSS Class
73
+ clas_help: CSS razred v katerega bo ovit prikaz novic
74
+ list: Prikaz seznama
75
+ list_help: Rails view za prikaz seznama novic. Privzeto dc_news/list.
76
+ show: Prikaz dokumenta
77
+ show_help: Rails view za prikaz dokumenta. Privzeto dc_news/show.
78
+ link: Link
79
+ link_help: Nadrejena povezava za prikaz dokumenta. Privzeto je to povezava trenutne strani.
@@ -1,3 +1,3 @@
1
1
  module DrgBlogNewsForum
2
- VERSION = "0.5.51.1"
2
+ VERSION = "0.5.52.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg_blog_news_forum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.51.1
4
+ version: 0.5.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damjan Rems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-07 00:00:00.000000000 Z
11
+ date: 2018-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -54,17 +54,19 @@ files:
54
54
  - app/controllers/drgcms_controls/dc_forum_topic_control.rb
55
55
  - app/controllers/drgcms_controls/dc_forum_topic_dc_reply_control.rb
56
56
  - app/controllers/drgcms_controls/dc_news_dc_reply_control.rb
57
+ - app/controllers/drgcms_controls/reply_control.rb
57
58
  - app/forms/cms_menu.yml
58
59
  - app/forms/dc_blog.yml
59
60
  - app/forms/dc_forum.yml
60
- - app/forms/dc_forum_policy_rule.yml
61
61
  - app/forms/dc_forum_topic.yml
62
62
  - app/forms/dc_news.yml
63
63
  - app/forms/dc_reply.yml
64
+ - app/forms/forum_settings.yml
65
+ - app/forms/news_settings.yml
64
66
  - app/forms/reply.yml
65
67
  - app/helpers/application_helper.rb
66
68
  - app/helpers/dc_blog_renderer.rb
67
- - app/helpers/dc_forum_helper.rb
69
+ - app/helpers/dc_bnf_helper.rb
68
70
  - app/helpers/dc_forum_renderer.rb
69
71
  - app/helpers/dc_news_renderer.rb
70
72
  - app/models/dc_blog.rb
@@ -75,19 +77,18 @@ files:
75
77
  - app/models/dc_reply.rb
76
78
  - app/views/dc_blog/_blog.html.erb
77
79
  - app/views/dc_blog/_blogers.html.erb
78
- - app/views/dc_blog/_entries.html.erb
79
- - app/views/dc_blog/_entry.html.erb
80
80
  - app/views/dc_blog/_last_blogs.erb
81
+ - app/views/dc_blog/_list.html.erb
82
+ - app/views/dc_blog/_show.html.erb
81
83
  - app/views/dc_forum/_forums.html.erb
82
84
  - app/views/dc_forum/_topic.html.erb
83
85
  - app/views/dc_forum/_topics.html.erb
84
- - app/views/dc_news/_entries.html.erb
85
- - app/views/dc_news/_entry.html.erb
86
86
  - app/views/dc_news/_last_news.erb
87
- - app/views/dc_news/_news.html.erb
87
+ - app/views/dc_news/_list.html.erb
88
+ - app/views/dc_news/_show.html.erb
88
89
  - app/views/dc_replay/_reply.html.erb
89
- - config/locales/dc_forum_en.yml
90
- - config/locales/dc_forum_sl.yml
90
+ - config/locales/dc_bnf_en.yml
91
+ - config/locales/dc_bnf_sl.yml
91
92
  - config/locales/models_en.yml
92
93
  - config/locales/models_sl.yml
93
94
  - lib/drg_blog_news_forum.rb
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  version: '0'
118
119
  requirements: []
119
120
  rubyforge_project:
120
- rubygems_version: 2.6.14
121
+ rubygems_version: 2.6.14.1
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: 'DRG CMS: Blog, news and forum plugin for DRG CMS'
@@ -1,2 +0,0 @@
1
- extend: dc_policy_rule
2
- table: dc_forum_policy_rule
@@ -1,19 +0,0 @@
1
- <div class="wrap">
2
- <div class="blog-title">
3
- <h1><%= params[:name] %>, <%= t('dc_blog.my_blog') %></h1>
4
- </div>
5
-
6
- <%= if session[:edit_mode] > 1
7
- dc_link_for_create(controller: 'cmsedit', table: 'dc_blog', title: 'dc_blog.new_entry' )
8
- end %>
9
-
10
- <% for entry in entries %>
11
- <div class="blog-entry">
12
-
13
- <%= link_to( entry.subject,
14
- { path: 'blog', name: params[:name], link: entry.link } )%>
15
-
16
- <div class="blog-date"><h4><%= dc_pretty_date(entry.created_at) %></h4></div>
17
- </div>
18
- <% end %>
19
- </div>
@@ -1,15 +0,0 @@
1
- <div class="wrap">
2
- <div class="news-title">
3
- <h1><%= t('dc_news.news') %></h1>
4
- </div>
5
- <%= if session[:edit_mode] > 1
6
- dc_link_for_create(controller: 'cmsedit', table: 'dc_news', title: 'dc_blog.new_entry' )
7
- end %>
8
- <% for entry in entries %>
9
-
10
- <div class="news-entry">
11
- <h4><%= link_to( entry.subject, { path: 'news', link: entry.link } )%></h4>
12
- <%= dc_pretty_date(entry.created_at) %>
13
- </div>
14
- <% end %>
15
- </div>
@@ -1,23 +0,0 @@
1
- <div class="wrap">
2
- <% if session[:edit_mode] > 1 %>
3
- <%= dc_link_for_create(controller: 'cmsedit', table: 'dc_news', title: 'dc_news.new_entry' ) %>
4
- <br><br>
5
- <%= dc_link_for_edit(controller: 'cmsedit', table: 'dc_news', title: 'dc_news.edit_entry', id: entry.id ) %>
6
- <% end %>
7
-
8
- <div class="news-subject"><h2><%= entry.subject %></h2></div>
9
- <div class="news-date"><h3>
10
- <%= t('dc_blog.author') + ' ' + entry.created_by_name + ', ' + dc_pretty_date(entry.created_at) %>
11
- </h3></div><br>
12
-
13
- <div class="news-body"><%= entry.body.html_safe %></div>
14
- <div class="social-sites"><%= social_sites %></div>
15
-
16
- <div class="news-replies">
17
- <h2><%= t('dc_blog.comments') %></h2>
18
- <%= render partial: 'dc_replay/reply', formats: [:html],
19
- locals: { replies: replies, parent_id: entry.id, parent_document: 'dc_news' } %>
20
- </div>
21
-
22
- <iframe id="iframe_edit" name="iframe_edit" scrolling="no"></iframe>
23
- </div>
@@ -1,26 +0,0 @@
1
- <div class="wrap">
2
- <div class="news-title">
3
- <%= title %>
4
- </div>
5
-
6
- <%= if session[:edit_mode] > 1
7
- dc_link_for_create(controller: 'cmsedit', table: 'dc_news', title: 'dc_blog.new_entry' )
8
- end %>
9
-
10
- <% if news %>
11
- <div class="news-date"><%= dc_pretty_date(news.created_at) %></div>
12
- <div class="news-subject"><%= news.subject %></div>
13
- <div style="clear:both;"></div>
14
-
15
- <div class="news-body"><%= news.body%></div>
16
-
17
- <div class="news-replies">
18
- <%= render partial: 'dc_reply/reply', formats: [:html],
19
- locals: { replies: replies, parent_id: news.id } %>
20
- </div>
21
-
22
- <iframe id="iframe_edit" name="iframe_edit" scrolling="no"></iframe>
23
- <% else %>
24
- <br><br><br>Sorry no news. Yet ;-)
25
- <% end %>
26
- </div>