Almirah 0.0.4 → 0.0.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: 0cec091b4437bbdeb9ea83b3a55638fafef7b0d629ba9eb1f069594ec420651c
4
- data.tar.gz: 6de241968325f0d89227f25b854332aa697a8af659e49d91fe5130112fcb31ea
3
+ metadata.gz: b3ac78a8239af2167c9f9e90c66fe8693a51d8909282757710e45b8a0375aba5
4
+ data.tar.gz: 544347bbb28b9e7b288f3c9b37e93c487bc6fd0ac863fcfa7c12fb2cc36d0bc7
5
5
  SHA512:
6
- metadata.gz: 5196218711f21202659e7cf84b5e1f8329ace42a00831d80acc275357e4b2b38cecb1af6842cc3b9b439f8a1d8c78610761756af5b9e565ce77b3f0aa64d24fd
7
- data.tar.gz: a23964002a9c745e7529182b6e2ae684b4ca6a9fd7c963a7eae553c370ac64565edd6be4412dfa27c8ed4517f9273562e14ab4adfebe818cf13bce6102b72736
6
+ metadata.gz: d0170e32eac2109e8559413261c43a230730da8dc4add50342a807e3a054e57c8f5950e83cce4bdaded5b317697da863c82e13bd13cc0250887336d2ed2de77a
7
+ data.tar.gz: 8388732d6f4fd9d4b4e796470d1ce153a635484cf1d9400d48a3eb3f1d2146d70c8be649bac7927832a29990c6745b0dcc9e4ca247c00b6a5e5c5546d68228a0
@@ -3,10 +3,12 @@ require_relative "paragraph"
3
3
  class Heading < Paragraph
4
4
 
5
5
  attr_accessor :level
6
+ attr_accessor :anchor_id
6
7
 
7
8
  def initialize(text, level)
8
9
  @text = text
9
10
  @level = level
11
+ @anchor_id = self.getTextWithoutSpaces()
10
12
  end
11
13
 
12
14
  def to_html
@@ -15,10 +17,9 @@ class Heading < Paragraph
15
17
  s += "</table>"
16
18
  @@htmlTableRenderInProgress = false
17
19
  end
18
- headingLevel = level.to_s
19
- itemTextNoSpaces = self.getTextWithoutSpaces
20
- s += "<a name=\"#{itemTextNoSpaces}\"></a>\n\r"
21
- s += "<h#{headingLevel}> #{@text} <a href=\"\##{itemTextNoSpaces}\" class=\"heading_anchor\">"
20
+ headingLevel = level.to_s
21
+ s += "<a name=\"#{@anchor_id}\"></a>\n\r"
22
+ s += "<h#{headingLevel}> #{@text} <a href=\"\##{@anchor_id}\" class=\"heading_anchor\">"
22
23
  s += "&para;</a></h#{headingLevel}>"
23
24
  return s
24
25
  end
@@ -0,0 +1,27 @@
1
+ require_relative "doc_item"
2
+
3
+ class Image < DocItem
4
+
5
+ attr_accessor :text
6
+ attr_accessor :path
7
+
8
+ def initialize(text, path)
9
+ @text = text
10
+ @path = path
11
+ end
12
+
13
+ def getTextWithoutSpaces
14
+ return @text.split.join('-')
15
+ end
16
+
17
+ def to_html
18
+ s = ''
19
+ if @@htmlTableRenderInProgress
20
+ s += "</table>\n\r"
21
+ @@htmlTableRenderInProgress = false
22
+ end
23
+
24
+ s += "<img src=\"#{@path}\" alt=\"#{@text}\">"
25
+ return s
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "doc_item"
2
+
3
+ class MarkdownList < DocItem
4
+
5
+ attr_accessor :rows
6
+
7
+ def initialize(first_row)
8
+ @rows = Array.new
9
+ @rows.append(first_row)
10
+ end
11
+
12
+ def addRow(row)
13
+ @rows.append(row)
14
+ end
15
+
16
+ def to_html
17
+ s = ''
18
+ if @@htmlTableRenderInProgress
19
+ s += "</table>/n/r"
20
+ @@htmlTableRenderInProgress = false
21
+ end
22
+
23
+ s += "<ul>\n\r"
24
+ @rows.each do |r|
25
+ s += "\t<li>#{r}</li>\n\r"
26
+ end
27
+ s += "</ul>\n\r"
28
+
29
+ return s
30
+ end
31
+ end
@@ -1,8 +1,6 @@
1
1
  require_relative "specification"
2
2
  require_relative "doc_items/doc_item"
3
- require_relative "doc_items/heading"
4
- require_relative "doc_items/paragraph"
5
- require_relative "doc_items/controlled_paragraph"
3
+ require_relative "navigation_pane"
6
4
 
7
5
  class HtmlRender
8
6
 
@@ -10,13 +8,15 @@ class HtmlRender
10
8
  attr_accessor :htmlRows
11
9
  attr_accessor :outputFile
12
10
  attr_accessor :document
11
+ attr_accessor :nav_pane
13
12
 
14
- def initialize(document, template, outputFile)
13
+ def initialize(document, nav_pane, template, outputFile)
15
14
 
16
15
  @template = template
17
16
  @outputFile = outputFile
18
17
  @htmlRows = Array.new
19
18
  @document = document
19
+ @nav_pane = nav_pane
20
20
 
21
21
  self.render()
22
22
  self.saveRenderToFile()
@@ -43,6 +43,8 @@ class HtmlRender
43
43
  self.htmlRows.each do |r|
44
44
  file.puts r
45
45
  end
46
+ elsif s.include?('{{NAV_PANE}}')
47
+ file.puts self.nav_pane.to_html
46
48
  else
47
49
  file.puts s
48
50
  end
@@ -0,0 +1,25 @@
1
+ require_relative "doc_items/doc_item"
2
+ require_relative "specification"
3
+
4
+ class NavigationPane
5
+
6
+ attr_accessor :specifications
7
+
8
+ def initialize(specifications)
9
+ @specifications = specifications
10
+ end
11
+
12
+ def to_html
13
+ s = "<ul class=\"fa-ul\">\n"
14
+ @specifications.each do |spec|
15
+ s += "\t<li><span class=\"fa-li\"><i class=\"fa fa-folder-open-o\"> </i></span> #{spec.key.downcase}\n"
16
+ s += "\t\t<ul class=\"fa-ul\">\n"
17
+ s += "\t\t\t<li><span class=\"fa-li\"><i class=\"fa fa-plus-square-o\"> </i></span>\n"
18
+ s += "\t\t\t\t<a href=\".\\..\\#{spec.key.downcase }\\#{spec.key.downcase }.html\">#{spec.title}</a>\n"
19
+ s += "\t\t\t</li>\n"
20
+ s += "\t\t</ul>\n"
21
+ s += "\t</li>\n"
22
+ end
23
+ s += "</ul>\n"
24
+ end
25
+ end
@@ -0,0 +1,98 @@
1
+ require_relative "doc_items/doc_item"
2
+ require_relative "specification"
3
+ require_relative "html_render"
4
+ require_relative "navigation_pane"
5
+
6
+ class Project
7
+
8
+ attr_accessor :specifications
9
+ attr_accessor :project_root_directory
10
+ attr_accessor :gem_root
11
+ attr_accessor :specifications_dictionary
12
+
13
+ def initialize(path, gem_root)
14
+ @project_root_directory = path
15
+ @specifications = Array.new
16
+ @gem_root = gem_root
17
+ @specifications_dictionary = Hash.new
18
+
19
+ parse_all_documents()
20
+ link_all_specifications()
21
+ render_all_specifications()
22
+
23
+ end
24
+
25
+ def parse_all_documents
26
+
27
+ Dir.glob( "#{@project_root_directory}/**/*.md" ).each do |f|
28
+ puts f
29
+ spec = Specification.new(f)
30
+ @specifications.append(spec)
31
+ end
32
+ end
33
+
34
+ def link_all_specifications
35
+ combList = @specifications.combination(2)
36
+ combList.each do |c|
37
+ self.link_two_specifications(c[0], c[1])
38
+ end
39
+ end
40
+
41
+ def link_two_specifications(doc_A, doc_B)
42
+
43
+ if doc_A.key == doc_B.up_link_key
44
+ top_document = doc_A
45
+ bottom_document = doc_B
46
+ elsif doc_B.key == doc_A.up_link_key
47
+ top_document = doc_B
48
+ bottom_document = doc_A
49
+ else
50
+ puts "No Links"
51
+ return # no links
52
+ end
53
+
54
+ bottom_document.controlledParagraphs.each do |item|
55
+
56
+ if top_document.dictionary.has_key?(item.up_link.to_s)
57
+
58
+ topItem = top_document.dictionary[item.up_link.to_s]
59
+
60
+ unless topItem.down_links
61
+ topItem.down_links = Array.new
62
+ end
63
+ topItem.down_links.append(item)
64
+
65
+ #if tmp = /^([a-zA-Z]+)[-]\d+/.match(item.id)
66
+ # top_document.downlinkKey = tmp[1].upcase
67
+ #end
68
+ end
69
+ end
70
+ end
71
+
72
+ def render_all_specifications
73
+
74
+ # create a sidebar first
75
+ nav_pane = NavigationPane.new(@specifications)
76
+
77
+ pass = @project_root_directory
78
+
79
+ FileUtils.remove_dir(pass + "/build", true)
80
+ FileUtils.mkdir_p(pass + "/build/specifications")
81
+
82
+ @specifications.each do |spec|
83
+
84
+ img_src_dir = pass + "/specifications/" + spec.key.downcase + "/img"
85
+ img_dst_dir = pass + "/build/specifications/" + spec.key.downcase + "/img"
86
+
87
+ FileUtils.mkdir_p(img_dst_dir)
88
+
89
+ if File.directory?(img_src_dir)
90
+ FileUtils.copy_entry( img_src_dir, img_dst_dir )
91
+ end
92
+
93
+ HtmlRender.new( spec, nav_pane,
94
+ @gem_root + "/lib/almirah/templates/page.html",
95
+ "#{pass}/build/specifications/#{spec.key.downcase}/#{spec.key.downcase}.html" )
96
+ end
97
+ end
98
+ end
@@ -4,26 +4,32 @@ require_relative "doc_items/paragraph"
4
4
  require_relative "doc_items/blockquote"
5
5
  require_relative "doc_items/controlled_paragraph"
6
6
  require_relative "doc_items/markdown_table"
7
+ require_relative "doc_items/image"
8
+ require_relative "doc_items/markdown_list"
7
9
 
8
10
  class Specification
9
11
 
10
12
  attr_accessor :path
11
13
  attr_accessor :docItems
14
+ attr_accessor :headings
12
15
  attr_accessor :title
13
16
  attr_accessor :key
14
17
  attr_accessor :up_link_key
15
18
  attr_accessor :dictionary
16
19
  attr_accessor :controlledParagraphs
17
20
  attr_accessor :tempMdTable
21
+ attr_accessor :tempMdList
18
22
 
19
23
  def initialize(fele_path)
20
24
 
21
25
  @path = fele_path
22
26
  @title = ""
23
27
  @docItems = Array.new
28
+ @headings = Array.new
24
29
  @controlledParagraphs = Array.new
25
30
  @dictionary = Hash.new
26
31
  @tempMdTable = nil
32
+ @tempMdList = nil
27
33
 
28
34
  @key = File.basename(fele_path, File.extname(fele_path)).upcase
29
35
  @up_link_key = ""
@@ -44,14 +50,19 @@ class Specification
44
50
  if @tempMdTable
45
51
  self.docItems.append(@tempMdTable)
46
52
  @tempMdTable = nil
53
+ end
54
+ if @tempMdList
55
+ self.docItems.append(@tempMdList)
56
+ @tempMdList = nil
47
57
  end
48
58
 
49
59
  level = res[1].length
50
60
  value = res[2]
51
61
  item = Heading.new(value, level)
52
62
  self.docItems.append(item)
53
-
54
- if level == 1
63
+ self.headings.append(item)
64
+
65
+ if level == 1 && self.title == ""
55
66
  self.title = value
56
67
  end
57
68
 
@@ -60,6 +71,10 @@ class Specification
60
71
  if @tempMdTable
61
72
  self.docItems.append(@tempMdTable)
62
73
  @tempMdTable = nil
74
+ end
75
+ if @tempMdList
76
+ self.docItems.append(@tempMdList)
77
+ @tempMdList = nil
63
78
  end
64
79
 
65
80
  id = res[1]
@@ -83,8 +98,47 @@ class Specification
83
98
  self.dictionary[ id.to_s ] = item #for fast search
84
99
  self.controlledParagraphs.append(item) #for fast search
85
100
 
101
+ elsif res = /^[!]\[(.*)\]\((.*)\)/.match(s) # Image
102
+
103
+ if @tempMdTable
104
+ self.docItems.append(@tempMdTable)
105
+ @tempMdTable = nil
106
+ end
107
+ if @tempMdList
108
+ self.docItems.append(@tempMdList)
109
+ @tempMdList = nil
110
+ end
111
+
112
+ img_text = res[1]
113
+ img_path = res[2]
114
+
115
+ item = Image.new( img_text, img_path )
116
+
117
+ self.docItems.append(item)
118
+
119
+ elsif res = /^(\*\s?)+(.*)/.match(s) #check if bullet list
120
+
121
+ if @tempMdTable
122
+ self.docItems.append(@tempMdTable)
123
+ @tempMdTable = nil
124
+ end
125
+
126
+ row = res[2]
127
+
128
+ if @tempMdList
129
+ @tempMdList.addRow(row)
130
+ else
131
+ item = MarkdownList.new(row)
132
+ @tempMdList = item
133
+ end
134
+
86
135
  elsif s[0] == '|' #check if table
87
136
 
137
+ if @tempMdList
138
+ self.docItems.append(@tempMdList)
139
+ @tempMdList = nil
140
+ end
141
+
88
142
  if res = /^[|](-{3,})[|]/.match(s) #check if it is a separator first
89
143
 
90
144
  if @tempMdTable
@@ -112,6 +166,10 @@ class Specification
112
166
  if @tempMdTable
113
167
  self.docItems.append(@tempMdTable)
114
168
  @tempMdTable = nil
169
+ end
170
+ if @tempMdList
171
+ self.docItems.append(@tempMdList)
172
+ @tempMdList = nil
115
173
  end
116
174
 
117
175
  item = Blockquote.new(res[1])
@@ -121,7 +179,12 @@ class Specification
121
179
  if @tempMdTable
122
180
  self.docItems.append(@tempMdTable)
123
181
  @tempMdTable = nil
124
- end
182
+ end
183
+ if @tempMdList
184
+ self.docItems.append(@tempMdList)
185
+ @tempMdList = nil
186
+ end
187
+
125
188
  item = Paragraph.new(s)
126
189
  self.docItems.append(item)
127
190
  end
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <!-- CSS -->
6
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
6
7
  <style>
7
8
  body {
8
9
  font-family: Verdana, sans-serif;
@@ -15,12 +16,12 @@
15
16
  #main {
16
17
  flex-grow: 2;
17
18
  display: flex;
18
- flex-direction: row-reverse;
19
+ flex-direction: row;
19
20
  }
20
21
  #content {
21
22
  flex-grow: 1;
22
23
  background-color: #fff;
23
- margin: 0px;
24
+ margin-top: 30px;
24
25
  padding: 10px 16px 10px 16px;
25
26
  overflow-x: auto;
26
27
  }
@@ -135,11 +136,68 @@
135
136
  margin-top: 4px;
136
137
  margin-bottom: 4px;
137
138
  }
139
+ #nav_pane{
140
+ flex-shrink: 0;
141
+ padding: 16px 8px 2px 8px;
142
+ background: #EEEEEE;
143
+ border-left: 1px solid #ddd;
144
+ position: fixed;
145
+ height: 100%; /* 100% Full-height */
146
+ visibility: hidden;
147
+ }
148
+ @media screen and (min-width: 0px) and (max-width: 1089px) {#nav_pane{width: 22%;}}
149
+ @media screen and (min-width: 1090px) and (max-width: 1279px) {#nav_pane{width: 240px;}}
150
+ @media screen and (min-width: 1280px) and (max-width: 1599px) {#nav_pane{width: 280px;}}
151
+ @media screen and (min-width: 1600px) and (max-width: 1919px) {#nav_pane{width: 320px;}}
152
+ @media screen and (min-width: 1920px) and (max-width: 2559px) {#nav_pane{width: 360px;}}
153
+ @media screen and (min-width: 2560px) {#nav_pane{width: 380px;}}
154
+ #top_nav{
155
+ background-color: #169;
156
+ overflow: hidden;
157
+ position: fixed;
158
+ width: 100%;
159
+ }
160
+ #top_nav a {
161
+ float: left;
162
+ color: white;
163
+ text-align: center;
164
+ padding: 4px 6px;
165
+ text-decoration: none;
166
+ font-size: 1.5em;
167
+ font-family: "Trebuchet MS", Verdana, sans-serif;
168
+ }
169
+ #top_nav a:hover {
170
+ background-color: black;
171
+ color: white;
172
+ }
173
+ #top_nav a.active {
174
+ background-color: #169;
175
+ color: white;
176
+ }
177
+
138
178
  </style>
179
+ <script>
180
+ function openNav() {
181
+ document.getElementById("nav_pane").style.visibility = "visible";
182
+ console.log("Mouse In")
183
+ }
184
+
185
+ function closeNav() {
186
+ document.getElementById("nav_pane").style.visibility = "hidden";
187
+ console.log("Mouse Out");
188
+ }
189
+ </script>
139
190
  </head>
140
191
  <body>
192
+ <div id="top_nav">
193
+ <a href="javascript:void(0)" onclick="openNav()"><span><i class="fa fa-bars" aria-hidden="true"></i></span>&nbsp;Navigation</a>
194
+ <a href="javascript:void(0)"> About</a>
195
+ </div>
141
196
  <div id="main">
142
- <div id="content">
197
+ <div id="nav_pane">
198
+ {{NAV_PANE}}
199
+ </div>
200
+ <div id="content" href="javascript:void(0)" onclick="closeNav()">
143
201
  {{CONTENT}}
144
202
  </div>
145
203
  </div>
data/lib/almirah.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require "thor"
2
- require_relative "almirah/specification"
3
- require_relative "almirah/linker"
4
- require_relative "almirah/html_render"
2
+ require_relative "almirah/project"
5
3
 
6
4
  class CLI < Thor
7
5
  desc "please <pass>", "say <pass>"
@@ -17,30 +15,9 @@ class Almirah
17
15
  end
18
16
 
19
17
  def start(pass)
20
- # Documents
21
- documentList = Array.new
22
18
 
23
- # Parse
24
- Dir.glob( "#{pass}/**/*.md" ).each do |f|
25
- puts f
26
- spec = Specification.new(f)
27
- documentList.append(spec)
28
- end
29
-
30
- # Link
31
- linker = Linker.new
32
- linker.link(documentList[0], documentList[1])
19
+ prj = Project.new pass, getGemRoot
33
20
 
34
- # Render
35
- FileUtils.remove_dir(pass + "/build", true)
36
- FileUtils.mkdir_p(pass + "/build/specifications")
37
-
38
- documentList.each do |spec|
39
- FileUtils.mkdir_p(pass + "/build/specifications/" + spec.key.downcase)
40
- HtmlRender.new( spec,
41
- getGemRoot() + "/lib/almirah/templates/page.html",
42
- "#{pass}/build/specifications/#{spec.key.downcase}/#{spec.key.downcase}.html" )
43
- end
44
21
  end
45
22
 
46
23
  end
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.0.4
4
+ version: 0.0.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-01-27 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The software part of the Almirah system
14
14
  email: oleksandr.ivanov.development@gmail.com
@@ -23,13 +23,16 @@ files:
23
23
  - lib/almirah/doc_items/controlled_paragraph.rb
24
24
  - lib/almirah/doc_items/doc_item.rb
25
25
  - lib/almirah/doc_items/heading.rb
26
+ - lib/almirah/doc_items/image.rb
27
+ - lib/almirah/doc_items/markdown_list.rb
26
28
  - lib/almirah/doc_items/markdown_table.rb
27
29
  - lib/almirah/doc_items/paragraph.rb
28
30
  - lib/almirah/html_render.rb
29
- - lib/almirah/linker.rb
31
+ - lib/almirah/navigation_pane.rb
32
+ - lib/almirah/project.rb
30
33
  - lib/almirah/specification.rb
31
34
  - lib/almirah/templates/page.html
32
- homepage: https://rubygems.org/gems/almirah
35
+ homepage: http://almirah.site
33
36
  licenses:
34
37
  - MIT
35
38
  metadata: {}
@@ -1,42 +0,0 @@
1
- require_relative "doc_items/doc_item"
2
- require_relative "specification"
3
-
4
- class Linker
5
-
6
- attr_accessor :field
7
-
8
- def initialize()
9
- @field = "field"
10
- end
11
-
12
- def link(doc_A, doc_B)
13
-
14
- if doc_A.key == doc_B.up_link_key
15
- top_document = doc_A
16
- bottom_document = doc_B
17
- elsif doc_B.key == doc_A.up_link_key
18
- top_document = doc_B
19
- bottom_document = doc_A
20
- else
21
- puts "No Links"
22
- return # no links
23
- end
24
-
25
- bottom_document.controlledParagraphs.each do |item|
26
-
27
- if top_document.dictionary.has_key?(item.up_link.to_s)
28
-
29
- topItem = top_document.dictionary[item.up_link.to_s]
30
-
31
- unless topItem.down_links
32
- topItem.down_links = Array.new
33
- end
34
- topItem.down_links.append(item)
35
-
36
- #if tmp = /^([a-zA-Z]+)[-]\d+/.match(item.id)
37
- # top_document.downlinkKey = tmp[1].upcase
38
- #end
39
- end
40
- end
41
- end
42
- end