Skip to content

Commit 44c5234

Browse files
committed
ALso sanitize dots and parenthesises for slug generation
1 parent feacb99 commit 44c5234

File tree

22 files changed

+144
-106
lines changed

22 files changed

+144
-106
lines changed

frontend/templates/views/2021/partials/category-filter.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
[% if format in '{{ scope.categoryFormats|unique|list|tojson }}' %]
1717
{% set category = category.split('.')[1] if category and category.split('.')|length == 2 else category %}
1818

19-
<a class="ap-pill [% if {{ filter_categories }}.includes(category) and category == '{{ category|slug }}' %]--selected[% endif %]"
20-
href="{{ doc.url.path }}?category={{category|slug}}#filter"
19+
<a class="ap-pill [% if {{ filter_categories }}.includes(category) and category == '{{ category|custom_slug }}' %]--selected[% endif %]"
20+
href="{{ doc.url.path }}?category={{category|custom_slug}}#filter"
2121
name="{{ _(category) }}">
2222
{{ _(category) }}
2323
</a>

frontend/templates/views/examples/documentation.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<input class="ap-a-sidebar-toggle-input ap-a-sidebar-toggle-input-toc" type="checkbox" name="toc" id="toc" autocomplete="off">
4949
<ul>
5050
<li>
51-
<a href="#{{ doc.example.document.title|slug }}">{{ doc.example.document.title }}</a>
51+
<a href="#{{ doc.example.document.title|custom_slug }}">{{ doc.example.document.title }}</a>
5252
<ul>
5353
<li>
5454
{% for section in doc.example.document.sections %}
@@ -76,7 +76,7 @@
7676
</ul>
7777

7878
{% include '/views/partials/breadcrumbs.j2' %}
79-
<h1 class="ap--title" id="{{ doc.example.document.title|slug }}">{{ doc.example.document.title }}</h1>
79+
<h1 class="ap--title" id="{{ doc.example.document.title|custom_slug }}">{{ doc.example.document.title }}</h1>
8080

8181
{# Render widget to toggle experiments if there are any #}
8282
{% if doc.example.document.metadata.experiments %}

frontend/templates/views/partials/category-filter.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
[% if format in '{{ scope.categoryFormats|unique|list|tojson }}' %]
1616
{% set category = category.split('.')[1] if category and category.split('.')|length == 2 else category %}
1717

18-
<a class="ap-a-pill [% if {{ filter_categories }}.includes(category) and category == '{{ category|slug }}' %]filtered[% endif %]"
19-
href="{{ doc.url.path }}?category={{category|slug}}#filter"
18+
<a class="ap-a-pill [% if {{ filter_categories }}.includes(category) and category == '{{ category|custom_slug }}' %]filtered[% endif %]"
19+
href="{{ doc.url.path }}?category={{category|custom_slug}}#filter"
2020
name="{{ _(category) }}">
2121
{{ _(category) }}
2222
</a>

frontend/templates/views/partials/teaser.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{% if teaser_doc.view == '/views/detail/success-story-detail.j2' %}
33
{% do doc.styles.addCssFile('css/components/molecules/teaser-success-story.css') %}
44
<div class="ap-m-teaser ap-m-teaser-success-story"
5-
[% if category in {{ doc.collection.list_docs(locale=doc.locale)|map(attribute='category')|unique|list|tojson }} and category not in '{{ teaser_doc.category|slug }}' %]hidden[% endif %]
6-
[hidden]="filter.category != 'none' && filter.category != '{{ teaser_doc.category|slug }}'">
5+
[% if category in {{ doc.collection.list_docs(locale=doc.locale)|map(attribute='category')|unique|list|tojson }} and category not in '{{ teaser_doc.category|custom_slug }}' %]hidden[% endif %]
6+
[hidden]="filter.category != 'none' && filter.category != '{{ teaser_doc.category|custom_slug }}'">
77
<a href="{{ teaser_doc.url.path }}">
88

99
{% if teaser_doc.category %}
@@ -54,7 +54,7 @@
5454
{% do doc.styles.addCssFile('/css/components/molecules/teaser-template.css') %}
5555
{% set teaser = teaser_doc.teaser or {} %}
5656
{% set square = (teaser.image.width / teaser.image.height == 1) %}
57-
<div class="ap-m-teaser ap-m-teaser-template ap-m-teaser-template-{{ teaser_doc.formats[0] }}{{ ' ap-m-teaser-square' if square }}" [hidden]="activeFilter.chosenFilter != 'none' && activeFilter.chosenFilter != '{{ teaser_doc.category|slug }}'" >
57+
<div class="ap-m-teaser ap-m-teaser-template ap-m-teaser-template-{{ teaser_doc.formats[0] }}{{ ' ap-m-teaser-square' if square }}" [hidden]="activeFilter.chosenFilter != 'none' && activeFilter.chosenFilter != '{{ teaser_doc.category|custom_slug }}'" >
5858
{% if teaser_doc.url.path %}
5959
{% set navigation_url = teaser_doc.url.path %}
6060
{% else %}
@@ -107,7 +107,7 @@
107107
{% do doc.styles.addCssFile('/css/components/molecules/teaser-example.css') %}
108108
{% set formats = teaser_doc.formats or ['websites'] %}
109109
[% if ({{ formats|tojson }}).includes(format) %]
110-
<div class="ap-m-teaser ap-m-teaser-example" data-category="{{ teaser_doc.category|slug }}" [hidden]="activeFilter.chosenFilter != 'none' && activeFilter.chosenFilter != '{{ teaser_doc.category|slug }}'">
110+
<div class="ap-m-teaser ap-m-teaser-example" data-category="{{ teaser_doc.category|custom_slug }}" [hidden]="activeFilter.chosenFilter != 'none' && activeFilter.chosenFilter != '{{ teaser_doc.category|custom_slug }}'">
111111
{% if teaser_doc.used_components %}
112112
<div class="ap-m-teaser-info-trigger">
113113
<strong>{{ _(teaser_doc.used_components|length) }} AMP components</strong> used

frontend/templates/views/partials/tools-teaser.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% if tool.formats and tool.formats|length == 1 and not format %}
55
{% do doc.styles.addCssFile('css/components/molecules/tag.css') %}
66
<div class="ap-m-tag ap-m-tag-{{ tool.formats[0] }} ap-m-teaser-tag" role="filter" tabindex="0"
7-
on="tap:AMP.setState({activeFilter: {chosenFilter: '{{tool.formats[0]|slug}}' } })">
7+
on="tap:AMP.setState({activeFilter: {chosenFilter: '{{tool.formats[0]|custom_slug}}' } })">
88
<div class="ap-m-teaser-tag-icon ap-m-teaser-tag-{{tool.formats[0]}} ap-a-ico">
99
<svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#amp-{{tool.formats[0]}}"></use></svg>
1010
</div>

gulpfile.js/build.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,13 @@ function buildPrepare(done) {
314314

315315
await sh('mkdir -p artifacts');
316316
await sh(`tar cfj ${SETUP_ARCHIVE} ${SETUP_STORED_PATHS.join(' ')}`);
317-
},
318-
// eslint-disable-next-line prefer-arrow-callback
319-
function exit(_done) {
320-
done();
321-
_done();
322-
process.exit(0);
323317
}
318+
// eslint-disable-next-line prefer-arrow-callback
319+
// function exit(_done) {
320+
// done();
321+
// _done();
322+
// process.exit(0);
323+
// }
324324
)(done);
325325
}
326326

pages/content/amp-dev/about/success-stories/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ <h1 class="ap-o-stage-content-headline-big">{{ _('Success stories' ) }}</h1>
105105
</button>
106106
{% for category, stories in categories %}
107107
<button
108-
[% if category == '{{ category|slug }}' %]
108+
[% if category == '{{ category|custom_slug }}' %]
109109
class="ap-a-pill filtered"
110110
[% else %]
111111
class="ap-a-pill"
112112
[% endif %]
113-
on="tap:AMP.navigateTo(url='{{ g.doc('/content/amp-dev/about/success-stories/index.html', locale=doc.locale).url.path }}?category={{ category|slug }}')"
114-
name="{{ category|slug }}">
113+
on="tap:AMP.navigateTo(url='{{ g.doc('/content/amp-dev/about/success-stories/index.html', locale=doc.locale).url.path }}?category={{ category|custom_slug }}')"
114+
name="{{ category|custom_slug }}">
115115
{{ _(category) }}
116116
</button>
117117
{% endfor %}

pages/content/amp-dev/community/roadmap.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2 class="ap-t-roadmap-filter-headline">{{ _('Select working groups') }}</h2>
6868

6969
[% set roadmap_quarter = {{ doc.roadmap.quarters.working_groups[quarter]|tojson }} %]
7070
[% if not category or roadmap_quarter.includes(category) %]
71-
<amp-animation id="anim-{{ quarter|slug }}" layout="nodisplay">
71+
<amp-animation id="anim-{{ quarter|custom_slug }}" layout="nodisplay">
7272
<script type="application/json">
7373
{
7474
"duration": ".3s",
@@ -82,7 +82,7 @@ <h2 class="ap-t-roadmap-filter-headline">{{ _('Select working groups') }}</h2>
8282
}
8383
},
8484
{
85-
"selector": "#nav-item-{{ quarter|slug }}",
85+
"selector": "#nav-item-{{ quarter|custom_slug }}",
8686
"keyframes": {
8787
"opacity": "1"
8888
}
@@ -94,7 +94,7 @@ <h2 class="ap-t-roadmap-filter-headline">{{ _('Select working groups') }}</h2>
9494
}
9595
},
9696
{
97-
"selector": "#nav-item-timeline-{{ quarter|slug }}",
97+
"selector": "#nav-item-timeline-{{ quarter|custom_slug }}",
9898
"keyframes": {
9999
"opacity": "1"
100100
}
@@ -104,13 +104,13 @@ <h2 class="ap-t-roadmap-filter-headline">{{ _('Select working groups') }}</h2>
104104
</script>
105105
</amp-animation>
106106
<button class="ap-t-roadmap-navigation-list-item"
107-
on="tap:{{ 'status-updates' if loop.first else quarter|slug }}.scrollTo(duration=500)">
107+
on="tap:{{ 'status-updates' if loop.first else quarter|custom_slug }}.scrollTo(duration=500)">
108108
<h3 class="ap-t-roadmap-navigation-list-item-title nav-item-title"
109-
id="nav-item-{{ quarter|slug }}">
109+
id="nav-item-{{ quarter|custom_slug }}">
110110
{{ quarter }}
111111
</h3>
112112
<span class="ap-t-roadmap-navigation-list-item-timeline nav-item-timeline"
113-
id="nav-item-timeline-{{ quarter|slug }}">
113+
id="nav-item-timeline-{{ quarter|custom_slug }}">
114114
</span>
115115
</button>
116116
[% endif %]
@@ -133,11 +133,11 @@ <h2 class="ap-t-roadmap-filter-headline">{{ _('Select working groups') }}</h2>
133133
[% if not category or quarters['{{ issue.quarter }}'].includes(category) %]
134134
[% set currenQuarter = '{{ issue.quarter }}' %]
135135
<amp-position-observer intersection-ratios=".95"
136-
target="{{ issue.quarter|slug }}"
137-
on="enter:anim-{{ issue.quarter|slug }}.start"
136+
target="{{ issue.quarter|custom_slug }}"
137+
on="enter:anim-{{ issue.quarter|custom_slug }}.start"
138138
layout="nodisplay">
139139
</amp-position-observer>
140-
<aside class="ap-t-roadmap-list-item-quarter" id="{{ issue.quarter|slug }}">
140+
<aside class="ap-t-roadmap-list-item-quarter" id="{{ issue.quarter|custom_slug }}">
141141
<h3>{{ issue.quarter }}</h3>
142142
</aside>
143143
[% endif %]

pages/content/amp-dev/documentation/components/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ <h2>Filter by category</h2>
142142
{% set scope.categoryFormats = scope.categoryFormats + formats %}
143143
{% endfor %}
144144

145-
[% if not {{ filter_categories }}.includes(category) or {{ filter_categories }}.includes(category) and category == '{{ category|slug }}' %]
145+
[% if not {{ filter_categories }}.includes(category) or {{ filter_categories }}.includes(category) and category == '{{ category|custom_slug }}' %]
146146
{% set category_name = category.split('.')[1] if category and category.split('.')|length == 2 else category %}
147147
<div id="{{ category }}" class="ap-m-table-component">
148148
{% if category %}

pages/content/amp-dev/documentation/examples/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ <h2>{{ _('AMP Playground') }}</h2>
234234
{# Category names might contain indices for sorting. Tidy them up #}
235235
{% set filter_categories = [] %}
236236
{% for category in categories|map(attribute=0)|list %}
237-
{% set category = (category.split('.')[1] if category and category.split('.')|length == 2 else category)|slug %}
237+
{% set category = (category.split('.')[1] if category and category.split('.')|length == 2 else category)|custom_slug %}
238238
{% do filter_categories.append(category) %}
239239
{% endfor %}
240240
{% set filter_categories = filter_categories|tojson %}
@@ -245,7 +245,7 @@ <h2>{{ _('Filter by category') }}</h2>
245245
{% for category, documents in categories %}
246246
{% set category_name = category.split('.')[1] if category and category.split('.')|length == 2 else category %}
247247

248-
[% if not {{ filter_categories }}.includes(category) or {{ filter_categories }}.includes(category) and category == '{{ category_name|slug }}' %]
248+
[% if not {{ filter_categories }}.includes(category) or {{ filter_categories }}.includes(category) and category == '{{ category_name|custom_slug }}' %]
249249
[% if format in {{ documents|map(attribute='formats')|sum(start=[])|unique|list|tojson }} %]
250250
<h4 id="{{ category_name }}">{{ _(category_name) }}</h4>
251251
[% endif %]

0 commit comments

Comments
 (0)