10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 05:43:46 +01:00
This commit is contained in:
Anthony Scemama 2020-11-25 01:52:53 +01:00
parent 988e660d23
commit 2b6099dff9
8 changed files with 27 additions and 11 deletions

View File

@ -3,9 +3,9 @@ index 88ba656e..5d97890c 100644
--- a/config.toml --- a/config.toml
+++ b/config.toml +++ b/config.toml
@@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
-baseURL = "/" -baseURL = "http://localhost:1313/QUESTDB_website/"
-#baseURL = "https://lcpq.github.io/QUESTDB_website/" -#baseURL = "https://lcpq.github.io/QUESTDB_website/"
+#baseURL = "/" +#baseURL = "http://localhost:1313/QUESTDB_website/"
+baseURL = "https://lcpq.github.io/QUESTDB_website/" +baseURL = "https://lcpq.github.io/QUESTDB_website/"
canonifyurls = true canonifyurls = true

View File

@ -1,4 +1,4 @@
baseURL = "/" baseURL = "http://localhost:1313/QUESTDB_website/"
#baseURL = "https://lcpq.github.io/QUESTDB_website/" #baseURL = "https://lcpq.github.io/QUESTDB_website/"
canonifyurls = true canonifyurls = true

View File

@ -28,7 +28,8 @@ class PubliData{
} }
static GetPathForDOI(DOI){ static GetPathForDOI(DOI){
return `/data/publis/${DOI.replaceAll(".","/")}` var site_url = window.location.origin;
return site_url + `/data/publis/${DOI.replaceAll(".","/")}`
} }
static GetAbstractURLForDOI(DOI){ static GetAbstractURLForDOI(DOI){
return `${PubliData.GetPathForDOI(DOI)}/abstract.html` return `${PubliData.GetPathForDOI(DOI)}/abstract.html`
@ -41,4 +42,4 @@ class PubliData{
static async getAbstractTexForDOIAsync(DOI){ static async getAbstractTexForDOIAsync(DOI){
return await getTextFromFileUrlAsync(PubliData.GetAbstractURLForDOI(DOI)) return await getTextFromFileUrlAsync(PubliData.GetAbstractURLForDOI(DOI))
} }
} }

View File

@ -232,8 +232,9 @@ class dataFileBase {
return /^#\s*([A-Za-z_]+)\s*:\s*(.*)$/; return /^#\s*([A-Za-z_]+)\s*:\s*(.*)$/;
} }
async getGeometryAsync(state = null) { async getGeometryAsync(state = null) {
var site_url = "/"+window.location.pathname.split('/')[1];
// var text = await getTextFromFileUrlAsync(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`) // var text = await getTextFromFileUrlAsync(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`)
var text = getTextFromFileUrl(`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`) var text = getTextFromFileUrl(site_url+`/data/structures/${this.set.name.replace("#", "")}/${this.molecule.toLowerCase()}.xyz`)
var lines = text.split("\n") var lines = text.split("\n")
var indexes = lines.findAllIndexes((line) => { var indexes = lines.findAllIndexes((line) => {
return line.match(/^\d+$/) return line.match(/^\d+$/)

View File

@ -1,3 +1,4 @@
function getFullDataPath(path) { function getFullDataPath(path) {
return '/data/' + path; var site_url = "/"+window.location.pathname.split('/')[1];
return site_url+'/data/' + path;
} }

View File

@ -1,5 +1,6 @@
var fileCache = function () { var fileCache = function () {
var json_url = "/data/database.json"; var site_url = "/"+window.location.pathname.split('/')[1];
var json_url = site_url+"/data/database.json";
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open("GET",json_url, false); req.open("GET",json_url, false);
req.send(); req.send();

View File

@ -5,11 +5,12 @@ class indexDB {
} }
var db = new indexDB var db = new indexDB
const maxAge= (DebugMode.Enabled,0,600) const maxAge= (DebugMode.Enabled,0,600)
const text = await getTextFromFileUrlAsync("/data/index.yaml",{"Cache-Control":`max-age=${maxAge}`}) var site_url = "/"+window.location.pathname.split('/')[1];
const text = await getTextFromFileUrlAsync(site_url+"/data/index.yaml",{"Cache-Control":`max-age=${maxAge}`})
const myYaml = jsyaml.load(text); const myYaml = jsyaml.load(text);
db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets))); db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets)));
db.others = ((myYaml.others === null) ? [] : Array.from(myYaml.others)); db.others = ((myYaml.others === null) ? [] : Array.from(myYaml.others));
window.indexDB=db window.indexDB=db
return db return db
} }
} }

View File

@ -5,8 +5,19 @@ import os.path
import json import json
def main(): def main():
baseURL = "/"
with open("config.toml","r") as f:
for line in f.readlines():
if line.startswith("baseURL"):
baseURL = line.split('=')[1].strip()[1:-1]
break
if baseURL.startswith("http"):
baseURL = '/'+baseURL.split('/')[3]+'/'
print (baseURL)
d = {} d = {}
os.chdir("static") os.chdir("static")
try: try:
@ -18,7 +29,7 @@ def main():
filename = os.path.join(root,name) filename = os.path.join(root,name)
with open(filename,'r',encoding="utf8") as f: with open(filename,'r',encoding="utf8") as f:
try: try:
d["/"+filename] = f.read() d[baseURL+filename] = f.read()
except UnicodeDecodeError: except UnicodeDecodeError:
pass pass