Commit 6c574bd2 authored by Isabella Skořepová's avatar Isabella Skořepová

Implement subtags

parent d4b0d211
Pipeline #540 passed with stage
in 7 seconds
stages:
- test
- deploy
trigger:
......@@ -9,25 +8,6 @@ trigger:
script:
- "curl -X POST -F token=$GITLAB_TOKEN -F ref=master https://git.ok1kvk.cz/api/v3/projects/72/trigger/builds"
basictest:
stage: test
script:
- node --version
- npm --version
- npm install
- node index.js --contentdir sitegin/tests/content --staticdir sitegin/tests/static --builddir build --noserver
unittest:
stage: test
script:
- node --version
- npm --version
- npm install
- npm test
artifacts:
paths:
- coverage
cache:
paths:
- node_modules
......
......@@ -10,26 +10,24 @@ var toURL = function(url) {
module.exports = function(obj) {
console.log('Build step: Tags');
return new Promise(function(resolve, reject) {
var tags = [];
var tagPages = {};
var tags = [{
text: 'Všechny články a aktuality',
url: 'tag/vse',
}];
var tagPages = {
'tag/vse': [],
};
obj.pages.forEach(function(article) {
if(!article.metadata.tags && !article.metadata.notarticle) {
article.metadata.tags = [ 'Článek' ];
if(!article.metadata.tags) {
article.metadata.tags = [];
}
if(article.metadata.tags) {
if(!article.metadata.notarticle) {
var hasarticletag = false;
article.metadata.tags.forEach(function(tag) {
if(toURL(tag) == 'clanek') hasarticletag = true;
})
if(!hasarticletag) article.metadata.tags.push('Článek');
}
var ntags = [];
article.metadata.tags.forEach(function(tag) {
tag = {
text: tag,
url: toURL(tag)
url: 'tag/'+toURL(tag)
}
ntags.push(tag);
if(tags.map(function(e) { return e.url; }).indexOf(tag.url) < 0)
......@@ -37,6 +35,12 @@ module.exports = function(obj) {
if(tagPages[tag.url] === undefined) tagPages[tag.url] = [];
tagPages[tag.url].push(article)
})
if(!article.metadata.notarticle) {
ntags.push(tags[0])
tagPages[tags[0].url].push(article)
}
article.metadata.tags = ntags;
}
});
......@@ -44,7 +48,8 @@ module.exports = function(obj) {
obj.tags = [];
if(!Array.isArray(obj.redirects)) obj.redirects = [];
var generateTagPages = function(file, pageList) {
var generateTagPages = function(tag, pageList, subtags) {
const file = tag.url
var pg = {};
pg.type = 'redirect';
pg.file = file;
......@@ -80,6 +85,8 @@ module.exports = function(obj) {
tagPage.file = file+'/'+p;
tagPage.type = 'tag';
tagPage.tag = tag;
tagPage.subtags = subtags;
tagPage.metadata.firstpage = firstpage;
tagPage.metadata.prevpage = prevpage;
tagPage.metadata.prevurl = prevurl;
......@@ -104,8 +111,59 @@ module.exports = function(obj) {
});
}
const gen = (arr) => arr.map(a => ({ text: a, url: 'tag/'+toURL(a) }))
const subtags = {
'tag/konstrukce': gen([
'Konstrukce pro začátečníky',
'HAM konstrukce',
'Konstrukce s mikroprocesorem',
]),
'tag/stalo-se': gen([
'Akce pro veřejnost',
'Napsali o nás',
'Ocenění',
'Soutěž',
'SK',
'Radioklub',
]),
'tag/programovani': gen([
'C/C++',
'Javascript',
'LaTeX',
'Nástroje',
]),
'tag/mikroprocesory': gen([
'AVR',
'Periferie',
'Knihovny',
]),
'tag/technicke-clanky': gen([
'Eagle',
]),
'tag/zavody': gen([
'HF',
'VHF',
]),
'tag/aktuality': gen([
'Pozvánky',
'Stalo se',
'Závody',
]),
'tag/clanky': gen([
'Programování',
'Mikroprocesory',
'Konstrukce',
'Technické články',
'Zajímavosti',
]),
'tag/vse': gen([
'Aktuality',
'Články',
])
}
tags.forEach(function(tag) {
generateTagPages('tag/'+tag.url, tagPages[tag.url])
generateTagPages(tag, tagPages[tag.url], subtags[tag.url])
})
resolve(obj);
})
......
......@@ -70,7 +70,7 @@ footer.page-footer {
}
#content, #search {
padding-bottom: 20px;
padding-top: 104px;
padding-top: 70px;
margin: 0 auto;
}
html, body {
......@@ -171,6 +171,10 @@ nav.subnav li {
right: 0;
}
.breadcrumb, .breadcrumb:last-child {
color: rgba(0, 0, 0, 0.7);
}
.search-icon svg, .menu-icon svg {
height: 64px;
width: 30px;
......
......@@ -32,6 +32,7 @@
{% block content %}
<div class="section container" id="content">
<div class="row">&nbsp;</div>
<div class="metadata">
<h2 id="title">{{ metadata.title }}</h2>
{% if not metadata.nodate %}
......@@ -50,8 +51,8 @@
{% endif %}
<div class="tags">
{% for tag in metadata.tags %}
{% if tag.url != "clanek" %}
<a href="{{ config.baseurl }}/tag/{{ tag.url }}"><div class="chip">{{ tag.text }}</div></a>
{% if tag.url != "tag/vse" %}
<a href="{{ config.baseurl }}/{{ tag.url }}/1/"><div class="chip">{{ tag.text }}</div></a>
{% endif %}
{% endfor %}
</div>
......
......@@ -48,7 +48,7 @@
{{ svgs.menu("#fff",false) }}
</a>
<div style="z-index: 2" class="brand-logo">
<a id="logo-container" href="{{ config.baseurl }}/tag/clanek/1/" >
<a id="logo-container" href="{{ config.baseurl }}/tag/vse/1/" >
<img class="hide-on-small-and-up" src="{{ config.baseurl }}/theme/icon56.png">
<img class="hide-on-med-and-up hide-on-ultra-small" src="{{ config.baseurl }}/theme/logo56.png">
<img class="hide-on-small-only" src="{{ config.baseurl }}/theme/logo64.png">
......
{% import "partials/svgs.html.nunj" as svgs %}
<div id=content class=container>
<div class="section">
<div class="row">
<div class="col">
<a class="breadcrumb">{{ tag.text }}</a>
{% if subtags %}
{% for subtag in subtags %}
<a href="{{ config.baseurl }}/{{ subtag.url }}" class="chip">{{ subtag.text }}</a>
{% endfor %}
{% endif %}
</div>
</div>
<div class="row">
{% for page in content %}
<div class="col s12 m6 l4"><!-- s12 m6 l4-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment