#95 [refactor] rename "template" to "pronoun"

This commit is contained in:
Avris 2020-11-11 00:47:44 +01:00
parent 629a12698e
commit e3cd8956d6
48 changed files with 433 additions and 417 deletions

View File

@ -1,11 +1,11 @@
<template>
<span>
<span v-for="part in example[(example.isHonorific ? template.isPluralHonorific(counter) : template.isPlural(counter)) ? 'pluralParts' : 'singularParts']">
<strong v-if="part.variable">{{template.getMorpheme(part.str, counter)}}</strong>
<span v-for="part in example[(example.isHonorific ? pronoun.isPluralHonorific(counter) : pronoun.isPlural(counter)) ? 'pluralParts' : 'singularParts']">
<strong v-if="part.variable">{{pronoun.getMorpheme(part.str, counter)}}</strong>
<span v-else>{{part.str}}</span>
</span>
<small v-if="link">
(<nuxt-link :to="'/' + template.canonicalName">{{ template.canonicalName }}</nuxt-link>)
(<nuxt-link :to="'/' + pronoun.canonicalName">{{ pronoun.canonicalName }}</nuxt-link>)
</small>
</span>
</template>
@ -14,7 +14,7 @@
export default {
props: {
example: { required: true },
template: { required: true },
pronoun: { required: true },
counter: { default: 0 },
link: { type: Boolean },
}

View File

@ -62,7 +62,7 @@
icon: 'home',
text: this.$t('home.header'),
textLong: this.$t('home.headerLong'),
extra: ['all', this.config.template.any.route],
extra: ['all', this.config.pronouns.any.route],
});
if (this.config.sources.enabled) {

View File

@ -11,12 +11,12 @@
<h3 class="h5">
<nuxt-link :to="'/' + option">
<span v-if="option.includes('&')">
<T>template.alt.header</T>
<T>pronouns.alt.header</T>
<small>({{ option.replace(/&/g, glue) }})</small>
</span>
<span v-else>
{{ getTemplate(templates, option).description }}
<small>({{ getTemplate(templates, option).name(glue) }})</small>
{{ getPronoun(pronouns, option).description }}
<small>({{ getPronoun(pronouns, option).name(glue) }})</small>
</span>
</nuxt-link>
</h3>
@ -27,8 +27,8 @@
</template>
<script>
import { templates } from "../src/data";
import { getTemplate } from "../src/buildTemplate";
import { pronouns } from "../src/data";
import { getPronoun } from "../src/buildPronoun";
export default {
props: {
@ -36,9 +36,9 @@
},
data() {
return {
templates: templates,
getTemplate: getTemplate,
glue: ' ' + this.$t('template.or') + ' ',
pronouns,
getPronoun: getPronoun,
glue: ' ' + this.$t('pronouns.or') + ' ',
}
}
}

View File

@ -1,7 +1,7 @@
<template>
<span class="badge badge-secondary toggle-hover">
<Icon v="book-open"/>
<span class="togglable"><T>template.normative</T></span>
<span class="togglable"><T>pronouns.normative</T></span>
</span>
</template>

View File

@ -37,7 +37,7 @@
required maxlength="255"/>
</div>
<div class="form-group">
<label for="templates"><T>sources.submit.extra</T></label>
<label for="pronouns"><T>sources.submit.extra</T></label>
<input type="text" id="extra" class="form-control" v-model="form.extra"
maxlength="255"/>
</div>
@ -53,8 +53,8 @@
</ListInput>
</div>
<div class="form-group">
<label for="templates" class="required"><T>sources.submit.templates</T></label>
<input type="text" id="templates" class="form-control" v-model="form.templates"
<label for="pronouns" class="required"><T>sources.submit.pronouns</T></label>
<input type="text" id="pronouns" class="form-control" v-model="form.pronouns"
required maxlength="255"/>
</div>
<div class="form-group">
@ -82,7 +82,7 @@
data() {
return {
form: {
templates: '',
pronouns: '',
type: '',
author: '',
title: '',
@ -105,7 +105,7 @@
this.submitting = false;
this.afterSubmit = true;
this.form = {
templates: '',
pronouns: '',
type: '',
author: '',
title: '',

View File

@ -2,7 +2,7 @@ locale: '_'
header: false
template:
pronouns:
enabled: false
sources:

View File

@ -5,7 +5,7 @@
<script>
export default {
props: {
selectedTemplate: { required: true },
selectedPronoun: { required: true },
counter: { required: true },
}
}

View File

@ -1,4 +1,4 @@
name templates description
name pronouns description
Normative forms he,she Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć.
Neutral forms they Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników.
Formy wymienne he&she,he&they,she&they Wiele osób niebinarnych używa zamiennie więcej niż jednej formy (np. męskich i żeńskich albo żeńskich i nijakich) i można się do nich zwracać w dowolnej z nich.
Can't render this file because it contains an unexpected character in line 3 and column 240.

View File

@ -1,7 +1,7 @@
title: 'Pronouns.page'
description: 'Usage examples of personal pronouns and gender neutral language.'
template:
pronouns:
or: 'or'
notFound:

View File

@ -2,7 +2,7 @@ locale: 'en'
header: true
template:
pronouns:
enabled: true
default: 'he'
any:
@ -112,3 +112,16 @@ profile:
- ['partner', 'boyfriend', 'girlfriend', 'joyfriend', 'husband', 'wife', 'kissmate']
redirects: []
api:
examples:
pronouns_all: ['/api/pronouns']
pronouns_one:
- '/api/pronouns/she/her'
- '/api/pronouns/she/her?examples[]=Did%20you%20ask%20%7Bpronoun_object%7D%20to%20join%20us%3F'
sources_all: ['/api/sources']
sources_one: ['/api/sources/queerZaimki'] # TODO
nouns_all: ['/api/nouns']
nouns_search: ['/api/nouns/search/person']

View File

@ -18,11 +18,11 @@
</thead>
<tbody>
<tr>
<td>{{ selectedTemplate.getMorpheme('pronoun_subject', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_object', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('possessive_determiner', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('possessive_pronoun', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('reflexive', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_subject', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_object', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('possessive_determiner', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('possessive_pronoun', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('reflexive', counter) }}</td>
</tr>
</tbody>
</table>
@ -33,7 +33,7 @@
<script>
export default {
props: {
selectedTemplate: { required: true },
selectedPronoun: { required: true },
counter: { required: true },
}
}

View File

@ -1,4 +1,4 @@
name templates description
name pronouns description
Normative forms he,she Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć.
Neutral forms they Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników.
Formy wymienne he&she,he&they,she&they Wiele osób niebinarnych używa zamiennie więcej niż jednej formy (np. męskich i żeńskich albo żeńskich i nijakich) i można się do nich zwracać w dowolnej z nich.
Can't render this file because it contains an unexpected character in line 3 and column 240.

View File

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -9,7 +9,7 @@ home:
about:
- >
TODO
templates: 'Propozycje form'
pronouns: 'Propozycje form'
generator:
header: 'Generator form'
description: >
@ -21,7 +21,7 @@ home:
alt: 'Możesz tu również wpisać formy wymienne w każdym polu z osobna, np. <code>jego&jej</code> = „jego” lub „jej”.'
whatisit: 'O co chodzi w tej stronie?'
template:
pronouns:
examples: 'Example usage in sentences'
plural: 'Plural'
intro: 'My pronouns are'
@ -389,3 +389,8 @@ terms:
header: 'Terms of Service'
lastUpdate: 'Last Updated'
consent: 'By registering you''re accepting the'
api:
header: 'Public API'
example: 'Example'
query: 'Query string parameters'

View File

@ -2,7 +2,7 @@ locale: 'pl'
header: true
template:
pronouns:
enabled: true
default: 'on'
any:
@ -145,7 +145,7 @@ people:
english:
enabled: false
route: 'english'
templateGroups:
pronounGroups:
-
name: 'Normative forms'
description:

View File

@ -0,0 +1,72 @@
<template>
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th></th>
<th><em>I received</em></th>
<th><em>You played</em></th>
<th><em>Somebody told them they are pretty</em></th>
</tr>
</thead>
<tbody>
<tr v-for="(description, pronoun) in t">
<th>
<nuxt-link :to="'/' + pronouns[pronoun].canonicalName">
{{pronouns[pronoun].name()}}
<br v-if="description"/>
<small>{{description}}</small>
</nuxt-link>
</th>
<td v-if="pronouns[pronoun].plural">
Dosta<strong>{{pronouns[pronoun].morphemes.verb_end_inter}}śmy</strong>
</td>
<td v-else>
Dostał<strong>{{pronouns[pronoun].morphemes.verb_middle_inter}}m</strong>
</td>
<td v-if="pronouns[pronoun].plural">
Gra<strong>{{pronouns[pronoun].morphemes.verb_end_inter}}ście</strong>
</td>
<td v-else>
Grał<strong>{{pronouns[pronoun].morphemes.verb_middle_inter}}ś</strong>
</td>
<td v-if="pronouns[pronoun].plural">
Powiedzieli <strong>{{pronouns[pronoun].morphemes.pronoun_d}}</strong>,
że [<strong>{{pronouns[pronoun].morphemes.pronoun_n}}</strong>]
ładn<strong>{{pronouns[pronoun].morphemes.adjective_n}}</strong>
</td>
<td v-else>
Powiedzieli <strong>{{pronouns[pronoun].morphemes.pronoun_d}}</strong>,
że [<strong>{{pronouns[pronoun].morphemes.pronoun_n}}</strong>]
jest ładn<strong>{{pronouns[pronoun].morphemes.adjective_n}}</strong>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import { pronouns } from "../../src/data";
import { getPronoun } from "../../src/buildPronoun";
import { buildDict } from "../../src/helpers";
export default {
props: {
t: { required: true },
},
data() {
const that = this;
return {
pronouns: buildDict(function* () {
for (let name in that.t) {
if (!that.t.hasOwnProperty(name)) {
continue;
}
yield [name, getPronoun(pronouns, name)];
}
}),
};
},
}
</script>

View File

@ -19,12 +19,13 @@
</thead>
<tbody>
<tr>
<td>{{ selectedTemplate.getMorpheme('pronoun_n', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_g', counter) }} / {{ selectedTemplate.getMorpheme('pronoun_g_acc', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_d', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_a', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_i', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_l', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_n', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_g', counter) }} / {{
selectedPronoun.getMorpheme('pronoun_g_acc', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_d', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_a', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_i', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_l', counter) }}</td>
</tr>
</tbody>
</table>
@ -42,10 +43,10 @@
</thead>
<tbody>
<tr>
<td>-{{ selectedTemplate.getMorpheme('verb_middle_inter', counter) }}{{ selectedTemplate.isPlural(counter) ? 'śmy' : 'm'}}</td>
<td>-{{ selectedTemplate.getMorpheme('verb_middle_inter', counter) }}{{ selectedTemplate.isPlural(counter) ? 'ście' : 'ś'}}</td>
<td>-{{ selectedTemplate.getMorpheme('verb_end_about', counter) }}</td>
<td>-{{ selectedTemplate.getMorpheme('adjective_n', counter) }}</td>
<td>-{{ selectedPronoun.getMorpheme('verb_middle_inter', counter) }}{{selectedPronoun.isPlural(counter) ? 'śmy' : 'm'}}</td>
<td>-{{ selectedPronoun.getMorpheme('verb_middle_inter', counter) }}{{selectedPronoun.isPlural(counter) ? 'ście' : 'ś'}}</td>
<td>-{{ selectedPronoun.getMorpheme('verb_end_about', counter) }}</td>
<td>-{{ selectedPronoun.getMorpheme('adjective_n', counter) }}</td>
</tr>
</tbody>
</table>
@ -56,7 +57,7 @@
<script>
export default {
props: {
selectedTemplate: { required: true },
selectedPronoun: { required: true },
counter: { required: true },
}
}

View File

@ -1,4 +1,4 @@
name templates description
name pronouns description
Formy normatywne on,ona Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć.
Formy nijakie ono/jego,ono/jej,ono/jejgo,ono/jeno,ono/jenu,vono Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią infantylnie, dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników.
Dukaizmy onu,onu/jejo,ne Neologiczne formy stworzone oryginalnie dla <a href="https://pl.wikipedia.org/wiki/Perfekcyjna_niedoskona%C5%82o%C5%9B%C4%87" target="_blank" rel="noopener">powieści fantastycznych</a>. Choć system dukaizmów jest spójny i analogiczny do form normatywnych, to dla nieznaznajomionych brzmi obco. Jest to jedna z najczęściej wybieranych opcji. Niektóre osoby używają też zmodyfikowanych wariantów wykorzystujących inne zaimki w części przypadków przy zachowaniu dukajowskiej koniugacji czasowników.
Can't render this file because it contains an unexpected character in line 3 and column 285.

View File

Can't render this file because it has a wrong number of fields in line 10.

View File

@ -1,72 +0,0 @@
<template>
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th></th>
<th><em>I received</em></th>
<th><em>You played</em></th>
<th><em>Somebody told them they are pretty</em></th>
</tr>
</thead>
<tbody>
<tr v-for="(description, template) in t">
<th>
<nuxt-link :to="'/' + templates[template].canonicalName">
{{templates[template].name()}}
<br v-if="description"/>
<small>{{description}}</small>
</nuxt-link>
</th>
<td v-if="templates[template].plural">
Dosta<strong>{{templates[template].morphemes.verb_end_inter}}śmy</strong>
</td>
<td v-else>
Dostał<strong>{{templates[template].morphemes.verb_middle_inter}}m</strong>
</td>
<td v-if="templates[template].plural">
Gra<strong>{{templates[template].morphemes.verb_end_inter}}ście</strong>
</td>
<td v-else>
Grał<strong>{{templates[template].morphemes.verb_middle_inter}}ś</strong>
</td>
<td v-if="templates[template].plural">
Powiedzieli <strong>{{templates[template].morphemes.pronoun_d}}</strong>,
że [<strong>{{templates[template].morphemes.pronoun_n}}</strong>]
ładn<strong>{{templates[template].morphemes.adjective_n}}</strong>
</td>
<td v-else>
Powiedzieli <strong>{{templates[template].morphemes.pronoun_d}}</strong>,
że [<strong>{{templates[template].morphemes.pronoun_n}}</strong>]
jest ładn<strong>{{templates[template].morphemes.adjective_n}}</strong>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import { templates } from "../../src/data";
import { getTemplate } from "../../src/buildTemplate";
import { buildDict } from "../../src/helpers";
export default {
props: {
t: { required: true },
},
data() {
const that = this;
return {
templates: buildDict(function* () {
for (let name in that.t) {
if (!that.t.hasOwnProperty(name)) {
continue;
}
yield [name, getTemplate(templates, name)];
}
}),
};
},
}
</script>

View File

@ -40,7 +40,7 @@ home:
„{/oni=dzwonili} z gazowni”,
„będę robić”, itp.
Tutaj idziemy po prostu o krok dalej.
templates: 'Propozycje form'
pronouns: 'Propozycje form'
generator:
header: 'Generator form'
description: >
@ -52,7 +52,7 @@ home:
alt: 'Możesz tu również wpisać formy wymienne w każdym polu z osobna, np. <code>jego&jej</code> = „jego” lub „jej”.'
whatisit: 'O co chodzi w tej stronie?'
template:
pronouns:
examples: 'Przykłady użycia w zdaniu'
plural: 'Liczba mnoga'
intro: 'Moje zaimki to'
@ -89,7 +89,7 @@ sources:
submit:
header: 'Zgłoś przykład do dodania'
action: 'Zgłoś'
templates: 'Które zaimki/formy są użyte?'
pronouns: 'Które zaimki/formy są użyte?'
type: 'Rodzaj źródła kultury'
author: 'Autor'
title: 'Tytuł'

View File

@ -156,13 +156,13 @@ export default {
}
}
if (config.template.enabled) {
routes.push({ path: '/' + config.template.any.route, component: resolve(__dirname, 'routes/any.vue') });
if (config.pronouns.enabled) {
routes.push({ path: '/' + config.pronouns.any.route, component: resolve(__dirname, 'routes/any.vue') });
}
routes.push({ path: '/api', component: resolve(__dirname, 'routes/api.vue') });
routes.push({ name: 'all', path: '*', component: resolve(__dirname, 'routes/template.vue') });
routes.push({ name: 'all', path: '*', component: resolve(__dirname, 'routes/pronoun.vue') });
},
},
}

View File

@ -1,5 +1,5 @@
<template>
<Homepage v-if="config.template.enabled"/>
<Homepage v-if="config.pronouns.enabled"/>
<Select v-else/>
</template>

View File

@ -2,18 +2,18 @@
<div class="container">
<h2>
<Icon v="tag"/>
<T>template.intro</T>:
<T>pronouns.intro</T>:
</h2>
<section>
<div class="alert alert-primary">
<h2 class="text-center mb-0">
<strong><T>template.any.short</T></strong>
<strong><T>pronouns.any.short</T></strong>
</h2>
<p class="h6 small text-center mb-0 mt-2">
<em>
<T>template.any.description</T>
(<T>template.any.options</T>)
<T>pronouns.any.description</T>
(<T>pronouns.any.options</T>)
</em>
</p>
</div>
@ -22,18 +22,18 @@
<section>
<h2 class="h4">
<Icon v="file-signature"/>
<T>template.examples</T>:
<T>pronouns.examples</T>:
</h2>
<ul>
<li v-for="example in examples" class="my-1">
<Example :example="example" :template="randomTemplate()" link/>
<Example :example="example" :pronoun="randomPronoun()" link/>
</li>
</ul>
</section>
<section>
<Share :title="`${$t('template.intro')}: ${$t('template.any.short')}`"/>
<Share :title="`${$t('pronouns.intro')}: ${$t('pronouns.any.short')}`"/>
</section>
<Separator icon="info"/>
@ -49,7 +49,7 @@
</template>
<script>
import { examples, templates } from "~/src/data";
import { examples, pronouns } from "~/src/data";
import { head } from "../src/helpers";
export default {
@ -60,14 +60,14 @@
},
head() {
return head({
title: `${this.$t('template.intro')}: ${this.$t('template.any.short')}`,
banner: `api/banner/${this.$t('template.any.short')}.png`,
title: `${this.$t('pronouns.intro')}: ${this.$t('pronouns.any.short')}`,
banner: `api/banner/${this.$t('pronouns.any.short')}.png`,
});
},
methods: {
randomTemplate() {
const keys = Object.keys(templates);
return templates[keys[keys.length * Math.random() << 0]];
randomPronoun() {
const keys = Object.keys(pronouns);
return pronouns[keys[keys.length * Math.random() << 0]];
},
}
}

View File

@ -41,7 +41,7 @@
data() {
return {
groups: [{
enabled: this.config.template.enabled,
enabled: this.config.pronouns.enabled,
header: 'home.header',
icon: 'tags',
endpoints: {

View File

@ -12,23 +12,21 @@
<Separator icon="list"/>
<ul class="list-group mt-5">
<li v-for="templateGroup in config.english.templateGroups" class="list-group-item">
<li v-for="pronounGroup in config.english.pronounGroups" class="list-group-item">
<h3 class="h4">
{{templateGroup.name}}
{{pronounGroup.name}}
</h3>
<p v-for="p in templateGroup.description">
<p v-for="p in pronounGroup.description">
<LinkedText :text="p"/>
</p>
<EnglishTable v-if="templateGroup.table" :t="templateGroup.table"/>
<EnglishTable v-if="pronounGroup.table" :t="pronounGroup.table"/>
</li>
</ul>
<ScrollButton/>
</div>
</template>
<script>
import EnglishTable from "../data/templates/EnglishTable";
import EnglishTable from "../data/pronouns/EnglishTable";
import { head } from "../src/helpers";
export default {

View File

@ -18,11 +18,11 @@
<section>
<h2>
<Icon v="tags"/>
<T>home.templates</T>
<T>home.pronouns</T>
</h2>
<ul class="list-group mt-4">
<li v-for="[group, groupTemplates] in templateLibrary.split()" class="list-group-item">
<li v-for="[group, groupPronouns] in pronounLibrary.split()" class="list-group-item">
<p class="h5">
{{ group.name }}
</p>
@ -31,37 +31,37 @@
<em v-html="group.description"></em>
</div>
<ul class="list-unstyled">
<li v-for="template in groupTemplates" :key="template.canonicalName">
<nuxt-link v-if="typeof template === 'string'" :to="'/' + template">
<strong>{{template.replace(/&/g, ' ' + $t('template.or') + ' ')}}</strong>
<li v-for="pronoun in groupPronouns" :key="pronoun.canonicalName">
<nuxt-link v-if="typeof pronoun === 'string'" :to="'/' + pronoun">
<strong>{{pronoun.replace(/&/g, ' ' + $t('pronouns.or') + ' ')}}</strong>
</nuxt-link>
<nuxt-link v-else :to="addSlash('/' + template.canonicalName)">
<strong>{{template.name(glue)}}</strong>
<nuxt-link v-else :to="addSlash('/' + pronoun.canonicalName)">
<strong>{{pronoun.name(glue)}}</strong>
<small>{{template.description}}</small>
<small>{{pronoun.description}}</small>
</nuxt-link>
<NormativeBadge v-if="template.normative"/>
<NormativeBadge v-if="pronoun.normative"/>
</li>
</ul>
</li>
<li class="list-group-item">
<a v-if="!customiseMultiple" href="#" @click.prevent="customiseMultiple = true" class="btn btn-outline-primary btn-block">
<Icon v="sliders-h-square"/>
<T>template.alt.button</T>
<T>pronouns.alt.button</T>
</a>
<div v-else class="card">
<div class="card-header">
<Icon v="sliders-h-square"/>
<T>template.alt.header</T>:
<T>pronouns.alt.header</T>:
</div>
<div class="card-body">
<div class="card-title">
<ul class="list-inline d-inline mb-0">
<li class="list-inline-item" v-for="(template, pronoun) in templates">
<button :class="['btn', multiple.includes(pronoun) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']"
@click="toggleMultiple(pronoun)"
<li class="list-inline-item" v-for="(pronoun, pronounName) in pronouns">
<button :class="['btn', multiple.includes(pronounName) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']"
@click="toggleMultiple(pronounName)"
>
{{template.name()}}
{{pronoun.name()}}
</button>
</li>
</ul>
@ -94,11 +94,11 @@
<li class="list-inline-item pt-1 h5">
<T>home.generator.base</T>:
</li>
<li class="list-inline-item" v-for="(template, pronoun) in templates">
<button :class="['btn', template.name(glue) === selectedTemplate.name(glue) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']"
@click="selectedTemplate = templates[pronoun].clone()"
<li class="list-inline-item" v-for="(pronoun, pronounName) in pronouns">
<button :class="['btn', pronoun.name(glue) === selectedPronoun.name(glue) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']"
@click="selectedPronoun = pronouns[pronounName].clone()"
>
{{template.name(glue)}}
{{pronoun.name(glue)}}
</button>
</li>
</ul>
@ -106,26 +106,26 @@
<div class="alert alert-primary">
<p class="h3 mb-0 text-center">
{{ selectedTemplate.name(glue) }}
{{ selectedPronoun.name(glue) }}
<br/>
<input v-model="selectedTemplate.description"
<input v-model="selectedPronoun.description"
class="form-control form-input p-0 form-control-sm"
:size="selectedTemplate.description.length + 3"
:size="selectedPronoun.description.length + 3"
maxlength="48"
/>
</p>
</div>
<p>
<T>template.examples</T>:
<T>pronouns.examples</T>:
</p>
<template v-for="isHonorific in [false, true]" v-if="examples.filter(e => e.isHonorific === isHonorific).length">
<ul>
<li v-for="example in examples" v-if="example.isHonorific === isHonorific">
<span v-for="part in clearExampleParts(example[(isHonorific ? selectedTemplate.isPluralHonorific() : selectedTemplate.isPlural()) ? 'pluralParts' : 'singularParts'])">
<input v-if="part.variable" v-model="selectedTemplate.morphemes[part.str]"
<span v-for="part in clearExampleParts(example[(isHonorific ? selectedPronoun.isPluralHonorific() : selectedPronoun.isPlural()) ? 'pluralParts' : 'singularParts'])">
<input v-if="part.variable" v-model="selectedPronoun.morphemes[part.str]"
:class="['form-control form-input p-0', {'active': selectedMorpheme === part.str}]"
:size="selectedTemplate.morphemes[part.str] ? selectedTemplate.morphemes[part.str].length : 0"
:size="selectedPronoun.morphemes[part.str] ? selectedPronoun.morphemes[part.str].length : 0"
maxlength="12"
@focus="selectedMorpheme = part.str"
@blur="selectedMorpheme = ''"
@ -136,12 +136,12 @@
</ul>
<div class="my-3">
<div class="custom-control custom-switch" v-if="isHonorific">
<input type="checkbox" class="custom-control-input" id="pluralHonorific" v-model="selectedTemplate.pluralHonorific[0]">
<label class="custom-control-label" for="pluralHonorific"><T>template.plural</T> <Icon v="level-up"/></label>
<input type="checkbox" class="custom-control-input" id="pluralHonorific" v-model="selectedPronoun.pluralHonorific[0]">
<label class="custom-control-label" for="pluralHonorific"><T>pronouns.plural</T> <Icon v="level-up"/></label>
</div>
<div class="custom-control custom-switch" v-else>
<input type="checkbox" class="custom-control-input" id="plural" v-model="selectedTemplate.plural[0]">
<label class="custom-control-label" for="plural"><T>template.plural</T> <Icon v="level-up"/></label>
<input type="checkbox" class="custom-control-input" id="plural" v-model="selectedPronoun.plural[0]">
<label class="custom-control-label" for="plural"><T>pronouns.plural</T> <Icon v="level-up"/></label>
</div>
</div>
</template>
@ -166,10 +166,10 @@
</li>
<li class="list-group-item">
<p class="h5">
<nuxt-link :to="'/' + config.template.any.route"><T>template.any.header</T></nuxt-link>
<nuxt-link :to="'/' + config.pronouns.any.route"><T>pronouns.any.header</T></nuxt-link>
</p>
<p>
<T>template.any.description</T>
<T>pronouns.any.description</T>
</p>
</li>
</ul>
@ -186,21 +186,21 @@
</template>
<script>
import { examples, templates, getSources, templateLibrary } from "~/src/data";
import { examples, pronouns, getSources, pronounLibrary } from "~/src/data";
import { ExamplePart } from "~/src/classes";
import Compressor from "../src/compressor";
import { getTemplate } from "../src/buildTemplate";
import MORPHEMES from '../data/templates/morphemes';
import { getPronoun } from "../src/buildPronoun";
import MORPHEMES from '../data/pronouns/morphemes';
export default {
data() {
return {
examples: examples,
templates: templates,
getTemplate: getTemplate,
templateLibrary: templateLibrary,
examples,
pronouns,
getPronoun,
pronounLibrary,
selectedTemplate: templates[this.config.template.default].clone(),
selectedPronoun: pronouns[this.config.pronouns.default].clone(),
selectedMorpheme: '',
customiseMultiple: false,
@ -208,18 +208,18 @@
customise: false,
glue: ' ' + this.$t('template.or') + ' ',
glue: ' ' + this.$t('pronouns.or') + ' ',
}
},
computed: {
usedBase() {
const name = this.selectedTemplate.name(this.glue);
for (let key in this.templates) {
if (this.templates.hasOwnProperty(key)) {
const name = this.selectedPronoun.name(this.glue);
for (let key in this.pronouns) {
if (this.pronouns.hasOwnProperty(key)) {
if (key === name) {
return key;
}
for (let alias of this.templates[key].aliases) {
for (let alias of this.pronouns[key].aliases) {
if (alias === name) {
return key;
}
@ -230,17 +230,17 @@
return null;
},
usedBaseEquals() {
return this.usedBase && this.templates[this.usedBase].equals(this.selectedTemplate);
return this.usedBase && this.pronouns[this.usedBase].equals(this.selectedPronoun);
},
longLink() {
const base = this.templates[this.selectedTemplate.morphemes[MORPHEMES[0]]];
const base = this.pronouns[this.selectedPronoun.morphemes[MORPHEMES[0]]];
return base
? Compressor.compress(this.selectedTemplate.toArray(), base.toArray()).join(',')
: this.selectedTemplate.toString();
? Compressor.compress(this.selectedPronoun.toArray(), base.toArray()).join(',')
: this.selectedPronoun.toString();
},
link() {
if (!this.selectedTemplate.pronoun()) {
if (!this.selectedPronoun.pronoun()) {
return null;
}
return this.addSlash(this.$base + '/' + (this.usedBaseEquals ? this.usedBase : this.longLink));
@ -253,7 +253,7 @@
return this.addSlash(this.$base + '/' + this.multiple.join('&'));
},
sources() {
return getSources(this.selectedTemplate);
return getSources(this.selectedPronoun);
},
},
methods: {

View File

@ -66,8 +66,8 @@
</h3>
<ul class="list-unstyled">
<li v-for="{link, template, opinion} in pronounTemplates">
<Opinion :word="template.name(glue)" :opinion="opinion" :link="`/${link}`"/>
<li v-for="{link, pronoun, opinion} in pronounOpinions">
<Opinion :word="pronoun.name(glue)" :opinion="opinion" :link="`/${link}`"/>
</li>
</ul>
</div>
@ -109,15 +109,15 @@
<script>
import { head } from "../src/helpers";
import { templates } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate";
import { pronouns } from "~/src/data";
import { buildPronoun } from "../src/buildPronoun";
export default {
data() {
return {
username: this.$route.params.pathMatch,
profiles: {},
glue: ' ' + this.$t('template.or') + ' ',
glue: ' ' + this.$t('pronouns.or') + ' ',
allFlags: process.env.FLAGS,
}
},
@ -136,23 +136,23 @@
return null;
},
pronounTemplates() {
const pronounTemplates = [];
pronounOpinions() {
const pronounOpinions = [];
for (let pronoun in this.profile.pronouns) {
if (!this.profile.pronouns.hasOwnProperty(pronoun)) { continue; }
const link = pronoun.replace(new RegExp('^' + this.$base), '').replace(new RegExp('^/'), '');
const template = buildTemplate(templates, link);
const pronounEntity = buildPronoun(pronouns, link);
if (template) {
pronounTemplates.push({
if (pronounEntity) {
pronounOpinions.push({
link,
template,
opinion: this.profile.pronouns[pronoun],
pronoun: pronounEntity,
opinion: this.profile.pronouns[pronounEntity],
});
}
}
return pronounTemplates;
return pronounOpinions;
},
},
head() {

View File

@ -99,8 +99,8 @@
<script>
import { head, dictToList, listToDict, buildList } from "../src/helpers";
import { templates } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate";
import { pronouns } from "~/src/data";
import { buildPronoun } from "../src/buildPronoun";
import config from '../data/config.suml';
const defaultWords = config.profile.defaultWords.map(c => buildList(function* () {
@ -170,8 +170,8 @@
};
},
methods: {
buildTemplate(link) {
return buildTemplate(templates, link);
buildPronoun(link) {
return buildPronoun(pronouns, link);
},
async save() {
this.saving = true;
@ -189,9 +189,8 @@
},
validatePronoun(pronoun) {
const link = pronoun.replace(new RegExp('^' + this.$base), '').replace(new RegExp('^/'), '');
const template = buildTemplate(templates, link);
return template ? null : 'profile.pronounsNotFound'
return buildPronoun(pronouns, link) ? null : 'profile.pronounsNotFound'
},
},
head() {

View File

@ -1,16 +1,16 @@
<template>
<NotFound v-if="!selectedTemplate"/>
<NotFound v-if="!selectedPronoun"/>
<div v-else class="container">
<h2>
<Icon v="tag"/>
<T>template.intro</T>:
<T>pronouns.intro</T>:
</h2>
<section>
<div class="alert alert-primary">
<h2 class="text-center mb-0">
<strong v-if="nameOptions.length === 1">
{{ selectedTemplate.name(glue) }}
{{ selectedPronoun.name(glue) }}
</strong>
<template v-else>
<template v-for="(nameOption, i) in nameOptions">
@ -23,11 +23,11 @@
</template>
</template>
</h2>
<p class="h6 small text-center mb-0 mt-2" v-if="selectedTemplate.description">
<p class="h6 small text-center mb-0 mt-2" v-if="selectedPronoun.description">
<em>
({{Array.isArray(selectedTemplate.description)
? ($t('template.alt.header') + ': ' + selectedTemplate.description.join(glue))
: selectedTemplate.description
({{Array.isArray(selectedPronoun.description)
? ($t('pronouns.alt.header') + ': ' + selectedPronoun.description.join(glue))
: selectedPronoun.description
}})
</em>
</p>
@ -37,46 +37,46 @@
<section>
<h2 class="h4">
<Icon v="file-signature"/>
<T>template.examples</T>:
<T>pronouns.examples</T>:
</h2>
<ul>
<li v-for="example in examples" class="my-1">
<Example :example="example" :template="selectedTemplate" :counter="counter"/>
<Example :example="example" :pronoun="selectedPronoun" :counter="counter"/>
</li>
</ul>
</section>
<GrammarTables :selectedTemplate="selectedTemplate" :counter="counter"/>
<GrammarTables :selectedPronoun="selectedPronoun" :counter="counter"/>
<section v-if="selectedTemplate.history">
<div class="alert alert-info" v-for="part in selectedTemplate.history.split('@')">
<section v-if="selectedPronoun.history">
<div class="alert alert-info" v-for="part in selectedPronoun.history.split('@')">
<Icon v="info-circle"/>
<LinkedText :text="part"/>
</div>
</section>
<section v-if="templateGroup && templateGroup.group.description">
<section v-if="pronounGroup && pronounGroup.group.description">
<ul class="list-group mt-4">
<li class="list-group-item">
<p class="h5">
{{ templateGroup.group.name }}
{{ pronounGroup.group.name }}
</p>
<div class="small my-1">
<Icon v="info-circle"/>
<em v-html="templateGroup.group.description"></em>
<em v-html="pronounGroup.group.description"></em>
</div>
<ul class="list-unstyled">
<li v-for="template in templateGroup.groupTemplates" :key="template.canonicalName">
<nuxt-link v-if="typeof template === 'string'" :to="'/' + template">
<strong>{{template.replace(/&/g, ' ' + $t('template.or') + ' ')}}</strong>
<li v-for="pronoun in pronounGroup.groupPronouns" :key="pronoun.canonicalName">
<nuxt-link v-if="typeof pronoun === 'string'" :to="'/' + pronoun">
<strong>{{pronoun.replace(/&/g, ' ' + $t('pronouns.or') + ' ')}}</strong>
</nuxt-link>
<nuxt-link v-else :to="addSlash('/' + template.canonicalName)">
<strong>{{template.name(glue)}}</strong>
<nuxt-link v-else :to="addSlash('/' + pronoun.canonicalName)">
<strong>{{pronoun.name(glue)}}</strong>
<small>{{template.description}}</small>
<small>{{pronoun.description}}</small>
</nuxt-link>
<NormativeBadge v-if="template.normative"/>
<NormativeBadge v-if="pronoun.normative"/>
</li>
</ul>
</li>
@ -87,7 +87,7 @@
</section>
<section>
<Share :title="`${$t('template.intro')}: ${selectedTemplate.name(glue)}`"/>
<Share :title="`${$t('pronouns.intro')}: ${selectedPronoun.name(glue)}`"/>
</section>
<section v-if="Object.keys(sources).length">
@ -107,27 +107,27 @@
</template>
<script>
import { examples, templates, getSources, templateLibrary } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate";
import { examples, pronouns, getSources, pronounLibrary } from "~/src/data";
import { buildPronoun } from "../src/buildPronoun";
import { head } from "../src/helpers";
import GrammarTables from "../data/templates/GrammarTables";
import GrammarTables from "../data/pronouns/GrammarTables";
import LinkedText from "../components/LinkedText";
export default {
components: {LinkedText, GrammarTables },
data() {
const selectedTemplate = this.config.template.enabled
? buildTemplate(templates, decodeURIComponent(this.$route.path.substr(1).replace(/\/$/, '')))
const selectedPronoun = this.config.pronouns.enabled
? buildPronoun(pronouns, decodeURIComponent(this.$route.path.substr(1).replace(/\/$/, '')))
: null;
return {
examples,
templates,
glue: ' ' + this.$t('template.or') + ' ',
pronouns,
glue: ' ' + this.$t('pronouns.or') + ' ',
selectedTemplate,
nameOptions: selectedTemplate ? selectedTemplate.nameOptions() : [],
templateGroup: templateLibrary.find(selectedTemplate),
selectedPronoun,
nameOptions: selectedPronoun ? selectedPronoun.nameOptions() : [],
pronounGroup: pronounLibrary.find(selectedPronoun),
counter: 0,
}
@ -138,8 +138,8 @@
}
},
head() {
return this.selectedTemplate ? head({
title: `${this.$t('template.intro')}: ${this.selectedTemplate.name(this.glue)}`,
return this.selectedPronoun ? head({
title: `${this.$t('pronouns.intro')}: ${this.selectedPronoun.name(this.glue)}`,
banner: `api/banner${this.$route.path.replace(/\/$/, '')}.png`,
}) : {};
},
@ -150,7 +150,7 @@
},
computed: {
sources() {
return getSources(this.selectedTemplate);
return getSources(this.selectedPronoun);
},
},
}

View File

@ -27,7 +27,7 @@
<T>sources.toc</T>
</button>
<ul v-if="tocShown" class="list-group">
<li v-for="[group, groupTemplates] in templateLibrary.split(filterTemplate, false)" v-if="groupTemplates.length" class="list-group-item">
<li v-for="[group, groupPronouns] in pronounLibrary.split(filterPronoun, false)" v-if="groupPronouns.length" class="list-group-item">
<p class="h5">
{{ group.name }}
</p>
@ -36,23 +36,23 @@
<em v-html="group.description"></em>
</div>
<ul class="list-unstyled">
<li v-for="template in groupTemplates" :key="template.canonicalName">
<a v-if="typeof template === 'string'" :href="'#' + toId(template)">
<strong>{{ template.replace(/&/g, glue) }}</strong>
<li v-for="pronoun in groupPronouns" :key="pronoun.canonicalName">
<a v-if="typeof pronoun === 'string'" :href="'#' + toId(pronoun)">
<strong>{{ pronoun.replace(/&/g, glue) }}</strong>
</a>
<a v-else :href="'#' + toId(template.name(glue))">
<strong>{{ template.name(glue) }}</strong>
<a v-else :href="'#' + toId(pronoun.name(glue))">
<strong>{{ pronoun.name(glue) }}</strong>
<small>{{ template.description }}</small>
<small>{{ pronoun.description }}</small>
</a>
<NormativeBadge v-if="template.normative"/>
<NormativeBadge v-if="pronoun.normative"/>
</li>
</ul>
</li>
<li class="list-group-item" v-if="otherSources.length">
<p class="h5 mb-0">
<a :href="'#' + $t('template.othersRaw')">
<strong><T>template.others</T></strong>
<a :href="'#' + $t('pronouns.othersRaw')">
<strong><T>pronouns.others</T></strong>
</a>
</p>
</li>
@ -87,12 +87,12 @@
</div>
</section>
<section v-for="template in templates" v-if="template.sources.length">
<SourceList :names="template.sources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="toId(template.name(glue))">
<nuxt-link :to="'/' + template.pronoun()">
{{ template.description }}
<small>({{ template.name(glue) }})</small>
<section v-for="pronoun in pronouns" v-if="pronoun.sources.length">
<SourceList :names="pronoun.sources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="toId(pronoun.name(glue))">
<nuxt-link :to="'/' + pronoun.pronoun()">
{{ pronoun.description }}
<small>({{ pronoun.name(glue) }})</small>
</nuxt-link>
</h2>
</SourceList>
@ -102,7 +102,7 @@
<SourceList :names="sources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="toId(multiple)">
<nuxt-link :to="'/' + multiple">
<T>template.alt.header</T>
<T>pronouns.alt.header</T>
<small>({{ multiple.replace(/&/g, ' lub ') }})</small>
</nuxt-link>
</h2>
@ -111,8 +111,8 @@
<section v-if="otherSources.length">
<SourceList :names="otherSources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="$t('template.othersRaw')">
<T>template.others</T>
<h2 class="h4" :id="$t('pronouns.othersRaw')">
<T>pronouns.others</T>
</h2>
</SourceList>
</section>
@ -120,7 +120,7 @@
</template>
<script>
import { templates, sources, templateLibrary } from '../src/data'
import { pronouns, sources, pronounLibrary } from '../src/data'
import sourcesForMultipleForms from '../data/sources/sourcesMultiple';
import { Source } from "../src/classes";
import { head } from "../src/helpers";
@ -128,14 +128,14 @@
export default {
data() {
return {
templates: templates,
pronouns,
sourcesForMultipleForms: sourcesForMultipleForms,
templateLibrary: templateLibrary,
pronounLibrary,
tocShown: false,
sourceTypes: Source.TYPES,
filter: '',
filterType: '',
glue: ' ' + this.$t('template.or') + ' ',
glue: ' ' + this.$t('pronouns.or') + ' ',
submitShown: false,
};
},
@ -155,8 +155,8 @@
computed: {
otherSources() {
const other = new Set(Object.keys(sources));
for (let template of Object.values(this.templates)) {
for (let source of template.sources) {
for (let pronoun of Object.values(this.pronouns)) {
for (let source of pronoun.sources) {
other.delete(source);
}
}
@ -172,7 +172,7 @@
toId(str) {
return str.replace(/\//g, '-').replace(/&/g, '_');
},
filterTemplate(t) {
filterPronoun(t) {
if (typeof t === 'string') {
return Object.keys(sourcesForMultipleForms).includes(t);
}

View File

@ -34,7 +34,7 @@ app.use(require('./routes/user').default);
app.use(require('./routes/profile').default);
app.use(require('./routes/admin').default);
app.use(require('./routes/templates').default);
app.use(require('./routes/pronouns').default);
app.use(require('./routes/sources').default);
app.use(require('./routes/nouns').default);

View File

@ -3,7 +3,7 @@ import SQL from 'sql-template-strings';
import {createCanvas, loadImage, registerFont} from "canvas";
import { loadSuml } from '../loader';
import avatar from '../avatar';
import {buildTemplate, parseTemplates} from "../../src/buildTemplate";
import {buildPronoun, parsePronouns} from "../../src/buildPronoun";
import {loadTsv} from "../../src/tsv";
const translations = loadSuml('translations');
@ -26,8 +26,8 @@ const drawCircle = (context, image, x, y, size) => {
const router = Router();
router.get('/banner/:templateName*.png', async (req, res) => {
const templateName = req.params.templateName + req.params[0];
router.get('/banner/:pronounName*.png', async (req, res) => {
const pronounName = req.params.pronounName + req.params[0];
const width = 1200
const height = 600
const mime = 'image/png';
@ -52,8 +52,8 @@ router.get('/banner/:templateName*.png', async (req, res) => {
context.fillText(translations.title, width / leftRatio + imageSize / 1.5, height / 2 + 48);
}
if (templateName.startsWith('@')) {
const user = await req.db.get(SQL`SELECT id, username, email, avatarSource FROM users WHERE username=${templateName.substring(1)}`);
if (pronounName.startsWith('@')) {
const user = await req.db.get(SQL`SELECT id, username, email, avatarSource FROM users WHERE username=${pronounName.substring(1)}`);
if (!user) {
await fallback();
return res.set('content-type', mime).send(canvas.toBuffer(mime));
@ -77,25 +77,25 @@ router.get('/banner/:templateName*.png', async (req, res) => {
return res.set('content-type', mime).send(canvas.toBuffer(mime));
}
const template = buildTemplate(
parseTemplates(loadTsv(__dirname + '/../../data/templates/templates.tsv')),
templateName,
const pronoun = buildPronoun(
parsePronouns(loadTsv(__dirname + '/../../data/pronouns/pronouns.tsv')),
pronounName,
);
const logo = await loadImage('node_modules/@fortawesome/fontawesome-pro/svgs/light/tags.svg');
if (!template && templateName !== 'dowolne') { // TODO
if (!pronoun && pronounName !== 'dowolne') { // TODO
await fallback();
return res.set('content-type', mime).send(canvas.toBuffer(mime));
}
context.drawImage(logo, width / leftRatio - imageSize / 2, height / 2 - imageSize / 1.25 / 2, imageSize, imageSize / 1.25)
context.font = 'regular 48pt Quicksand'
context.fillText(translations.template.intro + ':', width / leftRatio + imageSize / 1.5, height / 2 - 36)
context.fillText(translations.pronouns.intro + ':', width / leftRatio + imageSize / 1.5, height / 2 - 36)
const templateNameOptions = templateName === 'dowolne' ? ['dowolne'] : template.nameOptions();
context.font = `bold ${templateNameOptions.length <= 2 ? '70' : '36'}pt Quicksand`
context.fillText(templateNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (templateNameOptions.length <= 2 ? 72 : 24))
const pronounNameOptions = pronounName === 'dowolne' ? ['dowolne'] : pronoun.nameOptions();
context.font = `bold ${pronounNameOptions.length <= 2 ? '70' : '36'}pt Quicksand`
context.fillText(pronounNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (pronounNameOptions.length <= 2 ? 72 : 24))
return res.set('content-type', mime).send(canvas.toBuffer(mime));
});

View File

@ -1,6 +1,6 @@
import { Router } from 'express';
import { loadTsv } from '../loader';
import {buildTemplate, parseTemplates} from "../../src/buildTemplate";
import {buildPronoun, parsePronouns} from "../../src/buildPronoun";
import {buildList} from "../../src/helpers";
import {Example} from "../../src/classes";
@ -12,7 +12,7 @@ const buildExample = e => new Example(
const requestExamples = r => {
if (!r || !r.length) {
return loadTsv('templates/examples');
return loadTsv('pronouns/examples');
}
return buildList(function* () {
@ -34,17 +34,17 @@ const addExamples = (pronoun, examples) => {
const router = Router();
router.get('/pronouns', async (req, res) => {
const templates = parseTemplates(loadTsv('templates/templates'));
for (let template in templates) {
if (!templates.hasOwnProperty(template)) { continue; }
templates[template].examples = addExamples(templates[template], requestExamples(req.query.examples))
const pronouns = parsePronouns(loadTsv('pronouns/pronouns'));
for (let pronoun in pronouns) {
if (!pronouns.hasOwnProperty(pronoun)) { continue; }
pronouns[pronoun].examples = addExamples(pronouns[pronoun], requestExamples(req.query.examples))
}
return res.json(templates);
return res.json(pronouns);
});
router.get('/pronouns/:pronoun*', async (req, res) => {
const pronoun = buildTemplate(
parseTemplates(loadTsv('templates/templates')),
const pronoun = buildPronoun(
parsePronouns(loadTsv('pronouns/pronouns')),
req.params.pronoun + req.params[0],
);
if (pronoun) {

View File

@ -10,7 +10,7 @@ const generateId = title => {
const buildEmail = (data, user) => {
const human = [
`<li><strong>user:</strong> ${user ? user.username : ''}</li>`,
`<li><strong>templates:</strong> ${data.templates}</li>`,
`<li><strong>pronouns:</strong> ${data.pronouns}</li>`,
];
const tsv = [generateId(data.title) || '???'];

68
src/buildPronoun.js Normal file
View File

@ -0,0 +1,68 @@
import { Pronoun } from "./classes";
import Compressor from "./compressor";
import { buildDict } from "./helpers";
import MORPHEMES from '../data/pronouns/morphemes';
export const addAliasesToPronouns = (pronouns) => {
const pronounsWithAliases = {}
for (let base in pronouns) {
if (pronouns.hasOwnProperty(base)) {
const pronoun = pronouns[base];
pronounsWithAliases[base] = pronoun;
for (let alias of pronoun.aliases) {
pronounsWithAliases[alias] = pronoun;
}
}
}
return pronounsWithAliases;
}
export const getPronoun = (pronouns, id) => {
return addAliasesToPronouns(pronouns)[id];
}
export const buildPronoun = (pronouns, path) => {
const pronounsWithAliases = addAliasesToPronouns(pronouns);
const pronounStr = path.split(',');
let base = null;
for (let option of pronounStr[0].split('&')) {
if (!base) {
base = pronounsWithAliases[option]
} else {
base = base.merge(pronounsWithAliases[option])
}
}
return pronounStr.length === 1
? base
: Pronoun.from(Compressor.uncompress(pronounStr, base ? base.toArray() : null));
}
export const parsePronouns = (pronounsRaw) => {
return buildDict(function* () {
for (let t of pronounsRaw) {
const aliases = t.key.split(',');
yield [
aliases[0],
new Pronoun(
aliases[0],
t.description,
t.normative,
buildDict(function* () {
for (let morpheme of MORPHEMES) {
yield [morpheme, t[morpheme]];
}
}),
[t.plural],
[t.pluralHonorific],
t.sources ? t.sources.split(',') : [],
aliases.slice(1),
t.history,
)
];
}
});
}

View File

@ -1,68 +0,0 @@
import { Template } from "./classes";
import Compressor from "./compressor";
import { buildDict } from "./helpers";
import MORPHEMES from '../data/templates/morphemes';
export const addAliasesToTemplates = (templates) => {
const templatesWithAliases = {}
for (let base in templates) {
if (templates.hasOwnProperty(base)) {
const template = templates[base];
templatesWithAliases[base] = template;
for (let alias of template.aliases) {
templatesWithAliases[alias] = template;
}
}
}
return templatesWithAliases;
}
export const getTemplate = (templates, id) => {
return addAliasesToTemplates(templates)[id];
}
export const buildTemplate = (templates, path) => {
const templatesWithAliases = addAliasesToTemplates(templates);
const templateStr = path.split(',');
let base = null;
for (let option of templateStr[0].split('&')) {
if (!base) {
base = templatesWithAliases[option]
} else {
base = base.merge(templatesWithAliases[option])
}
}
return templateStr.length === 1
? base
: Template.from(Compressor.uncompress(templateStr, base ? base.toArray() : null));
}
export const parseTemplates = (templatesRaw) => {
return buildDict(function* () {
for (let t of templatesRaw) {
const aliases = t.key.split(',');
yield [
aliases[0],
new Template(
aliases[0],
t.description,
t.normative,
buildDict(function* () {
for (let morpheme of MORPHEMES) {
yield [morpheme, t[morpheme]];
}
}),
[t.plural],
[t.pluralHonorific],
t.sources ? t.sources.split(',') : [],
aliases.slice(1),
t.history,
)
];
}
});
}

View File

@ -1,5 +1,5 @@
import {buildDict, buildList, capitalise} from "./helpers";
import MORPHEMES from '../data/templates/morphemes';
import MORPHEMES from '../data/pronouns/morphemes';
export class ExamplePart {
constructor(variable, str) {
@ -110,7 +110,7 @@ const escape = s => {
.replace(/\?/g, '%3F');
}
export class Template {
export class Pronoun {
constructor (canonicalName, description, normative, morphemes, plural, pluralHonorific, sources = [], aliases = [], history = null) {
this.canonicalName = canonicalName;
this.description = description;
@ -143,7 +143,7 @@ export class Template {
}
clone() {
return new Template(this.canonicalName, this.description, this.normative, clone(this.morphemes), this.plural, this.pluralHonorific);
return new Pronoun(this.canonicalName, this.description, this.normative, clone(this.morphemes), this.plural, this.pluralHonorific);
}
equals(other) {
@ -151,7 +151,7 @@ export class Template {
}
merge(other) {
return new Template(
return new Pronoun(
this.canonicalName + '&' + other.canonicalName,
Array.isArray(this.description) ? [...this.description, other.description] : [this.description, other.description],
this.normative && other.normative,
@ -225,7 +225,7 @@ export class Template {
m[MORPHEMES[parseInt(i)]] = data[parseInt(i)];
}
return new Template(
return new Pronoun(
m[MORPHEMES[0]],
data[data.length - 1],
false,
@ -236,61 +236,61 @@ export class Template {
}
}
export class TemplateGroup {
constructor(name, templates, description = null) {
export class PronounGroup {
constructor(name, pronouns, description = null) {
this.name = name;
this.templates = templates;
this.pronouns = pronouns;
this.description = description;
}
}
export class TemplateLibrary {
constructor(groups, templates) {
export class PronounLibrary {
constructor(groups, pronouns) {
this.groups = groups;
this.templates = templates;
this.pronouns = pronouns;
}
*split(filter = null, includeOthers = true) {
let templatesLeft = Object.keys(this.templates);
let pronounsLeft = Object.keys(this.pronouns);
const that = this;
for (let g of this.groups) {
yield [g, buildList(function* () {
for (let t of g.templates) {
templatesLeft = templatesLeft.filter(i => i !== t);
const template = that.templates[t] || t;
if (!filter || filter(template)) {
yield template;
for (let t of g.pronouns) {
pronounsLeft = pronounsLeft.filter(i => i !== t);
const pronoun = that.pronouns[t] || t;
if (!filter || filter(pronoun)) {
yield pronoun;
}
}
})];
}
if (!templatesLeft.length || !includeOthers) {
if (!pronounsLeft.length || !includeOthers) {
return;
}
yield [
new TemplateGroup('Inne formy', templatesLeft),
new PronounGroup('Inne formy', pronounsLeft),
buildList(function* () {
for (let t of templatesLeft) {
if (!filter || filter(that.templates[t])) {
yield that.templates[t];
for (let t of pronounsLeft) {
if (!filter || filter(that.pronouns[t])) {
yield that.pronouns[t];
}
}
}),
];
}
find(template) {
if (!template) {
find(pronoun) {
if (!pronoun) {
return null;
}
for (let [group, groupTemplates] of this.split()) {
for (let t of groupTemplates) {
if (t.canonicalName === template.canonicalName) {
return {group, groupTemplates};
for (let [group, groupPronouns] of this.split()) {
for (let t of groupPronouns) {
if (t.canonicalName === pronoun.canonicalName) {
return {group, groupPronouns};
}
}
}

View File

@ -1,6 +1,6 @@
import {Source, Example, NounTemplate, TemplateGroup, TemplateLibrary, Name, Person, NounDeclension} from './classes'
import {Source, Example, NounTemplate, PronounGroup, PronounLibrary, Name, Person, NounDeclension} from './classes'
import { buildDict, buildList } from './helpers';
import { parseTemplates, getTemplate } from './buildTemplate';
import { parsePronouns, getPronoun } from './buildPronoun';
import sourcesForMultipleForms from '../data/sources/sourcesMultiple';
export const locales = {
@ -16,10 +16,10 @@ export const socialProviders = {
google: { name: 'Google' },
}
import templatesRaw from '../data/templates/templates.tsv';
export const templates = parseTemplates(templatesRaw);
import pronounsRaw from '../data/pronouns/pronouns.tsv';
export const pronouns = parsePronouns(pronounsRaw);
import examplesRaw from '../data/templates/examples.tsv';
import examplesRaw from '../data/pronouns/examples.tsv';
export const examples = buildList(function* () {
for (let e of examplesRaw) {
yield new Example(
@ -49,23 +49,23 @@ export const sources = buildDict(function* () {
}
});
export const getSources = (selectedTemplate) => {
if (!selectedTemplate) {
export const getSources = (selectedPronoun) => {
if (!selectedPronoun) {
return {};
}
let sources = {};
for (let multiple in sourcesForMultipleForms) {
if (sourcesForMultipleForms.hasOwnProperty(multiple)) {
if (multiple === selectedTemplate.canonicalName) {
if (multiple === selectedPronoun.canonicalName) {
sources[multiple] = sourcesForMultipleForms[multiple];
}
}
}
for (let option of selectedTemplate.nameOptions()) {
const template = getTemplate(templates, option);
if (template && template.sources.length) {
sources[option] = template.sources;
for (let option of selectedPronoun.nameOptions()) {
const pronoun = getPronoun(pronouns, option);
if (pronoun && pronoun.sources.length) {
sources[option] = pronoun.sources;
}
}
return sources;
@ -85,18 +85,18 @@ export const nounTemplates = buildList(function* () {
}
});
import templateGroupsRaw from '../data/templates/templateGroups.tsv';
export const templateGroups = buildList(function* () {
for (let g of templateGroupsRaw) {
yield new TemplateGroup(
import pronounGroupsRaw from '../data/pronouns/pronounGroups.tsv';
export const pronounGroups = buildList(function* () {
for (let g of pronounGroupsRaw) {
yield new PronounGroup(
g.name,
g.templates.split(','),
g.pronouns.split(','),
g.description,
);
}
});
export const templateLibrary = new TemplateLibrary(templateGroups, templates);
export const pronounLibrary = new PronounLibrary(pronounGroups, pronouns);
import namesRaw from '../data/names/names.tsv';
export const names = buildDict(function* () {