Almirah 0.1.4 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7a10581e498b38097f10868900c903c9e3bad04bfb3e1d63170bada3222c65b
4
- data.tar.gz: 70ac0c4e2893e69ae0aa6c146c4c7a1da2b4ddd7ae0249604bc0b9afcb4980dd
3
+ metadata.gz: c28aa00ca57d213d56625d51372284eaff2668db942bb08fccd4d2c0bae10a72
4
+ data.tar.gz: ce278d1ab81147f9bddae86230da83575921ef26fcd849133e7d138433a6a7fd
5
5
  SHA512:
6
- metadata.gz: 9d2f2cfe15dd20b56c31cab7748304007497cbb4a03928df501b2628a261861003a8a0d576ff084ebd54128b03a5c521e6e1da94e8125f93e1233bee94a06ddc
7
- data.tar.gz: ff4cbc8d03219cb9792a854dfabbe0b968a097b73e57fca89f0a027bcca11916c646dbca4e64539ea3ac3f6a0b6213d18b71e4e9e323e57a05d83240289bf057
6
+ metadata.gz: 73fb32081f15b4314046976855e4474edf94cca23e146507210a6e232418e6b844d1d51c6bf1d7cbaad0b32a203abbc24cf38c1608e400a68485f58d7911ae2d
7
+ data.tar.gz: 71155f2804459d0ac0d82777f070e8628f3d1d8d3949bab4468bae35f9d04f495d78523b239a8ed5fff2df16ba98cf789c1b97017deb3b92d01a58ef81a5fe49
@@ -17,6 +17,8 @@ require_relative "doc_items/image"
17
17
  require_relative "doc_items/markdown_list"
18
18
  require_relative "doc_items/doc_footer"
19
19
 
20
+ require_relative "dom/document"
21
+
20
22
  class DocFabric
21
23
 
22
24
  def self.add_lazy_doc_id(path)
@@ -65,6 +67,7 @@ class DocFabric
65
67
 
66
68
  if level == 1 && doc.title == ""
67
69
  doc.title = value
70
+ level = 0 # Doc Title is a Root
68
71
  Heading.reset_global_section_number()
69
72
  end
70
73
 
@@ -82,7 +85,7 @@ class DocFabric
82
85
  Heading.reset_global_section_number()
83
86
  end
84
87
 
85
- item = Heading.new(title, 1)
88
+ item = Heading.new(title, 0)
86
89
  item.parent_doc = doc
87
90
  doc.items.append(item)
88
91
  doc.headings.append(item)
@@ -366,5 +369,9 @@ class DocFabric
366
369
  item = DocFooter.new
367
370
  item.parent_doc = doc
368
371
  doc.items.append(item)
372
+ # Build dom
373
+ if doc.is_a?(Specification)
374
+ doc.dom = Document.new(doc.headings)
375
+ end
369
376
  end
370
377
  end
@@ -11,57 +11,68 @@ class Heading < Paragraph
11
11
  def initialize(text, level)
12
12
  @text = text
13
13
  @level = level
14
- @anchor_id = getTextWithoutSpaces()
15
14
 
16
- if @@global_section_number == ""
17
- @@global_section_number = "1"
18
- for n in 1..(level-1) do
19
- @@global_section_number += ".1"
20
- end
21
- else
22
- previous_level = @@global_section_number.split(".").length
15
+ if level != 0 # skip Doc Title
16
+ if @@global_section_number == ""
17
+ @@global_section_number = "1"
18
+ for n in 1..(level-1) do
19
+ @@global_section_number += ".1"
20
+ end
21
+ else
22
+ previous_level = @@global_section_number.split(".").length
23
23
 
24
- if previous_level == level
24
+ if previous_level == level
25
25
 
26
- a = @@global_section_number.split(".")
27
- a[-1] = (a[-1].to_i() +1).to_s
28
- @@global_section_number = a.join(".")
26
+ a = @@global_section_number.split(".")
27
+ a[-1] = (a[-1].to_i() +1).to_s
28
+ @@global_section_number = a.join(".")
29
29
 
30
- elsif level > previous_level
30
+ elsif level > previous_level
31
31
 
32
- a = @@global_section_number.split(".")
33
- a.push("1")
34
- @@global_section_number = a.join(".")
35
-
36
- else # level < previous_level
32
+ a = @@global_section_number.split(".")
33
+ a.push("1")
34
+ @@global_section_number = a.join(".")
35
+
36
+ else # level < previous_level
37
37
 
38
- a = @@global_section_number.split(".")
39
- delta = previous_level - level
40
- a.pop(delta)
41
- @@global_section_number = a.join(".")
42
- # increment
43
- a = @@global_section_number.split(".")
44
- a[-1] = (a[-1].to_i() +1).to_s
45
- @@global_section_number = a.join(".")
38
+ a = @@global_section_number.split(".")
39
+ delta = previous_level - level
40
+ a.pop(delta)
41
+ @@global_section_number = a.join(".")
42
+ # increment
43
+ a = @@global_section_number.split(".")
44
+ a[-1] = (a[-1].to_i() +1).to_s
45
+ @@global_section_number = a.join(".")
46
+ end
46
47
  end
47
48
  end
48
49
  @section_number = @@global_section_number
50
+ @anchor_id = get_anchor_text()
49
51
  end
50
52
 
51
53
  def get_section_info
52
54
  s = @section_number + " " + @text
53
55
  end
54
56
 
57
+ def get_anchor_text()
58
+ s = @section_number + "-" + getTextWithoutSpaces()
59
+ end
60
+
55
61
  def to_html
56
62
  s = ''
57
63
  if @@htmlTableRenderInProgress
58
64
  s += "</table>\n"
59
65
  @@htmlTableRenderInProgress = false
60
66
  end
61
- headingLevel = level.to_s
67
+ heading_level = level.to_s
68
+ heading_text = get_section_info()
69
+ if level == 0
70
+ heading_level = 1.to_s # Render Doc Title as a regular h1
71
+ heading_text = @text # Doc Title does not have a section number
72
+ end
62
73
  s += "<a name=\"#{@anchor_id}\"></a>\n"
63
- s += "<h#{headingLevel}> #{@text} <a href=\"\##{@anchor_id}\" class=\"heading_anchor\">"
64
- s += "&para;</a></h#{headingLevel}>"
74
+ s += "<h#{heading_level}> #{heading_text} <a href=\"\##{@anchor_id}\" class=\"heading_anchor\">"
75
+ s += "&para;</a></h#{heading_level}>"
65
76
  return s
66
77
  end
67
78
 
@@ -6,6 +6,7 @@ class BaseDocument
6
6
  attr_accessor :headings
7
7
  attr_accessor :title
8
8
  attr_accessor :id
9
+ attr_accessor :dom
9
10
 
10
11
  def initialize(fele_path)
11
12
 
@@ -14,6 +15,7 @@ class BaseDocument
14
15
  @headings = Array.new
15
16
  @title = ""
16
17
  @id = ""
18
+ @dom = nil
17
19
  end
18
20
 
19
21
  def save_html_to_file html_rows, nav_pane, output_file_path
@@ -37,7 +39,7 @@ class BaseDocument
37
39
  file.puts r
38
40
  end
39
41
  elsif s.include?('{{NAV_PANE}}')
40
- if nav_pane
42
+ if nav_pane
41
43
  file.puts nav_pane.to_html
42
44
  end
43
45
  elsif s.include?('{{DOCUMENT_TITLE}}')
@@ -57,7 +57,7 @@ class Traceability < BaseDocument
57
57
  def render_table_row(top_item)
58
58
  s = ""
59
59
  top_f_text = top_item.format_string( top_item.text )
60
-
60
+
61
61
  if top_item.down_links
62
62
 
63
63
  if @is_agregated
@@ -81,6 +81,7 @@ class Traceability < BaseDocument
81
81
  end
82
82
 
83
83
  else
84
+ top_item_rendered = false
84
85
  top_item.down_links.each do |bottom_item|
85
86
 
86
87
  id_color = ""
@@ -97,8 +98,18 @@ class Traceability < BaseDocument
97
98
  s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{bottom_f_text}</td>\n"
98
99
  s += "\t\t<td class=\"item_text\" style='width: 16%;'>#{document_section}</td>\n"
99
100
  s += "\t</tr>\n"
101
+ top_item_rendered = true
100
102
  end
101
103
  end
104
+ unless top_item_rendered
105
+ s += "\t<tr>\n"
106
+ s += "\t\t<td class=\"item_id\" #{id_color}><a href=\"./../#{top_item.parent_doc.id}/#{top_item.parent_doc.id}.html##{top_item.id}\" class=\"external\">#{top_item.id}</a></td>\n"
107
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'>#{top_f_text}</td>\n"
108
+ s += "\t\t<td class=\"item_id\"></td>\n"
109
+ s += "\t\t<td class=\"item_text\" style='width: 34%;'></td>\n"
110
+ s += "\t\t<td class=\"item_text\" style='width: 16%;'></td>\n"
111
+ s += "\t</tr>\n"
112
+ end
102
113
  end
103
114
  else
104
115
  s += "\t<tr>\n"
@@ -0,0 +1,28 @@
1
+ class DocSection
2
+
3
+ attr_accessor :sections
4
+ attr_accessor :heading
5
+ attr_accessor :parent_section
6
+
7
+ def initialize(heading)
8
+ @sections = Array.new
9
+ @heading = heading
10
+ @parent_section = nil
11
+ end
12
+
13
+ def to_html
14
+ s = ''
15
+ s += "\t<li><span class=\"fa-li\"><i class=\"fa fa-plus-square-o\"> </i></span>"
16
+ s += "<a href=\"\#" + @heading.anchor_id.to_s + "\">" + @heading.get_section_info + "</a>\n"
17
+ if @sections.length >0
18
+ s += "\t\t<ul class=\"fa-ul\">\n"
19
+ @sections.each do |sub_section|
20
+ s += sub_section.to_html()
21
+ end
22
+ s += "\t\t</ul>\n"
23
+ end
24
+ s += "</li>\n"
25
+ return s
26
+ end
27
+
28
+ end
@@ -0,0 +1,63 @@
1
+ require_relative "doc_section"
2
+
3
+ class Document
4
+
5
+ attr_accessor :root_section
6
+
7
+ @@sections_stack = Array.new
8
+
9
+ def initialize(headings_list)
10
+ @root_section = nil
11
+
12
+ build_sections_tree(headings_list)
13
+ end
14
+
15
+ def build_sections_tree(headings_list)
16
+
17
+ headings_list.each do |h|
18
+
19
+ if @root_section == nil
20
+
21
+ s = DocSection.new(h)
22
+ s.parent_section = nil
23
+ @root_section = s
24
+ @@sections_stack.push s
25
+
26
+ elsif @@sections_stack[-1].heading.level == h.level
27
+
28
+ s = DocSection.new(h)
29
+ @@sections_stack[-2].sections.append(s)
30
+ @@sections_stack[-1] = s
31
+
32
+ elsif h.level > @@sections_stack[-1].heading.level
33
+
34
+ s = DocSection.new(h)
35
+ @@sections_stack[-1].sections.append(s)
36
+ @@sections_stack.push s
37
+
38
+ else
39
+ while h.level < @@sections_stack[-1].heading.level
40
+ @@sections_stack.pop
41
+ end
42
+
43
+ s = DocSection.new(h)
44
+ @@sections_stack[-2].sections.append(s)
45
+ @@sections_stack[-1] = s
46
+ end
47
+ end
48
+ end
49
+
50
+ def section_tree_to_html
51
+ s = ''
52
+ s += "<a href=\"\#" + @root_section.heading.anchor_id.to_s + "\">" + @root_section.heading.text + "</a>\n"
53
+ if @root_section.sections.length >0
54
+ s += "\t<ul class=\"fa-ul\" style=\"margin-top: 2px;\">\n"
55
+ @root_section.sections.each do |sub_section|
56
+ s += sub_section.to_html()
57
+ end
58
+ s += "\t</ul>\n"
59
+ end
60
+
61
+ return s
62
+ end
63
+ end
@@ -3,21 +3,15 @@ class NavigationPane
3
3
 
4
4
  attr_accessor :specifications
5
5
 
6
- def initialize(specifications)
7
- @specifications = specifications
6
+ def initialize(specification)
7
+ @doc = specification
8
8
  end
9
9
 
10
- def to_html
11
- s = "<ul class=\"fa-ul\">\n"
12
- @specifications.each do |spec|
13
- s += "\t<li><span class=\"fa-li\"><i class=\"fa fa-folder-open-o\"> </i></span> #{spec.id}\n"
14
- s += "\t\t<ul class=\"fa-ul\">\n"
15
- s += "\t\t\t<li><span class=\"fa-li\"><i class=\"fa fa-plus-square-o\"> </i></span>\n"
16
- s += "\t\t\t\t<a href=\".\\..\\#{spec.id }\\#{spec.id }.html\">#{spec.title}</a>\n"
17
- s += "\t\t\t</li>\n"
18
- s += "\t\t</ul>\n"
19
- s += "\t</li>\n"
10
+ def to_html
11
+ if @doc.dom
12
+ return @doc.dom.section_tree_to_html()
13
+ else
14
+ return ''
20
15
  end
21
- s += "</ul>\n"
22
16
  end
23
17
  end
@@ -15,6 +15,7 @@ class Project
15
15
  attr_accessor :specifications_dictionary
16
16
  attr_accessor :index
17
17
  attr_accessor :project
18
+ attr_accessor :on_server
18
19
 
19
20
  def initialize(path)
20
21
  @project_root_directory = path
@@ -25,6 +26,7 @@ class Project
25
26
  @specifications_dictionary = Hash.new
26
27
  @index = nil
27
28
  @project = self
29
+ @on_server = false
28
30
 
29
31
  FileUtils.remove_dir(@project_root_directory + "/build", true)
30
32
  end
@@ -225,10 +227,7 @@ class Project
225
227
  @index = Index.new( @project )
226
228
  end
227
229
 
228
- def render_all_specifications(spec_list)
229
-
230
- # create a sidebar first
231
- # nav_pane = NavigationPane.new(@specifications)
230
+ def render_all_specifications(spec_list)
232
231
 
233
232
  pass = @project_root_directory
234
233
 
@@ -247,7 +246,9 @@ class Project
247
246
  FileUtils.copy_entry( img_src_dir, img_dst_dir )
248
247
  end
249
248
 
250
- doc.to_html( nil, "#{pass}/build/specifications/" )
249
+ # create a sidebar first
250
+ nav_pane = NavigationPane.new(doc)
251
+ doc.to_html( nav_pane, "#{pass}/build/specifications/" )
251
252
  end
252
253
  end
253
254
 
@@ -173,14 +173,30 @@
173
173
  #modal_image_id{
174
174
  cursor: default;
175
175
  }
176
+ #closed_nav_pane{
177
+ padding: 0px;
178
+ background: #169;
179
+ border: 0px;
180
+ position: fixed;
181
+ width: 5px;
182
+ height: 100%; /* 100% Full-height */
183
+ visibility: visible;
184
+ cursor: pointer;
185
+ }
186
+ #closed_nav_pane:hover{
187
+ width: 10px;
188
+ }
176
189
  #nav_pane{
177
190
  flex-shrink: 0;
178
- padding: 16px 8px 2px 8px;
191
+ padding: 32px 8px 8px 8px;
179
192
  background: #EEEEEE;
180
- border-left: 1px solid #ddd;
193
+ border: 1px solid #ddd;
181
194
  position: fixed;
182
195
  height: 100%; /* 100% Full-height */
183
196
  visibility: hidden;
197
+ z-index: 1;
198
+ overflow-y: auto;
199
+ cursor: pointer;
184
200
  }
185
201
  @media screen and (min-width: 0px) and (max-width: 1089px) {#nav_pane{width: 22%;}}
186
202
  @media screen and (min-width: 1090px) and (max-width: 1279px) {#nav_pane{width: 240px;}}
@@ -188,12 +204,13 @@
188
204
  @media screen and (min-width: 1600px) and (max-width: 1919px) {#nav_pane{width: 320px;}}
189
205
  @media screen and (min-width: 1920px) and (max-width: 2559px) {#nav_pane{width: 360px;}}
190
206
  @media screen and (min-width: 2560px) {#nav_pane{width: 380px;}}
207
+
191
208
  #top_nav{
192
209
  background-color: #169;
193
210
  overflow: hidden;
194
211
  position: fixed;
195
212
  width: 100%;
196
- z-index: 1;
213
+ z-index: 2;
197
214
  }
198
215
  #top_nav a {
199
216
  float: left;
@@ -286,12 +303,10 @@
286
303
  <script>
287
304
  function openNav() {
288
305
  document.getElementById("nav_pane").style.visibility = "visible";
289
- console.log("Mouse In")
290
306
  }
291
307
 
292
308
  function closeNav() {
293
309
  document.getElementById("nav_pane").style.visibility = "hidden";
294
- console.log("Mouse Out");
295
310
  }
296
311
 
297
312
  window.onload = (event) => {
@@ -303,6 +318,13 @@ window.onload = (event) => {
303
318
  elem.style.width = "640px";
304
319
  }
305
320
  }
321
+ // Scroll a bit to make navigated anchor visible
322
+ //setTimeout(function() {
323
+ // window.scrollBy({
324
+ // top: -40,
325
+ // behavior: "smooth"
326
+ // });
327
+ // }, 200);
306
328
  };
307
329
 
308
330
  function downlink_OnClick(clicked){
@@ -316,6 +338,8 @@ function navigate_to_home(){
316
338
  if (document.title != "Document Index")
317
339
  {
318
340
  window.location.href = "./../../index.html";
341
+ }else{
342
+ window.location.href = "./index.html";
319
343
  }
320
344
  }
321
345
 
@@ -341,11 +365,12 @@ function modal_close_OnClick(clicked){
341
365
  <body>
342
366
  <div id="top_nav">
343
367
  <a href="javascript:void(0)" onclick="navigate_to_home()"><span><i class="fa fa-home" aria-hidden="true"></i></span>&nbsp;Home</a>
344
- <!--a href="javascript:void(0)"> About</a-->
345
368
  <a class="split">{{DOCUMENT_TITLE}}</a>
346
369
  </div>
347
370
  <div id="main">
348
- <div id="nav_pane">
371
+ <div id="closed_nav_pane" href="javascript:void(0)" onclick="openNav()">
372
+ </div>
373
+ <div id="nav_pane" onclick="closeNav()">
349
374
  {{NAV_PANE}}
350
375
  </div>
351
376
  <div id="content" href="javascript:void(0)" onclick="closeNav()">
data/lib/almirah.rb CHANGED
@@ -7,9 +7,9 @@ class CLI < Thor
7
7
  def please(project_folder)
8
8
  a = Almirah.new project_folder
9
9
  if options[:results]
10
- a.results options[:results]
10
+ a.results( options[:results], false )
11
11
  else
12
- a.default
12
+ a.default(false)
13
13
  end
14
14
  end
15
15
 
@@ -18,6 +18,17 @@ class CLI < Thor
18
18
  a = Almirah.new project_folder
19
19
  a.transform "docx"
20
20
  end
21
+
22
+ option :results
23
+ desc "server <project_folder>", "say <project_folder>"
24
+ def server(project_folder)
25
+ a = Almirah.new project_folder
26
+ if options[:results]
27
+ a.results( options[:results], true )
28
+ else
29
+ a.default(true)
30
+ end
31
+ end
21
32
  end
22
33
 
23
34
  class Almirah
@@ -32,7 +43,8 @@ class Almirah
32
43
  File.expand_path './..', File.dirname(__FILE__)
33
44
  end
34
45
 
35
- def results( test_run )
46
+ def results( test_run, on_server )
47
+ @project.on_server = on_server
36
48
  @project.specifications_and_results test_run
37
49
  end
38
50
 
@@ -40,7 +52,8 @@ class Almirah
40
52
  @project.transform file_extension
41
53
  end
42
54
 
43
- def default()
55
+ def default(on_server)
56
+ @project.on_server = on_server
44
57
  @project.specifications_and_protocols
45
58
  end
46
59
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Almirah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksandr Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-18 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The software part of the Almirah framework
14
14
  email: oleksandr.ivanov.development@gmail.com
@@ -40,6 +40,8 @@ files:
40
40
  - lib/almirah/doc_types/protocol.rb
41
41
  - lib/almirah/doc_types/specification.rb
42
42
  - lib/almirah/doc_types/traceability.rb
43
+ - lib/almirah/dom/doc_section.rb
44
+ - lib/almirah/dom/document.rb
43
45
  - lib/almirah/navigation_pane.rb
44
46
  - lib/almirah/project.rb
45
47
  - lib/almirah/templates/page.html