Skip to content

Commit

Permalink
hxlm-js (hdp #18, lisp #18): index.html also part of the hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Apr 4, 2021
1 parent e05f84a commit e8886a4
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 57 deletions.
52 changes: 31 additions & 21 deletions hxlm-js/bootstrapper/hdp-aux.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,59 @@ console.log('hdp-aux.js')
class HDPAux {

_DEBUG = false
_console_html_wrapper = '.hdp-console-items'
static _console_QS = '.hdp-console-items'

constructor(res) {
if (typeof HDP_DEBUG !== 'undefined') {
self._DEBUG = HDP_DEBUG
}
}

_console_html_template(res_str, lang) {
static _console_html_template(res_str, lang) {
let lang_ = lang || 'lang-json';
let tpl = `<div class="hdp-console-item">
<pre><code class="${lang_}>
let iid = "hciid-" + Date.now()
// console.log('lang_', lang_, res_str, iid)
let tpl = `<div class="hdp-console-item" id="${iid}>
<pre>aaa<code class="${lang_}>
${res_str}
</code>
</pre>
</div>`
return tpl
}

static dump_to_html(res, selector) {
console.log(document.querySelector(selector).innerHTML)
let out = document.querySelector(selector)
out.innerHTML = JSON.stringify(res, null, 2)
// out.innerHTML = JSON.stringify(res, space = 2)
// https://highlightjs.org/usage/
if (hljs && hljs.highlightAll) {
hljs.highlightAll()
}
}
// static dump_to_html(res, selector) {
// // console.log('dump_to_html', document.querySelector(selector).innerHTML)
// let out = document.querySelector(selector)
// out.innerHTML = JSON.stringify(res, null, 2)
// // out.innerHTML = JSON.stringify(res, space = 2)
// // https://highlightjs.org/usage/
// if (hljs && hljs.highlightAll) {
// hljs.highlightAll()
// }
// }

console_html(res) {
let wrapper_qss = this._console_html_wrapper
let wrapper_el = document.querySelector(wrapper_qss)
let output = this._console_html_template(
static console_html(res) {
// console.log('console_html started', res)
// console.log('console_html', self._console_html_wrapper, self._console_html_template())
// let wrapper_qss = HDPAux._hdp_console_items_selector
let wrapper_el = document.querySelector(HDPAux._console_QS)
// console.log('console_html wrapper_el', wrapper_el)
let output = HDPAux._console_html_template(
JSON.stringify(res, null, 2)
)
console.log('')
// console.log('console_html', wrapper_el, output)
// console.log('testeste', out, this._console_html_template())
if (wrapper_el) {
wrapper_el.appendChild(output)
wrapper_el.innerHTML = wrapper_el.innerHTML + output
// wrapper_el.appendChild(output)
// https://highlightjs.org/usage/
if (hljs && hljs.highlightAll) {
hljs.highlightAll()
}
} else {
console.error('HDPAux.console_html [' +
wrapper_qss + '] not found');
HDPAux._console_QS + '] not found');
console.log('HDPAux.console_html fallback', res);
}
// this_._DEBUG && console.log('console_html out', out)
Expand Down
64 changes: 49 additions & 15 deletions hxlm-js/bootstrapper/hdp-minimam.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class HDPMiniman {
let resultatum = new Object({
securum: null,
insecurum: null, // insecurum: true,
factum: '(qdp->ENG "Not tested")',
factum: '(qdp->ENG "Complex tests not implemented yet")',
})
self._DEBUG && console.log('_securum', resultatum)
return resultatum
Expand All @@ -86,15 +86,19 @@ class HDPMiniman {
* Trivia:
* - https://en.wiktionary.org/wiki/initium
*/
_initium_lkg() {
let this_ = this
async _initium_lkg() {
let topself = self
let topthis = this
// console.log('_initium_lkg', self.FONTEM_LKG, topself.FONTEM_LKG)
fetch(self.FONTEM_LKG).then(async function (response) {
var contentType = response.headers.get("content-type");
if (contentType && contentType.indexOf("application/json") !== -1) {
const json = await response.json()
const sec = this_._securum(json, 'LKG')
const sec = topthis._securum(json, 'LKG')
if (!sec.insecurum) {
self.ONTOLOGIA_LKG = json
// Remove either topself or topthis from here
topself.ONTOLOGIA_LKG = json
topthis.ONTOLOGIA_LKG = json
// console.log(self.ONTOLOGIA_LKG)
return json
} else {
Expand All @@ -116,15 +120,18 @@ class HDPMiniman {
* Trivia:
* - https://en.wiktionary.org/wiki/initium
*/
_initium_vkg() {
let this_ = this
async _initium_vkg() {
let topself = self
let topthis = this
fetch(self.FONTEM_VKG).then(async function (response) {
var contentType = response.headers.get("content-type");
if (contentType && contentType.indexOf("application/json") !== -1) {
const json = await response.json()
const sec = this_._securum(json, 'VKG')
const sec = topthis._securum(json, 'VKG')
if (!sec.insecurum) {
self.ONTOLOGIA_VKG = json
// Remove either topself or topthis from here
topself.ONTOLOGIA_VKG = json
topthis.ONTOLOGIA_VKG = json
// console.log(self.ONTOLOGIA_VKG)
return json
} else {
Expand Down Expand Up @@ -224,19 +231,46 @@ class HDPMiniman {
* - https://en.wiktionary.org/wiki/index#Latin
*/
async explanare(index) {
let topself = self
let topthis = this
// console.log('explanare, self._DEBUG', self._DEBUG)
if (self._DEBUG){
console.log('explanare', {
'FONTEM_LKG': topself.FONTEM_LKG,
'FONTEM_VKG': topself.FONTEM_VKG,
'ONTOLOGIA_LKG': topself.ONTOLOGIA_LKG,
//'ONTOLOGIA_LKG2': topthis.ONTOLOGIA_LKG,
'ONTOLOGIA_VKG': topself.ONTOLOGIA_VKG,
//'ONTOLOGIA_VKG2': topthis.ONTOLOGIA_VKG
})
}

// console.log()

// Without options, we will return quick/sumrized information
if(!index) {
if (!index) {
let resultatum = new Object()
resultatum.FONTEM_LKG = self.FONTEM_LKG
resultatum.FONTEM_VKG = self.FONTEM_VKG
return resultatum
resultatum.FONTEM_LKG = topself.FONTEM_LKG
resultatum.FONTEM_VKG = topself.FONTEM_VKG
resultatum.LKG = topself.ONTOLOGIA_LKG || 'explanare("LKG") ...'
resultatum.VKG = topself.ONTOLOGIA_VKG || 'explanare("VKG") ...'
// resultatum.VKG = 'explanare("VKG") ...'
// return resultatum
return new Promise(function (resolve, reject) {
resolve(resultatum)
// reject('teste teste reject')
// setTimeout(function(){
// resolve(['comedy', 'drama', 'action'])
// }, 2000);
});
}
if (index == 'LKG') {
return this._get_lkg()
return this._initium_lkg()
// return this._get_lkg()
}
if (index == 'VKG') {
return this._get_vkg()
return this._initium_vkg()
// return this._get_vkg()
}

// Unknow index
Expand Down
7 changes: 4 additions & 3 deletions hxlm-js/hxlm-js.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHA384 (bootstrapper/hdp-aux.js) = d33d92c769b1fa0467f38f797c99406d47182400782f5c0744b37c9e53486d8a331b8d2319990920a250b90523786809
SHA384 (bootstrapper/hdp-minimam.mjs) = 11cff20de3a0e05067be0b32fc28dd70e7e278c0d1ccb25bc32627566056a48b9898d79f004fb7600a2b21bf7881216d
SHA384 (bootstrapper/hdplisp.js) = cd118e73f7ea84b780cc4ebb4e7e99cbf2bf41eecac7ca7b43be6ad5ac22b39189bd01a8fa380b237734030c205228cf
SHA384 (index.html) = ba83f6bf76065f2f1a5988c5377d53962946a3587be71fe168acd52121482c0fc626c670ed9626a0e7a527ac02632990
SHA384 (bootstrapper/hdp-aux.js) = 09aea6ea9fe1ba700cee07e64f840280a316e3bcdf0964d9fdf3a7fe7ffb4ee4c1d3bd109f73c356e9b79fc8959256c7
SHA384 (bootstrapper/hdp-minimam.mjs) = 2559e6c03a135c044361e403936a0fcc820fe80d974a5a751a4f4589f64216ec801edc923386522ce20a0bbd802e29fe
SHA384 (bootstrapper/hdplisp.js) = 2be79b367fe635ca52a23b6163aea3ef29aa2bbadfb595bba696198977fdbb062c1438cd3934cb2ea557d6ed47d385ad
56 changes: 43 additions & 13 deletions hxlm-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,22 @@ <h3>JavaScript</h3>
// let HDP_DEBUG = true
bootstrapping = HDPMiniman.bootstrapping()
hdp = new HDPMiniman(bootstrapping)
aux = new HDPAux()

// This return an quick overview
hdp.explanare().then(console.log)
hdp.explanare().then(console.log).catch(console.error)

// Return the Localization Knowledge Graph, when ready
hdp.explanare('LKG').then(console.log)
hdp.explanare('LKG').then(console.log).catch(console.error)

// Return the Vocabulary Knowledge Graph, when ready
hdp.explanare('VKG').then(console.log)
hdp.explanare('VKG').then(console.log).catch(console.error)


aux.console_html()
</code>
</pre>
<h3>console.log</h3>
<div class="hdp-console-items">

<p>old content</p>
</div>
<pre><code class="lang-json" id="hdp-explanare">

Expand Down Expand Up @@ -78,24 +76,56 @@ <h3>console.log</h3>
<script src="./bootstrapper/hdp-minimam.mjs"></script>

<script>

// let HDP_DEBUG = true
bootstrapping = HDPMiniman.bootstrapping()
hdp = new HDPMiniman(bootstrapping)
aux = new HDPAux()

// This return an quick overview
hdp.explanare().then(console.log).catch(console.error)

hdp.explanare('LKG').then(console.log)
// Return the Localization Knowledge Graph, when ready
hdp.explanare('LKG').then(console.log).catch(console.error)

// This return an quick overview
hdp.explanare().then(console.log)
// Return the Vocabulary Knowledge Graph, when ready
hdp.explanare('VKG').then(console.log).catch(console.error)

// Here is where we, in fact, show the results on the page
hdp.explanare('LKG').then(HDPAux.console_html).catch(console.error)
hdp.explanare('VKG').then(HDPAux.console_html).catch(console.error)


// hdp.explanare('VKG').then(function(content) {
// console.log('teste123', content)
// HDPAux.console_html(content)
// }, function(onerror) {
// console.error('teste123', onerror)
// }).catch(console.error)


// // let HDP_DEBUG = true
// bootstrapping = HDPMiniman.bootstrapping()
// hdp = new HDPMiniman(bootstrapping)
// // aux = new HDPAux()


// hdp.explanare('LKG').then(console.log)

// // This return an quick overview
// hdp.explanare().then(console.log).catch(console.error)
// hdp.explanare().then(console.log).then(HDPAux.dump_to_html).catch(console.error)

// Return the Localization Knowledge Graph, when ready
hdp.explanare('LKG').then(console.log)
// hdp.explanare('LKG').then(console.log)

// Return the Vocabulary Knowledge Graph, when ready
hdp.explanare('VKG').then(console.log)
// hdp.explanare('VKG').then(console.log)

// hdp.explanare().then(console.log).then(aux.console_html)
//hdp.explanare('VKG').then(console.log).then(HDPAux.console_html)
// hdp.explanare('VKG').then(console.log).then(function(result) {
// // console.log('oioioi', result)
// HDPAux.console_html(result)
// }).catch(alert)
// aux.console_html()

// HDPAux.dump_to_html(hdp.explanare(), '#hdp-explanare')
Expand Down
14 changes: 9 additions & 5 deletions prepare-hxlm-relsease.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
# shellcheck disable=SC2129,SC2164
#===============================================================================
#
# FILE: prepare-hxlm-relsease.sh
Expand Down Expand Up @@ -57,23 +58,26 @@ sha384sum --check core.vkg.json.sum

### hxlm-js/ -------------------------------------------------------------------
echo "> > hxlm-js"
cd "$ROOTDIR" || exit
cd "$ROOTDIR"

## Create the hashes

cd hxlm-js/ || exit
cd hxlm-js/

# First file, clean old checksums
rm hxlm-js.sum

# The rest, append
sha384sum --tag bootstrapper/hdp-aux.js > hxlm-js.sum

# Initialize
sha384sum --tag index.html > hxlm-js.sum

# The rest, append
sha384sum --tag bootstrapper/hdp-aux.js >> hxlm-js.sum
sha384sum --tag bootstrapper/hdp-minimam.mjs >> hxlm-js.sum
sha384sum --tag bootstrapper/hdplisp.js >> hxlm-js.sum

## Check the hashes
sha384sum --check hxlm-js.sum

#### Additional commands _______________________________________________________
# cd "$ROOTDIR" || exit
# cd "$ROOTDIR"

0 comments on commit e8886a4

Please sign in to comment.