drg_manual 0.0.4 → 0.0.5
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 +4 -4
- data/app/forms/dc_manual.yml +4 -0
- data/app/{helpers → renderers}/dc_manual_renderer.rb +29 -20
- data/lib/drg_manual/version.rb +1 -1
- metadata +31 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c4f5d856a68ffb3c41fd2f495ad40682661e4d76fb323be3f8d602391eb2f5
|
4
|
+
data.tar.gz: e723ba98794dbe7e85fafcb482e898d267deb6e3453de2e9ae19bae782c47fae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca2264bac60ea2f840f4906cdc355086b470441943d4bafa6764b57261668b406c6a0a45bde6db3c7f17c929f0a029b1224e5903788ddc6fd327fa331d893ff2
|
7
|
+
data.tar.gz: d375d13ecf71ef4e9778cacf03b2b49efc89f1c1b8c2eb42a83cfde01a84c9c95598374501f115b25132c24fc88f05015c95867f03d91df05493fa0a5a71cf63
|
data/app/forms/dc_manual.yml
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#coding: utf-8
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2018+ Damjan Rems
|
4
3
|
#
|
@@ -27,6 +26,7 @@
|
|
27
26
|
########################################################################
|
28
27
|
class DcManualRenderer
|
29
28
|
include DcApplicationHelper
|
29
|
+
include CmsCommonHelper
|
30
30
|
|
31
31
|
########################################################################
|
32
32
|
#
|
@@ -54,27 +54,27 @@ end
|
|
54
54
|
# Find document.
|
55
55
|
########################################################################
|
56
56
|
def find_document
|
57
|
-
# found bookname in path link
|
57
|
+
# found bookname in path link
|
58
58
|
book_name_ix = @path.index(@parent.page.link)
|
59
59
|
@manual = DcManual.find_by(link: @path[book_name_ix+1])
|
60
60
|
if @manual
|
61
61
|
@prepand_path = @path.shift(book_name_ix+2)
|
62
62
|
else
|
63
|
-
# manual_id should be set in page settings
|
64
|
-
manual_id
|
63
|
+
# manual_id should be set in page settings
|
64
|
+
manual_id = @opts.dig(:settings, 'manual', 'manual_id')
|
65
65
|
@prepand_path = @path.shift(book_name_ix+1)
|
66
66
|
@manual = DcManual.find(manual_id) if manual_id
|
67
67
|
end
|
68
68
|
return if @manual.nil?
|
69
|
-
# ids for editing manual page
|
69
|
+
# ids for editing manual page
|
70
70
|
@manual_ids = ''
|
71
|
-
# Determine selected page
|
71
|
+
# Determine selected page
|
72
72
|
@manual_page = @manual
|
73
73
|
while (link_page = @path.shift) != nil do
|
74
74
|
@manual_ids << (@manual_ids.blank? ? '' : ';') + "#{@manual_page.id}"
|
75
75
|
@manual_page = @manual_page.dc_manual_pages.find_by(link: link_page)
|
76
76
|
if @manual_page.nil?
|
77
|
-
# select first page if path is in error
|
77
|
+
# select first page if path is in error
|
78
78
|
@manual_page = @manual
|
79
79
|
break
|
80
80
|
end
|
@@ -95,15 +95,15 @@ end
|
|
95
95
|
# Create submenus for a menu
|
96
96
|
########################################################################
|
97
97
|
def submenu(menu_item, menu, parent_path)
|
98
|
-
# is active when ids path matches parent path or last (my id) matches manual_page
|
98
|
+
# is active when ids path matches parent path or last (my id) matches manual_page
|
99
99
|
last_item = menu_item[1].split(';').last
|
100
100
|
is_active = (@manual_ids.match(menu_item[1]) or last_item.match(@manual_page.id.to_s)) ? ' is-active' : ''
|
101
101
|
|
102
102
|
html = parent_path.blank? ? '' : "<li class=\"#{is_active}\">#{menu_link_for(menu_item, parent_path)}"
|
103
|
-
# select subpages
|
103
|
+
# select subpages
|
104
104
|
sub_pages = menu.select {|e| e[2] == menu_item[1]}
|
105
105
|
return html if sub_pages.size == 0
|
106
|
-
|
106
|
+
|
107
107
|
sub_pages.sort! {|a,b| a[3] <=> b[3]}
|
108
108
|
sub_pages.each do |page|
|
109
109
|
html << %Q[<ul class="menu vertical nested #{is_active}" >]
|
@@ -125,13 +125,20 @@ def manual_menu
|
|
125
125
|
</ul>]
|
126
126
|
end
|
127
127
|
|
128
|
+
########################################################################
|
129
|
+
#
|
130
|
+
########################################################################
|
131
|
+
def body_for_examples
|
132
|
+
@manual_page.body
|
133
|
+
end
|
134
|
+
|
128
135
|
#######################################################################
|
129
136
|
# Render manual data
|
130
137
|
#######################################################################
|
131
138
|
def default
|
132
139
|
@path = @opts[:path]
|
133
|
-
return list if @path.size == 1
|
134
|
-
# link for manual settings on the page
|
140
|
+
return list if @path.size == 1 and @opts.dig(:settings, 'manual', 'manual_id').nil?
|
141
|
+
# link for manual settings on the page
|
135
142
|
edit_html = ''
|
136
143
|
if dc_edit_mode?
|
137
144
|
edit_html << @parent.dc_link_for_edit(table: 'dc_memory', title: 'dc_manual.settings',
|
@@ -142,13 +149,13 @@ def default
|
|
142
149
|
end
|
143
150
|
find_document()
|
144
151
|
return "ERROR! #{@parent.params[:path]} #{edit_html}" if @manual.nil? or @manual_page.nil?
|
145
|
-
|
152
|
+
|
146
153
|
if dc_edit_mode?
|
147
154
|
opts = { action: 'edit', table: 'dc_manual',
|
148
155
|
id: @manual._id, title: 'dc_manual.edit' }
|
149
156
|
edit_html << dc_link_for_edit(opts)
|
150
157
|
end
|
151
|
-
|
158
|
+
|
152
159
|
html = %Q[
|
153
160
|
<div class="wrap">
|
154
161
|
<div class="row manual">
|
@@ -156,8 +163,8 @@ def default
|
|
156
163
|
#{edit_html}#{manual_menu()}
|
157
164
|
</div>
|
158
165
|
<div class="column small-12 medium-9 large-8 body">]
|
159
|
-
|
160
|
-
# ;add dc_manual_pages
|
166
|
+
|
167
|
+
# ;add dc_manual_pages
|
161
168
|
no_subsections = @manual_ids.split(';').size
|
162
169
|
table = 'dc_manual' + ';dc_manual_page'*no_subsections
|
163
170
|
form_name = @manual_ids.blank? ? 'dc_manual' : 'dc_manual_page'
|
@@ -168,7 +175,7 @@ def default
|
|
168
175
|
title: I18n.t('dc_manual.edit_chapter', title: @manual_page.title) }
|
169
176
|
html << dc_link_for_edit(opts) + '<br>'.html_safe
|
170
177
|
end
|
171
|
-
# Add new subchapter
|
178
|
+
# Add new subchapter
|
172
179
|
ids = @manual_ids + (@manual_ids.blank? ? '' : ';') + @manual_page.id.to_s
|
173
180
|
table = 'dc_manual' + ';dc_manual_page'*(no_subsections+1)
|
174
181
|
opts = { controller: 'cmsedit', action: 'new', form_name: 'dc_manual_page',
|
@@ -176,17 +183,19 @@ def default
|
|
176
183
|
title: I18n.t('dc_manual.new_chapter', title: @manual_page.title) }
|
177
184
|
html << dc_link_for_create(opts) + '<br>'.html_safe
|
178
185
|
end
|
179
|
-
|
186
|
+
|
180
187
|
can_view, msg = dc_user_can_view(@parent, @manual_page)
|
188
|
+
# process body before it is outputed to browser
|
189
|
+
body = @opts[:body_render] ? send(@opts[:body_render]) : @manual_page.body
|
181
190
|
html << if can_view
|
182
|
-
%Q[<h1>#{@manual_page.title}</h1>#{
|
191
|
+
%Q[<h1>#{@manual_page.title}</h1>#{body}<br>
|
183
192
|
<div class='updated'>
|
184
193
|
#{t('dc_manual.updated')} <b>#{@manual_page.updated_at.strftime('%d.%m.%Y')}</b>
|
185
194
|
</div>]
|
186
195
|
else
|
187
196
|
msg
|
188
197
|
end
|
189
|
-
html << '</div
|
198
|
+
html << '</div>'*3
|
190
199
|
end
|
191
200
|
|
192
201
|
########################################################################
|
data/lib/drg_manual/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drg_manual
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damjan Rems
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: drg_cms
|
@@ -39,9 +39,9 @@ files:
|
|
39
39
|
- app/forms/dc_manual.yml
|
40
40
|
- app/forms/dc_manual_page.yml
|
41
41
|
- app/forms/dc_manual_settings.yml
|
42
|
-
- app/helpers/dc_manual_renderer.rb
|
43
42
|
- app/models/dc_manual.rb
|
44
43
|
- app/models/dc_manual_page.rb
|
44
|
+
- app/renderers/dc_manual_renderer.rb
|
45
45
|
- app/views/dc_manual/_list.html.erb
|
46
46
|
- config/locales/dc_manual_en.yml
|
47
47
|
- config/locales/dc_manual_sl.yml
|
@@ -87,7 +87,7 @@ licenses:
|
|
87
87
|
- MIT-LICENSE
|
88
88
|
metadata:
|
89
89
|
source_code: https://github.com/drgcms/drg-manual
|
90
|
-
post_install_message:
|
90
|
+
post_install_message:
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -102,39 +102,39 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
105
|
+
rubygems_version: 3.1.2
|
106
|
+
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: 'DRG CMS: Manual plugin'
|
109
109
|
test_files:
|
110
|
-
- test/drg_manual_test.rb
|
111
|
-
- test/test_helper.rb
|
112
110
|
- test/integration/navigation_test.rb
|
111
|
+
- test/test_helper.rb
|
112
|
+
- test/dummy/script/rails
|
113
113
|
- test/dummy/README.rdoc
|
114
|
-
- test/dummy/
|
115
|
-
- test/dummy/
|
116
|
-
- test/dummy/
|
117
|
-
- test/dummy/
|
118
|
-
- test/dummy/
|
119
|
-
- test/dummy/
|
120
|
-
- test/dummy/
|
114
|
+
- test/dummy/app/views/layouts/application.html.erb
|
115
|
+
- test/dummy/app/helpers/application_helper.rb
|
116
|
+
- test/dummy/app/controllers/application_controller.rb
|
117
|
+
- test/dummy/app/assets/stylesheets/application.css
|
118
|
+
- test/dummy/app/assets/javascripts/application.js
|
119
|
+
- test/dummy/public/422.html
|
120
|
+
- test/dummy/public/404.html
|
121
|
+
- test/dummy/public/favicon.ico
|
122
|
+
- test/dummy/public/500.html
|
123
|
+
- test/dummy/Rakefile
|
124
|
+
- test/dummy/config.ru
|
121
125
|
- test/dummy/config/environment.rb
|
126
|
+
- test/dummy/config/boot.rb
|
127
|
+
- test/dummy/config/routes.rb
|
122
128
|
- test/dummy/config/application.rb
|
123
129
|
- test/dummy/config/database.yml
|
124
|
-
- test/dummy/config/routes.rb
|
125
|
-
- test/dummy/config/boot.rb
|
126
|
-
- test/dummy/config/environments/development.rb
|
127
130
|
- test/dummy/config/environments/test.rb
|
128
131
|
- test/dummy/config/environments/production.rb
|
129
|
-
- test/dummy/
|
130
|
-
- test/dummy/
|
131
|
-
- test/dummy/
|
132
|
-
- test/dummy/
|
133
|
-
- test/dummy/
|
134
|
-
- test/dummy/
|
135
|
-
- test/dummy/
|
136
|
-
- test/dummy/
|
137
|
-
- test/
|
138
|
-
- test/dummy/app/assets/stylesheets/application.css
|
139
|
-
- test/dummy/config.ru
|
140
|
-
- test/dummy/script/rails
|
132
|
+
- test/dummy/config/environments/development.rb
|
133
|
+
- test/dummy/config/locales/en.yml
|
134
|
+
- test/dummy/config/initializers/secret_token.rb
|
135
|
+
- test/dummy/config/initializers/inflections.rb
|
136
|
+
- test/dummy/config/initializers/mime_types.rb
|
137
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
138
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
139
|
+
- test/dummy/config/initializers/session_store.rb
|
140
|
+
- test/drg_manual_test.rb
|