Skip to content
Snippets Groups Projects
Unverified Commit c10be205 authored by Tom Wiesing's avatar Tom Wiesing
Browse files

Performance tuning

This commit adds a lot of performance tuning, making the page compile
much faster (<= 10 seconds)
parent 17179849
No related branches found
No related tags found
No related merge requests found
# Repository holding the sources of the KWARC.info website # Repository holding the sources of the KWARC.info website
**Building this page can take up to 30 seconds. This is normal and to be expected.**
Note for authors: When editing some text, please do not hard wrap existing lines. Note for authors: When editing some text, please do not hard wrap existing lines.
This plays very bad with diffs, in particular an entire paragraph shows up as changed even though it might just be a single line. This plays very bad with diffs, in particular an entire paragraph shows up as changed even though it might just be a single line.
Furthermore, this introduces lots and lots of merge conflicts Furthermore, this introduces lots and lots of merge conflicts
...@@ -25,6 +23,21 @@ See the above links for details. ...@@ -25,6 +23,21 @@ See the above links for details.
* `project/` -- people -- event_activites: folders used to generate menu pages (as set in `_config.yml`) * `project/` -- people -- event_activites: folders used to generate menu pages (as set in `_config.yml`)
* `_tagpages` : the tag pages, each tag gets an almost empty md file so that the tag page gets generated by jekyll * `_tagpages` : the tag pages, each tag gets an almost empty md file so that the tag page gets generated by jekyll
## Performance
This jekyll page is tuned in order to build as fast as possible.
It also makes use of the [jekyll-compress-html](https://github.com/penibelst/jekyll-compress-html) layout, to be efficiently transferable over network.
During the evolution of the website, the build time has changed dramatically.
It used to take around 5 minutes to build, with a few optimizations it now only takes up 15 seconds.
The biggest slowdowns were:
* unneeded iterations
* iterations within iterations (usually not required, if one thinks carefully)
* `if` conditions within a loop, instead of a `where` clause
* full iteration to extract a single item (use `first` instead)
* repeated sorting of `site.pages` by the same `menu_order` key (instead sort this once and use a global variable)
* multiple chained `if`s instead of a single `and`
* unneeded variable assignments (these seem to take a lot of time in liquid)
## How to use Jekyll to test/build this website ## How to use Jekyll to test/build this website
This is a [*static website*](http://en.wikipedia.org/wiki/Static_web_page) automatically generated with [Jekyll](http://jekyllrb.com/) by [GitHub Pages](http://pages.github.com/). This is a [*static website*](http://en.wikipedia.org/wiki/Static_web_page) automatically generated with [Jekyll](http://jekyllrb.com/) by [GitHub Pages](http://pages.github.com/).
...@@ -91,10 +104,10 @@ Furthermore, if these are mixed between folders and static items, the folders wi ...@@ -91,10 +104,10 @@ Furthermore, if these are mixed between folders and static items, the folders wi
- menu_title: 'FAU links' - menu_title: 'FAU links'
items: items:
- menu_title: 'Overview' - menu_title: 'Overview'
menu_external: true external: true
url: 'https://fau.de/' url: 'https://fau.de/'
- menu_title: 'CS department' - menu_title: 'CS department'
menu_external: true external: true
url: 'https://cs.fau.de/' url: 'https://cs.fau.de/'
``` ```
......
...@@ -85,5 +85,5 @@ defaults: ...@@ -85,5 +85,5 @@ defaults:
path: "" path: ""
values: values:
menu_hidden: false menu_hidden: false
menu_external: false
menu_order: 100 menu_order: 100
external: false
\ No newline at end of file
...@@ -13,10 +13,6 @@ ...@@ -13,10 +13,6 @@
<a href="https://github.com/KWARC" title="GitHub" class="waves-effect waves-teal btn-flat"> <a href="https://github.com/KWARC" title="GitHub" class="waves-effect waves-teal btn-flat">
<i class="fa fa-github" aria-hidden="true"></i> GitHub <i class="fa fa-github" aria-hidden="true"></i> GitHub
</a> </a>
<!--
-->
<a href="{{ site.baseurl }}/atom.xml" title="Atom Feed" class="waves-effect waves-teal btn-flat"> <a href="{{ site.baseurl }}/atom.xml" title="Atom Feed" class="waves-effect waves-teal btn-flat">
<i class="fa fa-rss" aria-hidden="true"></i> Atom Feed <i class="fa fa-rss" aria-hidden="true"></i> Atom Feed
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<!--Import Google Icon Font --> <!--Import Google Icon Font -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Import materialize --> <!-- Import materialize -->
<link type="text/css" rel="stylesheet" href="{{ site.baseurl }}/public/{{ site.materialize }}/css/materialize.min.css" media="screen,projection"/> <link type="text/css" rel="stylesheet" href="{{ site.baseurl }}/public/{{ site.materialize }}/css/materialize.min.css" media="screen,projection"/>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="container"> <div class="container">
<div class="nav-wrapper"> <div class="nav-wrapper">
<a class="page-title"> <a class="page-title">
{% if page.title == "Home" %}{{ site.title }}{% else %}{{ page.title }}{% endif %} {% if page.url == "/" %}{{ site.title }}{% else %}{{ page.title }}{% endif %}
</a> </a>
</div> </div>
</div> </div>
...@@ -23,10 +23,8 @@ ...@@ -23,10 +23,8 @@
</div> </div>
</li> </li>
{% for item in site.menu | sort:"menu_order %} {% for item in site.menu | sort:"menu_order" %}
{% if item.folder %} {% if (item.folder or item.items) %}
{% include menu_sub.html %}
{% elsif item.items %}
{% include menu_sub.html %} {% include menu_sub.html %}
{% else %} {% else %}
{% include menu_single.html %} {% include menu_single.html %}
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
<li <li
{% if page.url == item.url %}class="active"{% endif %} {% if page.url == item.url %}class="active"{% endif %}
> >
<a {% if item.external %}
href="{% unless item.menu_external %}{{ site.baseurl }}{% endunless %}{{ item.url }}" <a href="{{ item.url }}" target="_blank">
{% if item.menu_external %}target="_blank"{% endif %} {% else %}
> <a href="{{ site.baseurl }}{{ item.url }}">
{% endif %}
{% if item.menu_title %} {% if item.menu_title %}
{{ item.menu_title }} {{ item.menu_title }}
{% else %} {% else %}
......
{% comment %} {% comment %}
This page creates a submenu item. It expects an appropriate `item` as argument. This page creates a submenu item. It expects an appropriate `item` as argument.
It also expects the global 'sorted_pages' argument.
{% endcomment %} {% endcomment %}
{% unless item.menu_hidden %} {% unless item.menu_hidden %}
{% assign base_folder = page.url | split: '/' %}
<!-- Figure out our current location --> <!-- if we are in the right folder, we are active -->
{% assign url_parts = page.url | split: '/' %} {% if base_folder[1] == item.folder %}
{% assign base_url = url_parts | last %} {% assign menu_active = true %}
{% assign base_folder = url_parts[1] %} {% else %}
{% assign menu_active = false %}
{% for item in (item.items | where: "url", page.url) %}
{% unless item.external %}
{% assign menu_active = true %}
<!-- active because {{item}} -->
{% endunless %}
{% endfor %}
{% endif %}
<!-- Find out if we are active -->
{% assign menu_active = false %}
<!-- if we are in the right folder, we are active --> <!-- Find the current folder -->
{% if base_folder == item.folder %} {% assign item_folder = item.folder %}
{% assign menu_active = true %}
{% endif %}
<!-- check if we are in the current oder -->
{% for item in item.items %}
{% unless item.menu_page %}
{% unless item.external_page %}
{% if item.url == page.url %}
{% assign menu_active = true %}
{% endif %}
{% endunless %}
{% endunless %}
{% endfor %}
{% assign pages = site.pages | sort: "menu_order"%}
<!-- Find the current folder -->
{% assign item_folder = item.folder %}
<li class="no-padding"> <li class="no-padding">
<ul class="collapsible collapsible-accordion"> <ul class="collapsible collapsible-accordion">
<li class="bold"> <li class="bold">
<a class="collapsible-header {% if menu_active %}active{% endif %}"> <a class="collapsible-header {% if menu_active %}active{% endif %}">
{% if item.menu_title %} {% if item.menu_title %}
{{ item.menu_title }} {{ item.menu_title }}
{% else %} {% else %}
{{ item.title }} {{ item.title }}
{% endif %}
</a>
<div class="collapsible-body">
<ul>
<!-- If we have folders, iterate over them -->
{% if item.folder %}
{% for item in pages %}
<!-- get the current page -->
{% assign sub_parts = item.url | split: '/' %}
{% assign sub_url = sub_parts | last %}
{% assign sub_folder = sub_parts[1] %}
<!-- if we are in the right folder, include it -->
{% if sub_folder == item_folder %}
{% include menu_single.html %}
{% endif %} {% endif %}
{% endfor %} </a>
{% endif %} <div class="collapsible-body">
<ul>
<!-- if we have items, iterate over them --> <!-- If we have folders, iterate over them -->
{% if item.items %} {% if item.folder %}
{% assign sitems = item.items | sort: "menu_order"%} {% for item in sorted_pages %}
{% for item in sitems %}
{% include menu_single.html %} {% assign sub_components = item.url | split: '/' %}
{% endfor %} {% if sub_components[1] == item_folder %}
{% endif %} {% include menu_single.html %}
</ul> {% endif %}
</div> {% endfor %}
</li> {% endif %}
</ul>
</li> <!-- if we have items, iterate over them -->
{% if item.items %}
{% for item in (item.items | sort: "menu_order") %}
{% include menu_single.html %}
{% endfor %}
{% endif %}
</ul>
</div>
</li>
</ul>
</li>
{% endunless %} {% endunless %}
\ No newline at end of file
{% capture purl %}/people/{{person}}/{% endcapture %} {% comment %}
{% assign pname = person %} This page creates a single 'chip' for linking to a person.
{% assign pimg = "" %} It expects the username of the person as the 'person' variable
{% endcomment %}
{% for pp in site.pages %} {% capture purl %}/people/{{person}}/{% endcapture %}
{% if pp.url == purl %} {% assign pp = site.pages | where: "url", purl | first %}
{% assign pname = pp.fullname %}
{% assign pimg = pp.pic %}
{% endif %}
{% endfor %}
<a href="{{ site.baseurl }}{{purl}}"> {% if pp %}
<div class="chip"> <a href="{{ site.baseurl }}{{purl}}">
{% if pimg != "" %} <div class="chip">
<img src="{{ site.baseurl }}/{{pimg}}"> <img src="{{ site.baseurl }}/{{pp.pic}}">
{% endif %} {{pp.fullname}}
{{pname}} </div>
</div> </a>
</a> {% else %}
\ No newline at end of file <a href="{{ site.baseurl }}{{purl}}">
<div class="chip">
{{person}}
</div>
</a>
{% endif %}
\ No newline at end of file
{% comment %}
Generates a link to a single post.
Expects the page representing the post as a 'post' variable.
{% endcomment %}
<div class="post-link"> <div class="post-link">
<h3 class="post-title"> <h3 class="post-title">
...@@ -7,8 +11,7 @@ ...@@ -7,8 +11,7 @@
</h3> </h3>
<p class="post-meta" > <p class="post-meta" >
{% assign firsttag = post.tags | first %} {% assign firsttag = post.tags | first %}
{% assign tmp_list = site.tagpages | where:"tag", firsttag %} {% assign type = site.tagpages | where:"tag", firsttag | first %}
{% assign type = tmp_list | first %}
<span class="post-type">{{ type.title }} by {{post.author}}</span> - <span class="post-type">{{ type.title }} by {{post.author}}</span> -
{% if post.location %}<span class="post-location">{{post.location}}</span> - {% endif %} {% if post.location %}<span class="post-location">{{post.location}}</span> - {% endif %}
<span class="post-date">{{ post.date | date_to_string }}</span> <span class="post-date">{{ post.date | date_to_string }}</span>
......
---
layout: page
title: Project Activites
alltags: True
menu_order: 101
---
{% comment %}
Project activities are generated through the /_posts/ folder
{% endcomment %}
<h2>By tag</h2>
{% assign with_post_numbers = true %}
{% include tags_module.html %}
<div class="tagcloud" >
<span class="tag" ><a class="btn btn-default" href="{{ site.blog_path}}">All activites <span class="badge">{{ site.posts.size }}</span></a></span>
{{ tagscontent }}
</div>
<h2>Most recent activites</h2>
{% for post in site.posts %}
{% if forloop.index < 5 %}
{% include post_link.html %}
{% endif %}
{% endfor %}
<a href="{{ site.blog_path}}">See all</a>
--- ---
layout: compress layout: compress
--- ---
{% assign sorted_pages = site.pages | sort: "menu_order" %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en-us"> <html lang="en-us">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment