Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 81 additions & 75 deletions _layouts/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,120 +18,126 @@
<link type="text/css" rel="stylesheet" href="../css/Ubuntu.css" media="screen"/>
<link rel="shortcut icon" href="../favicon.ico?v=2" type="image/x-icon">
<meta charset="utf-8">
<title>{{ page.title | escape }} - {{ site.data.localization.title[page.lang] }}</title>
<title>{{- page.title | escape -}} - {{- site.data.localization.title[page.lang] -}}</title>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the spaces have visual meaning in the title

<script type="text/javascript">
var current_page_id = "page-" + {{ page.path | jsonify }};
var current_page_id = "page-" + {{- page.path | jsonify -}};
</script>
<style>
.clicked .toggle-hint:before {
content: "{{ site.data.localization.hint.shown[page.lang] }}";
content: "{{- site.data.localization.hint.shown[page.lang] -}}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, this is not needed but also ok.

}

.secret .toggle-hint:before {
content: "{{ site.data.localization.hint.hidden[page.lang] }}";
content: "{{- site.data.localization.hint.hidden[page.lang] -}}";
}

.playfield.verbose .match.ok:after {
content: "{{ site.data.localization.match.matched[page.lang] }}";
content: "{{- site.data.localization.match.matched[page.lang] -}}";
}

.playfield.verbose .match.fail:after {
content: "{{ site.data.localization.match.shouldNotMatch[page.lang] }}";
content: "{{- site.data.localization.match.shouldNotMatch[page.lang] -}}";
}

.playfield.verbose .nomatch.ok:after {
content: "{{ site.data.localization.match.shouldMatch[page.lang] }}";
content: "{{- site.data.localization.match.shouldMatch[page.lang] -}}";
}

.playfield.verbose .nomatch.fail:after {
content: "{{ site.data.localization.match.noMatch[page.lang] }}";
content: "{{- site.data.localization.match.noMatch[page.lang] -}}";
}

.quiz .expression:before {
content: "{{ site.data.localization.quiz.before[page.lang] }}";
content: "{{- site.data.localization.quiz.before[page.lang] -}}";
}

.quiz .expression:after {
content: "{{ site.data.localization.quiz.after[page.lang] }}";
content: "{{- site.data.localization.quiz.after[page.lang] -}}";
}

.quiz .button-ok:before {
content: "{{ site.data.localization.quiz.yes[page.lang] }}";
content: "{{- site.data.localization.quiz.yes[page.lang] -}}";
}

.quiz .button-fail:before {
content: "{{ site.data.localization.quiz.no[page.lang] }}";
content: "{{- site.data.localization.quiz.no[page.lang] -}}";
}
</style>
</head>
<body>
<header>
<div class="progress">
{% assign same_topic_started = false %}
{% assign should_assign_next = false %}
{% assign has_next_page = false %}
{% assign step_index = 0 %}
{% assign next_page = nil %}
{% for p in site.pages %}
{% assign file_name = page.path | split: "/" %}
{% assign file_name = file_name[1] %}

{% assign p_file_name = p.path | split: "/" %}
{% assign p_file_name = p_file_name[1] %}

{% assign topic = file_name | split: "-" | first %}
{% assign p_topic = p_file_name | split: "-" | first %}

{% if p.lang == page.lang %}
{% assign step_index = step_index | plus: 1 %}
{% if p_topic == topic and same_topic_started == false %}
{% comment %}{% endcomment %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know what this line is for.

{%- assign same_topic_started = false -%}
{%- assign should_assign_next = false -%}
{%- assign has_next_page = false -%}
{%- assign step_index = 0 -%}
{%- assign next_page = nil -%}
{%- for p in site.pages -%}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the lines which make the file so much bigger.

{%- assign file_name = page.path | split: "/" -%}
{%- assign file_name = file_name[1] -%}

{%- assign p_file_name = p.path | split: "/" -%}
{%- assign p_file_name = p_file_name[1] -%}

{%- assign topic = file_name | split: "-" | first -%}
{%- assign p_topic = p_file_name | split: "-" | first -%}

{%- if p.lang == page.lang -%}
{%- assign step_index = step_index | plus: 1 -%}
{%- if p_topic == topic and same_topic_started == false -%}
<div class="same-topic">
{% assign same_topic_started = true %}
{% endif %}
{% if p_topic != topic and same_topic_started == true %}
{% comment %}{% endcomment %}
{%- assign same_topic_started = true -%}
{%- endif -%}
{%- if p_topic != topic and same_topic_started == true -%}
</div>
{% assign same_topic_started = false %}
{% endif %}
<a id="page-{{ p.path }}" class="step {% if page == p %}current{% endif %}" href="..{{ p.url }}">{% if page == p %}{{ step_index }}{% endif %}</a>
{% if should_assign_next %}
{% assign should_assign_next = false %}
{% assign has_next_page = true %}
{% assign next_page = p %}
{% endif %}
{% if page == p %}
{% assign should_assign_next = true %}
{% endif %}
{% endif %}
{% endfor %}
{% if same_topic_started %}
{% comment %}{% endcomment %}
{%- assign same_topic_started = false -%}
{%- endif -%}
<a id="page-{{- p.path -}}" class="step {%- if page == p -%}current{%- endif -%}" href="..{{- p.url -}}">{%- if page == p -%}{{- step_index -}}{%- endif -%}</a>
{% comment %}{% endcomment %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know why you put the comment there. Could you elaborate?

{%- if should_assign_next -%}
{%- assign should_assign_next = false -%}
{%- assign has_next_page = true -%}
{%- assign next_page = p -%}
{%- endif -%}
{%- if page == p -%}
{%- assign should_assign_next = true -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if same_topic_started -%}
</div>
{% endif %}
{% comment %}{% endcomment %}
{%- endif -%}
</div>
<h2>{{ page.title | escape }}</h2>
{% comment %}{% endcomment %}
<h2>{{- page.title | escape -}}</h2>
</header>
<div class="main">
{{ content }}
{% if has_next_page %}
<a href="..{{ next_page.url }}" class="next-page">{{ site.data.localization.footer.nextStep[page.lang] }}</a>
{% endif %}
{{- content -}}
{%- if has_next_page -%}
<a href="..{{- next_page.url -}}" class="next-page">{{- site.data.localization.footer.nextStep[page.lang] -}}</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the - has no effect here. Did you do it for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reply will be a reply to all the threads here. When editing the layout file, I did two things:

  1. I search-replaced the following strings:
    • "{{ " --> "{{- "
    • "{% " --> "{%- "
    • " }}" --> " -}}"
    • " %}" --> " -%}"

This took out all the whitespace between elements. However, it does not save indentation, as you requested in the solution:

Please use this to reduce the number spaces.
When you do that, please keep the indentation intact - each element should be on a new line.

Taking out all the whitespace put each <a> in the <header> on the same line. I had to add some space back so that each <a> had its own line.

  1. I added comments to make spaces after certain html elements inside the <header>.

Before these changes, the page source looked like this: view-source:https://coderdojopotsdam.github.io/regex-tutorial/en/00-01.html?

After the changes, the page source looked like this: view-source:https://undoingtech.github.io/regex-tutorial/en/00-01.html?

Note: I cannot provide a link directly to the source code, so you will have to view it yourself after you click on the link.

{%- endif -%}
</div>
<footer>
<div class = "languageFooterMenu" >
<select id="languageMenu" onchange="changeLanguage()">

{% assign languagesArray = 'English,Deutsch,Svenska' | split: ',' %}

{% for language in languagesArray %}
{% assign lang = language | slice: 0, 2 | downcase %}
{{ lang }}
{{ page.lang }}
{% if lang == page.lang %}
<option id = page.lang selected href="..{{page.url}}" value="{{ page.url | remove: ".html"}}">{{language}}</option>
{% endif %}
{% if lang != page.lang %}
<option id = "{{lang}}" href="..{{page.url | replace: page.lang, lang}}" value="{{ page.url | remove: ".html" | replace: page.lang, lang}}" >{{language}}</option>
{% endif %}
{% endfor %}
{%- assign languagesArray = 'English,Deutsch,Svenska' | split: ',' -%}

{%- for language in languagesArray -%}
{%- assign lang = language | slice: 0, 2 | downcase -%}
{{- lang -}}
{{- page.lang -}}
{%- if lang == page.lang -%}
<option id = page.lang selected href="..{{page.url}}" value="{{- page.url | remove: ".html"}}">{{language}}</option>
{%- endif -%}
{%- if lang != page.lang -%}
<option id = "{{lang}}" href="..{{page.url | replace: page.lang, lang}}" value="{{- page.url | remove: ".html" | replace: page.lang, lang}}" >{{language}}</option>
{%- endif -%}
{%- endfor -%}
</select>

<script>
Expand All @@ -152,20 +158,20 @@ <h2>{{ page.title | escape }}</h2>
</script>
</div>
<div class="links">
<a href="{{ site.data.localization.github.edit }}/{{ page.path }}">{{ site.data.localization.footer.edit[page.lang] }}</a>
<a href="{{ site.data.localization.github.newIssue }}">{{ site.data.localization.footer.newIssue[page.lang] }}</a>
<a href="javascript:deleteCookies()">{{ site.data.localization.footer.deleteCookies[page.lang] }}</a>
<a href="{{ site.data.localization.github.view }}/{{ page.path }}">{{ site.data.localization.footer.view[page.lang] }}</a>
<a href="{{- site.data.localization.github.edit -}}/{{- page.path -}}">{{- site.data.localization.footer.edit[page.lang] -}}</a>
<a href="{{- site.data.localization.github.newIssue -}}">{{- site.data.localization.footer.newIssue[page.lang] -}}</a>
<a href="javascript:deleteCookies()">{{- site.data.localization.footer.deleteCookies[page.lang] -}}</a>
<a href="{{- site.data.localization.github.view -}}/{{- page.path -}}">{{- site.data.localization.footer.view[page.lang] -}}</a>
</div>
<div class="license">
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons Lizenzvertrag" style="border-width:0" src="../img/cc-by-sa.png" />
</a>
{{ site.data.localization.license[page.lang] }}
{% assign lowercase_content = content | downcase %}
{% if lowercase_content contains "<img" %}
{{ site.data.localization.licenseImage[page.lang] }}
{% endif %}
{{- site.data.localization.license[page.lang] -}}
{%- assign lowercase_content = content | downcase -%}
{%- if lowercase_content contains "<img" -%}
{{- site.data.localization.licenseImage[page.lang] -}}
{%- endif -%}
</div>
</footer>
</body>
Expand Down