Pleasing eslint & fixing run.sh

This commit is contained in:
Lucas Cimon 2019-02-13 20:13:31 +01:00
parent 4c24a01c60
commit fef873996f
No known key found for this signature in database
GPG Key ID: 08DA831E717571EE
4 changed files with 25 additions and 19 deletions

View File

@ -2,6 +2,7 @@
"extends": ["strict"], "extends": ["strict"],
"globals": { "globals": {
"document": false, "document": false,
"langs": true,
"window": false, "window": false,
"$": false "$": false
}, },

2
run.sh
View File

@ -6,7 +6,7 @@ set -o pipefail -o errexit -o nounset -o xtrace
install () { install () {
pip install pelican markdown beautifulsoup4 pillow pip install pelican markdown beautifulsoup4 pillow
./gen_statics_bundles.py ./gen_statics_bundles.py || true
} }
install_dev () { install_dev () {

View File

@ -10,13 +10,15 @@
window.tagFilters = {}; window.tagFilters = {};
function parseQuery(queryString) { function parseQuery(queryString) {
let query = {}; const query = {};
(queryString[0] === '?' ? queryString.substr(1) : queryString).split('&').forEach(pair => { (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&').forEach((pair) => {
pair = pair.split('='); pair = pair.split('=');
let name = decodeURIComponent(pair[0]); const name = decodeURIComponent(pair[0]);
let values = decodeURIComponent(pair[1] || '').split(','); const values = decodeURIComponent(pair[1] || '').split(',');
if (!query[name]) { query[name] = []; } if (!query[name]) {
Array.prototype.push.apply(query[name], values); query[name] = [];
}
Array.prototype.push.apply(query[name], values);
}); });
return query; return query;
} }
@ -86,18 +88,21 @@
updateArticlesVisibility(); updateArticlesVisibility();
}; };
// This is a bit redundant with /tag/$tag.html pages, but is slightly more powerful as it allow to combine multiple filters // This is a bit redundant with /tag/$tag.html pages,
let queryParams = parseQuery(window.location.search); // but is slightly more powerful as it allow to combine multiple filters
for (let [qpName, qpValue] of Object.entries(queryParams)) { const queryParams = parseQuery(window.location.search);
if (!qpValue) { continue; } for (const [ qpName, qpValue ] of Object.entries(queryParams)) {
if (!qpValue) {
continue;
}
if (qpName === 'lang') { if (qpName === 'lang') {
let buttonElem = document.getElementById('lang-tag-filter'); const buttonElem = document.getElementById('lang-tag-filter');
window.toggleLangTagFilter.bind(buttonElem)(qpValue[0]); window.toggleLangTagFilter.bind(buttonElem)(qpValue[0]);
} else if (qpName === 'tags') { } else if (qpName === 'tags') {
qpValue.forEach(tag => { qpValue.forEach((tag) => {
let buttonElem = document.getElementById(tag + '-tag-filter'); const buttonElem = document.getElementById(`${ tag }-tag-filter`);
window.toggleTagFilter.bind(buttonElem)(tag); window.toggleTagFilter.bind(buttonElem)(tag);
}); });
} }
} }
}()); }());

View File

@ -266,7 +266,7 @@
</div> </div>
</aside> </aside>
<script src="{{SITEURL}}/theme/bundle-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-efddc02.js"></script> <script src="{{SITEURL}}/theme/bundle-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-12d0265.js"></script>
{% include 'disqus_count.html' %} {% include 'disqus_count.html' %}
{% include 'analytics.html' %} {% include 'analytics.html' %}