Almirah 0.1.8 → 0.2.0
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 +4 -4
- data/lib/almirah/doc_fabric.rb +6 -0
- data/lib/almirah/doc_items/doc_item.rb +4 -0
- data/lib/almirah/doc_items/heading.rb +11 -0
- data/lib/almirah/doc_types/base_document.rb +21 -0
- data/lib/almirah/project.rb +54 -43
- data/lib/almirah/project_configuration.rb +42 -0
- data/lib/almirah/search/specifications_db.rb +37 -0
- data/lib/almirah/templates/css/main.css +298 -0
- data/lib/almirah/templates/css/search.css +40 -0
- data/lib/almirah/templates/page.html +7 -357
- data/lib/almirah/templates/scripts/main.js +61 -0
- data/lib/almirah/templates/scripts/orama_search.js +136 -0
- data/lib/almirah.rb +3 -1
- metadata +8 -2
@@ -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
|
-
|
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2024-06-04 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
|
@@ -44,7 +44,13 @@ files:
|
|
44
44
|
- lib/almirah/dom/document.rb
|
45
45
|
- lib/almirah/navigation_pane.rb
|
46
46
|
- lib/almirah/project.rb
|
47
|
+
- lib/almirah/project_configuration.rb
|
48
|
+
- lib/almirah/search/specifications_db.rb
|
49
|
+
- lib/almirah/templates/css/main.css
|
50
|
+
- lib/almirah/templates/css/search.css
|
47
51
|
- lib/almirah/templates/page.html
|
52
|
+
- lib/almirah/templates/scripts/main.js
|
53
|
+
- lib/almirah/templates/scripts/orama_search.js
|
48
54
|
homepage: http://almirah.site
|
49
55
|
licenses:
|
50
56
|
- MIT
|