diff --git a/dev/dictionary-validate.js b/dev/dictionary-validate.js index 26c8185b..873bcb8a 100644 --- a/dev/dictionary-validate.js +++ b/dev/dictionary-validate.js @@ -71,14 +71,14 @@ async function validateDictionary(archive, schemas) { function getSchemas() { return { - index: readSchema('../ext/bg/data/dictionary-index-schema.json'), - kanjiBankV1: readSchema('../ext/bg/data/dictionary-kanji-bank-v1-schema.json'), - kanjiBankV3: readSchema('../ext/bg/data/dictionary-kanji-bank-v3-schema.json'), - kanjiMetaBankV3: readSchema('../ext/bg/data/dictionary-kanji-meta-bank-v3-schema.json'), - tagBankV3: readSchema('../ext/bg/data/dictionary-tag-bank-v3-schema.json'), - termBankV1: readSchema('../ext/bg/data/dictionary-term-bank-v1-schema.json'), - termBankV3: readSchema('../ext/bg/data/dictionary-term-bank-v3-schema.json'), - termMetaBankV3: readSchema('../ext/bg/data/dictionary-term-meta-bank-v3-schema.json') + index: readSchema('../ext/data/schemas/dictionary-index-schema.json'), + kanjiBankV1: readSchema('../ext/data/schemas/dictionary-kanji-bank-v1-schema.json'), + kanjiBankV3: readSchema('../ext/data/schemas/dictionary-kanji-bank-v3-schema.json'), + kanjiMetaBankV3: readSchema('../ext/data/schemas/dictionary-kanji-meta-bank-v3-schema.json'), + tagBankV3: readSchema('../ext/data/schemas/dictionary-tag-bank-v3-schema.json'), + termBankV1: readSchema('../ext/data/schemas/dictionary-term-bank-v1-schema.json'), + termBankV3: readSchema('../ext/data/schemas/dictionary-term-bank-v3-schema.json'), + termMetaBankV3: readSchema('../ext/data/schemas/dictionary-term-meta-bank-v3-schema.json') }; } diff --git a/ext/bg/js/audio-downloader.js b/ext/bg/js/audio-downloader.js index 25c25250..4e77419b 100644 --- a/ext/bg/js/audio-downloader.js +++ b/ext/bg/js/audio-downloader.js @@ -300,7 +300,7 @@ class AudioDownloader { async _getCustomAudioListSchema() { let schema = this._customAudioListSchema; 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, { method: 'GET', mode: 'no-cors', diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 3dd1955f..3970fe2d 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -211,7 +211,7 @@ class Backend { this._translator.prepare(deinflectionReasions); 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._applyOptions('background'); diff --git a/ext/bg/js/dictionary-importer.js b/ext/bg/js/dictionary-importer.js index 33870259..4cb608db 100644 --- a/ext/bg/js/dictionary-importer.js +++ b/ext/bg/js/dictionary-importer.js @@ -50,7 +50,7 @@ class DictionaryImporter { 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); const dictionaryTitle = index.title; @@ -280,17 +280,17 @@ class DictionaryImporter { _getDataBankSchemaPaths(version) { const termBank = ( version === 1 ? - '/bg/data/dictionary-term-bank-v1-schema.json' : - '/bg/data/dictionary-term-bank-v3-schema.json' + '/data/schemas/dictionary-term-bank-v1-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 = ( version === 1 ? - '/bg/data/dictionary-kanji-bank-v1-schema.json' : - '/bg/data/dictionary-kanji-bank-v3-schema.json' + '/data/schemas/dictionary-kanji-bank-v1-schema.json' : + '/data/schemas/dictionary-kanji-bank-v3-schema.json' ); - const kanjiMetaBank = '/bg/data/dictionary-kanji-meta-bank-v3-schema.json'; - const tagBank = '/bg/data/dictionary-tag-bank-v3-schema.json'; + const kanjiMetaBank = '/data/schemas/dictionary-kanji-meta-bank-v3-schema.json'; + const tagBank = '/data/schemas/dictionary-tag-bank-v3-schema.json'; return [termBank, termMetaBank, kanjiBank, kanjiMetaBank, tagBank]; } diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 9e0e9cf0..1105dfed 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -28,7 +28,7 @@ class OptionsUtil { } 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) { @@ -487,7 +487,7 @@ class OptionsUtil { async _updateVersion3(options) { // Version 3 changes: // 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; } @@ -572,7 +572,7 @@ class OptionsUtil { }); 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; } @@ -592,7 +592,7 @@ class OptionsUtil { // Added global option useSettingsV2. // Added anki.checkForDuplicates. // 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.useSettingsV2 = false; 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.maximumClipboardSearchLength => clipboard.maximumSearchLength. // 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; for (const profile of options.profiles) { profile.options.translation.textReplacements = { diff --git a/ext/bg/settings2.html b/ext/bg/settings2.html index 88a55206..37bb1996 100644 --- a/ext/bg/settings2.html +++ b/ext/bg/settings2.html @@ -2283,7 +2283,7 @@
  • JSON - 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 this schema file. + The format of the JSON file is specified in this schema file.
  • diff --git a/ext/bg/data/custom-audio-list-schema.json b/ext/data/schemas/custom-audio-list-schema.json similarity index 100% rename from ext/bg/data/custom-audio-list-schema.json rename to ext/data/schemas/custom-audio-list-schema.json diff --git a/ext/bg/data/dictionary-index-schema.json b/ext/data/schemas/dictionary-index-schema.json similarity index 100% rename from ext/bg/data/dictionary-index-schema.json rename to ext/data/schemas/dictionary-index-schema.json diff --git a/ext/bg/data/dictionary-kanji-bank-v1-schema.json b/ext/data/schemas/dictionary-kanji-bank-v1-schema.json similarity index 100% rename from ext/bg/data/dictionary-kanji-bank-v1-schema.json rename to ext/data/schemas/dictionary-kanji-bank-v1-schema.json diff --git a/ext/bg/data/dictionary-kanji-bank-v3-schema.json b/ext/data/schemas/dictionary-kanji-bank-v3-schema.json similarity index 100% rename from ext/bg/data/dictionary-kanji-bank-v3-schema.json rename to ext/data/schemas/dictionary-kanji-bank-v3-schema.json diff --git a/ext/bg/data/dictionary-kanji-meta-bank-v3-schema.json b/ext/data/schemas/dictionary-kanji-meta-bank-v3-schema.json similarity index 100% rename from ext/bg/data/dictionary-kanji-meta-bank-v3-schema.json rename to ext/data/schemas/dictionary-kanji-meta-bank-v3-schema.json diff --git a/ext/bg/data/dictionary-tag-bank-v3-schema.json b/ext/data/schemas/dictionary-tag-bank-v3-schema.json similarity index 100% rename from ext/bg/data/dictionary-tag-bank-v3-schema.json rename to ext/data/schemas/dictionary-tag-bank-v3-schema.json diff --git a/ext/bg/data/dictionary-term-bank-v1-schema.json b/ext/data/schemas/dictionary-term-bank-v1-schema.json similarity index 100% rename from ext/bg/data/dictionary-term-bank-v1-schema.json rename to ext/data/schemas/dictionary-term-bank-v1-schema.json diff --git a/ext/bg/data/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json similarity index 100% rename from ext/bg/data/dictionary-term-bank-v3-schema.json rename to ext/data/schemas/dictionary-term-bank-v3-schema.json diff --git a/ext/bg/data/dictionary-term-meta-bank-v3-schema.json b/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json similarity index 100% rename from ext/bg/data/dictionary-term-meta-bank-v3-schema.json rename to ext/data/schemas/dictionary-term-meta-bank-v3-schema.json diff --git a/ext/bg/data/options-schema.json b/ext/data/schemas/options-schema.json similarity index 100% rename from ext/bg/data/options-schema.json rename to ext/data/schemas/options-schema.json diff --git a/ext/bg/data/anki-field-templates-upgrade-v2.handlebars b/ext/data/templates/anki-field-templates-upgrade-v2.handlebars similarity index 100% rename from ext/bg/data/anki-field-templates-upgrade-v2.handlebars rename to ext/data/templates/anki-field-templates-upgrade-v2.handlebars diff --git a/ext/bg/data/anki-field-templates-upgrade-v4.handlebars b/ext/data/templates/anki-field-templates-upgrade-v4.handlebars similarity index 100% rename from ext/bg/data/anki-field-templates-upgrade-v4.handlebars rename to ext/data/templates/anki-field-templates-upgrade-v4.handlebars diff --git a/ext/bg/data/anki-field-templates-upgrade-v6.handlebars b/ext/data/templates/anki-field-templates-upgrade-v6.handlebars similarity index 100% rename from ext/bg/data/anki-field-templates-upgrade-v6.handlebars rename to ext/data/templates/anki-field-templates-upgrade-v6.handlebars diff --git a/ext/bg/data/anki-field-templates-upgrade-v8.handlebars b/ext/data/templates/anki-field-templates-upgrade-v8.handlebars similarity index 100% rename from ext/bg/data/anki-field-templates-upgrade-v8.handlebars rename to ext/data/templates/anki-field-templates-upgrade-v8.handlebars diff --git a/ext/bg/data/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars similarity index 100% rename from ext/bg/data/default-anki-field-templates.handlebars rename to ext/data/templates/default-anki-field-templates.handlebars diff --git a/test/test-options-util.js b/test/test-options-util.js index 310e3d88..e4bc4e94 100644 --- a/test/test-options-util.js +++ b/test/test-options-util.js @@ -620,10 +620,10 @@ async function testFieldTemplatesUpdate(extDir) { const content = fs.readFileSync(path.join(extDir, fileName), {encoding: 'utf8'}); return templatePatcher.parsePatch(content).addition; }; - const update2 = loadDataFile('bg/data/anki-field-templates-upgrade-v2.handlebars'); - const update4 = loadDataFile('bg/data/anki-field-templates-upgrade-v4.handlebars'); - const update6 = loadDataFile('bg/data/anki-field-templates-upgrade-v6.handlebars'); - const update8 = loadDataFile('bg/data/anki-field-templates-upgrade-v8.handlebars'); + const update2 = loadDataFile('data/templates/anki-field-templates-upgrade-v2.handlebars'); + const update4 = loadDataFile('data/templates/anki-field-templates-upgrade-v4.handlebars'); + const update6 = loadDataFile('data/templates/anki-field-templates-upgrade-v6.handlebars'); + const update8 = loadDataFile('data/templates/anki-field-templates-upgrade-v8.handlebars'); const data = [ // Standard format