Skip to content

Commit

Permalink
feat: #64 For non-standard vocabularies, title in the header in now a…
Browse files Browse the repository at this point in the history
… link to the vocabulary page.
  • Loading branch information
dmitry-weirdo committed Nov 25, 2024
1 parent 855c4bd commit 666d1de
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ru.klavogonki.kgparser;

import ru.klavogonki.kgparser.http.UrlConstructor;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -205,6 +207,11 @@ public String getNamePrepositional() {
return namePrepositional;
}

@Override
public String getLink() {
return UrlConstructor.dictionaryPage(getId());
}

public final String code;
public final String name;
public final String namePrepositional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,9 @@ public String getName() {
public String getNamePrepositional() {
return getDisplayNameInPrepositionalCase(this);
}

@Override
public String getLink() {
return null; // todo: is there a link to normal dictionaries page?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface Vocabulary {
String getName();

String getNamePrepositional();

String getLink(); // ссылка на страницу словаря
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public class VocabularyDto {
private String name;

private String namePrepositional;

private String link;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

<div class="section" id="table-container">

<#import "./vocabulary-link.ftl" as vl> <#-- link to dictionary -->

<table class="data" aria-label="${header}">
<tr>
<th scope="col" rowspan="2">#</th>
Expand All @@ -43,8 +45,7 @@

<#list vocabularies as vocabulary>

<#-- todo: link to vocabulary, get right from Dto, use ftl template -->
<th scope="col" colspan="7">${vocabulary.name}</th>
<th scope="col" colspan="7"><@vl.vocabularyLink vocabulary=vocabulary/></th>

</#list>
</tr>
Expand Down
10 changes: 10 additions & 0 deletions kgstatsSrv/src/main/resources/ftl/vocabulary-link.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<#-- expects Vocabulary as vocabulary -->
<#macro vocabularyLink vocabulary>
<#if vocabulary.link??>
<a href="${vocabulary.link}" target="_blank" rel="noopener noreferrer">
${vocabulary.name}
</a>
<#else>
${vocabulary.name}
</#if>
</#macro>
Loading

0 comments on commit 666d1de

Please sign in to comment.