Buildtime improvements (#7315)

* Remove whitespace generation

this removes about 65MB of added whitespace, which didn't need
generating

* Remove liquid compression.

Most of the stripepd whitespace, is already removed in the previous
commit. And this removes more then 50% of the build time ( localy )

* Remove unneeded whitespace generation
This commit is contained in:
Robbert Müller 2018-11-01 11:11:05 +01:00 committed by Franck Nijhof
parent 2edafd9953
commit d54499fc21
4 changed files with 89 additions and 103 deletions

View File

@ -1,141 +1,141 @@
{% assign components = site.components | sort_natural: 'title' %}
{% assign github_main_repo = 'https://github.com/home-assistant/home-assistant/blob/master/homeassistant' %}
{%- assign components = site.components | sort_natural: 'title' -%}
{%- assign github_main_repo = 'https://github.com/home-assistant/home-assistant/blob/master/homeassistant' -%}
<section class="aside-module grid__item one-whole lap-one-half">
{% include edit_github.html %}
{%- include edit_github.html -%}
<div class='brand-logo-container section'>
{% if page.logo %}
{%- if page.logo -%}
<img src='/images/supported_brands/{{ page.logo }}' />
{% endif %}
{%- endif -%}
</div>
{% assign file_parts = page.url | split: '/' | last | split: '.' %}
{%- assign file_parts = page.url | split: '/' | last | split: '.' -%}
{% if file_parts.size == 2 %}
{% assign is_platform = true %}
{% assign imp_name = file_parts[1] %}
{% assign parent_name = file_parts[0] %}
{% assign parent_url = parent_name | prepend: '/components/' | append: '/' %}
{% assign parent_component = components | where: 'url', parent_url | first %}
{% else %}
{% assign is_platform = false %}
{% assign imp_name = file_parts | first %}
{% endif %}
{%- if file_parts.size == 2 -%}
{%- assign is_platform = true -%}
{%- assign imp_name = file_parts[1] -%}
{%- assign parent_name = file_parts[0] -%}
{%- assign parent_url = parent_name | prepend: '/components/' | append: '/' -%}
{%- assign parent_component = components | where: 'url', parent_url | first -%}
{%- else -%}
{%- assign is_platform = false -%}
{%- assign imp_name = file_parts | first -%}
{%- endif -%}
{% if page.ha_iot_class %}
{%- if page.ha_iot_class -%}
<div class='section'>
IoT class<sup><a href='/blog/2016/02/12/classifying-the-internet-of-things/#classifiers'><i class="icon-info-sign"></i></a></sup>: {{ page.ha_iot_class }}
</div>
{% endif %}
{%- endif -%}
{% if page.ha_qa_scale %}
{%- if page.ha_qa_scale -%}
<div class='section'>
Quality Scale: <a href='/docs/quality_scale/'>
{% if page.ha_qa_scale == 'platinum' %}
{%- if page.ha_qa_scale == 'platinum' -%}
🏆 (platinum)
{% elsif page.ha_qa_scale == 'gold' %}
{%- elsif page.ha_qa_scale == 'gold' -%}
🥇 (gold)
{% elsif page.ha_qa_scale == 'silver' %}
{%- elsif page.ha_qa_scale == 'silver' -%}
🥈 (silver)
{% elsif page.ha_qa_scale == 'internal' %}
{%- elsif page.ha_qa_scale == 'internal' -%}
🏠 (internal)
{% endif %}
{%- endif -%}
</a>
</div>
{% endif %}
{%- endif -%}
{% if page.ha_release %}
{%- if page.ha_release -%}
<div class='section'>
Introduced in release: {{ page.ha_release }}
</div>
{% endif %}
{%- endif -%}
{% if is_platform %}
{%- if is_platform -%}
<div class='section'>
Source:
<a href='{{github_main_repo}}{{parent_url}}{{imp_name}}.py'>{{parent_name}}/{{imp_name}}.py</a>
</div>
{% endif %}
{%- endif -%}
{% if is_platform and parent_name != 'sensor' %}
{%- if is_platform and parent_name != 'sensor' -%}
<div class='section'>
This is a platform for
<a href='{{parent_component.url}}'>the {{parent_component.title}} component</a>.
</div>
{% elsif is_platform == false and imp_name != 'ifttt' %}
{%- elsif is_platform == false and imp_name != 'ifttt' -%}
{% assign platforms_found = false %}
{% for component in components %}
{% if component.url != page.url %}
{% assign comp_imp_name = component.url | split: '/' | last | split: '.' | first %}
{% if comp_imp_name == imp_name %}
{% unless platforms_found %}
{% assign platforms_found = true %}
{%- assign platforms_found = false -%}
{%- for component in components -%}
{%- if component.url != page.url -%}
{%- assign comp_imp_name = component.url | split: '/' | last | split: '.' | first -%}
{%- if comp_imp_name == imp_name %}
{%- unless platforms_found -%}
{%- assign platforms_found = true -%}
<h1 class='title delta'>Platforms</h1>
<ul class='divided'>
{% endunless %}
{%- endunless -%}
<li><a href='{{component.url}}'>
{{component.title}}
</a></li>
{% endif %}
{% endif %}
{% endfor %}
{% endif -%}
{%- endif -%}
{%- endfor -%}
{% if platforms_found %}
{%- if platforms_found -%}
</ul>
{% endif %}
{%- endif -%}
{% endif %}
{%- endif -%}
{% assign related_found = false %}
{% for component in components %}
{% if component.url != page.url %}
{% assign comp_file_parts = component.url | split: '/' | last | split: '.' %}
{% if comp_file_parts.size == 2 %}
{% assign comp_imp_name = comp_file_parts | last %}
{% else %}
{% assign comp_imp_name = comp_file_parts | first %}
{% endif %}
{%- assign related_found = false -%}
{%- for component in components -%}
{%- if component.url != page.url -%}
{%- assign comp_file_parts = component.url | split: '/' | last | split: '.' -%}
{%- if comp_file_parts.size == 2 -%}
{%- assign comp_imp_name = comp_file_parts | last -%}
{%- else -%}
{%- assign comp_imp_name = comp_file_parts | first -%}
{%- endif -%}
{% if comp_imp_name == imp_name %}
{% unless related_found %}
{% assign related_found = true %}
{%- if comp_imp_name == imp_name -%}
{%- unless related_found -%}
{%- assign related_found = true -%}
<div class='section'>
<h1 class='title delta'>Related components</h1>
<ul class='divided'>
{% endunless %}
{%- endunless -%}
<li><a href='{{component.url}}'>
{{component.title}}
</a></li>
{% endif %}
{% endif %}
{% endfor %}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{% if related_found %}
{%- if related_found -%}
</ul>
</div>
{% endif %}
{%- endif -%}
{% if page.ha_category %}
{%- if page.ha_category -%}
<div class='section'>
<h1 class="title delta">Category {{page.ha_category}}</h1>
<ul class='divided'>
{% for component in components %}
{% if component.ha_category == page.ha_category %}
{%- for component in components -%}
{%- if component.ha_category == page.ha_category -%}
<li>
{% if component.url == page.url %}
{%- if component.url == page.url -%}
{{component.title}}
{% else %}
{%- else -%}
<a href='{{component.url}}'>{{component.title}}</a>
{% endif %}
{%- endif -%}
</li>
{% endif %}
{% endfor %}
{%- endif -%}
{%- endfor -%}
</ul>
</div>
{% endif %}
{%- endif -%}
</section>

View File

@ -1,10 +0,0 @@
---
# Jekyll layout that compresses HTML
# v3.0.2
# http://jch.penibelst.de/
# © 20142015 Anatol Broder
# MIT License
---
{% capture _LINE_FEED %}
{% endcapture %}{% if site.compress_html.ignore.envs contains jekyll.environment %}{{ content }}{% else %}{% capture _content %}{{ content }}{% endcapture %}{% assign _profile = site.compress_html.profile %}{% if site.compress_html.endings == "all" %}{% assign _endings = "html head body li dt dd p rt rp optgroup option colgroup caption thead tbody tfoot tr td th" | split: " " %}{% else %}{% assign _endings = site.compress_html.endings %}{% endif %}{% for _element in _endings %}{% capture _end %}</{{ _element }}>{% endcapture %}{% assign _content = _content | remove: _end %}{% endfor %}{% if _profile and _endings %}{% assign _profile_endings = _content | size | plus: 1 %}{% endif %}{% for _element in site.compress_html.startings %}{% capture _start %}<{{ _element }}>{% endcapture %}{% assign _content = _content | remove: _start %}{% endfor %}{% if _profile and site.compress_html.startings %}{% assign _profile_startings = _content | size | plus: 1 %}{% endif %}{% if site.compress_html.comments == "all" %}{% assign _comments = "<!-- -->" | split: " " %}{% else %}{% assign _comments = site.compress_html.comments %}{% endif %}{% if _comments.size == 2 %}{% capture _comment_befores %}.{{ _content }}{% endcapture %}{% assign _comment_befores = _comment_befores | split: _comments.first %}{% for _comment_before in _comment_befores %}{% if forloop.first %}{% continue %}{% endif %}{% capture _comment_outside %}{% if _carry %}{{ _comments.first }}{% endif %}{{ _comment_before }}{% endcapture %}{% capture _comment %}{% unless _carry %}{{ _comments.first }}{% endunless %}{{ _comment_outside | split: _comments.last | first }}{% if _comment_outside contains _comments.last %}{{ _comments.last }}{% assign _carry = false %}{% else %}{% assign _carry = true %}{% endif %}{% endcapture %}{% assign _content = _content | remove_first: _comment %}{% endfor %}{% if _profile %}{% assign _profile_comments = _content | size | plus: 1 %}{% endif %}{% endif %}{% assign _pre_befores = _content | split: "<pre" %}{% assign _content = "" %}{% for _pre_before in _pre_befores %}{% assign _pres = _pre_before | split: "</pre>" %}{% assign _pres_after = "" %}{% if _pres.size != 0 %}{% if site.compress_html.blanklines %}{% assign _lines = _pres.last | split: _LINE_FEED %}{% capture _pres_after %}{% for _line in _lines %}{% assign _trimmed = _line | split: " " | join: " " %}{% if _trimmed != empty or forloop.last %}{% unless forloop.first %}{{ _LINE_FEED }}{% endunless %}{{ _line }}{% endif %}{% endfor %}{% endcapture %}{% else %}{% assign _pres_after = _pres.last | split: " " | join: " " %}{% endif %}{% endif %}{% capture _content %}{{ _content }}{% if _pre_before contains "</pre>" %}<pre{{ _pres.first }}</pre>{% endif %}{% unless _pre_before contains "</pre>" and _pres.size == 1 %}{{ _pres_after }}{% endunless %}{% endcapture %}{% endfor %}{% if _profile %}{% assign _profile_collapse = _content | size | plus: 1 %}{% endif %}{% if site.compress_html.clippings == "all" %}{% assign _clippings = "html head title base link meta style body article section nav aside h1 h2 h3 h4 h5 h6 hgroup header footer address p hr blockquote ol ul li dl dt dd figure figcaption main div table caption colgroup col tbody thead tfoot tr td th" | split: " " %}{% else %}{% assign _clippings = site.compress_html.clippings %}{% endif %}{% for _element in _clippings %}{% assign _edges = " <e;<e; </e>;</e>;</e> ;</e>" | replace: "e", _element | split: ";" %}{% assign _content = _content | replace: _edges[0], _edges[1] | replace: _edges[2], _edges[3] | replace: _edges[4], _edges[5] %}{% endfor %}{% if _profile and _clippings %}{% assign _profile_clippings = _content | size | plus: 1 %}{% endif %}{{ _content }}{% if _profile %} <table id="compress_html_profile_{{ site.time | date: "%Y%m%d" }}" class="compress_html_profile"> <thead> <tr> <td>Step <td>Bytes <tbody> <tr> <td>raw <td>{{ content | size }}{% if _profile_endings %} <tr> <td>endings <td>{{ _profile_endings }}{% endif %}{% if _profile_startings %} <tr> <td>startings <td>{{ _profile_startings }}{% endif %}{% if _profile_comments %} <tr> <td>comments <td>{{ _profile_comments }}{% endif %}{% if _profile_collapse %} <tr> <td>collapse <td>{{ _profile_collapse }}{% endif %}{% if _profile_clippings %} <tr> <td>clippings <td>{{ _profile_clippings }}{% endif %} </table>{% endif %}{% endif %}

View File

@ -1,7 +1,3 @@
---
layout: compress
---
{% capture root_url %}{{ site.root | strip_slash }}{% endcapture %}{% include site/head.html %}
<body {% if page.body_id %} id="{{ page.body_id }}"{% endif %}>

View File

@ -40,11 +40,11 @@ Support for these components is provided by the Home Assistant community.
<a href='#version/{{ added_one_ago_version }}' class="btn added_one_version_ago">Added in {{ added_one_ago_version }} ({{ one_ago_version_components_count }})</a>
<a href='#version/{{ added_two_ago_version }}' class="btn added_two_versions_ago">Added in {{ added_two_ago_version }} ({{ two_ago_version_components_count }})</a>
{% for category in categories %}
{% if category and category != 'Other' %}
{%- for category in categories -%}
{%- if category and category != 'Other' -%}
<a href='#{{ category | slugify }}' class="btn">{{ category }} ({{ components | where: 'ha_category', category | size }})</a>
{% endif %}
{% endfor %}
{%- endif -%}
{%- endfor -%}
<a href='#other' class="btn">Other</a>
</div>
@ -61,11 +61,11 @@ Support for these components is provided by the Home Assistant community.
{% comment %}
## Pages without categories
{% for component in components %}
{%- for component in components -%}
{% unless component.ha_category %}
<p>{{ component.title }}</p>
{% endunless %}
{% endfor %}
{%- endfor -%}
{% endcomment %}
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.js"></script>
@ -89,14 +89,14 @@ Support for these components is provided by the Home Assistant community.
<script type="text/javascript">
// This object contains all components we have
var allComponents = [
{% for component in components %}
{% if component.ha_category %}
{% assign sliced_version = component.ha_release | split: '.' %}
{% assign minor_version = sliced_version[1]|plus: 0 %}
{% assign major_version = sliced_version[0]|plus: 0 %}
{%- for component in components -%}
{%- if component.ha_category -%}
{%- assign sliced_version = component.ha_release | split: '.' -%}
{%- assign minor_version = sliced_version[1]|plus: 0 -%}
{%- assign major_version = sliced_version[0]|plus: 0 -%}
{url:"{{ component.url }}", title:"{{component.title}}", cat:"{{component.ha_category | slugify}}", featured: {% if component.featured %}true{% else %}false{% endif %}, v: "{{major_version}}.{{minor_version}}", logo: "{{component.logo}}"},
{% endif %}
{% endfor %}
{% endif -%}
{%- endfor -%}
false
];
allComponents.pop(); // remove placeholder element at the end
@ -260,10 +260,10 @@ allComponents.pop(); // remove placeholder element at the end
<noscript>
<ul>
{% for component in components %}
{% if component.ha_category %}
{%- for component in components -%}
{%- if component.ha_category -%}
<li><a href='{{ component.url }}'>{{ component.title }}</a></li>
{% endif %}
{% endfor %}
{%- endif -%}
{%- endfor -%}
</ul>
</noscript>