Fixing stuff

This commit is contained in:
Lucas Cimon 2017-11-30 01:54:19 +01:00
parent 98ffe5e6a7
commit f258f0becb
No known key found for this signature in database
GPG Key ID: 6AF36E0DE97FE852
8 changed files with 106 additions and 81 deletions

11
.eslintrc Executable file
View File

@ -0,0 +1,11 @@
{
"extends": ["strict"],
"globals": {
"document": false,
"window": false,
"$": false
},
"rules": {
"no-undefined": 0
}
}

View File

@ -31,3 +31,9 @@
- "--ignore=Bad value \"DUMMY\" for attribute \"type\" on element \"link\": Subtype missing"
files: ^templates/[^/]*\.html$
exclude: ^templates/(index|tipue_search)\.html$
- repo: local
hooks:
- id: make-eslint
language: system
entry: make eslint
files: ''

View File

@ -1,19 +1,17 @@
# BEWARE ! Makefiles require the use of hard tabs
NODE_BIN := node_modules/.bin
.PHONY: install check test
.PHONY: install check lint test
install:
npm install csslint eslint eslint-config-strict eslint-plugin-filenames htmlhint htmllint-cli jscs
npm install -g csslint eslint eslint-config-strict eslint-plugin-filenames htmlhint htmllint-cli lighthouse
pip install pre-commit
pre-commit install
check:
$(NODE_BIN)/eslint $(git ls-files [ grep '\.js$')
$(NODE_BIN)/jscs $(git ls-files [ grep '\.js$')
$(NODE_BIN)/csslint --ignore=order-alphabetical $(git ls-files [ grep '\.css$')
check: eslint
pre-commit run --all-files
eslint:
eslint templates/js/*.js
test:
./test_ludochaordic.sh

View File

@ -1,5 +1,7 @@
mg
==============
pelican-mg
==========
[![Build Status](https://travis-ci.org/Lucas-C/pelican-mg.svg?branch=master)](https://travis-ci.org/Lucas-C/pelican-mg)
A minimal theme for [Pelican](http://blog.getpelican.com/) that uses uikit.
The theme is suited for a single author blog. Feeds are provided via ATOM.

View File

@ -1,10 +1,10 @@
$(document).ready(function() {
$(document).ready(() => {
$('.tipue_search').tipuesearch({
'show': 10,
'mode': 'json',
'showURL': false,
'descriptiveWords': 75,
'highlightEveryTerm': true,
'contentLocation': './tipue_search.json'
show: 10,
mode: 'json',
showURL: false,
descriptiveWords: 75,
highlightEveryTerm: true,
contentLocation: './tipue_search.json',
});
});

View File

@ -4,17 +4,43 @@
* - true => select ONLY articles with this tag
* - false => do NOT select articles with this tag
* */
window.tagFilters = {}
(function iife() {
'strict';
function indexOf(array, predicate) {
for (var i = 0; i < array.length; i++) if (predicate(array[i])) return array[i];
window.tagFilters = {};
function includes(anArray, value) {
return anArray.indexOf(value) >= 0;
}
function includes(array, value) {
return array.indexOf(value) !== -1;
};
function toggleTagFilter(tag) {
var filterState = window.tagFilters[tag]
function updateArticlesVisibility() {
const includeFilters = Object.keys(window.tagFilters).filter((tagFilter) => window.tagFilters[tagFilter] === true);
const excludeFilters = Object.keys(window.tagFilters).filter((tagFilter) => window.tagFilters[tagFilter] === false);
Array.prototype.slice.call(document.getElementsByTagName('article')).forEach((article) => {
// article-excerpt: we ignore it
if (!article.dataset.tags) {
return;
}
const articleTags = JSON.parse(article.dataset.tags);
const allIncludeTags = includeFilters.every((tag) => includes(articleTags, tag));
const anyExcludeTag = excludeFilters.some((tag) => includes(articleTags, tag));
// Now implementing the core logic
let shouldDisplay = !anyExcludeTag;
if (shouldDisplay && includeFilters.length > 0) {
shouldDisplay = allIncludeTags;
}
if (shouldDisplay) {
article.classList.remove('mg-faded');
} else {
article.classList.add('mg-faded');
}
});
}
window.toggleTagFilter = function toggleTagFilter(tag) {
let filterState = window.tagFilters[tag];
if (filterState === true) {
this.classList.remove('mg-tag-filter-include');
filterState = false;
@ -31,48 +57,20 @@ function toggleTagFilter(tag) {
}
window.tagFilters[tag] = filterState;
updateArticlesVisibility();
}
};
function toggleLangTagFilter(langs) {
var lang = this.textContent;
window.tagFilters['lang:'+lang] = undefined;
window.toggleLangTagFilter = function toggleLangTagFilter(langs) {
let lang = this.textContent;
window.tagFilters[`lang:${ lang }`] = undefined;
lang = langs[langs.indexOf(lang) + 1];
if (typeof lang === 'undefined') {
lang = 'lang'
lang = 'lang';
this.title = 'Language filter (disabled)';
} else {
window.tagFilters['lang:'+lang] = true;
this.title = 'Language filter (include only "' + lang + '" articles)';
window.tagFilters[`lang:${ lang }`] = true;
this.title = `Language filter (include only "${ lang }" articles)`;
}
this.textContent = lang;
updateArticlesVisibility();
}
function updateArticlesVisibility() {
var includeFilters = Object.keys(window.tagFilters).filter(function (tagFilter) {
return window.tagFilters[tagFilter] === true;
});
var excludeFilters = Object.keys(window.tagFilters).filter(function (tagFilter) {
return window.tagFilters[tagFilter] === false;
});
Array.prototype.slice.call(document.getElementsByTagName('article')).forEach(function (article) {
if (!article.dataset.tags) { // article-excerpt: we ignore it
return;
}
var articleTags = JSON.parse(article.dataset.tags);
var allIncludeTags = includeFilters.every(function (tag) { return includes(articleTags, tag); });
var anyExcludeTag = excludeFilters.some(function (tag) { return includes(articleTags, tag); });
// Now implementing the core logic
var shouldDisplay = !anyExcludeTag;
if (shouldDisplay && includeFilters.length > 0) {
shouldDisplay = allIncludeTags;
}
if (shouldDisplay) {
article.classList.remove('mg-faded');
} else {
article.classList.add('mg-faded');
}
});
}
};
}());

View File

@ -1,4 +1,4 @@
$(document).ready(function() {
$(document).ready(() => {
$('.mg-container-social').height($('article').height());
$('#mg-panel-social').stick_in_parent({offset_top: 35});
$('#mg-panel-social').stick_in_parent({ 'offset_top': 35 });
});

View File

@ -1,6 +1,10 @@
#!/bin/bash
set -o pipefail -o errexit -o nounset -o xtrace
cd ..
git clone https://github.com/getpelican/pelican-plugins.git
git submodule update --init image_process representative_image tag_cloud
cd ..
git clone https://github.com/Lucas-C/ludochaordic.git
cd ludochaordic
@ -8,5 +12,11 @@ cd ludochaordic
pip install pelican markdown beautifulsoup4 pillow
make DEBUG=1 OUTPUTDIR=output devserver
node_modules/.bin/htmlhint output/
node_modules/.bin/htmllint output/
csslint --ignore=order-alphabetical output/theme/css/main.css
htmlhint output/
htmllint output/
make devserver
lighthouse http://localhost:
make stopserver