Move data folder (#1371)

* Move handlebars template files

* Move schema files
This commit is contained in:
toasted-nutbread 2021-02-12 19:56:24 -05:00 committed by GitHub
parent 37f9161718
commit 2b4af57bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 28 additions and 28 deletions

View File

@ -71,14 +71,14 @@ async function validateDictionary(archive, schemas) {
function getSchemas() { function getSchemas() {
return { return {
index: readSchema('../ext/bg/data/dictionary-index-schema.json'), index: readSchema('../ext/data/schemas/dictionary-index-schema.json'),
kanjiBankV1: readSchema('../ext/bg/data/dictionary-kanji-bank-v1-schema.json'), kanjiBankV1: readSchema('../ext/data/schemas/dictionary-kanji-bank-v1-schema.json'),
kanjiBankV3: readSchema('../ext/bg/data/dictionary-kanji-bank-v3-schema.json'), kanjiBankV3: readSchema('../ext/data/schemas/dictionary-kanji-bank-v3-schema.json'),
kanjiMetaBankV3: readSchema('../ext/bg/data/dictionary-kanji-meta-bank-v3-schema.json'), kanjiMetaBankV3: readSchema('../ext/data/schemas/dictionary-kanji-meta-bank-v3-schema.json'),
tagBankV3: readSchema('../ext/bg/data/dictionary-tag-bank-v3-schema.json'), tagBankV3: readSchema('../ext/data/schemas/dictionary-tag-bank-v3-schema.json'),
termBankV1: readSchema('../ext/bg/data/dictionary-term-bank-v1-schema.json'), termBankV1: readSchema('../ext/data/schemas/dictionary-term-bank-v1-schema.json'),
termBankV3: readSchema('../ext/bg/data/dictionary-term-bank-v3-schema.json'), termBankV3: readSchema('../ext/data/schemas/dictionary-term-bank-v3-schema.json'),
termMetaBankV3: readSchema('../ext/bg/data/dictionary-term-meta-bank-v3-schema.json') termMetaBankV3: readSchema('../ext/data/schemas/dictionary-term-meta-bank-v3-schema.json')
}; };
} }

View File

@ -300,7 +300,7 @@ class AudioDownloader {
async _getCustomAudioListSchema() { async _getCustomAudioListSchema() {
let schema = this._customAudioListSchema; let schema = this._customAudioListSchema;
if (schema === null) { if (schema === null) {
const url = chrome.runtime.getURL('/bg/data/custom-audio-list-schema.json'); const url = chrome.runtime.getURL('/data/schemas/custom-audio-list-schema.json');
const response = await fetch(url, { const response = await fetch(url, {
method: 'GET', method: 'GET',
mode: 'no-cors', mode: 'no-cors',

View File

@ -211,7 +211,7 @@ class Backend {
this._translator.prepare(deinflectionReasions); this._translator.prepare(deinflectionReasions);
await this._optionsUtil.prepare(); await this._optionsUtil.prepare();
this._defaultAnkiFieldTemplates = (await this._fetchAsset('/bg/data/default-anki-field-templates.handlebars')).trim(); this._defaultAnkiFieldTemplates = (await this._fetchAsset('/data/templates/default-anki-field-templates.handlebars')).trim();
this._options = await this._optionsUtil.load(); this._options = await this._optionsUtil.load();
this._applyOptions('background'); this._applyOptions('background');

View File

@ -50,7 +50,7 @@ class DictionaryImporter {
const index = JSON.parse(await indexFile.async('string')); const index = JSON.parse(await indexFile.async('string'));
const indexSchema = await this._getSchema('/bg/data/dictionary-index-schema.json'); const indexSchema = await this._getSchema('/data/schemas/dictionary-index-schema.json');
this._validateJsonSchema(index, indexSchema, indexFileName); this._validateJsonSchema(index, indexSchema, indexFileName);
const dictionaryTitle = index.title; const dictionaryTitle = index.title;
@ -280,17 +280,17 @@ class DictionaryImporter {
_getDataBankSchemaPaths(version) { _getDataBankSchemaPaths(version) {
const termBank = ( const termBank = (
version === 1 ? version === 1 ?
'/bg/data/dictionary-term-bank-v1-schema.json' : '/data/schemas/dictionary-term-bank-v1-schema.json' :
'/bg/data/dictionary-term-bank-v3-schema.json' '/data/schemas/dictionary-term-bank-v3-schema.json'
); );
const termMetaBank = '/bg/data/dictionary-term-meta-bank-v3-schema.json'; const termMetaBank = '/data/schemas/dictionary-term-meta-bank-v3-schema.json';
const kanjiBank = ( const kanjiBank = (
version === 1 ? version === 1 ?
'/bg/data/dictionary-kanji-bank-v1-schema.json' : '/data/schemas/dictionary-kanji-bank-v1-schema.json' :
'/bg/data/dictionary-kanji-bank-v3-schema.json' '/data/schemas/dictionary-kanji-bank-v3-schema.json'
); );
const kanjiMetaBank = '/bg/data/dictionary-kanji-meta-bank-v3-schema.json'; const kanjiMetaBank = '/data/schemas/dictionary-kanji-meta-bank-v3-schema.json';
const tagBank = '/bg/data/dictionary-tag-bank-v3-schema.json'; const tagBank = '/data/schemas/dictionary-tag-bank-v3-schema.json';
return [termBank, termMetaBank, kanjiBank, kanjiMetaBank, tagBank]; return [termBank, termMetaBank, kanjiBank, kanjiMetaBank, tagBank];
} }

View File

@ -28,7 +28,7 @@ class OptionsUtil {
} }
async prepare() { async prepare() {
this._optionsSchema = await this._fetchAsset('/bg/data/options-schema.json', true); this._optionsSchema = await this._fetchAsset('/data/schemas/options-schema.json', true);
} }
async update(options) { async update(options) {
@ -487,7 +487,7 @@ class OptionsUtil {
async _updateVersion3(options) { async _updateVersion3(options) {
// Version 3 changes: // Version 3 changes:
// Pitch accent Anki field templates added. // Pitch accent Anki field templates added.
await this._applyAnkiFieldTemplatesPatch(options, '/bg/data/anki-field-templates-upgrade-v2.handlebars'); await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v2.handlebars');
return options; return options;
} }
@ -572,7 +572,7 @@ class OptionsUtil {
}); });
profileOptions.scanning.inputs = scanningInputs; profileOptions.scanning.inputs = scanningInputs;
} }
await this._applyAnkiFieldTemplatesPatch(options, '/bg/data/anki-field-templates-upgrade-v4.handlebars'); await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v4.handlebars');
return options; return options;
} }
@ -592,7 +592,7 @@ class OptionsUtil {
// Added global option useSettingsV2. // Added global option useSettingsV2.
// Added anki.checkForDuplicates. // Added anki.checkForDuplicates.
// Added general.glossaryLayoutMode; removed general.compactGlossaries. // Added general.glossaryLayoutMode; removed general.compactGlossaries.
await this._applyAnkiFieldTemplatesPatch(options, '/bg/data/anki-field-templates-upgrade-v6.handlebars'); await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v6.handlebars');
options.global.showPopupPreview = false; options.global.showPopupPreview = false;
options.global.useSettingsV2 = false; options.global.useSettingsV2 = false;
for (const profile of options.profiles) { for (const profile of options.profiles) {
@ -665,7 +665,7 @@ class OptionsUtil {
// Moved general.enableClipboardMonitor => clipboard.enableSearchPageMonitor. Forced value to false due to a bug which caused its value to not be read. // Moved general.enableClipboardMonitor => clipboard.enableSearchPageMonitor. Forced value to false due to a bug which caused its value to not be read.
// Moved general.maximumClipboardSearchLength => clipboard.maximumSearchLength. // Moved general.maximumClipboardSearchLength => clipboard.maximumSearchLength.
// Added clipboard.autoSearchContent. // Added clipboard.autoSearchContent.
await this._applyAnkiFieldTemplatesPatch(options, '/bg/data/anki-field-templates-upgrade-v8.handlebars'); await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v8.handlebars');
options.global.useSettingsV2 = true; options.global.useSettingsV2 = true;
for (const profile of options.profiles) { for (const profile of options.profiles) {
profile.options.translation.textReplacements = { profile.options.translation.textReplacements = {

View File

@ -2283,7 +2283,7 @@
</li> </li>
<li> <li>
<strong>JSON</strong> - The link is interpreted as a link to a JSON file, which is downloaded and parsed for audio URLs. <strong>JSON</strong> - The link is interpreted as a link to a JSON file, which is downloaded and parsed for audio URLs.
The format of the JSON file is specified in <a href="/bg/data/custom-audio-list-schema.json" target="_blank" rel="noopener noreferrer">this schema file</a>. The format of the JSON file is specified in <a href="/data/schemas/custom-audio-list-schema.json" target="_blank" rel="noopener noreferrer">this schema file</a>.
</li> </li>
</ul> </ul>
<p> <p>

View File

@ -620,10 +620,10 @@ async function testFieldTemplatesUpdate(extDir) {
const content = fs.readFileSync(path.join(extDir, fileName), {encoding: 'utf8'}); const content = fs.readFileSync(path.join(extDir, fileName), {encoding: 'utf8'});
return templatePatcher.parsePatch(content).addition; return templatePatcher.parsePatch(content).addition;
}; };
const update2 = loadDataFile('bg/data/anki-field-templates-upgrade-v2.handlebars'); const update2 = loadDataFile('data/templates/anki-field-templates-upgrade-v2.handlebars');
const update4 = loadDataFile('bg/data/anki-field-templates-upgrade-v4.handlebars'); const update4 = loadDataFile('data/templates/anki-field-templates-upgrade-v4.handlebars');
const update6 = loadDataFile('bg/data/anki-field-templates-upgrade-v6.handlebars'); const update6 = loadDataFile('data/templates/anki-field-templates-upgrade-v6.handlebars');
const update8 = loadDataFile('bg/data/anki-field-templates-upgrade-v8.handlebars'); const update8 = loadDataFile('data/templates/anki-field-templates-upgrade-v8.handlebars');
const data = [ const data = [
// Standard format // Standard format