drg_manual 0.0.1
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 +60 -0
- data/Rakefile +39 -0
- data/app/assets/stylesheets/drg_manual.css +52 -0
- data/app/controllers/drgcms_controls/dc_book_chapter_dc_reply_control.rb +50 -0
- data/app/forms/cms_menu.yml +34 -0
- data/app/forms/dc_manual.yml +58 -0
- data/app/forms/dc_manual_page.yml +70 -0
- data/app/forms/dc_manual_settings.yml +17 -0
- data/app/helpers/dc_manual_renderer.rb +209 -0
- data/app/models/dc_manual.rb +135 -0
- data/app/models/dc_manual_page.rb +71 -0
- data/app/views/dc_manual/_chapter.html.erb +36 -0
- data/app/views/dc_manual/_chapter_old.html.erb +34 -0
- data/app/views/dc_manual/_list.html.erb +13 -0
- data/app/views/dc_manual/_toc.html.erb +10 -0
- data/config/locales/dc_manual_en.yml +91 -0
- data/config/locales/dc_manual_sl.yml +83 -0
- data/config/routes.rb +2 -0
- data/lib/drg_manual.rb +6 -0
- data/lib/drg_manual/engine.rb +4 -0
- data/lib/drg_manual/version.rb +3 -0
- data/lib/tasks/drg_manual_tasks.rake +31 -0
- data/lib/tasks/error_test.rake +17 -0
- data/test/drg_manual_test.rb +7 -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.ru +4 -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/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/test_helper.rb +15 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7da9d2693c1ed2ef587bab36fb87739b4db73bad
|
4
|
+
data.tar.gz: 2cb5aa108d3939063808f9f3b43de677d0a69846
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: def3863a5070aed0c7d777933ccd5f8011b1b6ba93936d25c26245c1b224912e62fdc5a08605defd85b610b1936f2faa46a695cb2109f341fe2e91b2459d2554
|
7
|
+
data.tar.gz: b8d88f7756fde5d94662a9a566c59c8983eb77c5aed81b1550ac39d6c0b9521d7a06832f1aa8847d3c831d84b13b854dcac9675cf7ca164d086c122dab722908
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# DrgBooks
|
2
|
+
|
3
|
+
DrgBooks plugin implements documentation management in DRG CMS enabled web site.
|
4
|
+
|
5
|
+
Configuration
|
6
|
+
----------------
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
Add this line to your Gemfile:
|
11
|
+
```ruby
|
12
|
+
gem 'drg_books'
|
13
|
+
```
|
14
|
+
|
15
|
+
Create apropriate dc_page document with related design. Use this line in design.
|
16
|
+
```irb
|
17
|
+
div id="docs"><%= dc_render(:dc_book) %></div>
|
18
|
+
```
|
19
|
+
|
20
|
+
Update routes.rb
|
21
|
+
```ruby
|
22
|
+
get '/books/:method/:book_id/', to: 'dc_main#page', :defaults => { path: 'books' }
|
23
|
+
get '/books/:method/:book_id/:chapter_id', to: 'dc_main#page', :defaults => { path: 'books' }
|
24
|
+
get '/books/:method/:book_id/:chapter_id/:version', to: 'dc_main#page', :defaults => { path: 'books' }
|
25
|
+
```
|
26
|
+
|
27
|
+
Documentation
|
28
|
+
-------------
|
29
|
+
|
30
|
+
Please see the DRG CMS website for up-to-date documentation:
|
31
|
+
[www.drgcms.org](http://www.drgcms.org)
|
32
|
+
|
33
|
+
License
|
34
|
+
-------
|
35
|
+
|
36
|
+
Copyright (c) 2012-2015 Damjan Rems
|
37
|
+
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
39
|
+
a copy of this software and associated documentation files (the
|
40
|
+
"Software"), to deal in the Software without restriction, including
|
41
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
42
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
43
|
+
permit persons to whom the Software is furnished to do so, subject to
|
44
|
+
the following conditions:
|
45
|
+
|
46
|
+
The above copyright notice and this permission notice shall be
|
47
|
+
included in all copies or substantial portions of the Software.
|
48
|
+
|
49
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
50
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
51
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
52
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
53
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
54
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
55
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
56
|
+
|
57
|
+
Credits
|
58
|
+
-------
|
59
|
+
|
60
|
+
Damjan Rems: damjan dot rems at gmail dot com
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'DrgManual'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
Bundler::GemHelper.install_tasks
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
|
31
|
+
Rake::TestTask.new(:test) do |t|
|
32
|
+
t.libs << 'lib'
|
33
|
+
t.libs << 'test'
|
34
|
+
t.pattern = 'test/**/*_test.rb'
|
35
|
+
t.verbose = false
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
task :default => :test
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/*
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2018+ 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
|
+
.manual .menu a {
|
27
|
+
padding: 5px 0;
|
28
|
+
font-size: 1.2em;
|
29
|
+
color: #666;
|
30
|
+
}
|
31
|
+
.manual .title {
|
32
|
+
font-size: 1.3em;
|
33
|
+
font-weight: bold;
|
34
|
+
}
|
35
|
+
.manual .title a {
|
36
|
+
color: #db363a;
|
37
|
+
}
|
38
|
+
.manual .menu a:hover {
|
39
|
+
color: #444;
|
40
|
+
}
|
41
|
+
|
42
|
+
.manual .menu .is-active > a {
|
43
|
+
color: #444;
|
44
|
+
font-weight: bold;
|
45
|
+
background-color: transparent;
|
46
|
+
}
|
47
|
+
|
48
|
+
.manual .column:first-child {
|
49
|
+
background: linear-gradient(to top, #eee 0%, #fefefe 100%);
|
50
|
+
padding: 1em;
|
51
|
+
border-radius: 2px;
|
52
|
+
}
|
@@ -0,0 +1,50 @@
|
|
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::DcBookChapterDcReplyControl
|
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 = @record._parent.dc_replies.find(params[:reply_to])
|
37
|
+
@record.subject = "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
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012-2013 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
|
+
menu:
|
25
|
+
80_drg_manuals:
|
26
|
+
caption: Manuals
|
27
|
+
icon: book lg
|
28
|
+
items:
|
29
|
+
10:
|
30
|
+
caption: helpers.label.drg_manual.tabletitle
|
31
|
+
controller: cmsedit
|
32
|
+
icon: book lg
|
33
|
+
table: drg_manual
|
34
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Form DcManual
|
2
|
+
table: dc_manual
|
3
|
+
index:
|
4
|
+
actions: standard
|
5
|
+
|
6
|
+
result_set:
|
7
|
+
actions:
|
8
|
+
standard : yes
|
9
|
+
|
10
|
+
columns:
|
11
|
+
10:
|
12
|
+
name: title
|
13
|
+
width: 30%
|
14
|
+
20:
|
15
|
+
name: updated_at
|
16
|
+
format: '%d.%m.%Y'
|
17
|
+
30:
|
18
|
+
name: order
|
19
|
+
40:
|
20
|
+
name: active
|
21
|
+
eval: dc_icon4_boolean
|
22
|
+
|
23
|
+
form:
|
24
|
+
actions: standard
|
25
|
+
|
26
|
+
tabs:
|
27
|
+
1basic:
|
28
|
+
10:
|
29
|
+
name: title
|
30
|
+
type: text_field
|
31
|
+
size: 80
|
32
|
+
20:
|
33
|
+
name: link
|
34
|
+
type: text_field
|
35
|
+
size: 80
|
36
|
+
30:
|
37
|
+
name: policy_id
|
38
|
+
type: select
|
39
|
+
eval: dc_choices4_site_policies
|
40
|
+
html:
|
41
|
+
include_blank: true
|
42
|
+
40:
|
43
|
+
name: active
|
44
|
+
type: check_box
|
45
|
+
|
46
|
+
2body:
|
47
|
+
20:
|
48
|
+
name: body
|
49
|
+
type: html_field
|
50
|
+
options: 'height: 800,width: 800'
|
51
|
+
|
52
|
+
3pages:
|
53
|
+
10:
|
54
|
+
name: dc_manual_pages
|
55
|
+
type: embedded
|
56
|
+
form_name: dc_manual_page
|
57
|
+
html:
|
58
|
+
height: 1000
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Form for drg_manual_pages
|
2
|
+
table: dc_manual_pages
|
3
|
+
index:
|
4
|
+
actions: new
|
5
|
+
|
6
|
+
result_set:
|
7
|
+
actions:
|
8
|
+
standard : yes
|
9
|
+
|
10
|
+
columns:
|
11
|
+
10:
|
12
|
+
name: title
|
13
|
+
width: 30%
|
14
|
+
20:
|
15
|
+
name: updated_at
|
16
|
+
format: '%d.%m.%Y'
|
17
|
+
30:
|
18
|
+
name: order
|
19
|
+
40:
|
20
|
+
name: active
|
21
|
+
eval: dc_icon4_boolean
|
22
|
+
width: 5%
|
23
|
+
|
24
|
+
form:
|
25
|
+
actions: standard
|
26
|
+
|
27
|
+
tabs:
|
28
|
+
1basic:
|
29
|
+
10:
|
30
|
+
name: title
|
31
|
+
type: text_field
|
32
|
+
size: 80
|
33
|
+
20:
|
34
|
+
name: link
|
35
|
+
type: text_field
|
36
|
+
size: 80
|
37
|
+
30:
|
38
|
+
name: policy_id
|
39
|
+
type: select
|
40
|
+
eval: dc_choices4_site_policies
|
41
|
+
html:
|
42
|
+
include_blank: true
|
43
|
+
40:
|
44
|
+
name: order
|
45
|
+
type: text_field
|
46
|
+
size: 2
|
47
|
+
|
48
|
+
50:
|
49
|
+
name: active
|
50
|
+
type: check_box
|
51
|
+
|
52
|
+
60:
|
53
|
+
name: use_page
|
54
|
+
type: tree_select
|
55
|
+
eval: "DcManual.get_all_menus()"
|
56
|
+
style: "max-height: 300px"
|
57
|
+
|
58
|
+
2body:
|
59
|
+
20:
|
60
|
+
name: body
|
61
|
+
type: html_field
|
62
|
+
options: 'height: 600,width: 800'
|
63
|
+
|
64
|
+
3pages:
|
65
|
+
10:
|
66
|
+
name: dc_manual_pages
|
67
|
+
type: embedded
|
68
|
+
form_name: dc_manual_page
|
69
|
+
html:
|
70
|
+
height: 1000
|
@@ -0,0 +1,17 @@
|
|
1
|
+
## Form for dc_manual settings
|
2
|
+
table: dc_memory
|
3
|
+
title: helpers.dc_manual.settings
|
4
|
+
controls: design_element_settings
|
5
|
+
|
6
|
+
form:
|
7
|
+
actions:
|
8
|
+
1: save
|
9
|
+
|
10
|
+
fields:
|
11
|
+
10:
|
12
|
+
name: prirocnik_id
|
13
|
+
text: helpers.dc_manual.drg_manual_id
|
14
|
+
help: helpers.dc_manual.drg_manual_id_help
|
15
|
+
type: select
|
16
|
+
eval: "dc_choices4('dc_manual','title')"
|
17
|
+
|
@@ -0,0 +1,209 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2018+ 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
|
+
#
|
27
|
+
########################################################################
|
28
|
+
class DcManualRenderer
|
29
|
+
include DcApplicationHelper
|
30
|
+
|
31
|
+
########################################################################
|
32
|
+
#
|
33
|
+
########################################################################
|
34
|
+
def initialize( parent, opts={} )
|
35
|
+
@parent = parent
|
36
|
+
@opts = opts
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
#########################################################################
|
41
|
+
# List all manuals
|
42
|
+
########################################################################
|
43
|
+
def list
|
44
|
+
html = "<div class='#{@opts[:div] || 'list-manuals'}'>"
|
45
|
+
if @opts[:edit_mode] > 1
|
46
|
+
html << dc_link_for_create({ controller: 'cmsedit', table: 'dc_manual', title: t('dc_manual.new') })
|
47
|
+
end
|
48
|
+
manuals = DcManual.where(active: true).sort(title: 1).to_a
|
49
|
+
html << @parent.render( partial: 'dc_manual/list', locals: { manuals: manuals }, formats: [:html] )
|
50
|
+
html << '</div>'
|
51
|
+
end
|
52
|
+
|
53
|
+
########################################################################
|
54
|
+
# Find document.
|
55
|
+
########################################################################
|
56
|
+
def find_document
|
57
|
+
# found bookname in path link
|
58
|
+
book_name_ix = @path.index(@parent.page.link)
|
59
|
+
@manual = DcManual.find_by(link: @path[book_name_ix+1])
|
60
|
+
if @manual
|
61
|
+
@prepand_path = @path.shift(book_name_ix+2)
|
62
|
+
else
|
63
|
+
# manual_id should be set in page settings
|
64
|
+
manual_id = @opts.dig(:settings, 'manual', 'manual_id')
|
65
|
+
@prepand_path = @path.shift(book_name_ix+1)
|
66
|
+
@manual = DcManual.find(manual_id) if manual_id
|
67
|
+
end
|
68
|
+
return if @manual.nil?
|
69
|
+
# ids for editing manual page
|
70
|
+
@manual_ids = ''
|
71
|
+
# Determine selected page
|
72
|
+
@manual_page = @manual
|
73
|
+
while (link_page = @path.shift) != nil do
|
74
|
+
@manual_ids << (@manual_ids.blank? ? '' : ';') + "#{@manual_page.id}"
|
75
|
+
@manual_page = @manual_page.dc_manual_pages.find_by(link: link_page)
|
76
|
+
if @manual_page.nil?
|
77
|
+
# select first page if path is in error
|
78
|
+
@manual_page = @manual
|
79
|
+
break
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
########################################################################
|
85
|
+
# Create link for one page
|
86
|
+
########################################################################
|
87
|
+
def menu_link_for(menu, parent_path)
|
88
|
+
document_link = parent_path + [menu[4]]
|
89
|
+
document_link.shift # remove link to document name
|
90
|
+
link = "/#{@prepand_path.join('/')}/#{document_link.join('/')}"
|
91
|
+
@parent.link_to(menu[0],link)
|
92
|
+
end
|
93
|
+
|
94
|
+
########################################################################
|
95
|
+
# Create submenus for a menu
|
96
|
+
########################################################################
|
97
|
+
def submenu(menu_item, menu, parent_path)
|
98
|
+
# is active when ids path matches parent path or last (my id) matches manual_page
|
99
|
+
last_item = menu_item[1].split(';').last
|
100
|
+
is_active = (@manual_ids.match(menu_item[1]) or last_item.match(@manual_page.id.to_s)) ? ' is-active' : ''
|
101
|
+
|
102
|
+
html = parent_path.blank? ? '' : "<li class=\"#{is_active}\">#{menu_link_for(menu_item, parent_path)}"
|
103
|
+
# select subpages
|
104
|
+
sub_pages = menu.select {|e| e[2] == menu_item[1]}
|
105
|
+
return html if sub_pages.size == 0
|
106
|
+
#
|
107
|
+
sub_pages.sort! {|a,b| a[3] <=> b[3]}
|
108
|
+
sub_pages.each do |page|
|
109
|
+
html << %Q[<ul class="menu vertical nested #{is_active}" >]
|
110
|
+
html << submenu(page, menu, parent_path + [menu_item[4]] )
|
111
|
+
html << '</ul>'
|
112
|
+
end
|
113
|
+
html << '</li>'
|
114
|
+
end
|
115
|
+
|
116
|
+
########################################################################
|
117
|
+
# Create menu
|
118
|
+
########################################################################
|
119
|
+
def manual_menu
|
120
|
+
menu = @manual.choices4_all_as_tree
|
121
|
+
html = "<div class=\"title\">#{menu_link_for(menu.first,[])}</div>"
|
122
|
+
html << submenu(menu.first, menu, [])
|
123
|
+
%Q[<ul id="manual-menu" class="is-active menu multilevel-accordion-menu " data-accordion-menu data-submenu-toggle="true">
|
124
|
+
#{html}
|
125
|
+
</ul>]
|
126
|
+
end
|
127
|
+
|
128
|
+
#######################################################################
|
129
|
+
# Render manual data
|
130
|
+
#######################################################################
|
131
|
+
def default
|
132
|
+
@path = @opts[:path]
|
133
|
+
return list if @path.size == 1
|
134
|
+
# link for manual settings on the page
|
135
|
+
edit_html = ''
|
136
|
+
if dc_edit_mode?
|
137
|
+
edit_html << @parent.dc_link_for_edit(table: 'dc_memory', title: 'dc_manual.settings',
|
138
|
+
form_name: 'dc_manual_settings', icon: 'book lg',
|
139
|
+
location: @parent.page.class.to_s,
|
140
|
+
field_name: 'params', id: @parent.page.id,
|
141
|
+
action: 'new', element: 'manual' )
|
142
|
+
end
|
143
|
+
find_document()
|
144
|
+
return "ERROR! #{@parent.params[:path]} #{edit_html}" if @manual.nil? or @manual_page.nil?
|
145
|
+
#
|
146
|
+
if dc_edit_mode?
|
147
|
+
opts = { action: 'edit', table: 'dc_manual',
|
148
|
+
id: @manual._id, title: 'dc_manual.edit' }
|
149
|
+
edit_html << dc_link_for_edit(opts)
|
150
|
+
end
|
151
|
+
#
|
152
|
+
html = %Q[
|
153
|
+
<div class="wrap">
|
154
|
+
<div class="row manual">
|
155
|
+
<div class="column small-12 medium-3 large-4">
|
156
|
+
#{edit_html}#{manual_menu()}
|
157
|
+
</div>
|
158
|
+
<div class="column small-12 medium-9 large-8 body">]
|
159
|
+
#
|
160
|
+
# ;add dc_manual_pages
|
161
|
+
no_subsections = @manual_ids.split(';').size
|
162
|
+
table = 'dc_manual' + ';dc_manual_page'*no_subsections
|
163
|
+
form_name = @manual_ids.blank? ? 'dc_manual' : 'dc_manual_page'
|
164
|
+
if dc_edit_mode?
|
165
|
+
unless @manual_ids.blank?
|
166
|
+
opts = { action: 'edit', form_name: form_name, table: table,
|
167
|
+
ids: @manual_ids, 'id' => @manual_page.id,
|
168
|
+
title: I18n.t('dc_manual.edit_chapter', title: @manual_page.title) }
|
169
|
+
html << dc_link_for_edit(opts) + '<br>'.html_safe
|
170
|
+
end
|
171
|
+
# Add new subchapter
|
172
|
+
ids = @manual_ids + (@manual_ids.blank? ? '' : ';') + @manual_page.id.to_s
|
173
|
+
table = 'dc_manual' + ';dc_manual_page'*(no_subsections+1)
|
174
|
+
opts = { controller: 'cmsedit', action: 'new', form_name: 'dc_manual_page',
|
175
|
+
table: table, ids: ids,
|
176
|
+
title: I18n.t('dc_manual.new_chapter', title: @manual_page.title) }
|
177
|
+
html << dc_link_for_create(opts) + '<br>'.html_safe
|
178
|
+
end
|
179
|
+
#
|
180
|
+
can_view, msg = dc_user_can_view(@parent, @manual_page)
|
181
|
+
html << if can_view
|
182
|
+
%Q[<h2>#{@manual_page.title}</h2>#{@manual_page.body}<br>
|
183
|
+
<div class='updated'>
|
184
|
+
#{t('dc_manual.updated')} <b>#{@manual_page.updated_at.strftime('%d.%m.%Y')}</b>
|
185
|
+
</div>]
|
186
|
+
else
|
187
|
+
msg
|
188
|
+
end
|
189
|
+
html << '</div></div></div>'
|
190
|
+
end
|
191
|
+
|
192
|
+
########################################################################
|
193
|
+
#
|
194
|
+
########################################################################
|
195
|
+
def render_html
|
196
|
+
method = @opts[:method] || 'default'
|
197
|
+
return "#{self.class}. Method #{method} not defined!" unless method
|
198
|
+
|
199
|
+
send method
|
200
|
+
end
|
201
|
+
|
202
|
+
########################################################################
|
203
|
+
#
|
204
|
+
########################################################################
|
205
|
+
def render_css
|
206
|
+
@manual.try :css
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|