forked from kittv/web
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
web/templates/macros.html

251 lines
7.1 KiB
HTML

{% macro nav_list_items(items) %}
{% if items %}
<ul>
{% for item in items %}
<li><a href="{{ item.path }}">{{ item.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% macro nav_list_items_main(items) %}
{% if items %}
<ul>
{% for item in items %}
{% set section = get_section(path=item.path~"/_index.md") %}
<li
{% if section.extra.color %}
style="--color: {{ section.extra.color }}"
{% else %}
style="--color: #5E81AC"
{% endif %}
>
{% if section.subsections %}
<a href="{{ section.permalink }}" class="rolldown">{{ section.title }}</a>
<div>
{% if section.extra.nav_title_left and section.extra.nav_title_right %}
<div class="title">{{ section.extra.nav_title_left }}</div>
<div class="title">{{ section.extra.nav_title_right }}</div>
{% endif %}
<ul>
{% for subsection in section.subsections %}
{% set subsection = get_section(path=subsection) %}
{% if not subsection.extra.nav_right %}
<li>
<a href="{{ subsection.permalink }}">
{% if subsection.extra.icon %}
<i class="{{ subsection.extra.icon | safe }}"></i>
{% endif %}
{{ subsection.title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
<ul>
{% for subsection in section.subsections %}
{% set subsection = get_section(path=subsection) %}
{% if subsection.extra.nav_right %}
<li>
<a href="{{ subsection.permalink }}">
{% if subsection.extra.icon %}
<i class="{{ subsection.extra.icon | safe }}"></i>
{% endif %}
{{ subsection.title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% else %}
<a href="{{ section.permalink }}">{{ section.title }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% macro breadcrumbs(page) %}
<div class="breadcrumbs">
<div class="wrap">
<a href="{{ config.base_url }}" class="home"><i class="ri-home-4-line"></i></a>
<ul>
{% for ancestor in page.ancestors %}
{% if loop.first %}{% continue %}{% endif %}
{% set section = get_section(path=ancestor) %}
<li><a href="{{ section.permalink }}">{{ section.title }}</a></li>
{% endfor %}
<li><a href="{{ page.permalink }}">{{ page.title }}</a></li>
</ul>
</div>
</div>
{% endmacro %}
{% macro list_posts(section, include_expired=false) %}
{% for post in section.pages %}
{% if include_expired==false and post.extra.expiration and post.extra.expiration | date(format="%s") | int + 86400 < now(timestamp=true) %}
{% continue %}
{% endif %}
<article>
<div class="title">
<a href="{{ post.permalink }}">{{ post.title }}</a>
</div>
{% if post.summary %}
{{ post.summary | safe }}
{% else %}
{{ post.content | safe }}
{% endif %}
{% if post.date %}
<div class="date">{{ post.date | date(format="%d.%m.%Y")}}</div>
{% endif %}
</article>
{% endfor %}
{% endmacro %}
{% macro list_external_links(section) %}
{% for post in section.pages %}
<a href="
{% if post.extra.link %}
{{ post.extra.link }}
{% else %}
{{ post.permalink }}
{% endif %}
">
<article
{% if post.extra.color %}
style="border-color: {{ post.extra.color }}"
{% endif %}
>
<div class="title">
{% if post.extra.logo %}
<img src="{{ post.permalink ~ "../" ~ post.extra.logo }}" alt="{{ post.title }}">
{% else %}
{{ post.title }}
{% endif %}
</div>
{{ post.content | safe }}
</article>
</a>
{% endfor %}
{% endmacro %}
{% macro list_people(group) %}
<div class="group">
{% for page in section.pages %}
{% if page.extra.group and page.extra.group == group %}
<article
{% if page.extra.color %}
style="--color: {{ page.extra.color }}"
{% else %}
style="--color: #81A1C1"
{% endif %}
>
{{ macro::profile_picture(profile=page) }}
<div class="info">
<div>
<div class="name"><a href="{{ page.permalink }}">{{ page.title }}</a></div>
{% if page.extra.role %}
<div class="role">{{ page.extra.role }}</div>
{% endif %}
</div>
<div class="other">
{{ macro::profile_info(profile=page) }}
</div>
</div>
</article>
{% endif %}
{% endfor %}
</div>
{% endmacro %}
{% macro print_profile() %}
<h1>{{ page.title }}</h1>
{% if page.extra.role %}
<div class="role">{{ page.extra.role }}</div>
{% endif %}
<div class="other">
{{ macro::profile_info(profile=page) }}
</div>
{% endmacro %}
{% macro profile_picture(profile) %}
{% set_global img = "../static/placeholder-avatar.jpg" %}
{% for asset in profile.assets %}
{% if asset is matching("img.(jpg|png)$") %}
{% set_global img = asset %}
{% break %}
{% endif %}
{% endfor %}
{% set image = resize_image(path=img, width=256, height=256, op="fill", quality=85) %}
<img src="{{ image.url }}" alt="{{ profile.title }}"></a>
{% endmacro %}
{% macro profile_info(profile) %}
{% if profile.extra.email %}
<div class="mail">
<a href="mailto:{{ profile.extra.email }}">{{ profile.extra.email }}</a>
</div>
{% endif %}
{% if profile.extra.phone %}
<div class="tel">
<a href="tel:{{ profile.extra.phone }}">{{ profile.extra.phone }}</a>
</div>
{% endif %}
{% if profile.extra.homepage %}
<div class="homepage">
<a href="{{ profile.extra.homepage }}">{{ profile.extra.homepage | replace(from="https://", to="") | replace(from="http://", to="") }}</a>
</div>
{% endif %}
{% if profile.extra.sis %}
<div class="cal">
<a href="https://is.cuni.cz/studium/rozvrhng/roz_ucitel_macro.php?fak=11410&ucitel={{ profile.extra.sis }}">Rozvrh</a>
</div>
{% endif %}
{% endmacro %}
{% macro gallery(page) %}
<div class="gallery">
{% for asset in page.assets %}
{% if asset is matching("[.](jpg|png)$") %}
{% set image = resize_image(path=asset, width=300, height=200, op="fill") %}
<a data-fancybox="{{ page.title }}" href="{{ get_url(path=asset) }}"><img src="{{ image.url }}" alt="{{ asset }}"></a>
{% endif %}
{% endfor %}
</div>
{% endmacro %}
{% macro gallery_list() %}
<div class="gallery index">
{% for gallery in section.pages %}
<a href="{{ gallery.permalink }}">
{% if gallery.extra.thumbnail %}
{% set_global img = "." ~ gallery.path ~ gallery.extra.thumbnail %}
{% else %}
{% set_global img = "../static/placeholder-avatar.jpg" %}
{% for asset in gallery.assets %}
{% if asset is matching("[.](jpg|png)$") %}
{% set_global img = asset %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% set image = resize_image(path=img, width=300, height=200, op="fill") %}
<img src="{{ image.url }}" alt="{{ gallery.title }}">
<div class="info">
<div class="title">{{ gallery.title }}</div>
{% if gallery.description %}
<div class="description">{{ gallery.description }}</div>
{% endif %}
<div class="date">2021-05-02</div>
</div>
</a>
{% endfor %}
</div>
{% endmacro %}