muwu 3.2.0 → 4.0.0

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/muwu/cli/help/summary +1 -1
  3. data/lib/muwu/cli/help/view +2 -2
  4. data/lib/muwu/controller/controller_interaction.rb +10 -4
  5. data/lib/muwu/default/default.rb +2 -8
  6. data/lib/muwu/helper/html_href_helper.rb +77 -77
  7. data/lib/muwu/helper/outline_helper.rb +22 -24
  8. data/lib/muwu/helper/regexp_lib.rb +26 -51
  9. data/lib/muwu/helper/sanitizer_helper.rb +5 -5
  10. data/lib/muwu/manifest/manifest.rb +52 -70
  11. data/lib/muwu/manifest_task/document_html.rb +16 -22
  12. data/lib/muwu/manifest_task/text.rb +13 -13
  13. data/lib/muwu/manifest_task/{text_item.rb → topic.rb} +9 -9
  14. data/lib/muwu/manifest_task_builder/text_builder.rb +24 -24
  15. data/lib/muwu/manifest_task_builder/{text_item_builder.rb → topic_builder.rb} +48 -74
  16. data/lib/muwu/project/project.rb +0 -8
  17. data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +57 -62
  18. data/lib/muwu/project_builder/assets/config/css/base/index.scss +3 -2
  19. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +35 -57
  20. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +2 -14
  21. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +6 -11
  22. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +35 -57
  23. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +2 -48
  24. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +18 -23
  25. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_topic.scss +38 -0
  26. data/lib/muwu/project_builder/assets/config/css/colors/dark.scss +33 -31
  27. data/lib/muwu/project_builder/assets/config/css/colors/index.scss +2 -1
  28. data/lib/muwu/project_builder/assets/config/css/colors/light.scss +33 -33
  29. data/lib/muwu/project_builder/project_validator.rb +7 -7
  30. data/lib/muwu/project_exception/{lynx_not_available.rb → no_html_viewer_configured.rb} +2 -2
  31. data/lib/muwu/project_exception/{text_source_file_not_found.rb → topic_source_file_not_found.rb} +6 -7
  32. data/lib/muwu/project_options/project_options.rb +4 -1
  33. data/lib/muwu/project_options_builder/project_option_validator_key.rb +17 -19
  34. data/lib/muwu/project_options_builder/project_option_validator_value.rb +42 -59
  35. data/lib/muwu/render_concat/render_concat.rb +22 -22
  36. data/lib/muwu/render_html_partial/js_library/navigation.js +1 -1
  37. data/lib/muwu/render_html_partial/render_contents.rb +139 -139
  38. data/lib/muwu/render_html_partial/render_document_html.rb +2 -2
  39. data/lib/muwu/render_html_partial/render_metadata.rb +25 -37
  40. data/lib/muwu/render_html_partial/render_navigator.rb +39 -39
  41. data/lib/muwu/render_html_partial/render_subcontents.rb +142 -143
  42. data/lib/muwu/render_html_partial/render_text.rb +11 -11
  43. data/lib/muwu/render_html_partial/render_title.rb +21 -21
  44. data/lib/muwu/render_html_partial/{render_text_item.rb → render_topic.rb} +62 -35
  45. data/lib/muwu/render_html_partial_builder/render_contents_builder.rb +17 -23
  46. data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +3 -9
  47. data/lib/muwu/render_html_partial_builder/render_text_builder.rb +11 -11
  48. data/lib/muwu/render_html_partial_builder/render_topic_builder.rb +281 -0
  49. data/lib/muwu/render_inspector/render_inspector.rb +58 -58
  50. data/lib/muwu/viewer/viewer.rb +2 -2
  51. data/lib/muwu.rb +2 -7
  52. metadata +30 -78
  53. data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +0 -24
  54. data/lib/muwu/render_html/render_markup_to_html.rb +0 -87
  55. data/lib/muwu/render_html_partial_builder/render_text_item_builder.rb +0 -274
  56. data/lib/muwu/var/deflistdiv.rb +0 -239
@@ -0,0 +1,281 @@
1
+ module Muwu
2
+ module RenderHtmlPartialBuilder
3
+ class TopicBuilder
4
+
5
+
6
+ include Muwu
7
+
8
+ attr_accessor :renderer
9
+
10
+
11
+ def self.build
12
+ builder = new
13
+ yield(builder)
14
+ builder.renderer
15
+ end
16
+
17
+
18
+ def initialize
19
+ @renderer = RenderHtmlPartial::Topic.new
20
+ end
21
+
22
+
23
+ def build_from_manifest_topic(manifest_topic)
24
+ @manifest_topic = manifest_topic
25
+ @project = manifest_topic.project
26
+ phase_1_set_id
27
+ phase_1_set_commonmarker_options
28
+ phase_1_set_destination
29
+ phase_1_set_generate_inner_identifiers
30
+ phase_1_set_heading
31
+ phase_1_set_heading_origin
32
+ phase_1_set_numbering
33
+ phase_1_set_depth
34
+ phase_1_set_numbering_as_text
35
+ phase_1_set_does_have_source_text
36
+ phase_1_set_is_parent_heading
37
+ phase_1_set_text_root_name
38
+ phase_2_set_source_filename_absolute
39
+ phase_2_set_source_filename_relative
40
+ phase_3_set_subtopics
41
+ phase_3_set_source_relative_segments
42
+ phase_4_set_end_links
43
+ phase_4_set_will_render_section_number
44
+ phase_4_set_subtopics_are_distinct
45
+ phase_5_set_html_id
46
+ end
47
+
48
+
49
+ def phase_1_set_commonmarker_options
50
+ @renderer.commonmarker_options = { extension: {}, render: {} }
51
+ @renderer.commonmarker_options[:extension].merge!({ description_lists: true })
52
+ if @project.options.render_punctuation_smart
53
+ @renderer.commonmarker_options[:render].merge!({ smart: true })
54
+ end
55
+ if @project.options.markdown_allows_raw_html
56
+ @renderer.commonmarker_options[:render].merge!({ unsafe: true })
57
+ end
58
+ end
59
+
60
+
61
+ def phase_1_set_destination
62
+ @renderer.destination = @manifest_topic.destination
63
+ end
64
+
65
+
66
+ def phase_1_set_does_have_source_text
67
+ if @manifest_topic.source_file_does_exist
68
+ @renderer.does_have_source_text = true
69
+ elsif @manifest_topic.source_file_does_not_exist
70
+ @renderer.does_have_source_text = false
71
+ end
72
+ end
73
+
74
+
75
+ def phase_1_set_generate_inner_identifiers
76
+ @renderer.generate_inner_identifiers = @project.options.generate_topic_inner_identifiers
77
+ end
78
+
79
+
80
+ def phase_1_set_heading
81
+ @renderer.heading = @manifest_topic.heading
82
+ end
83
+
84
+
85
+ def phase_1_set_heading_origin
86
+ @renderer.heading_origin = @manifest_topic.heading_origin
87
+ end
88
+
89
+
90
+ def phase_1_set_id
91
+ @renderer.id = @manifest_topic.id
92
+ end
93
+
94
+
95
+ def phase_1_set_is_parent_heading
96
+ @renderer.is_parent_heading = @manifest_topic.is_parent_heading
97
+ end
98
+
99
+
100
+ def phase_1_set_numbering
101
+ @renderer.numbering = @manifest_topic.numbering
102
+ end
103
+
104
+
105
+ def phase_1_set_depth
106
+ @renderer.depth = @manifest_topic.topic_depth
107
+ end
108
+
109
+
110
+ def phase_1_set_numbering_as_text
111
+ @renderer.numbering_as_text = @manifest_topic.numbering.join('.')
112
+ end
113
+
114
+
115
+ def phase_1_set_text_root_name
116
+ @renderer.text_root_name = @manifest_topic.text_root_name
117
+ end
118
+
119
+
120
+ def phase_2_set_source_filename_absolute
121
+ if @manifest_topic.source_file_does_exist
122
+ @renderer.source_filename_absolute = @manifest_topic.source_filename_absolute
123
+ end
124
+ end
125
+
126
+
127
+ def phase_2_set_source_filename_relative
128
+ if @manifest_topic.source_file_does_exist
129
+ @renderer.source_filename_relative = @manifest_topic.source_filename_relative
130
+ end
131
+ end
132
+
133
+
134
+ def phase_3_set_subtopics
135
+ if @manifest_topic.does_have_subtopics
136
+ @renderer.subtopics = determine_subtopics
137
+ end
138
+ end
139
+
140
+
141
+ def phase_3_set_source_relative_segments
142
+ segments = @manifest_topic.source_filename_relative.split('/')
143
+ segments.last.gsub!(/\.[\w\.]*\z/,'')
144
+ @renderer.source_relative_segments = segments
145
+ end
146
+
147
+
148
+ def phase_4_set_end_links
149
+ if topic_should_have_end_links
150
+ @renderer.end_links = determine_end_links
151
+ end
152
+ end
153
+
154
+
155
+ def phase_4_set_will_render_section_number
156
+ @renderer.will_render_section_number = determine_whether_topic_will_render_section_number
157
+ end
158
+
159
+
160
+ def phase_4_set_subtopics_are_distinct
161
+ @renderer.subtopics_are_distinct = determine_whether_subtopics_are_distinct
162
+ end
163
+
164
+
165
+ def phase_5_set_html_id
166
+ @renderer.html_id = Helper::HrefHelper.id_topic_header(@manifest_topic)
167
+ end
168
+
169
+
170
+ private
171
+
172
+
173
+ def build_renderer_topic(topic)
174
+ RenderHtmlPartialBuilder::TopicBuilder.build do |b|
175
+ b.build_from_manifest_topic(topic)
176
+ end
177
+ end
178
+
179
+
180
+ def determine_end_links
181
+ end_links = {}
182
+ if @project.options.render_section_end_links
183
+ @project.options.render_section_end_links.each do |link|
184
+ end_links[link] = determine_end_links_href(link)
185
+ end
186
+ end
187
+ end_links
188
+ end
189
+
190
+
191
+ def determine_end_links_href(link)
192
+ case link
193
+ when 'contents'
194
+ Helper::HrefHelper.link_to_contents_item(@manifest_topic, from: :topic)
195
+ when 'home'
196
+ Helper::HrefHelper.link_to_project_home(@project)
197
+ when 'top'
198
+ Helper::HrefHelper.link_to_document_top
199
+ end
200
+ end
201
+
202
+
203
+ def determine_subtopics
204
+ subtopics = []
205
+ @manifest_topic.subtopics.each do |subtopic|
206
+ subtopics << build_renderer_topic(subtopic)
207
+ end
208
+ subtopics
209
+ end
210
+
211
+
212
+ def determine_whether_subtopics_are_distinct
213
+ if @manifest_topic.does_have_subtopics
214
+ if @project.options.render_sections_distinctly_depth_max == nil
215
+ return true
216
+ elsif @renderer.depth < @project.options.render_sections_distinctly_depth_max
217
+ return true
218
+ elsif @renderer.depth >= @project.options.render_sections_distinctly_depth_max
219
+ return false
220
+ end
221
+ end
222
+ end
223
+
224
+
225
+ def determine_whether_topic_will_render_section_number
226
+ if @project.will_render_section_numbers && topic_should_be_distinct
227
+ true
228
+ end
229
+ end
230
+
231
+
232
+ def topic_should_be_distinct
233
+ if @project.options.render_sections_distinctly_depth_max == nil
234
+ return true
235
+ elsif @renderer.depth <= @project.options.render_sections_distinctly_depth_max
236
+ return true
237
+ elsif @renderer.depth > @project.options.render_sections_distinctly_depth_max
238
+ return false
239
+ end
240
+ end
241
+
242
+
243
+ def topic_should_have_end_links
244
+ if topic_should_be_distinct
245
+ return topic_distinct_should_have_end_links
246
+ else
247
+ return false
248
+ end
249
+ end
250
+
251
+
252
+ def topic_distinct_should_have_end_links
253
+ if @renderer.is_parent_heading
254
+ return topic_distinct_parent_should_have_end_links
255
+ elsif @renderer.does_have_source_text
256
+ return true
257
+ end
258
+ end
259
+
260
+
261
+ def topic_distinct_parent_should_have_end_links
262
+ if @renderer.does_have_source_text == true
263
+ return true
264
+ elsif @renderer.does_have_source_text == false
265
+ return topic_distinct_parent_without_source_should_have_end_links
266
+ end
267
+ end
268
+
269
+
270
+ def topic_distinct_parent_without_source_should_have_end_links
271
+ if determine_whether_subtopics_are_distinct == true
272
+ return false
273
+ elsif determine_whether_subtopics_are_distinct == false
274
+ return true
275
+ end
276
+ end
277
+
278
+
279
+ end
280
+ end
281
+ end
@@ -1,31 +1,31 @@
1
1
  module Muwu
2
2
  class RenderInspector
3
3
 
4
-
4
+
5
5
  include Muwu
6
6
 
7
7
 
8
8
  COLUMN_LEFT = 12
9
9
  SEPARATOR = ' '
10
-
11
-
10
+
11
+
12
12
  def initialize(project)
13
13
  @project = project
14
14
  end
15
-
16
-
17
-
15
+
16
+
17
+
18
18
  public
19
-
20
-
19
+
20
+
21
21
  def render_inspector
22
22
  render_inspector_project
23
23
  render_inspector_options
24
24
  render_inspector_manifest
25
25
  render_inspector_errors
26
26
  end
27
-
28
-
27
+
28
+
29
29
  def render_inspector_errors
30
30
  if @project.exceptions.any?
31
31
  @project.exceptions.each do |error|
@@ -34,8 +34,8 @@ module Muwu
34
34
  puts
35
35
  end
36
36
  end
37
-
38
-
37
+
38
+
39
39
  def render_inspector_manifest
40
40
  @project.manifest.documents.each do |document|
41
41
  case document
@@ -48,9 +48,9 @@ module Muwu
48
48
  end
49
49
  end
50
50
  end
51
-
52
-
53
- def render_inspector_options
51
+
52
+
53
+ def render_inspector_options
54
54
  puts @project.options
55
55
  @project.options.instance_variables.each do |option|
56
56
  key = option.to_s.gsub(/\A@/,'')
@@ -59,7 +59,7 @@ module Muwu
59
59
  end
60
60
  puts
61
61
  end
62
-
62
+
63
63
 
64
64
  def render_inspector_project
65
65
  puts @project
@@ -68,17 +68,17 @@ module Muwu
68
68
  puts indent("js_libraries: #{@project.javascript_libraries_requested}")
69
69
  puts
70
70
  end
71
-
72
-
71
+
72
+
73
73
 
74
74
  private
75
-
76
-
75
+
76
+
77
77
  def column_left(text)
78
78
  text.ljust(COLUMN_LEFT)
79
79
  end
80
-
81
-
80
+
81
+
82
82
  def indent(text)
83
83
  column_left(text).prepend(' ')
84
84
  end
@@ -93,14 +93,14 @@ module Muwu
93
93
  puts output
94
94
  end
95
95
  end
96
-
96
+
97
97
 
98
98
  def render_inspector_document_css(document)
99
99
  puts_line [document.to_s]
100
100
  puts_line [document.destination.to_s, document.destination.output_class, document.destination.output_filename]
101
101
  puts_line
102
102
  end
103
-
103
+
104
104
 
105
105
  def render_inspector_document_html(document)
106
106
  puts_line [document.to_s, "index: #{document.index}"]
@@ -110,8 +110,8 @@ module Muwu
110
110
  end
111
111
  puts_line
112
112
  end
113
-
114
-
113
+
114
+
115
115
  def render_inspector_document_js(document)
116
116
  puts_line [document.to_s]
117
117
  puts_line [
@@ -121,16 +121,16 @@ module Muwu
121
121
  ]
122
122
  puts_line
123
123
  end
124
-
125
-
124
+
125
+
126
126
  def render_inspector_error_report(error)
127
127
  puts_line [
128
128
  column_left(error.type.to_s),
129
129
  error.report
130
130
  ]
131
131
  end
132
-
133
-
132
+
133
+
134
134
  def render_inspector_manifest_task(task)
135
135
  case task
136
136
  when ManifestTask::Contents
@@ -145,28 +145,28 @@ module Muwu
145
145
  render_inspector_manifest_task_title(task)
146
146
  when ManifestTask::Text
147
147
  render_inspector_manifest_task_text(task)
148
- when ManifestTask::TextItem
149
- render_inspector_manifest_task_text_item(task)
148
+ when ManifestTask::Topic
149
+ render_inspector_manifest_task_topic(task)
150
150
  end
151
151
  end
152
-
153
-
152
+
153
+
154
154
  def render_inspector_manifest_task_contents(contents)
155
155
  puts_line [
156
156
  indent('Contents'),
157
157
  contents.naming.inspect
158
158
  ]
159
159
  end
160
-
161
-
160
+
161
+
162
162
  def render_inspector_manifest_task_metadata(metadata)
163
- puts_line [
163
+ puts_line [
164
164
  indent('Metadata'),
165
165
  metadata.metadata.to_s
166
166
  ]
167
167
  end
168
-
169
-
168
+
169
+
170
170
  def render_inspector_manifest_task_navigator(navigator)
171
171
  puts_line [
172
172
  indent('Navigator'),
@@ -175,8 +175,8 @@ module Muwu
175
175
  "next: #{navigator.document_next_index}"
176
176
  ]
177
177
  end
178
-
179
-
178
+
179
+
180
180
  def render_inspector_manifest_task_subcontents(contents)
181
181
  puts_line [
182
182
  indent('Subcontents'),
@@ -190,35 +190,35 @@ module Muwu
190
190
  indent('Text'),
191
191
  text.naming.inspect
192
192
  ]
193
- text.sections.each do |section|
194
- render_inspector_manifest_task(section)
193
+ text.topics.each do |topic|
194
+ render_inspector_manifest_task(topic)
195
195
  end
196
196
  end
197
-
198
-
199
- def render_inspector_manifest_task_text_item(text_item)
197
+
198
+
199
+ def render_inspector_manifest_task_topic(topic)
200
200
  puts_line [
201
- indent('| TextItem'),
202
- text_item.numbering.inspect,
203
- text_item.heading.inspect,
204
- text_item.source_filename,
205
- ('!!' if text_item.source_file_does_not_exist)
201
+ indent("| Topic #{topic.id}"),
202
+ topic.numbering.inspect,
203
+ topic.heading.inspect,
204
+ topic.source_filename,
205
+ ('!!' if topic.source_file_does_not_exist)
206
206
  ]
207
- if text_item.does_have_child_sections
208
- text_item.sections.each do |section|
209
- render_inspector_manifest_task(section)
207
+ if topic.does_have_subtopics
208
+ topic.subtopics.each do |subtopic|
209
+ render_inspector_manifest_task(subtopic)
210
210
  end
211
211
  end
212
212
  end
213
-
214
-
213
+
214
+
215
215
  def render_inspector_manifest_task_title(title)
216
216
  puts_line [
217
217
  indent('Title'),
218
218
  title.metadata.to_s
219
219
  ]
220
220
  end
221
-
222
-
221
+
222
+
223
223
  end
224
224
  end
@@ -29,9 +29,9 @@ module Muwu
29
29
 
30
30
  def view_home_document
31
31
  begin
32
- system "lynx #{@document_home_filepath}", exception: true
32
+ system "open #{@document_home_filepath}", exception: true
33
33
  rescue Errno::ENOENT
34
- raise ProjectExceptionHandler::Fatal.new(ProjectException::LynxNotAvailable.new)
34
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::NoHTMLViewerConfigured.new)
35
35
  end
36
36
  end
37
37
 
data/lib/muwu.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  module Muwu
2
2
 
3
-
4
- VERSION = '3.2.0'
3
+ VERSION = '4.0.0'
5
4
 
6
5
  GEM_HOME_LIB = File.absolute_path(File.join(File.dirname(__FILE__)))
7
6
  GEM_HOME_LIB_MUWU = File.absolute_path(File.join(GEM_HOME_LIB, 'muwu'))
@@ -9,19 +8,15 @@ module Muwu
9
8
 
10
9
  require 'commonmarker'
11
10
  require 'fileutils'
12
- require 'haml'
13
11
  require 'iso-639'
14
12
  require 'logger'
15
- require 'motion-markdown-it'
16
- require 'motion-markdown-it-plugins'
13
+ require 'nokogiri'
17
14
  require 'sassc'
18
15
  require 'yaml'
19
16
 
20
-
21
17
  require_relative 'loader'
22
18
 
23
19
 
24
-
25
20
  module_function
26
21
 
27
22