Almirah 0.1.9 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,368 +5,15 @@
5
5
  <title>{{DOCUMENT_TITLE}}</title>
6
6
  <!-- CSS -->
7
7
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
8
- <style>
9
- body {
10
- font-family: Verdana, sans-serif;
11
- font-size: 12px;
12
- color: #333;
13
- margin: 0;
14
- padding: 0;
15
- min-width: 900px;
16
- }
17
- #main {
18
- flex-grow: 2;
19
- display: flex;
20
- flex-direction: row;
21
- }
22
- #content {
23
- flex-grow: 1;
24
- background-color: #fff;
25
- margin-top: 30px;
26
- padding: 10px 16px 10px 16px;
27
- overflow-x: auto;
28
- }
29
- #content h1, h2, h3, h4, h5, h6 {
30
- color: #555;
31
- font-family: "Trebuchet MS", Verdana, sans-serif;
32
- padding: 2px 10px 1px 0px;
33
- margin: 0 0 10px 0;
34
- }
35
- h1 {
36
- font-size: 2em;
37
- }
38
- h2 {
39
- font-size: 1.8em;
40
- }
41
- h3 {
42
- font-size: 1.5em;
43
- }
44
- h4 {
45
- font-size: 1.2em;
46
- border: none;
47
- font-weight: bold;
48
- }
49
- h5 {
50
- font-size: 1em;
51
- }
52
- h6 {
53
- font-size: 1em; color: #8e8e8e;
54
- }
55
- a.heading_anchor {
56
- display: none;
57
- margin-left: 6px;
58
- text-decoration: none;
59
- }
60
- table.markdown_table{
61
- border: 1px solid #bbb;
62
- border-collapse: collapse;
63
- padding: 4px;
64
- margin-bottom: 4px;
65
- overflow: hidden;
66
- }
67
- table.markdown_table th{
68
- border: 1px solid #bbb;
69
- padding: 4px;
70
- display: table-cell;
71
- vertical-align: inherit;
72
- background-color:#EEEEEE;
73
- }
74
- table.markdown_table td{
75
- border: 1px solid #bbb;
76
- padding: 4px;
77
- display: table-cell;
78
- vertical-align: inherit;
79
- }
80
- table.controlled{
81
- border: 1px solid #e4e4e4;
82
- border-collapse: collapse;
83
- width: 100%;
84
- margin-bottom: 4px;
85
- border-spacing: 0px;
86
- border-radius: 3px;
87
- overflow: hidden;
88
- }
89
- table.controlled th {
90
- background-color:#e1f1fa;
91
- padding: 4px;
92
- white-space:nowrap;
93
- font-weight:normal;
94
- border: 1px solid #bbb;
95
- }
96
- table.controlled td {
97
- padding: 4px;
98
- text-align:center;
99
- vertical-align:middle;
100
- padding-right:10px;
101
- border: 1px solid #bbb;
102
- }
103
- table.controlled tr:first-child th {
104
- border-top: 0;
105
- }
106
- table.controlled tr:last-child td {
107
- border-bottom: 0;
108
- }
109
- table.controlled tr td:first-child,
110
- table.controlled tr th:first-child {
111
- border-left: 0;
112
- }
113
- table.controlled tr td:last-child,
114
- table.controlled tr th:last-child {
115
- border-right: 0;
116
- }
117
- table.controlled td.item_id {
118
- width: 3%;
119
- text-align: center;
120
- }
121
- table.controlled td.item_text{
122
- text-align: left;
123
- }
124
- table.controlled:not(.odd-even) tbody tr:nth-child(odd) { background-color:#f6f7f8; }
125
- table.controlled:not(.odd-even) tbody tr:nth-child(even) { background-color: #fff; }
126
- table.controlled:not(.odd-even) tbody tr:nth-child(odd):hover,
127
- table.controlled:not(.odd-even) tbody tr:nth-child(even):hover { background-color:#ffffdd; }
128
- a, a:link, a:visited {
129
- color: #169;
130
- text-decoration: none;
131
- display: inline-block;
132
- }
133
- a:active {
134
- color: #555;
135
- background-color:#deb887;
136
- text-decoration: none;
137
- display: inline-block;
138
- }
139
- div.blockquote {
140
- display: block;
141
- background:#f9f9fb;
142
- border-left: 3px double #bbb;
143
- font-style: italic;
144
- padding: 4px 1em 4px 4px;
145
- margin-top: 4px;
146
- margin-bottom: 4px;
147
- }
148
- code {
149
- display: block;
150
- background:#ffffee;
151
- border-left: 3px double #bbb;
152
- font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;
153
- padding: 4px 1em 4px 4px;
154
- margin-top: 4px;
155
- margin-bottom: 4px;
156
- }
157
- div.todoblock {
158
- display: block;
159
- background:#fcc;
160
- border-left: 3px double #bbb;
161
- font-style: italic;
162
- padding: 4px 1em 4px 4px;
163
- margin-top: 4px;
164
- margin-bottom: 4px;
165
- }
166
- img:hover{
167
- transition: 0.3s;
168
- }
169
- img{
170
- opacity: 0.9;
171
- cursor: pointer;
172
- }
173
- #modal_image_id{
174
- cursor: default;
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
- }
189
- #nav_pane{
190
- flex-shrink: 0;
191
- padding: 32px 8px 8px 8px;
192
- background: #EEEEEE;
193
- border: 1px solid #ddd;
194
- position: fixed;
195
- height: 100%; /* 100% Full-height */
196
- visibility: hidden;
197
- z-index: 1;
198
- overflow-y: auto;
199
- cursor: pointer;
200
- }
201
- @media screen and (min-width: 0px) and (max-width: 1089px) {#nav_pane{width: 22%;}}
202
- @media screen and (min-width: 1090px) and (max-width: 1279px) {#nav_pane{width: 240px;}}
203
- @media screen and (min-width: 1280px) and (max-width: 1599px) {#nav_pane{width: 280px;}}
204
- @media screen and (min-width: 1600px) and (max-width: 1919px) {#nav_pane{width: 320px;}}
205
- @media screen and (min-width: 1920px) and (max-width: 2559px) {#nav_pane{width: 360px;}}
206
- @media screen and (min-width: 2560px) {#nav_pane{width: 380px;}}
207
-
208
- #top_nav{
209
- background-color: #169;
210
- overflow: hidden;
211
- position: fixed;
212
- width: 100%;
213
- z-index: 2;
214
- }
215
- #top_nav a {
216
- float: left;
217
- color: white;
218
- text-align: center;
219
- padding: 4px 6px;
220
- text-decoration: none;
221
- font-size: 1.5em;
222
- font-family: "Trebuchet MS", Verdana, sans-serif;
223
- }
224
- #top_nav a.split {
225
- float: right;
226
- color: white;
227
- text-align: center;
228
- padding: 4px 6px;
229
- text-decoration: none;
230
- font-size: 1.5em;
231
- font-family: "Trebuchet MS", Verdana, sans-serif;
232
- }
233
- #top_nav a:hover {
234
- background-color: black;
235
- color: white;
236
- }
237
- #top_nav a.active {
238
- background-color: #169;
239
- color: white;
240
- }
241
- .modal {
242
- display: none; /* Hidden by default */
243
- position: fixed; /* Stay in place */
244
- z-index: 1; /* Sit on top */
245
- padding-top: 100px; /* Location of the box */
246
- left: 0;
247
- top: 0;
248
- width: 100%; /* Full width */
249
- height: 100%; /* Full height */
250
- overflow: auto; /* Enable scroll if needed */
251
- background-color: rgb(0,0,0); /* Fallback color */
252
- background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
253
- }
254
- .modal_image {
255
- margin: auto;
256
- display: block;
257
- width: 97%;
258
- /*max-width: 700px;*/
259
- }
260
- #modal_image_caption {
261
- margin: auto;
262
- display: block;
263
- width: 80%;
264
- max-width: 700px;
265
- text-align: center;
266
- color: #ccc;
267
- padding: 10px 0;
268
- height: 150px;
269
- }
270
- .modal_image, #modal_image_caption {
271
- animation-name: zoom;
272
- animation-duration: 0.6s;
273
- }
274
- @keyframes zoom {
275
- from {transform: scale(0.1)}
276
- to {transform: scale(1)}
277
- }
278
- .modal_close_btn {
279
- position: absolute;
280
- top: 15px;
281
- right: 35px;
282
- color: #f1f1f1;
283
- font-size: 30px;
284
- font-weight: bold;
285
- transition: 0.3s;
286
- }
287
- .modal_close_btn:hover,
288
- .modal_close_btn:focus {
289
- color: #bbb;
290
- text-decoration: none;
291
- cursor: pointer;
292
- }
293
- #footer {
294
- clear: both;
295
- border-top: 1px solid #bbb;
296
- font-size: 0.9em;
297
- color: #aaa;
298
- padding: 5px;
299
- text-align:center;
300
- background:#fff;
301
- }
302
- </style>
303
- <script>
304
- function openNav() {
305
- document.getElementById("nav_pane").style.visibility = "visible";
306
- }
307
-
308
- function closeNav() {
309
- document.getElementById("nav_pane").style.visibility = "hidden";
310
- }
311
-
312
- window.onload = (event) => {
313
- for (var i = 0, n = document.images.length; i < n; i++)
314
- {
315
- elem = document.images[i];
316
- if (elem.width > 640)
317
- {
318
- elem.style.width = "640px";
319
- }
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);
328
- };
329
-
330
- function downlink_OnClick(clicked){
331
- clicked.style.display = 'none';
332
- id_parts = clicked.id.split("_");
333
- required_id = "DLS_" + id_parts[1];
334
- document.getElementById(required_id).style.display = 'block';
335
- }
336
-
337
- function navigate_to_home(){
338
- if (document.title != "Document Index")
339
- {
340
- window.location.href = "./../../index.html";
341
- }else{
342
- window.location.href = "./index.html";
343
- }
344
- }
345
-
346
- // Modal window for image zoom
347
- function image_OnClick(clicked){
348
-
349
- var modal = document.getElementById('image_modal_div');
350
- var modalImg = document.getElementById("modal_image_id");
351
- var captionText = document.getElementById("modal_image_caption");
352
-
353
- modal.style.display = "block";
354
- modalImg.src = clicked.src;
355
- captionText.innerHTML = clicked.alt;
356
- }
357
-
358
- function modal_close_OnClick(clicked){
359
- var modal = document.getElementById('image_modal_div');
360
- modal.style.display = "none";
361
- }
362
-
363
- </script>
8
+ {{STYLES_AND_SCRIPTS}}
364
9
  </head>
365
10
  <body>
366
11
  <div id="top_nav">
367
12
  <a href="javascript:void(0)" onclick="navigate_to_home()"><span><i class="fa fa-home" aria-hidden="true"></i></span>&nbsp;Home</a>
13
+ <input type="text" id="searchInput" placeholder="Search.." style="display: none;">
368
14
  <a class="split">{{DOCUMENT_TITLE}}</a>
369
15
  </div>
16
+ <div id="search_dropdown" class="search-results-content" style="display: none;"></div>
370
17
  <div id="main">
371
18
  <div id="closed_nav_pane" href="javascript:void(0)" onclick="openNav()">
372
19
  </div>
@@ -378,7 +25,10 @@ function modal_close_OnClick(clicked){
378
25
  </div><!-- content -->
379
26
  </div><!-- main -->
380
27
  <div id="footer">
381
- Powered by <a target="_blank" rel="noopener" href="https://www.almirah.site/">Almirah Framework (0.1.8)</a>
28
+ Powered by <a target="_blank" rel="noopener" href="https://www.almirah.site/">
29
+ Almirah Framework
30
+ {{GEM_VERSION}}
31
+ </a>
382
32
  </div><!-- footer -->
383
33
  <!-- The modal window for image zoom -->
384
34
  <div id="image_modal_div" class="modal">
@@ -0,0 +1,61 @@
1
+ function openNav() {
2
+ document.getElementById("nav_pane").style.visibility = "visible";
3
+ }
4
+
5
+ function closeNav() {
6
+ document.getElementById("nav_pane").style.visibility = "hidden";
7
+ }
8
+
9
+ window.onload = (event) => {
10
+ for (var i = 0, n = document.images.length; i < n; i++)
11
+ {
12
+ elem = document.images[i];
13
+ if (elem.width > 640)
14
+ {
15
+ elem.style.width = "640px";
16
+ }
17
+ }
18
+ if ((document.title == "Document Index") && (document.URL.includes('http'))){
19
+ document.getElementById("searchInput").style.display = "block";
20
+ }
21
+ // Scroll a bit to make navigated anchor visible
22
+ //setTimeout(function() {
23
+ // window.scrollBy({
24
+ // top: -40,
25
+ // behavior: "smooth"
26
+ // });
27
+ // }, 200);
28
+ };
29
+
30
+ function downlink_OnClick(clicked){
31
+ clicked.style.display = 'none';
32
+ id_parts = clicked.id.split("_");
33
+ required_id = "DLS_" + id_parts[1];
34
+ document.getElementById(required_id).style.display = 'block';
35
+ }
36
+
37
+ function navigate_to_home(){
38
+ if (document.title != "Document Index")
39
+ {
40
+ window.location.href = "./../../index.html";
41
+ }else{
42
+ window.location.href = "./index.html";
43
+ }
44
+ }
45
+
46
+ // Modal window for image zoom
47
+ function image_OnClick(clicked){
48
+
49
+ var modal = document.getElementById('image_modal_div');
50
+ var modalImg = document.getElementById("modal_image_id");
51
+ var captionText = document.getElementById("modal_image_caption");
52
+
53
+ modal.style.display = "block";
54
+ modalImg.src = clicked.src;
55
+ captionText.innerHTML = clicked.alt;
56
+ }
57
+
58
+ function modal_close_OnClick(clicked){
59
+ var modal = document.getElementById('image_modal_div');
60
+ modal.style.display = "none";
61
+ }
@@ -0,0 +1,136 @@
1
+ // Do search only on the Index Page
2
+ import { create, search, insert } from 'https://unpkg.com/@orama/orama@latest/dist/index.js'
3
+
4
+ // Create DB
5
+ const db = await create({
6
+ schema: {
7
+ doc_title: 'string',
8
+ doc_color: 'string',
9
+ text: 'string',
10
+ heading_url: 'string',
11
+ heading_text: 'string'
12
+ }
13
+ })
14
+ // Load JSON DB
15
+ const response = await fetch("/data/specifications_db.json");
16
+ const data_rows = await response.json();
17
+ let i = 0;
18
+ while (i < data_rows.length) {
19
+ await insert(db, {
20
+ document: data_rows[i]["document"],
21
+ doc_color: data_rows[i]["doc_color"],
22
+ text: data_rows[i]["text"],
23
+ heading_url: data_rows[i]["heading_url"],
24
+ heading_text: data_rows[i]["heading_text"]
25
+ })
26
+ i++;
27
+ }
28
+
29
+ // Main db search function
30
+ async function search_onKeyUp(){
31
+
32
+ const search_input_text = document.getElementById("searchInput").value;
33
+ // Close drop down when empty
34
+ if ( search_input_text == ''){
35
+ document.getElementById("search_dropdown").style.display = "none";
36
+ }else{
37
+ document.getElementById("search_dropdown").style.display = "block";
38
+ }
39
+
40
+ const searchResult = await search(db, {
41
+ term: search_input_text,
42
+ properties: ['text', 'heading_text'],
43
+ exact: true,
44
+ });
45
+ if (searchResult == null){
46
+ return;
47
+ }
48
+ //console.log(searchResult.hits.map((hit) => hit.document));
49
+
50
+ // clear previous search
51
+ const myNode = document.getElementById("search_dropdown");
52
+ while (myNode.firstChild) {
53
+ myNode.removeChild(myNode.lastChild);
54
+ }
55
+
56
+ if (searchResult.count == 0){
57
+
58
+ const node = document.createElement("div");
59
+ node.classList.add('search-item');
60
+ const textnode = document.createTextNode("There are no matches found");
61
+ node.appendChild(textnode);
62
+ myNode.appendChild(node);
63
+
64
+ }else{
65
+
66
+ searchResult.hits.forEach ((value, index, array) =>{
67
+ const doc_title = value.document["document"]
68
+ const doc_color = value.document["doc_color"]
69
+ const heading_url = value.document["heading_url"]
70
+ const heading_text = value.document["heading_text"]
71
+ const search_text = value.document["text"]
72
+
73
+ const node_div = document.createElement("div");
74
+ node_div.classList.add('search-item');
75
+
76
+ const table = document.createElement("table");
77
+ table.classList.add('search-result-table');
78
+ node_div.appendChild(table);
79
+
80
+ const tbody = document.createElement("tbody");
81
+ table.appendChild(tbody);
82
+
83
+ // Row 1
84
+ let row = document.createElement("tr");
85
+ let cell = document.createElement("td");
86
+ let i = document.createElement("i");
87
+ i.classList.add("fa","fa-file-text-o");
88
+ i.style.backgroundColor = "#" + doc_color;
89
+ cell.appendChild(i);
90
+ let textnode = document.createTextNode("\xa0" + doc_title);
91
+ cell.appendChild(textnode);
92
+ row.appendChild(cell)
93
+ cell = document.createElement("td");
94
+
95
+ const a = document.createElement('a');
96
+ const link = document.createTextNode(heading_text)
97
+ a.appendChild(link);
98
+ a.title = heading_text;
99
+ a.href = heading_url;
100
+ document.body.appendChild(a);
101
+
102
+ cell.appendChild(a);
103
+ row.appendChild(cell)
104
+ tbody.appendChild(row)
105
+
106
+ // Row 2
107
+ row = document.createElement("tr");
108
+ cell = document.createElement("td");
109
+ cell.colSpan = 2;
110
+ let show_text_parts = search_text.split(" ", 10).join(" ");
111
+ textnode = document.createTextNode(show_text_parts);
112
+ cell.appendChild(textnode)
113
+ row.appendChild(cell)
114
+ tbody.appendChild(row)
115
+
116
+ myNode.appendChild(node_div);
117
+ })
118
+ }
119
+ }
120
+
121
+
122
+ document.getElementById("searchInput").addEventListener("keyup", search_onKeyUp);
123
+
124
+ // Show when focus in
125
+ document.getElementById("searchInput").addEventListener("focusin", (event) => {
126
+ // clear previous search
127
+ const element = document.getElementById("search_dropdown");
128
+ while (element.firstChild) {
129
+ element.removeChild(element.lastChild);
130
+ }
131
+ // show
132
+ const rect = document.getElementById("searchInput").getBoundingClientRect();
133
+ element.style.left = rect.left +'px';
134
+ element.style.top = rect.top + rect.height + 4 +'px';
135
+ element.style.display = "block";
136
+ });
data/lib/almirah.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "thor"
2
2
  require_relative "almirah/project"
3
+ require_relative "almirah/project_configuration"
3
4
 
4
5
  class CLI < Thor
5
6
  option :results
@@ -25,7 +26,8 @@ class Almirah
25
26
  attr_accessor :project
26
27
 
27
28
  def initialize(project_folder)
28
- @project = Project.new project_folder
29
+ config = ProjectConfiguration.new project_folder
30
+ @project = Project.new config
29
31
  end
30
32
 
31
33
  def getGemRoot()
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.9
4
+ version: 0.2.1
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-05-19 00:00:00.000000000 Z
11
+ date: 2024-06-09 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
@@ -34,9 +34,11 @@ files:
34
34
  - lib/almirah/doc_items/paragraph.rb
35
35
  - lib/almirah/doc_items/text_line.rb
36
36
  - lib/almirah/doc_items/todo_block.rb
37
+ - lib/almirah/doc_parser.rb
37
38
  - lib/almirah/doc_types/base_document.rb
38
39
  - lib/almirah/doc_types/coverage.rb
39
40
  - lib/almirah/doc_types/index.rb
41
+ - lib/almirah/doc_types/persistent_document.rb
40
42
  - lib/almirah/doc_types/protocol.rb
41
43
  - lib/almirah/doc_types/specification.rb
42
44
  - lib/almirah/doc_types/traceability.rb
@@ -44,7 +46,13 @@ files:
44
46
  - lib/almirah/dom/document.rb
45
47
  - lib/almirah/navigation_pane.rb
46
48
  - lib/almirah/project.rb
49
+ - lib/almirah/project_configuration.rb
50
+ - lib/almirah/search/specifications_db.rb
51
+ - lib/almirah/templates/css/main.css
52
+ - lib/almirah/templates/css/search.css
47
53
  - lib/almirah/templates/page.html
54
+ - lib/almirah/templates/scripts/main.js
55
+ - lib/almirah/templates/scripts/orama_search.js
48
56
  homepage: http://almirah.site
49
57
  licenses:
50
58
  - MIT