mirror of
https://github.com/c0de-archive/pelican-mg.git
synced 2024-12-22 00:12:41 +00:00
Fixing stuff
This commit is contained in:
parent
98ffe5e6a7
commit
f258f0becb
11
.eslintrc
Executable file
11
.eslintrc
Executable file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": ["strict"],
|
||||
"globals": {
|
||||
"document": false,
|
||||
"window": false,
|
||||
"$": false
|
||||
},
|
||||
"rules": {
|
||||
"no-undefined": 0
|
||||
}
|
||||
}
|
@ -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: ''
|
||||
|
14
Makefile
14
Makefile
@ -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
|
||||
|
@ -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.
|
||||
|
@ -1,10 +1,10 @@
|
||||
$(document).ready(function() {
|
||||
$('.tipue_search').tipuesearch({
|
||||
'show': 10,
|
||||
'mode': 'json',
|
||||
'showURL': false,
|
||||
'descriptiveWords': 75,
|
||||
'highlightEveryTerm': true,
|
||||
'contentLocation': './tipue_search.json'
|
||||
});
|
||||
$(document).ready(() => {
|
||||
$('.tipue_search').tipuesearch({
|
||||
show: 10,
|
||||
mode: 'json',
|
||||
showURL: false,
|
||||
descriptiveWords: 75,
|
||||
highlightEveryTerm: true,
|
||||
contentLocation: './tipue_search.json',
|
||||
});
|
||||
});
|
||||
|
@ -4,75 +4,73 @@
|
||||
* - 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];
|
||||
}
|
||||
function includes(array, value) {
|
||||
return array.indexOf(value) !== -1;
|
||||
};
|
||||
window.tagFilters = {};
|
||||
|
||||
function toggleTagFilter(tag) {
|
||||
var filterState = window.tagFilters[tag]
|
||||
function includes(anArray, value) {
|
||||
return anArray.indexOf(value) >= 0;
|
||||
}
|
||||
|
||||
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;
|
||||
this.classList.add('mg-tag-filter-exclude');
|
||||
this.title = 'Tag filter (exclude matching articles)';
|
||||
this.classList.remove('mg-tag-filter-include');
|
||||
filterState = false;
|
||||
this.classList.add('mg-tag-filter-exclude');
|
||||
this.title = 'Tag filter (exclude matching articles)';
|
||||
} else if (filterState === false) {
|
||||
this.classList.remove('mg-tag-filter-exclude');
|
||||
filterState = undefined;
|
||||
this.title = 'Tag filter (disabled)';
|
||||
this.classList.remove('mg-tag-filter-exclude');
|
||||
filterState = undefined;
|
||||
this.title = 'Tag filter (disabled)';
|
||||
} else {
|
||||
filterState = true;
|
||||
this.classList.add('mg-tag-filter-include');
|
||||
this.title = 'Tag filter (include matching articles)';
|
||||
filterState = true;
|
||||
this.classList.add('mg-tag-filter-include');
|
||||
this.title = 'Tag filter (include matching articles)';
|
||||
}
|
||||
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'
|
||||
this.title = 'Language filter (disabled)';
|
||||
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');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
@ -1,4 +1,4 @@
|
||||
$(document).ready(function() {
|
||||
$('.mg-container-social').height($('article').height());
|
||||
$('#mg-panel-social').stick_in_parent({offset_top: 35});
|
||||
$(document).ready(() => {
|
||||
$('.mg-container-social').height($('article').height());
|
||||
$('#mg-panel-social').stick_in_parent({ 'offset_top': 35 });
|
||||
});
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user