Skip to content

Commit

Permalink
preview tool updates
Browse files Browse the repository at this point in the history
  • Loading branch information
phfaist committed Aug 12, 2023
1 parent 122bdb2 commit cc9f774
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 19 deletions.
46 changes: 39 additions & 7 deletions previewtool/previewApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,41 @@ window.addEventListener('load', async () => {
const fs = fsRemoteCreateClient();

//
// load ZooDb
// Prepare the ZooDb default options
//

let defaultAppZooDbOptions = get_eczoo_full_options();

//
// load any existing citations cache to help our citations resolver
// because we don't have access to DOI & arXiv APIs due to their strict
// CORS settings
//

let loadedCitationsCache = {};
const fnameCitationsInfoCache = path.join(serverData.citationsinfo_cache_dir_default,
'cache_compiled_citations.json');
try {
loadedCitationsCache = JSON.parse(
await fs.promises.readFile(fnameCitationsInfoCache)
);
debug(`Loaded citations cache file ‘${fnameCitationsInfoCache}’`,
loadedCitationsCache);
} catch (error) {
console.warn(`Failed to load citations cache file ‘${fnameCitationsInfoCache}’, `
+ `will proceed without cached info.`, error);
}


//
// Finalize the ZooDb Options & load !
//

let appZooDbOptions = loMerge(
//
// our built-in default options/settings
//
get_eczoo_full_options(),
defaultAppZooDbOptions,

//
// custom options & settings
Expand All @@ -180,19 +207,23 @@ window.addEventListener('load', async () => {
// their public APIs seem to have strict CORS settings
// meaning we can't call them from other web apps
doi: new CitationSourceApiPlaceholder({
title: "DOI citation",
title: (doi) => `[DOI \\verbcode{${doi}}; citation text will appear on production zoo website]`,
cite_prefix: 'doi',
test_url: (_, cite_key) => `https://doi.org/${cite_key}`,
search_in_compiled_cache: loadedCitationsCache,
}),
arxiv: new CitationSourceApiPlaceholder({
title: "arXiv [& DOI?] citation",
title: (arxivid) => `[arXiv:${arxivid}; citation text will appear on production zoo website (& via DOI if published)]`,
cite_prefix: 'arxiv',
test_url: (_, cite_key) => `https://arxiv.org/abs/${cite_key}`,
search_in_compiled_cache: loadedCitationsCache,
}),
},
citation_manager_options: {
skip_save_cache: true,
}

cache_dir: '_zoodb_live_preview_dummy_cache_shouldnt_be_created',
cache_dir_create: false,

skip_save_cache: true,
},
allow_unresolved_references: true,
allow_unresolved_citations: true,
Expand All @@ -209,6 +240,7 @@ window.addEventListener('load', async () => {
);

let zoodb = new EcZooDb( appZooDbOptions );

zoodb.install_zoo_loader(new EcZooDbYamlDataLoader({
schema_root: `file://${serverData.schema_root_dir}/`,
throw_reload_errors: true,
Expand Down
3 changes: 3 additions & 0 deletions previewtool/runPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import path from 'path';

import { PreviewAppServer } from '@phfaist/zoodbtools_previewremote/startRemotePreviewApp.js';

import { citationsinfo_cache_dir_default } from '../eczoodb/dirs_defaults.js';


const __filename = (new URL('', import.meta.url)).pathname;
const __dirname = (new URL('.', import.meta.url)).pathname;
Expand All @@ -21,6 +23,7 @@ const settings = {
'appData.json': {
eczoo_data_dir: path.join(__dirname, '../../eczoo_data/'),
schema_root_dir: path.join(__dirname, '../eczoodb/'),
citationsinfo_cache_dir_default,
}
},

Expand Down
30 changes: 23 additions & 7 deletions site/site_data/eczoodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,31 @@ module.exports = async (configData) => {
const { EcZooDbYamlDataLoader } =
await import('@errorcorrectionzoo/eczoodb/load_yamldb.js');

cached_eczoodb = new EcZooDb({
fs,
fs_data_dir: eczoo_config.data_dir,
... get_eczoo_full_options()
});
cached_eczoodb.install_zoo_loader(new EcZooDbYamlDataLoader({ }));
try {

cached_eczoodb = new EcZooDb({
fs,
fs_data_dir: eczoo_config.data_dir,
... get_eczoo_full_options()
});
cached_eczoodb.install_zoo_loader(new EcZooDbYamlDataLoader({ }));

} catch (err) {
console.error(err);
console.err(`ERROR INITIALIZING ZOO: ${err}`);
throw err;
}
}

await cached_eczoodb.load();
try {

await cached_eczoodb.load();

} catch (err) {
console.error(err);
console.err(`ERROR LOADING ZOO: ${err}`);
throw err;
}

return cached_eczoodb;
};
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ __metadata:

"@phfaist/zoodb@https://github.com/phfaist/zoodb.git#main":
version: 0.1.1
resolution: "@phfaist/zoodb@https://github.com/phfaist/zoodb.git#commit=05d73422d87d8cd07e0d92825785a46e684e8dc2"
resolution: "@phfaist/zoodb@https://github.com/phfaist/zoodb.git#commit=1cbbfd090565b92d6eaa4b4d53c7e9661f90e18f"
dependencies:
"@apidevtools/json-schema-ref-parser": ^10.1.0
base32-encode: ^2.0.0
Expand All @@ -1915,13 +1915,13 @@ __metadata:
stream-parser: ^0.3.1
tippy.js: ^6.3.7
url: ^0.11.0
checksum: 934416aaa0ffa462ec96a44ea459aad58f39bf26dcd7799170ec50b0bae206d6f21a1d7ca38cdfaecb60d58a68eb4bc8a9ec00b305824ec1d9242ece5ccb6449
checksum: 2852ab130bbe35afd63e872c61f6420f506d9a60ec903f0dd4aa87bd07e055f7e9a799a4fc194e2afc1d0f21f773586183a9cbc602ff9ca84da8645c57976537
languageName: node
linkType: hard

"@phfaist/zoodbtools_preview@https://github.com/phfaist/zoodbtools.git#head=main&workspace=zoodbtools_preview":
version: 0.1.0
resolution: "@phfaist/zoodbtools_preview@https://github.com/phfaist/zoodbtools.git#workspace=zoodbtools_preview&commit=513f049b5969768c404778636a9aa5ae8a977615"
resolution: "@phfaist/zoodbtools_preview@https://github.com/phfaist/zoodbtools.git#workspace=zoodbtools_preview&commit=9f2c86132a64569e4772e6603b2491c7c7359c2f"
dependencies:
debug: ^4.3.4
escape-html: ^1.0.3
Expand All @@ -1931,13 +1931,13 @@ __metadata:
react-select: ^5.7.4
peerDependencies:
"@phfaist/zoodb": "*"
checksum: 16dc7f4084b1c46a1f817ff4604cb14a7de34e2afa38639abff7cd4bca4241c32ab545c702980965b9b5c6ae39c7c6da3e012cb843c6ab7d3a71e9c17048cc56
checksum: 73cbd526fb7749e0576fd61b76978f6b3d968796652c4b68455514c22a5f55eb871cff53efd36a25505f0095e2140ecaae5eb7a080af1b424cac504331788a6a
languageName: node
linkType: hard

"@phfaist/zoodbtools_previewremote@https://github.com/phfaist/zoodbtools.git#head=main&workspace=zoodbtools_previewremote":
version: 0.1.0
resolution: "@phfaist/zoodbtools_previewremote@https://github.com/phfaist/zoodbtools.git#workspace=zoodbtools_previewremote&commit=513f049b5969768c404778636a9aa5ae8a977615"
resolution: "@phfaist/zoodbtools_previewremote@https://github.com/phfaist/zoodbtools.git#workspace=zoodbtools_previewremote&commit=9f2c86132a64569e4772e6603b2491c7c7359c2f"
dependencies:
debug: ^4.3.4
fs-remote: ^0.1.9
Expand Down

0 comments on commit cc9f774

Please sign in to comment.