Almirah 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/almirah/doc_items/heading.rb +5 -4
- data/lib/almirah/html_render.rb +6 -1
- data/lib/almirah/navigation_pane.rb +25 -0
- data/lib/almirah/project.rb +98 -0
- data/lib/almirah/specification.rb +5 -2
- data/lib/almirah/templates/page.html +61 -3
- data/lib/almirah.rb +2 -37
- metadata +4 -3
- data/lib/almirah/linker.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3ac78a8239af2167c9f9e90c66fe8693a51d8909282757710e45b8a0375aba5
|
4
|
+
data.tar.gz: 544347bbb28b9e7b288f3c9b37e93c487bc6fd0ac863fcfa7c12fb2cc36d0bc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
20
|
-
s += "<a
|
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 += "¶</a></h#{headingLevel}>"
|
23
24
|
return s
|
24
25
|
end
|
data/lib/almirah/html_render.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "specification"
|
2
2
|
require_relative "doc_items/doc_item"
|
3
|
+
require_relative "navigation_pane"
|
3
4
|
|
4
5
|
class HtmlRender
|
5
6
|
|
@@ -7,13 +8,15 @@ class HtmlRender
|
|
7
8
|
attr_accessor :htmlRows
|
8
9
|
attr_accessor :outputFile
|
9
10
|
attr_accessor :document
|
11
|
+
attr_accessor :nav_pane
|
10
12
|
|
11
|
-
def initialize(document, template, outputFile)
|
13
|
+
def initialize(document, nav_pane, template, outputFile)
|
12
14
|
|
13
15
|
@template = template
|
14
16
|
@outputFile = outputFile
|
15
17
|
@htmlRows = Array.new
|
16
18
|
@document = document
|
19
|
+
@nav_pane = nav_pane
|
17
20
|
|
18
21
|
self.render()
|
19
22
|
self.saveRenderToFile()
|
@@ -40,6 +43,8 @@ class HtmlRender
|
|
40
43
|
self.htmlRows.each do |r|
|
41
44
|
file.puts r
|
42
45
|
end
|
46
|
+
elsif s.include?('{{NAV_PANE}}')
|
47
|
+
file.puts self.nav_pane.to_html
|
43
48
|
else
|
44
49
|
file.puts s
|
45
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
|
@@ -11,6 +11,7 @@ class Specification
|
|
11
11
|
|
12
12
|
attr_accessor :path
|
13
13
|
attr_accessor :docItems
|
14
|
+
attr_accessor :headings
|
14
15
|
attr_accessor :title
|
15
16
|
attr_accessor :key
|
16
17
|
attr_accessor :up_link_key
|
@@ -24,6 +25,7 @@ class Specification
|
|
24
25
|
@path = fele_path
|
25
26
|
@title = ""
|
26
27
|
@docItems = Array.new
|
28
|
+
@headings = Array.new
|
27
29
|
@controlledParagraphs = Array.new
|
28
30
|
@dictionary = Hash.new
|
29
31
|
@tempMdTable = nil
|
@@ -58,8 +60,9 @@ class Specification
|
|
58
60
|
value = res[2]
|
59
61
|
item = Heading.new(value, level)
|
60
62
|
self.docItems.append(item)
|
61
|
-
|
62
|
-
|
63
|
+
self.headings.append(item)
|
64
|
+
|
65
|
+
if level == 1 && self.title == ""
|
63
66
|
self.title = value
|
64
67
|
end
|
65
68
|
|
@@ -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
|
19
|
+
flex-direction: row;
|
19
20
|
}
|
20
21
|
#content {
|
21
22
|
flex-grow: 1;
|
22
23
|
background-color: #fff;
|
23
|
-
margin:
|
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> Navigation</a>
|
194
|
+
<a href="javascript:void(0)"> About</a>
|
195
|
+
</div>
|
141
196
|
<div id="main">
|
142
|
-
<div id="
|
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/
|
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,42 +15,9 @@ class Almirah
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def start(pass)
|
20
|
-
# Documents
|
21
|
-
documentList = Array.new
|
22
18
|
|
23
|
-
|
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
|
-
combList = documentList.combination(2)
|
33
|
-
combList.each do |c|
|
34
|
-
linker.link(c[0], c[1])
|
35
|
-
end
|
36
|
-
|
37
|
-
# Render
|
38
|
-
FileUtils.remove_dir(pass + "/build", true)
|
39
|
-
FileUtils.mkdir_p(pass + "/build/specifications")
|
40
|
-
|
41
|
-
documentList.each do |spec|
|
19
|
+
prj = Project.new pass, getGemRoot
|
42
20
|
|
43
|
-
img_src_dir = pass + "/specifications/" + spec.key.downcase + "/img"
|
44
|
-
img_dst_dir = pass + "/build/specifications/" + spec.key.downcase + "/img"
|
45
|
-
|
46
|
-
FileUtils.mkdir_p(img_dst_dir)
|
47
|
-
|
48
|
-
if File.directory?(img_src_dir)
|
49
|
-
FileUtils.copy_entry( img_src_dir, img_dst_dir )
|
50
|
-
end
|
51
|
-
|
52
|
-
HtmlRender.new( spec,
|
53
|
-
getGemRoot() + "/lib/almirah/templates/page.html",
|
54
|
-
"#{pass}/build/specifications/#{spec.key.downcase}/#{spec.key.downcase}.html" )
|
55
|
-
end
|
56
21
|
end
|
57
22
|
|
58
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
|
+
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-
|
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
|
@@ -28,7 +28,8 @@ files:
|
|
28
28
|
- lib/almirah/doc_items/markdown_table.rb
|
29
29
|
- lib/almirah/doc_items/paragraph.rb
|
30
30
|
- lib/almirah/html_render.rb
|
31
|
-
- lib/almirah/
|
31
|
+
- lib/almirah/navigation_pane.rb
|
32
|
+
- lib/almirah/project.rb
|
32
33
|
- lib/almirah/specification.rb
|
33
34
|
- lib/almirah/templates/page.html
|
34
35
|
homepage: http://almirah.site
|
data/lib/almirah/linker.rb
DELETED
@@ -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
|