Skip to content

Commit

Permalink
feat: #98 Extract the non-standard dictionary link generation into a …
Browse files Browse the repository at this point in the history
…separate macro to minimize the cumbersome duplication in the `header.ftl`.
  • Loading branch information
dmitry-weirdo committed Dec 3, 2024
1 parent 11a9cac commit 35cb0c8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<#-- expects PlayerEntity as player, or something with same used properties -->
<#macro dictionaryTopSpeedLink dictionaries dictionaryId>
<a href="./${dictionaries.getTopBySpeedFirstPageFilePath(dictionaryId)}">${dictionaries.getHeaderName(dictionaryId)}</a>
</#macro>
9 changes: 9 additions & 0 deletions kgstatsSrv/src/main/resources/ftl/example.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Player from map by id: ${idToPlayerMap?api.get(playerId).login}
<p>
<#assign nonStandardDictionaries = links.nonStandardDictionaries>

<#import "./dictionary-top-speed-link.ftl" as dtsl>

Non standard dictionaries context (from links): ${links.nonStandardDictionaries}
<br/>
<br/>
Expand All @@ -78,4 +80,11 @@ Player from map by id: ${idToPlayerMap?api.get(playerId).login}
<br/>
<br/>
Page header: ${nonStandardDictionaries.getHeaderName(5539)}
<br/>
<br/>
Link test:
<@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=5539/>

<#-- Мини-марафон, 800 знаков -->
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=6018/>
</p>
22 changes: 11 additions & 11 deletions kgstatsSrv/src/main/resources/ftl/header.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,37 @@

<div class="header-vertical-space"></div>

<#-- todo: extract getting header and into sub-template .ftl if it's possible to have template within template -->
<#import "./dictionary-top-speed-link.ftl" as dtsl>
<#assign nonStandardDictionaries = links.nonStandardDictionaries>

<#-- Обычный in English -->
<a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(5539)}">${nonStandardDictionaries.getHeaderName(5539)}</a>
<@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=5539/>

<#-- Мини-марафон, 800 знаков -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(6018)}">${nonStandardDictionaries.getHeaderName(6018)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=6018/>

<#-- Короткие тексты -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(1789)}">${nonStandardDictionaries.getHeaderName(1789)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=1789/>

<#-- Частотный словарь -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(192)}">${nonStandardDictionaries.getHeaderName(192)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=192/>

<#-- Соточка -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(25856)}">${nonStandardDictionaries.getHeaderName(25856)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=25856/>

<#-- Цифросоточка -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(62238)}">${nonStandardDictionaries.getHeaderName(62238)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=62238/>

<#-- Тренируем указательные -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(226)}">${nonStandardDictionaries.getHeaderName(226)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=226/>

<#-- todo: add some dictionary for middle fingers. Probably https://klavogonki.ru/vocs/5029/ :( -->

<#-- Безымянные -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(8223)}">${nonStandardDictionaries.getHeaderName(8223)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=8223/>

<#-- Мизинцы+ -->
| <a href="./${nonStandardDictionaries.getTopBySpeedFirstPageFilePath(3714)}">${nonStandardDictionaries.getHeaderName(3714)}</a>
| <@dtsl.dictionaryTopSpeedLink dictionaries=nonStandardDictionaries dictionaryId=3714/>

<div class="header-vertical-space"></div>

Expand Down

0 comments on commit 35cb0c8

Please sign in to comment.