Almirah 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fb9468eb0f2bd41ef114392ac41e3954da577bcbf008b0e1302d0436cd1222c
4
- data.tar.gz: fe5652461a3f368c77df81bbffafa4c127168bd3eb3af4c2f0c181c50e23a59e
3
+ metadata.gz: a4e770388ae634e216ef325d7f82a5d32d44bb5405dbea4e32783e3f0d2eea91
4
+ data.tar.gz: 20871334c2ba2179e361abd1319634281bde45ba38032ec2fd3dabdea98f6e3a
5
5
  SHA512:
6
- metadata.gz: 5b8ecdb79e738a58f1a8992735adbb7fe07f883f587f2d4b8314083bfdc2d750b31217738886c8c4abbba02b672e819d01257dd0fb6c70febe0bfe15e6912760
7
- data.tar.gz: bca5f63cab9daa24e21dbaaf1af7e3f9fa0297b60a9ea1a31bf5ebc38f5306290810ade574df8bd3979cc4df21d32bdfe1a4478813f3a016e7d4a51995f4e827
6
+ metadata.gz: ad3b925c13c5a6794a82eabb3cfc81894c3f5711e5250cb0cb1dbaee0e79ff56e0e571e1dbcedb969c8384b3db82a021c082017d0cba001cb4ea1a2c314d21cd
7
+ data.tar.gz: 38532ef2204233611d5330e5825c0ccc0234043eec49f54f81e768d2caecdbc20df78999a8dfed3b074b924fe7ae6c2bcc6d3658771863f7663ab75b8c5167d4
@@ -11,11 +11,11 @@ class Blockquote < DocItem
11
11
  def to_html
12
12
  s = ''
13
13
  if @@htmlTableRenderInProgress
14
- s += "</table>"
14
+ s += "</table>\n\r"
15
15
  @@htmlTableRenderInProgress = false
16
16
  end
17
17
 
18
- s += "<p>Note: #{@text}\n\r"
18
+ s += "<div class=\"blockquote\"><p>#{@text}</div>\n\r"
19
19
  return s
20
20
  end
21
21
  end
@@ -16,35 +16,35 @@ class ControlledParagraph < Paragraph
16
16
  def to_html
17
17
  s = ''
18
18
  unless @@htmlTableRenderInProgress
19
- s += "<table>\n\r"
19
+ s += "<table class=\"controlled\">\n\r"
20
20
  s += "\t<thead> <th>#</th> <th>Text</th> <th>UL</th> <th>DL</th> <th>COV</th> </thead>\n\r"
21
21
  @@htmlTableRenderInProgress = true
22
22
  end
23
23
  s += "\t<tr>\n\r"
24
- s += "\t\t<td> <a name=\"#{@id}\"></a>#{@id} </td>\n\r"
25
- s += "\t\t<td>#{@text}</td>\n\r"
24
+ s += "\t\t<td class=\"item_id\"> <a name=\"#{@id}\"></a>#{@id} </td>\n\r"
25
+ s += "\t\t<td class=\"item_text\">#{@text}</td>\n\r"
26
26
 
27
27
  if @up_link
28
28
  if tmp = /^([a-zA-Z]+)[-]\d+/.match(@up_link)
29
29
  up_link_doc_name = tmp[1].downcase
30
30
  end
31
- s += "\t\t<td><a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html\" class=\"external\">#{@up_link}</a></td>\n\r"
31
+ s += "\t\t<td class=\"item_id\"><a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html\" class=\"external\">#{@up_link}</a></td>\n\r"
32
32
  else
33
- s += "\t\t<td></td>\n\r"
33
+ s += "\t\t<td class=\"item_id\"></td>\n\r"
34
34
  end
35
35
 
36
36
  if @down_links
37
37
  if tmp = /^([a-zA-Z]+)[-]\d+/.match(@down_links[0].id) # guessing that all the links refer to one document
38
38
  down_link_doc_name = tmp[1].downcase
39
39
  end
40
- s += "\t\t<td><a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html\" class=\"external\">#{@down_links.length}</a></td>\n\r"
40
+ s += "\t\t<td class=\"item_id\"><a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html\" class=\"external\">#{@down_links.length}</a></td>\n\r"
41
41
  else
42
- s += "\t\t<td></td>\n\r"
42
+ s += "\t\t<td class=\"item_id\"></td>\n\r"
43
43
  end
44
44
 
45
45
  #s += "\t\t<td></td>\n\r" # UL
46
46
  #s += "\t\t<td></td>\n\r" # DL
47
- s += "\t\t<td></td>\n\r" # COV
47
+ s += "\t\t<td class=\"item_id\"></td>\n\r" # COV
48
48
  s += "\t</tr>\n\r"
49
49
  return s
50
50
  end
@@ -18,7 +18,7 @@ class Heading < Paragraph
18
18
  headingLevel = level.to_s
19
19
  itemTextNoSpaces = self.getTextWithoutSpaces
20
20
  s += "<a name=\"#{itemTextNoSpaces}\"></a>\n\r"
21
- s += "<h#{headingLevel}> #{@text} <a href=\"\##{itemTextNoSpaces}\">"
21
+ s += "<h#{headingLevel}> #{@text} <a href=\"\##{itemTextNoSpaces}\" class=\"heading_anchor\">"
22
22
  s += "&para;</a></h#{headingLevel}>"
23
23
  return s
24
24
  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
@@ -22,7 +22,7 @@ class MarkdownTable < DocItem
22
22
  @@htmlTableRenderInProgress = false
23
23
  end
24
24
 
25
- s += "<table>\n\r"
25
+ s += "<table class=\"markdown_table\">\n\r"
26
26
  s += "\t<thead>"
27
27
 
28
28
  @column_names.each do |h|
@@ -1,8 +1,5 @@
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"
6
3
 
7
4
  class HtmlRender
8
5
 
@@ -4,6 +4,8 @@ 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
 
@@ -15,6 +17,7 @@ class Specification
15
17
  attr_accessor :dictionary
16
18
  attr_accessor :controlledParagraphs
17
19
  attr_accessor :tempMdTable
20
+ attr_accessor :tempMdList
18
21
 
19
22
  def initialize(fele_path)
20
23
 
@@ -24,6 +27,7 @@ class Specification
24
27
  @controlledParagraphs = Array.new
25
28
  @dictionary = Hash.new
26
29
  @tempMdTable = nil
30
+ @tempMdList = nil
27
31
 
28
32
  @key = File.basename(fele_path, File.extname(fele_path)).upcase
29
33
  @up_link_key = ""
@@ -44,6 +48,10 @@ class Specification
44
48
  if @tempMdTable
45
49
  self.docItems.append(@tempMdTable)
46
50
  @tempMdTable = nil
51
+ end
52
+ if @tempMdList
53
+ self.docItems.append(@tempMdList)
54
+ @tempMdList = nil
47
55
  end
48
56
 
49
57
  level = res[1].length
@@ -60,11 +68,14 @@ class Specification
60
68
  if @tempMdTable
61
69
  self.docItems.append(@tempMdTable)
62
70
  @tempMdTable = nil
71
+ end
72
+ if @tempMdList
73
+ self.docItems.append(@tempMdList)
74
+ @tempMdList = nil
63
75
  end
64
76
 
65
77
  id = res[1]
66
78
  text = res[2]
67
- item = ControlledParagraph.new( text, id )
68
79
 
69
80
  #check if it contains the uplink
70
81
  if tmp = /(.*)\s+>\[(\S*)\]$/.match(text)
@@ -72,19 +83,59 @@ class Specification
72
83
  text = tmp[1]
73
84
  up_link = tmp[2]
74
85
 
75
- item.up_link = up_link
76
-
77
86
  if tmp = /^([a-zA-Z]+)[-]\d+/.match(up_link)
78
87
  self.up_link_key = tmp[1]
79
88
  end
80
89
  end
81
90
 
91
+ item = ControlledParagraph.new( text, id )
92
+ item.up_link = up_link
93
+
82
94
  self.docItems.append(item)
83
95
  self.dictionary[ id.to_s ] = item #for fast search
84
96
  self.controlledParagraphs.append(item) #for fast search
85
97
 
98
+ elsif res = /^[!]\[(.*)\]\((.*)\)/.match(s) # Image
99
+
100
+ if @tempMdTable
101
+ self.docItems.append(@tempMdTable)
102
+ @tempMdTable = nil
103
+ end
104
+ if @tempMdList
105
+ self.docItems.append(@tempMdList)
106
+ @tempMdList = nil
107
+ end
108
+
109
+ img_text = res[1]
110
+ img_path = res[2]
111
+
112
+ item = Image.new( img_text, img_path )
113
+
114
+ self.docItems.append(item)
115
+
116
+ elsif res = /^(\*\s?)+(.*)/.match(s) #check if bullet list
117
+
118
+ if @tempMdTable
119
+ self.docItems.append(@tempMdTable)
120
+ @tempMdTable = nil
121
+ end
122
+
123
+ row = res[2]
124
+
125
+ if @tempMdList
126
+ @tempMdList.addRow(row)
127
+ else
128
+ item = MarkdownList.new(row)
129
+ @tempMdList = item
130
+ end
131
+
86
132
  elsif s[0] == '|' #check if table
87
133
 
134
+ if @tempMdList
135
+ self.docItems.append(@tempMdList)
136
+ @tempMdList = nil
137
+ end
138
+
88
139
  if res = /^[|](-{3,})[|]/.match(s) #check if it is a separator first
89
140
 
90
141
  if @tempMdTable
@@ -112,6 +163,10 @@ class Specification
112
163
  if @tempMdTable
113
164
  self.docItems.append(@tempMdTable)
114
165
  @tempMdTable = nil
166
+ end
167
+ if @tempMdList
168
+ self.docItems.append(@tempMdList)
169
+ @tempMdList = nil
115
170
  end
116
171
 
117
172
  item = Blockquote.new(res[1])
@@ -121,7 +176,12 @@ class Specification
121
176
  if @tempMdTable
122
177
  self.docItems.append(@tempMdTable)
123
178
  @tempMdTable = nil
124
- end
179
+ end
180
+ if @tempMdList
181
+ self.docItems.append(@tempMdList)
182
+ @tempMdList = nil
183
+ end
184
+
125
185
  item = Paragraph.new(s)
126
186
  self.docItems.append(item)
127
187
  end
@@ -2,8 +2,146 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
+ <!-- CSS -->
6
+ <style>
7
+ body {
8
+ font-family: Verdana, sans-serif;
9
+ font-size: 12px;
10
+ color: #333;
11
+ margin: 0;
12
+ padding: 0;
13
+ min-width: 900px;
14
+ }
15
+ #main {
16
+ flex-grow: 2;
17
+ display: flex;
18
+ flex-direction: row-reverse;
19
+ }
20
+ #content {
21
+ flex-grow: 1;
22
+ background-color: #fff;
23
+ margin: 0px;
24
+ padding: 10px 16px 10px 16px;
25
+ overflow-x: auto;
26
+ }
27
+ #content h1, h2, h3, h4, h5, h6 {
28
+ color: #555;
29
+ font-family: "Trebuchet MS", Verdana, sans-serif;
30
+ padding: 2px 10px 1px 0px;
31
+ margin: 0 0 10px 0;
32
+ }
33
+ h1 {
34
+ font-size: 2em;
35
+ }
36
+ h2 {
37
+ font-size: 1.8em;
38
+ }
39
+ h3 {
40
+ font-size: 1.5em;
41
+ }
42
+ h4 {
43
+ font-size: 1.2em;
44
+ border: none;
45
+ font-weight: bold;
46
+ }
47
+ h5 {
48
+ font-size: 1em;
49
+ }
50
+ h6 {
51
+ font-size: 1em; color: #8e8e8e;
52
+ }
53
+ a.heading_anchor {
54
+ display: none;
55
+ margin-left: 6px;
56
+ text-decoration: none;
57
+ }
58
+ table.markdown_table{
59
+ border: 1px solid #bbb;
60
+ border-collapse: collapse;
61
+ padding: 4px;
62
+ margin-bottom: 4px;
63
+ overflow: hidden;
64
+ }
65
+ table.markdown_table th{
66
+ border: 1px solid #bbb;
67
+ padding: 4px;
68
+ display: table-cell;
69
+ vertical-align: inherit;
70
+ background-color:#EEEEEE;
71
+ }
72
+ table.markdown_table td{
73
+ border: 1px solid #bbb;
74
+ padding: 4px;
75
+ display: table-cell;
76
+ vertical-align: inherit;
77
+ }
78
+ table.controlled{
79
+ border: 1px solid #e4e4e4;
80
+ border-collapse: collapse;
81
+ width: 100%;
82
+ margin-bottom: 4px;
83
+ border-spacing: 0px;
84
+ border-radius: 3px;
85
+ overflow: hidden;
86
+ }
87
+ table.controlled th {
88
+ background-color:#e1f1fa;
89
+ padding: 4px;
90
+ white-space:nowrap;
91
+ font-weight:bold;
92
+ border: 1px solid #bbb;
93
+ }
94
+ table.controlled td {
95
+ text-align:center;
96
+ vertical-align:middle;
97
+ padding-right:10px;
98
+ border: 1px solid #bbb;
99
+ }
100
+ table.controlled tr:first-child th {
101
+ border-top: 0;
102
+ }
103
+ table.controlled tr:last-child td {
104
+ border-bottom: 0;
105
+ }
106
+ table.controlled tr td:first-child,
107
+ table.controlled tr th:first-child {
108
+ border-left: 0;
109
+ }
110
+ table.controlled tr td:last-child,
111
+ table.controlled tr th:last-child {
112
+ border-right: 0;
113
+ }
114
+ table.controlled td.item_id {
115
+ width: 3%;
116
+ text-align: center;
117
+ }
118
+ table.controlled td.item_text{
119
+ text-align: left;
120
+ }
121
+ table.controlled:not(.odd-even) tbody tr:nth-child(odd) { background-color:#f6f7f8; }
122
+ table.controlled:not(.odd-even) tbody tr:nth-child(even) { background-color: #fff; }
123
+ table.controlled:not(.odd-even) tbody tr:nth-child(odd):hover,
124
+ table.controlled:not(.odd-even) tbody tr:nth-child(even):hover { background-color:#ffffdd; }
125
+ a, a:link, a:visited {
126
+ color: #169;
127
+ text-decoration: none;
128
+ }
129
+ div.blockquote {
130
+ display: block;
131
+ background:#f9f9fb;
132
+ border-left: 3px double #bbb;
133
+ font-style: italic;
134
+ padding: 4px 1em 4px 4px;
135
+ margin-top: 4px;
136
+ margin-bottom: 4px;
137
+ }
138
+ </style>
5
139
  </head>
6
140
  <body>
7
- {{CONTENT}}
141
+ <div id="main">
142
+ <div id="content">
143
+ {{CONTENT}}
144
+ </div>
145
+ </div>
8
146
  </body>
9
147
 
data/lib/almirah.rb CHANGED
@@ -29,14 +29,26 @@ class Almirah
29
29
 
30
30
  # Link
31
31
  linker = Linker.new
32
- linker.link(documentList[0], documentList[1])
32
+ combList = documentList.combination(2)
33
+ combList.each do |c|
34
+ linker.link(c[0], c[1])
35
+ end
33
36
 
34
37
  # Render
35
38
  FileUtils.remove_dir(pass + "/build", true)
36
39
  FileUtils.mkdir_p(pass + "/build/specifications")
37
40
 
38
41
  documentList.each do |spec|
39
- FileUtils.mkdir_p(pass + "/build/specifications/" + spec.key.downcase)
42
+
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
+
40
52
  HtmlRender.new( spec,
41
53
  getGemRoot() + "/lib/almirah/templates/page.html",
42
54
  "#{pass}/build/specifications/#{spec.key.downcase}/#{spec.key.downcase}.html" )
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.3
4
+ version: 0.0.5
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-24 00:00:00.000000000 Z
11
+ date: 2024-01-29 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,15 @@ 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
31
  - lib/almirah/linker.rb
30
32
  - lib/almirah/specification.rb
31
33
  - lib/almirah/templates/page.html
32
- homepage: https://rubygems.org/gems/almirah
34
+ homepage: http://almirah.site
33
35
  licenses:
34
36
  - MIT
35
37
  metadata: {}