#51 dowolne zaimki

This commit is contained in:
Avris 2020-09-13 22:15:44 +02:00
parent 4c5ad00928
commit d16f20f9df
5 changed files with 126 additions and 8 deletions

22
components/Example.vue Normal file
View File

@ -0,0 +1,22 @@
<template>
<span>
<span v-for="part in example[(example.isHonorific ? template.pluralHonorific : template.plural) ? 'pluralParts' : 'singularParts']">
<strong v-if="part.variable">{{template.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>)
</small>
</span>
</template>
<script>
export default {
props: {
example: { required: true },
template: { required: true },
counter: { default: 0 },
link: { type: Boolean },
}
}
</script>

View File

@ -31,10 +31,7 @@
<ul>
<li v-for="example in examples" class="my-1">
<span v-for="part in example[(example.isHonorific ? selectedTemplate.pluralHonorific : selectedTemplate.plural) ? 'pluralParts' : 'singularParts']">
<strong v-if="part.variable">{{selectedTemplate.getMorpheme(part.str, counter)}}</strong>
<span v-else>{{part.str}}</span>
</span>
<Example :example="example" :template="selectedTemplate" :counter="counter"/>
</li>
</ul>
</section>

87
pages/dowolne.vue Normal file
View File

@ -0,0 +1,87 @@
<template>
<div class="container">
<Header/>
<h2>
<Icon v="tag"/>
Moje zaimki to:
</h2>
<section>
<div class="alert alert-primary">
<h2 class="text-center mb-0">
<strong>dowolne</strong>
</h2>
<p class="h6 small text-center mb-0 mt-2">
<em>
Choć dla wielu osób niezmiernie ważne jest, by używać wobec nich konkretnych zaimków,
innym nie przeszkadza zwracanie się w dowolny sposób
o ile wiadomo z kontekstu, że to o nich mowa
(przejrzyj listę możliwości <nuxt-link to="/"><Icon v="share"/>tutaj</nuxt-link>).
</em>
</p>
</div>
</section>
<section>
<h2 class="h4">
<Icon v="file-signature"/>
Przykłady użycia w zdaniu:
</h2>
<ul>
<li v-for="example in examples" class="my-1">
<Example :example="example" :template="randomTemplate()" link/>
</li>
</ul>
</section>
<section>
<Share title="Moje zaimki to: dowolne"/>
</section>
<Separator icon="info"/>
<section class="mb-0">
<h2 class="h4">
<Icon v="info-circle"/>
O co chodzi w tej stronie?
</h2>
<About/>
<Homepage align="center"/>
</section>
<ScrollButton/>
</div>
</template>
<script>
import { examples, templates } from "~/src/data";
export default {
data() {
return {
examples: examples,
}
},
head() {
const title = 'Moje zaimki to: dowolne';
const banner = `${process.env.baseUrl}/banner/dowolne.png`;
return {
title: title,
meta: [
{ hid: 'og:title', property: 'og:title', content: title },
{ hid: 'twitter:title', property: 'twitter:title', content: title },
{ hid: 'og:logo', property: 'og:logo', content: banner },
{ hid: 'twitter:image', property: 'twitter:image', content: banner },
],
}
},
methods: {
randomTemplate() {
const keys = Object.keys(templates);
return templates[keys[keys.length * Math.random() << 0]];
},
}
}
</script>

View File

@ -173,6 +173,16 @@
</div>
</div>
</li>
<li class="list-group-item">
<p class="h5">
<nuxt-link to="/dowolne">Dowolne zaimki</nuxt-link>
</p>
<p>
Choć dla wielu osób niezmiernie ważne jest, by używać wobec nich konkretnych zaimków,
innym nie przeszkadza zwracanie się w dowolny sposób
o ile wiadomo z kontekstu, że to o nich mowa.
</p>
</li>
</ul>
</section>

View File

@ -19,16 +19,18 @@ export default async function (req, res, next) {
return;
}
const templateName = decodeURIComponent(req.url.substr(1, req.url.length - 5));
const template = buildTemplate(
parseTemplates(loadTsv('templates.tsv')),
decodeURIComponent(req.url.substr(1, req.url.length - 5))
templateName,
);
const width = 1200
const height = 600
const mime = 'image/png';
const imageSize = 200;
const leftRatio = template ? 4 : 5;
const leftRatio = template || templateName === 'dowolne' ? 4 : 5;
registerFont('static/fonts/quicksand-v21-latin-ext_latin-regular.ttf', { family: 'Quicksand', weight: 'regular'});
registerFont('static/fonts/quicksand-v21-latin-ext_latin-700.ttf', { family: 'Quicksand', weight: 'bold'});
@ -43,11 +45,11 @@ export default async function (req, res, next) {
const image = await loadImage('node_modules/@fortawesome/fontawesome-pro/svgs/light/tags.svg');
context.drawImage(image, width / leftRatio - imageSize / 2, height / 2 - imageSize / 1.25 / 2, imageSize, imageSize / 1.25)
if (template) {
if (template || templateName === 'dowolne') {
context.font = 'regular 48pt Quicksand'
context.fillText('Moje zaimki to:', width / leftRatio + imageSize / 1.5, height / 2 - 36)
const templateNameOptions = template.nameOptions();
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))
} else {