From f69452917598e8d95ebe1a9e52ee73a299603476 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 19 Nov 2020 21:06:36 +0100 Subject: [PATCH 1/6] Remove some async DOI --- content/dataset.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/dataset.html b/content/dataset.html index 1a813649..9c72af9c 100644 --- a/content/dataset.html +++ b/content/dataset.html @@ -103,6 +103,8 @@ draft: false async function loadFiles() { processingIndicator.isActive = true var data = await loadAllData() + let db = await indexDB.loadAsync() + window.defaultDats = [] for (const sub of Object.values(data)) { for (const exSet of uniq(sub.map(d => d.set))) { @@ -110,7 +112,7 @@ draft: false for (mol of uniq(subset.map(d => d.molecule))) { const submol = subset.filter(d => d.molecule === mol) const source = await submol.findAsync(async (d) => { - if (await d.set.getDOIAsync() === "10.1021/acs.jctc.8b01205") { + if (db.sets.get(d.set.name)[d.set.index] === "10.1021/acs.jctc.8b01205") { return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ" } else { return d.method.isTBE From 5d637180c7502a5ac1f3d140f19504263539ceb4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 19 Nov 2020 23:12:14 +0100 Subject: [PATCH 2/6] Faster uniq function --- content/dataset.html | 1 + static/js/data.js | 18 ++++++++++++++++-- static/js/loadAllData.js | 2 ++ static/js/uniq.js | 15 +++++++++------ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/content/dataset.html b/content/dataset.html index 9c72af9c..4716fab5 100644 --- a/content/dataset.html +++ b/content/dataset.html @@ -112,6 +112,7 @@ draft: false for (mol of uniq(subset.map(d => d.molecule))) { const submol = subset.filter(d => d.molecule === mol) const source = await submol.findAsync(async (d) => { +// const source = submol.find((d) => { if (db.sets.get(d.set.name)[d.set.index] === "10.1021/acs.jctc.8b01205") { return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ" } else { diff --git a/static/js/data.js b/static/js/data.js index f711d035..7b1d9e6a 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -279,9 +279,9 @@ class dataFileBase { switch (trueTypeOf(file)) { case String.name: file = getFullDataPath(file) - const maxAge= (DebugMode.Enabled,0,600) + // const maxAge= (DebugMode.Enabled,0,600) // var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) - var str = await getTextFromFileUrl(file) + var str = await getTextFromFileUrl(file) //TODO break; case File.name: var str = await getTextFromUploadedFileAsync(file) @@ -291,6 +291,20 @@ class dataFileBase { dat.sourceFile = new websiteFile(file) return dat } + static load(file, kind = undefined) { + switch (trueTypeOf(file)) { + case String.name: + file = getFullDataPath(file) + var str = getTextFromFileUrl(file) + break; + case File.name: + var str = (async () => await getTextFromUploadedFileAsync(file))().then(x=>x) + break + } + var dat = this.loadString(str, kind); + dat.sourceFile = new websiteFile(file) + return dat + } _OnReadMetaPair(key, value) { switch (key) { case "molecule": diff --git a/static/js/loadAllData.js b/static/js/loadAllData.js index afc0d766..94158493 100644 --- a/static/js/loadAllData.js +++ b/static/js/loadAllData.js @@ -4,9 +4,11 @@ async function loadAllData() { fluo: [], }; for (const f of getAbsFilesName()) { +// dic.abs.push(VertDataFile.load(f,VertExcitationKinds.Absorbtion)) dic.abs.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Absorbtion)) } for (const f of getFluoFilesName()) { +// dic.fluo.push(VertDataFile.load(f,VertExcitationKinds.Fluorescence)) dic.fluo.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Fluorescence)) } return dic; diff --git a/static/js/uniq.js b/static/js/uniq.js index d492b157..9c69bf9c 100644 --- a/static/js/uniq.js +++ b/static/js/uniq.js @@ -1,8 +1,11 @@ function uniq(array) { - return uniqueArray = array.filter((obj1,index) => { - return index === array.findIndex(obj2 => { - return JSON.stringify(obj1) === JSON.stringify(obj2); - }); - }); -} \ No newline at end of file + if (array.length == 0) return []; + var sortedArray = array.sort().map( x => [x, JSON.stringify(x)] ); + var uniqueArray = [ sortedArray[0][0] ]; + for (let i=1 ; i Date: Thu, 19 Nov 2020 23:18:52 +0100 Subject: [PATCH 3/6] Acceleration --- content/dataset.html | 3 +-- static/js/data.js | 2 +- static/js/loadAllData.js | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/content/dataset.html b/content/dataset.html index 4716fab5..6ffec757 100644 --- a/content/dataset.html +++ b/content/dataset.html @@ -111,8 +111,7 @@ draft: false const subset = sub.filter(d => d.set.isSameSet(exSet)) for (mol of uniq(subset.map(d => d.molecule))) { const submol = subset.filter(d => d.molecule === mol) - const source = await submol.findAsync(async (d) => { -// const source = submol.find((d) => { + const source = submol.find((d) => { if (db.sets.get(d.set.name)[d.set.index] === "10.1021/acs.jctc.8b01205") { return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ" } else { diff --git a/static/js/data.js b/static/js/data.js index 7b1d9e6a..8e9148a6 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -281,7 +281,7 @@ class dataFileBase { file = getFullDataPath(file) // const maxAge= (DebugMode.Enabled,0,600) // var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) - var str = await getTextFromFileUrl(file) //TODO + var str = await getTextFromFileUrl(file) break; case File.name: var str = await getTextFromUploadedFileAsync(file) diff --git a/static/js/loadAllData.js b/static/js/loadAllData.js index 94158493..8515f1fa 100644 --- a/static/js/loadAllData.js +++ b/static/js/loadAllData.js @@ -4,12 +4,10 @@ async function loadAllData() { fluo: [], }; for (const f of getAbsFilesName()) { -// dic.abs.push(VertDataFile.load(f,VertExcitationKinds.Absorbtion)) - dic.abs.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Absorbtion)) + dic.abs.push(VertDataFile.load(f,VertExcitationKinds.Absorbtion)) } for (const f of getFluoFilesName()) { -// dic.fluo.push(VertDataFile.load(f,VertExcitationKinds.Fluorescence)) - dic.fluo.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Fluorescence)) + dic.fluo.push(VertDataFile.load(f,VertExcitationKinds.Fluorescence)) } return dic; } From 62b92912b61a964e5c74d29728d3d1468184ee5d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 19 Nov 2020 23:56:04 +0100 Subject: [PATCH 4/6] Fast load time --- static/js/GeometriesLoader.js | 6 +++--- static/js/Geometry.js | 7 +++---- static/js/data.js | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/static/js/GeometriesLoader.js b/static/js/GeometriesLoader.js index 2df41181..4370c432 100644 --- a/static/js/GeometriesLoader.js +++ b/static/js/GeometriesLoader.js @@ -6,11 +6,11 @@ class GeometriesLoader{ const myset=item.set.split("#").join("") try { const mol=await Geometry.loadXYZAsync(`/${myset}/${mymol}.xyz`) - xyzs.push(mol) + xyzs.push(mol) } catch (error) { console.error("Geometry not found",item) - } + } } return xyzs.flat() } -} \ No newline at end of file +} diff --git a/static/js/Geometry.js b/static/js/Geometry.js index f0e26c5c..7d9734a4 100644 --- a/static/js/Geometry.js +++ b/static/js/Geometry.js @@ -6,9 +6,8 @@ class Geometry { static async loadXYZAsync(file) { switch (trueTypeOf(file)) { case String.name: - file = getFullDataPath("/structures/"+file) - const maxAge= (DebugMode.Enabled,0,600) - var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) + file = getFullDataPath("structures"+file) + var str = getTextFromFileUrl(file) break; case File.name: var str = await getTextFromUploadedFileAsync(file) @@ -33,4 +32,4 @@ class Geometry { } return geoms } -} \ No newline at end of file +} diff --git a/static/js/data.js b/static/js/data.js index 8e9148a6..e259d8ff 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -281,7 +281,7 @@ class dataFileBase { file = getFullDataPath(file) // const maxAge= (DebugMode.Enabled,0,600) // var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) - var str = await getTextFromFileUrl(file) + var str = getTextFromFileUrl(file) break; case File.name: var str = await getTextFromUploadedFileAsync(file) From feaee8acd1bfc6a2eab2fbd19035a02fbef7be19 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 20 Nov 2020 00:23:28 +0100 Subject: [PATCH 5/6] Fast loading time --- content/dataset.html | 4 ++-- static/js/data.js | 13 ++++++++----- static/js/uniq.js | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/content/dataset.html b/content/dataset.html index 6ffec757..d0d1cbc9 100644 --- a/content/dataset.html +++ b/content/dataset.html @@ -101,9 +101,9 @@ draft: false await loadFiles() } async function loadFiles() { + const db = await indexDB.loadAsync() + const data = await loadAllData() processingIndicator.isActive = true - var data = await loadAllData() - let db = await indexDB.loadAsync() window.defaultDats = [] for (const sub of Object.values(data)) { diff --git a/static/js/data.js b/static/js/data.js index e259d8ff..74b8fe9c 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -261,17 +261,20 @@ class dataFileBase { }) } CopyExcitationsTypeFrom(data) { + var exc_strings = data.excitations.map( e => [e, JSON.stringify(e.initial), JSON.stringify(e.final) ] ) for (const ex of this.excitations) { - const ex2 = data.excitations.find((e) => { - return (JSON.stringify(e.initial) === JSON.stringify(ex.initial)) && (JSON.stringify(e.final) === JSON.stringify(ex.final)) + const exi = JSON.stringify(ex.initial) + const exf = JSON.stringify(ex.final) + const ex2 = exc_strings.find((e) => { + return (e[1]=== exi) && (e[2]=== exf) }) if (ex2 !== undefined) { if (DebugMode.Enabled) { - const restflag=ex.type.Value & ex2.type.Value + const restflag=ex.type.Value & ex2[0].type.Value const result=restflag==ex.type.Value - console.assert(result, "Excitation type error", data.molecule, ex, ex2, this.sourceFile) + console.assert(result, "Excitation type error", data.molecule, ex, ex2[0], this.sourceFile) } - ex.type = ex2.type + ex.type = ex2[0].type } } } diff --git a/static/js/uniq.js b/static/js/uniq.js index 9c69bf9c..17e067ba 100644 --- a/static/js/uniq.js +++ b/static/js/uniq.js @@ -1,7 +1,7 @@ function uniq(array) { if (array.length == 0) return []; - var sortedArray = array.sort().map( x => [x, JSON.stringify(x)] ); + const sortedArray = array.sort().map( x => [x, JSON.stringify(x)] ); var uniqueArray = [ sortedArray[0][0] ]; for (let i=1 ; i Date: Fri, 20 Nov 2020 09:19:04 +0100 Subject: [PATCH 6/6] First gh-pages script --- .github/workflows/gh-pages.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/gh-pages.yml diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 00000000..3d74b34c --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,31 @@ +name: github pages + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: refresh apt + run: sudo apt-get update + + - name: install dependencies + run: sudo apt-get install hugo + + - name: install theme + run: git submodule update --init --recursive + + - name: make + run: make + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./public +