mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-06-21 00:26:39 +02:00
Expand and use default dictionary and Updater
This commit is contained in:
parent
97170803fa
commit
9b7e797aef
4 changed files with 124 additions and 28 deletions
|
@ -27,29 +27,8 @@ export const MainDisplay = ({ dictionaryInfo, wordsToDisplay, updateDisplay, upd
|
||||||
specification={ dictionaryInfo.specification }
|
specification={ dictionaryInfo.specification }
|
||||||
description={ dictionaryInfo.description }
|
description={ dictionaryInfo.description }
|
||||||
partsOfSpeech={ dictionaryInfo.partsOfSpeech }
|
partsOfSpeech={ dictionaryInfo.partsOfSpeech }
|
||||||
alphabeticalOrder={['b', 'p', 't', 'd', 'a', 'o', 'j', 'e']}
|
details={ dictionaryInfo.details }
|
||||||
details={{
|
alphabeticalOrder={ dictionaryInfo.alphabeticalOrder }
|
||||||
phonology: {
|
|
||||||
consonants: ['b', 'p', 'd', 't', 'j'],
|
|
||||||
vowels: ['a', 'o', 'e'],
|
|
||||||
blends: ['ae', 'oe', 'tj', 'dy'],
|
|
||||||
phonotactics: {
|
|
||||||
onset: ['b', 'p', 'j'],
|
|
||||||
nucleus: ['a', 'o', 'e'],
|
|
||||||
coda: ['any'],
|
|
||||||
exceptions: 'There are no exceptions',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
grammar: {
|
|
||||||
content: 'The rules of the language are simple: just follow them!'
|
|
||||||
},
|
|
||||||
custom: [
|
|
||||||
{
|
|
||||||
name: 'Test Tab',
|
|
||||||
content: 'This is a test tab to test how custom tabs work!',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<WordsList
|
<WordsList
|
||||||
|
|
|
@ -24,6 +24,9 @@ class App extends Component {
|
||||||
specification: dictionary.specification,
|
specification: dictionary.specification,
|
||||||
description: dictionary.description,
|
description: dictionary.description,
|
||||||
partsOfSpeech: dictionary.partsOfSpeech,
|
partsOfSpeech: dictionary.partsOfSpeech,
|
||||||
|
details: dictionary.details,
|
||||||
|
alphabeticalOrder: dictionary.alphabeticalOrder,
|
||||||
|
|
||||||
displayedWords: [],
|
displayedWords: [],
|
||||||
searchConfig: null,
|
searchConfig: null,
|
||||||
}
|
}
|
||||||
|
@ -32,15 +35,23 @@ class App extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
get dictionaryInfo () {
|
get dictionaryInfo () {
|
||||||
const { name, specification, description, partsOfSpeech } = this.state;
|
const {
|
||||||
const info = {
|
|
||||||
name,
|
name,
|
||||||
specification,
|
specification,
|
||||||
description,
|
description,
|
||||||
partsOfSpeech,
|
partsOfSpeech,
|
||||||
};
|
details,
|
||||||
|
alphabeticalOrder,
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
return info;
|
return {
|
||||||
|
name,
|
||||||
|
specification,
|
||||||
|
description,
|
||||||
|
partsOfSpeech,
|
||||||
|
details,
|
||||||
|
alphabeticalOrder,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePartsOfSpeech () {
|
updatePartsOfSpeech () {
|
||||||
|
|
|
@ -8,10 +8,38 @@ const defaultDictionary = {
|
||||||
specification: 'Dictionary',
|
specification: 'Dictionary',
|
||||||
description: 'A new dictionary.',
|
description: 'A new dictionary.',
|
||||||
partsOfSpeech: ['Noun', 'Adjective', 'Verb'],
|
partsOfSpeech: ['Noun', 'Adjective', 'Verb'],
|
||||||
}
|
details: {
|
||||||
|
phonology: {
|
||||||
|
consonants: ['b', 'p', 'ɱ', 'ʃ', 'ʁ'],
|
||||||
|
vowels: ['a', 'o', 'e'],
|
||||||
|
blends: ['ae', 'oe', 'ɱʃ', 'pʁ'],
|
||||||
|
phonotactics: {
|
||||||
|
onset: ['none'],
|
||||||
|
nucleus: ['vowels'],
|
||||||
|
coda: ['any'],
|
||||||
|
exceptions: `You can enter exceptions to your phonotactics here using [Markdown](MARKDOWN_LINK)!`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orthography: {
|
||||||
|
notes: `You can enter notes on orthography here using [Markdown](MARKDOWN_LINK)!`
|
||||||
|
},
|
||||||
|
grammar: {
|
||||||
|
content: `You can enter grammar rules about your language here using [Markdown](MARKDOWN_LINK)!`,
|
||||||
|
},
|
||||||
|
custom: [
|
||||||
|
{
|
||||||
|
name: 'Example Tab',
|
||||||
|
content: `This is an _example_ tab to show how **tabs** work with [Markdown](MARKDOWN_LINK)!`,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alphabeticalOrder: ['b', 'p', 't', 'd', 'a', 'o', 'j', 'e'],
|
||||||
|
};
|
||||||
|
|
||||||
class DictionaryData {
|
class DictionaryData {
|
||||||
constructor () {
|
constructor () {
|
||||||
|
this.default = defaultDictionary;
|
||||||
|
|
||||||
if (['emptydb', 'donotsave'].includes(process.env.NODE_ENV)) {
|
if (['emptydb', 'donotsave'].includes(process.env.NODE_ENV)) {
|
||||||
store.remove('Lexiconga');
|
store.remove('Lexiconga');
|
||||||
}
|
}
|
||||||
|
@ -80,6 +108,67 @@ class DictionaryData {
|
||||||
return store.set('Lexiconga', updatedValues);
|
return store.set('Lexiconga', updatedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get details () {
|
||||||
|
return store.get('Lexiconga').details
|
||||||
|
|| defaultDictionary.details;
|
||||||
|
}
|
||||||
|
|
||||||
|
get consonants () {
|
||||||
|
return store.get('Lexiconga').details.phonology.consonants
|
||||||
|
|| defaultDictionary.details.phonology.consonants;
|
||||||
|
}
|
||||||
|
|
||||||
|
set consonants (array) {
|
||||||
|
assert(Array.isArray(array), 'Consonants must be passed as an array');
|
||||||
|
const updatedValues = store.get('Lexiconga');
|
||||||
|
updatedValues.details.phonology.consonants = array
|
||||||
|
.filter((value) => { return value !== '' })
|
||||||
|
.map((value) => { return value.trim() });
|
||||||
|
return store.set('Lexiconga', updatedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
get vowels () {
|
||||||
|
return store.get('Lexiconga').details.phonology.vowels
|
||||||
|
|| defaultDictionary.details.phonology.vowels;
|
||||||
|
}
|
||||||
|
|
||||||
|
set vowels (array) {
|
||||||
|
assert(Array.isArray(array), 'Vowels must be passed as an array');
|
||||||
|
const updatedValues = store.get('Lexiconga');
|
||||||
|
updatedValues.details.phonology.vowels = array
|
||||||
|
.filter((value) => { return value !== '' })
|
||||||
|
.map((value) => { return value.trim() });
|
||||||
|
return store.set('Lexiconga', updatedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
get blends () {
|
||||||
|
return store.get('Lexiconga').details.phonology.blends
|
||||||
|
|| defaultDictionary.details.phonology.blends;
|
||||||
|
}
|
||||||
|
|
||||||
|
set blends (array) {
|
||||||
|
assert(Array.isArray(array), 'Blends must be passed as an array');
|
||||||
|
const updatedValues = store.get('Lexiconga');
|
||||||
|
updatedValues.details.phonology.blends = array
|
||||||
|
.filter((value) => { return value !== '' })
|
||||||
|
.map((value) => { return value.trim() });
|
||||||
|
return store.set('Lexiconga', updatedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
get alphabeticalOrder () {
|
||||||
|
return store.get('Lexiconga').alphabeticalOrder
|
||||||
|
|| defaultDictionary.alphabeticalOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
set alphabeticalOrder (array) {
|
||||||
|
assert(Array.isArray(array), 'Parts of Speech must be passed as an array');
|
||||||
|
const updatedValues = store.get('Lexiconga');
|
||||||
|
updatedValues.alphabeticalOrder = array
|
||||||
|
.filter((value) => { return value !== '' })
|
||||||
|
.map((value) => { return value.trim() });
|
||||||
|
return store.set('Lexiconga', updatedValues);
|
||||||
|
}
|
||||||
|
|
||||||
get wordsPromise () {
|
get wordsPromise () {
|
||||||
return wordDb.words.toArray();
|
return wordDb.words.toArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,23 @@ export class Updater {
|
||||||
this.dictionary.partsOfSpeech = dicitonaryDetails.partsOfSpeech;
|
this.dictionary.partsOfSpeech = dicitonaryDetails.partsOfSpeech;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dicitonaryDetails.consonants) {
|
||||||
|
this.dictionary.consonants = dicitonaryDetails.consonants;
|
||||||
|
updatedDetails['details'] = this.dictionary.details;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dicitonaryDetails.vowels) {
|
||||||
|
this.dictionary.vowels = dicitonaryDetails.vowels;
|
||||||
|
updatedDetails['details'] = this.dictionary.details;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dicitonaryDetails.blends) {
|
||||||
|
this.dictionary.blends = dicitonaryDetails.blends;
|
||||||
|
updatedDetails['details'] = this.dictionary.details;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(updatedDetails);
|
||||||
|
|
||||||
if (updatedDetails.isEmpty()) {
|
if (updatedDetails.isEmpty()) {
|
||||||
reject('No dictionary details have changed.');
|
reject('No dictionary details have changed.');
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue