mirror of
https://github.com/c0de-archive/pelican-mg.git
synced 2024-12-22 08:22:40 +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"
|
- "--ignore=Bad value \"DUMMY\" for attribute \"type\" on element \"link\": Subtype missing"
|
||||||
files: ^templates/[^/]*\.html$
|
files: ^templates/[^/]*\.html$
|
||||||
exclude: ^templates/(index|tipue_search)\.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
|
# BEWARE ! Makefiles require the use of hard tabs
|
||||||
|
|
||||||
NODE_BIN := node_modules/.bin
|
.PHONY: install check lint test
|
||||||
|
|
||||||
.PHONY: install check test
|
|
||||||
|
|
||||||
install:
|
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
|
pip install pre-commit
|
||||||
pre-commit install
|
pre-commit install
|
||||||
|
|
||||||
check:
|
check: eslint
|
||||||
$(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$')
|
|
||||||
pre-commit run --all-files
|
pre-commit run --all-files
|
||||||
|
|
||||||
|
eslint:
|
||||||
|
eslint templates/js/*.js
|
||||||
|
|
||||||
test:
|
test:
|
||||||
./test_ludochaordic.sh
|
./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.
|
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.
|
The theme is suited for a single author blog. Feeds are provided via ATOM.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(() => {
|
||||||
$('.tipue_search').tipuesearch({
|
$('.tipue_search').tipuesearch({
|
||||||
'show': 10,
|
show: 10,
|
||||||
'mode': 'json',
|
mode: 'json',
|
||||||
'showURL': false,
|
showURL: false,
|
||||||
'descriptiveWords': 75,
|
descriptiveWords: 75,
|
||||||
'highlightEveryTerm': true,
|
highlightEveryTerm: true,
|
||||||
'contentLocation': './tipue_search.json'
|
contentLocation: './tipue_search.json',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,17 +4,43 @@
|
|||||||
* - true => select ONLY articles with this tag
|
* - true => select ONLY articles with this tag
|
||||||
* - false => do NOT select articles with this tag
|
* - false => do NOT select articles with this tag
|
||||||
* */
|
* */
|
||||||
window.tagFilters = {}
|
(function iife() {
|
||||||
|
'strict';
|
||||||
|
|
||||||
function indexOf(array, predicate) {
|
window.tagFilters = {};
|
||||||
for (var i = 0; i < array.length; i++) if (predicate(array[i])) return array[i];
|
|
||||||
}
|
|
||||||
function includes(array, value) {
|
|
||||||
return array.indexOf(value) !== -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
function toggleTagFilter(tag) {
|
function includes(anArray, value) {
|
||||||
var filterState = window.tagFilters[tag]
|
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) {
|
if (filterState === true) {
|
||||||
this.classList.remove('mg-tag-filter-include');
|
this.classList.remove('mg-tag-filter-include');
|
||||||
filterState = false;
|
filterState = false;
|
||||||
@ -31,48 +57,20 @@ function toggleTagFilter(tag) {
|
|||||||
}
|
}
|
||||||
window.tagFilters[tag] = filterState;
|
window.tagFilters[tag] = filterState;
|
||||||
updateArticlesVisibility();
|
updateArticlesVisibility();
|
||||||
}
|
};
|
||||||
|
|
||||||
function toggleLangTagFilter(langs) {
|
window.toggleLangTagFilter = function toggleLangTagFilter(langs) {
|
||||||
var lang = this.textContent;
|
let lang = this.textContent;
|
||||||
window.tagFilters['lang:'+lang] = undefined;
|
window.tagFilters[`lang:${ lang }`] = undefined;
|
||||||
lang = langs[langs.indexOf(lang) + 1];
|
lang = langs[langs.indexOf(lang) + 1];
|
||||||
if (typeof lang === 'undefined') {
|
if (typeof lang === 'undefined') {
|
||||||
lang = 'lang'
|
lang = 'lang';
|
||||||
this.title = 'Language filter (disabled)';
|
this.title = 'Language filter (disabled)';
|
||||||
} else {
|
} else {
|
||||||
window.tagFilters['lang:'+lang] = true;
|
window.tagFilters[`lang:${ lang }`] = true;
|
||||||
this.title = 'Language filter (include only "' + lang + '" articles)';
|
this.title = `Language filter (include only "${ lang }" articles)`;
|
||||||
}
|
}
|
||||||
this.textContent = lang;
|
this.textContent = lang;
|
||||||
updateArticlesVisibility();
|
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() {
|
$(document).ready(() => {
|
||||||
$('.mg-container-social').height($('article').height());
|
$('.mg-container-social').height($('article').height());
|
||||||
$('#mg-panel-social').stick_in_parent({offset_top: 35});
|
$('#mg-panel-social').stick_in_parent({ 'offset_top': 35 });
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -o pipefail -o errexit -o nounset -o xtrace
|
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 ..
|
cd ..
|
||||||
git clone https://github.com/Lucas-C/ludochaordic.git
|
git clone https://github.com/Lucas-C/ludochaordic.git
|
||||||
cd ludochaordic
|
cd ludochaordic
|
||||||
@ -8,5 +12,11 @@ cd ludochaordic
|
|||||||
pip install pelican markdown beautifulsoup4 pillow
|
pip install pelican markdown beautifulsoup4 pillow
|
||||||
make DEBUG=1 OUTPUTDIR=output devserver
|
make DEBUG=1 OUTPUTDIR=output devserver
|
||||||
|
|
||||||
node_modules/.bin/htmlhint output/
|
csslint --ignore=order-alphabetical output/theme/css/main.css
|
||||||
node_modules/.bin/htmllint output/
|
|
||||||
|
htmlhint output/
|
||||||
|
htmllint output/
|
||||||
|
|
||||||
|
make devserver
|
||||||
|
lighthouse http://localhost:
|
||||||
|
make stopserver
|
||||||
|
Loading…
Reference in New Issue
Block a user