-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharticles.html
96 lines (82 loc) · 3.51 KB
/
articles.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: Articles
meta-title: "Delphi Pascal Programming Articles | by DelphiDabbler"
meta-desc: "Index page listing and linking to all Delphi Pascal programming articles by DelphiDabbler"
---
<script>
/*
* Check for query string containing section in form /articles?article=<id>
* where <id> in [1..25] and redirect such to /articles/article-<id>. Any
* other query strings are ignored.
*
* This required only for articles that existed on the old site. The only
* valid query strings are 1..25. If new articles are added to the new site
* no changes are required here because new articles will never have been
* accessed using the query string method.
*
* This functionality added because Google was reporting the old query
* string URLs are still widely used. See issue #61.
*/
function redirectIfQueryStr() {
// get protocol, host and query string: we customise rest of URL
const protocol = window.location.protocol;
const host = location.host;
const [, queryStr] = window.location.href.split('?');
if (!queryStr)
return; // no query string
const queryParts = queryStr.split('&');
if (!queryParts)
return; // no query string
const articleQuery = queryParts.find(elt => {
return elt.startsWith('article=');
});
if (!articleQuery)
return; // no articles component of query string
const [, articleIdStr] = articleQuery.split('=');
if (!articleIdStr)
return; // no article id specified
articleId = parseInt(articleIdStr);
if ((articleId < 1) || (articleId > 25))
return; // invalid article id
// Construct new URL and redirect to it
// use:
// same protocol (could be http: or https:)
// same host (could be delphidabbler.com, www.delphidabbler.com or localhost for testing)
// reconstruct resource using articleId
window.location = protocol + '//' + host + '/articles/article-' + articleId;
}
redirectIfQueryStr();
</script>
<h1 role="heading">
Articles
</h1>
<p>This page lists various articles that discuss various aspects of Delphi programming. Choose articles of interest from the list below. Many articles include source code examples in Delphi Pascal.</p>
{% assign sorted_articles = site.articles | where: "index", true | sort: "article" | reverse -%}
<div class="panel-list-group">
<div class="list-group">
{% for article in sorted_articles -%}
{% assign test = forloop.index | modulo: 2 -%}
{% if test <> 0 %}
<div class="row">
{% endif %}
<div class="col-sm-6">
<a class="list-group-item" href="/articles/article-{{ article.article }}" aria-label="Read "{{ article.title | escape }}"">
<article role="section" aria-labelledby="art-{{ article.article | escape }}-head">
<div class="panel panel-primary">
<header class="panel-heading" id="art-{{ article.article | escape }}-head">
<h2>{{ article.title | escape }}</h2>
</div><!-- /.panel .panel-primary -->
<div class="panel-body">
<p>{{ article.summary | escape }}</p>
</div> <!-- ./panel-body -->
</article>
</a> <!-- list-group-item -->
</div> <!-- ./col-sm-6 -->
{% if test == 0 or forloop.last %}
</div> <!-- ./row -->
<!-- Clear the lg cols if their content doesn't match in height -->
<div class="clearfix visible-sm-block" role="presentation"></div>
{% endif %}
{%- endfor %}
</div> <!-- ./list-group -->
</div> <!-- ./panel-list-group -->