From d54499fc21a70f5855913dfaa1899106cda36190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robbert=20M=C3=BCller?= Date: Thu, 1 Nov 2018 11:11:05 +0100 Subject: [PATCH] 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 --- .../asides/component_navigation.html | 144 +++++++++--------- source/_layouts/compress.html | 10 -- source/_layouts/default.html | 4 - source/components/index.html | 34 ++--- 4 files changed, 89 insertions(+), 103 deletions(-) delete mode 100644 source/_layouts/compress.html diff --git a/source/_includes/asides/component_navigation.html b/source/_includes/asides/component_navigation.html index a165fe95e16..bd64fc7efe3 100644 --- a/source/_includes/asides/component_navigation.html +++ b/source/_includes/asides/component_navigation.html @@ -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' -%}
- {% include edit_github.html %} + {%- include edit_github.html -%}
- {% if page.logo %} + {%- if page.logo -%} - {% endif %} + {%- endif -%}
- {% 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 -%}
IoT class: {{ page.ha_iot_class }}
- {% endif %} + {%- endif -%} - {% if page.ha_qa_scale %} + {%- if page.ha_qa_scale -%} - {% endif %} + {%- endif -%} - {% if page.ha_release %} + {%- if page.ha_release -%}
Introduced in release: {{ page.ha_release }}
- {% endif %} + {%- endif -%} - {% if is_platform %} + {%- if is_platform -%} - {% endif %} + {%- endif -%} - {% if is_platform and parent_name != 'sensor' %} + {%- if is_platform and parent_name != 'sensor' -%} - {% 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 -%}

Platforms

- {% 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 -%}

Related components

    - {% endunless %} + {%- endunless -%}
  • {{component.title}}
  • - {% endif %} - {% endif %} - {% endfor %} + {%- endif -%} + {%- endif -%} + {%- endfor -%} - {% if related_found %} + {%- if related_found -%}
- {% endif %} + {%- endif -%} - {% if page.ha_category %} + {%- if page.ha_category -%}

Category {{page.ha_category}}

    - {% for component in components %} - {% if component.ha_category == page.ha_category %} + {%- for component in components -%} + {%- if component.ha_category == page.ha_category -%}
  • - {% if component.url == page.url %} + {%- if component.url == page.url -%} {{component.title}} - {% else %} + {%- else -%} {{component.title}} - {% endif %} + {%- endif -%}
  • - {% endif %} - {% endfor %} + {%- endif -%} + {%- endfor -%}
- {% endif %} + {%- endif -%}
diff --git a/source/_layouts/compress.html b/source/_layouts/compress.html deleted file mode 100644 index 8248010b4a8..00000000000 --- a/source/_layouts/compress.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -# Jekyll layout that compresses HTML -# v3.0.2 -# http://jch.penibelst.de/ -# © 2014–2015 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 %}{% 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: "" %}{% 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 "" %}{% endif %}{% unless _pre_before contains "" 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 = " ;; ;" | 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 %}
Step Bytes
raw {{ content | size }}{% if _profile_endings %}
endings {{ _profile_endings }}{% endif %}{% if _profile_startings %}
startings {{ _profile_startings }}{% endif %}{% if _profile_comments %}
comments {{ _profile_comments }}{% endif %}{% if _profile_collapse %}
collapse {{ _profile_collapse }}{% endif %}{% if _profile_clippings %}
clippings {{ _profile_clippings }}{% endif %}
{% endif %}{% endif %} diff --git a/source/_layouts/default.html b/source/_layouts/default.html index ca7e0199c2b..c0d9e9ca067 100644 --- a/source/_layouts/default.html +++ b/source/_layouts/default.html @@ -1,7 +1,3 @@ ---- -layout: compress ---- - {% capture root_url %}{{ site.root | strip_slash }}{% endcapture %}{% include site/head.html %} diff --git a/source/components/index.html b/source/components/index.html index 836e3152dcb..9839cf555ab 100644 --- a/source/components/index.html +++ b/source/components/index.html @@ -40,11 +40,11 @@ Support for these components is provided by the Home Assistant community. Added in {{ added_one_ago_version }} ({{ one_ago_version_components_count }}) Added in {{ added_two_ago_version }} ({{ two_ago_version_components_count }}) -{% for category in categories %} - {% if category and category != 'Other' %} +{%- for category in categories -%} + {%- if category and category != 'Other' -%} {{ category }} ({{ components | where: 'ha_category', category | size }}) - {% endif %} -{% endfor %} + {%- endif -%} +{%- endfor -%} Other @@ -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 %}

{{ component.title }}

{% endunless %} -{% endfor %} +{%- endfor -%} {% endcomment %} @@ -89,14 +89,14 @@ Support for these components is provided by the Home Assistant community.