diff --git a/README.md b/README.md index dae828d5eacb158e4d3ecd74af75f66d1b161ad9..815b904be80aefd1b72fb480c6a08b7b41f66fc6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # 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. 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 @@ -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`) * `_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 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 - menu_title: 'FAU links' items: - menu_title: 'Overview' - menu_external: true + external: true url: 'https://fau.de/' - menu_title: 'CS department' - menu_external: true + external: true url: 'https://cs.fau.de/' ``` diff --git a/_config.yml b/_config.yml index 09309077eadd6c3d3e48715afedc4ebafa1f280b..8a1959b25fe5e5697b7ee38808054f43e331d1fd 100644 --- a/_config.yml +++ b/_config.yml @@ -85,5 +85,5 @@ defaults: path: "" values: menu_hidden: false - menu_external: false menu_order: 100 + external: false \ No newline at end of file diff --git a/_includes/footer.html b/_includes/footer.html index 66ae87bd90899477f9ccc4d8706ea6f330044d2c..3f9bf2ba5395047360bc1245c9dbac55c576072e 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -13,10 +13,6 @@ <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 </a> - - <!-- - - --> <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 diff --git a/_includes/head.html b/_includes/head.html index 26f2921c4770ad6f8be1c07d591eddc581eab12f..d19c21c1833f092fdbf082ebff449752db8266d8 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -16,7 +16,7 @@ <!--Import Google Icon Font --> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> - + <!-- Import materialize --> <link type="text/css" rel="stylesheet" href="{{ site.baseurl }}/public/{{ site.materialize }}/css/materialize.min.css" media="screen,projection"/> diff --git a/_includes/header.html b/_includes/header.html index 551f8b483f286bb300b887f2856b2bc9f68888fd..937093b935e6eec01ae368819869227c91b88071 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -3,7 +3,7 @@ <div class="container"> <div class="nav-wrapper"> <a class="page-title"> - {% if page.title == "Home" %}{{ site.title }}{% else %}{{ page.title }}{% endif %} + {% if page.url == "/" %}{{ site.title }}{% else %}{{ page.title }}{% endif %} </a> </div> </div> @@ -23,10 +23,8 @@ </div> </li> - {% for item in site.menu | sort:"menu_order %} - {% if item.folder %} - {% include menu_sub.html %} - {% elsif item.items %} + {% for item in site.menu | sort:"menu_order" %} + {% if (item.folder or item.items) %} {% include menu_sub.html %} {% else %} {% include menu_single.html %} diff --git a/_includes/menu_single.html b/_includes/menu_single.html index 1a39724373aac08731caefe1e95261c7adcf5e16..6dec52f4c5727092a40bdf2401acb0aabf03bbc8 100644 --- a/_includes/menu_single.html +++ b/_includes/menu_single.html @@ -6,10 +6,12 @@ <li {% if page.url == item.url %}class="active"{% endif %} > - <a - href="{% unless item.menu_external %}{{ site.baseurl }}{% endunless %}{{ item.url }}" - {% if item.menu_external %}target="_blank"{% endif %} - > + {% if item.external %} + <a href="{{ item.url }}" target="_blank"> + {% else %} + <a href="{{ site.baseurl }}{{ item.url }}"> + {% endif %} + {% if item.menu_title %} {{ item.menu_title }} {% else %} diff --git a/_includes/menu_sub.html b/_includes/menu_sub.html index b4d7ef7e43849caf94495142809d31cecf0dd9d5..fa3153470151ec21b0f17a624eb72c32b1bc316a 100644 --- a/_includes/menu_sub.html +++ b/_includes/menu_sub.html @@ -1,75 +1,60 @@ {% 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 %} {% unless item.menu_hidden %} + {% assign base_folder = page.url | split: '/' %} - <!-- Figure out our current location --> - {% assign url_parts = page.url | split: '/' %} - {% assign base_url = url_parts | last %} - {% assign base_folder = url_parts[1] %} + <!-- if we are in the right folder, we are active --> + {% if base_folder[1] == item.folder %} + {% assign menu_active = true %} + {% 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 --> - {% if base_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 %} + <!-- Find the current folder --> + {% assign item_folder = item.folder %} - <li class="no-padding"> - <ul class="collapsible collapsible-accordion"> - <li class="bold"> - <a class="collapsible-header {% if menu_active %}active{% endif %}"> - {% if item.menu_title %} - {{ item.menu_title }} - {% else %} - {{ 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 %} + <li class="no-padding"> + <ul class="collapsible collapsible-accordion"> + <li class="bold"> + <a class="collapsible-header {% if menu_active %}active{% endif %}"> + {% if item.menu_title %} + {{ item.menu_title }} + {% else %} + {{ item.title }} {% endif %} - {% endfor %} - {% endif %} - - <!-- if we have items, iterate over them --> - {% if item.items %} - {% assign sitems = item.items | sort: "menu_order"%} - {% for item in sitems %} - {% include menu_single.html %} - {% endfor %} - {% endif %} - </ul> - </div> - </li> - </ul> - </li> + </a> + <div class="collapsible-body"> + <ul> + <!-- If we have folders, iterate over them --> + {% if item.folder %} + {% for item in sorted_pages %} + + {% assign sub_components = item.url | split: '/' %} + {% if sub_components[1] == item_folder %} + {% include menu_single.html %} + {% endif %} + {% endfor %} + {% endif %} + + <!-- 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 %} \ No newline at end of file diff --git a/_includes/pagination.html b/_includes/pagination.html index 15ce7e112e94ee72ddcb520ae688daaeb8a39c6f..029e2e8028b4c555c0bb265e39bcfb6e8d0c7349 100644 --- a/_includes/pagination.html +++ b/_includes/pagination.html @@ -1,61 +1,62 @@ -<nav aria-label="Page navigation"> - <ul class="pagination"> +{% comment %} + Renders a pagination element. + Expects the default jekyll 'paginator' as argument. +{% endcomment %} + +<ul class="pagination"> + + <!-- The previous page --> {% if paginator.previous_page %} - <li> - <a href="{{ site.baseurl }}{{paginator.previous_page_path}}" aria-label="Previous"> - <span aria-hidden="true">«</span> - </a> - </li> + <li class="waves-effect"> + <a href="{{ site.baseurl }}{{paginator.previous_page_path}}"> + <i class="material-icons">chevron_left</i> + </a> + </li> {% else %} - <li class="disabled" > - <a href="#" aria-label="Previous"> - <span aria-hidden="true">«</span> - </a> - </li> - {% endif %} - {% if paginator.page > 4 %} - <li><a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: 'page:num/', '' }}">1</a></li> - {% if paginator.page > 5 %} - <li class="disabled" ><a href="#" >...</a></li> - {% endif %} + <li class="disabled"> + <a href="#!"> + <i class="material-icons">chevron_left</i> + </a> + </li> {% endif %} - {% assign min_index = paginator.page | minus:3 %} - {% assign max_index = paginator.page | plus:3 %} - {% for p in (min_index..max_index) %} - {% if p > 0 and p <= paginator.total_pages %} - <li {% if p == paginator.page %} class="active" {% endif %}> - {% if p == 1 %} - <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: 'page:num/', '' }}">1</a> - {% else %} - <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', p }}">{{ p }}</a> - {% endif %} + + <!-- Show all the pages --> + {% for page in (1..paginator.total_pages) %} + {% if page == paginator.page %} + <li class='active'> + <a href="#!"> + {{page}} + </a> + </li> + {% elsif page == 1 %} + <li class="waves-effect"> + <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}"> + {{page}} + </a> + </li> + {% else %} + <li class="waves-effect"> + <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}"> + {{page}} + </a> </li> {% endif %} {% endfor %} - {% if max_index < paginator.total_pages %} - {% assign max_indexp = max_index | plus:1 %} - {% if max_indexp < paginator.total_pages %} - <li class="disabled" ><a href="#" >...</a></li> - {% endif %} - <li><a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', paginator.total_pages }}">{{ paginator.total_pages }}</a></li> - {% endif %} + + + <!-- The next page --> {% if paginator.next_page %} - <li> - <a href="{{ site.baseurl }}{{ paginator.next_page_path }}" aria-label="Next"> - <span aria-hidden="true">»</span> - </a> - </li> + <li class="waves-effect"> + <a href="{{ site.baseurl }}{{paginator.next_page_path}}"> + <i class="material-icons">chevron_right</i> + </a> + </li> {% else %} - <li class="disabled" > - <a href="#" aria-label="Next"> - <span aria-hidden="true">»</span> - </a> - </li> + <li class="disabled"> + <a href="#!"> + <i class="material-icons">chevron_right</i> + </a> + </li> {% endif %} - </ul> -</nav> - - - - - + +</ul> \ No newline at end of file diff --git a/_includes/people_chip.html b/_includes/people_chip.html index e949b2bb800cf44ec7b055f48af542c9862414ad..ea01f3c3c5efa7dd6092ec8b219556c891131dde 100644 --- a/_includes/people_chip.html +++ b/_includes/people_chip.html @@ -1,19 +1,22 @@ -{% capture purl %}/people/{{person}}/{% endcapture %} -{% assign pname = person %} -{% assign pimg = "" %} +{% comment %} + This page creates a single 'chip' for linking to a person. + It expects the username of the person as the 'person' variable +{% endcomment %} -{% for pp in site.pages %} - {% if pp.url == purl %} - {% assign pname = pp.fullname %} - {% assign pimg = pp.pic %} - {% endif %} -{% endfor %} +{% capture purl %}/people/{{person}}/{% endcapture %} +{% assign pp = site.pages | where: "url", purl | first %} -<a href="{{ site.baseurl }}{{purl}}"> - <div class="chip"> - {% if pimg != "" %} - <img src="{{ site.baseurl }}/{{pimg}}"> - {% endif %} - {{pname}} - </div> -</a> \ No newline at end of file +{% if pp %} + <a href="{{ site.baseurl }}{{purl}}"> + <div class="chip"> + <img src="{{ site.baseurl }}/{{pp.pic}}"> + {{pp.fullname}} + </div> + </a> +{% else %} + <a href="{{ site.baseurl }}{{purl}}"> + <div class="chip"> + {{person}} + </div> + </a> +{% endif %} \ No newline at end of file diff --git a/_includes/post_link.html b/_includes/post_link.html index da014bb1be2d4f704437eb120dc9482cf3cc8981..d996920434ffa092785556bb12f8185a398b8197 100644 --- a/_includes/post_link.html +++ b/_includes/post_link.html @@ -1,3 +1,7 @@ +{% comment %} + Generates a link to a single post. + Expects the page representing the post as a 'post' variable. +{% endcomment %} <div class="post-link"> <h3 class="post-title"> @@ -7,8 +11,7 @@ </h3> <p class="post-meta" > {% assign firsttag = post.tags | first %} - {% assign tmp_list = site.tagpages | where:"tag", firsttag %} - {% assign type = tmp_list | first %} + {% assign type = site.tagpages | where:"tag", firsttag | first %} <span class="post-type">{{ type.title }} by {{post.author}}</span> - {% if post.location %}<span class="post-location">{{post.location}}</span> - {% endif %} <span class="post-date">{{ post.date | date_to_string }}</span> diff --git a/_includes/posts.html b/_includes/posts.html deleted file mode 100644 index afce226f4a9642565f8a3211f1b6b6f80f013cc2..0000000000000000000000000000000000000000 --- a/_includes/posts.html +++ /dev/null @@ -1,33 +0,0 @@ ---- -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> - - diff --git a/_layouts/default.html b/_layouts/default.html index 9bc8f16d5e1b2ce8377cd0f91bae19bb5716559c..f03a9d31abbafc169cb02ef2c7a517dc112299f0 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -1,6 +1,7 @@ --- layout: compress --- +{% assign sorted_pages = site.pages | sort: "menu_order" %} <!DOCTYPE html> <html lang="en-us"> diff --git a/index.md b/index.md index 85719d49e363afd7cfbf49f56e15ef331765f556..f95cc4359815c63a959c72a165590281b591d4e9 100644 --- a/index.md +++ b/index.md @@ -14,10 +14,8 @@ This level of markup allows for offering interesting [knowledge management servi ## Recent News ([see all](/news/posts/)) -{% for post in site.posts %} - {% if forloop.index < 5 %} +{% for post in site.posts limit:5 %} {% include post_link.html %} - {% endif %} {% endfor %} <p>© {{ site.time | date: '%Y' }}. All rights reserved.</p> diff --git a/public/css/main.css b/public/css/main.css index e7de137782272499d5f4c548c7388ca173b44887..9c604bda35078b4dbd9dea1cce065ffacf9ac954 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -32,7 +32,10 @@ h1, h2, h3, h4, h5, h6 { /* background color */ -.page-footer, nav, .side-nav .collapsible-body > ul:not(.collapsible) > li.active, .side-nav.fixed .collapsible-body > ul:not(.collapsible) > li.active { +.page-footer, +nav, .side-nav .collapsible-body > ul:not(.collapsible) > li.active, +.side-nav.fixed .collapsible-body > ul:not(.collapsible) > li.active, +.pagination li.active { background-color: #5B78FD; }