mirror of
https://github.com/c0de-archive/pelican-mg.git
synced 2024-12-22 08:22:40 +00:00
Fixing tests & getting rid of Makefile
This commit is contained in:
parent
54b297bc30
commit
9a00ee06b7
@ -9,12 +9,11 @@
|
||||
sha: v1.1.4
|
||||
hooks:
|
||||
- id: remove-crlf
|
||||
exclude: npp/.*\.xml
|
||||
- id: remove-tabs
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: eslint
|
||||
name: eslint
|
||||
language: system
|
||||
entry: make eslint
|
||||
entry: sh -c 'eslint templates/js/*.js'
|
||||
files: ''
|
||||
|
@ -1,6 +1,6 @@
|
||||
language: python
|
||||
python: 3.5
|
||||
install: make install
|
||||
install: ./run.sh install
|
||||
script:
|
||||
- make check
|
||||
- make test
|
||||
- pre-commit run --all-files
|
||||
- ./run.sh test_ludochaordic
|
||||
|
17
Makefile
17
Makefile
@ -1,17 +0,0 @@
|
||||
# BEWARE ! Makefiles require the use of hard tabs
|
||||
|
||||
.PHONY: install check lint test
|
||||
|
||||
install:
|
||||
npm install -g csslint eslint eslint-config-strict eslint-plugin-filenames htmlhint htmllint-cli lighthouse
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
|
||||
check: eslint
|
||||
pre-commit run --all-files
|
||||
|
||||
eslint:
|
||||
eslint templates/js/*.js
|
||||
|
||||
test:
|
||||
./test_ludochaordic.sh
|
@ -46,7 +46,7 @@ Features
|
||||
* Analytics with Google Analytics, PIWIK and StatCounter.
|
||||
* Share buttons built with share urls.
|
||||
* Custom footer notice.
|
||||
* W3C-Validatated HTML
|
||||
* W3C-Validated HTML
|
||||
|
||||
Install
|
||||
-------
|
||||
|
31
gen_imgs_from_mds.py
Executable file
31
gen_imgs_from_mds.py
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
import html5lib, os, sys
|
||||
from markdown import markdown
|
||||
|
||||
SMALLEST_JPG = b'\xff\xd8\xff\xdb\x00C\x00\x03\x02\x02\x02\x02\x02\x03\x02\x02\x02\x03\x03\x03\x03\x04\x06\x04\x04\x04\x04\x04\x08\x06\x06\x05\x06\t\x08\n\n\t\x08\t\t\n\x0c\x0f\x0c\n\x0b\x0e\x0b\t\t\r\x11\r\x0e\x0f\x10\x10\x11\x10\n\x0c\x12\x13\x12\x10\x13\x0f\x10\x10\x10\xff\xc9\x00\x0b\x08\x00\x01\x00\x01\x01\x01\x11\x00\xff\xcc\x00\x06\x00\x10\x10\x05\xff\xda\x00\x08\x01\x01\x00\x00?\x00\xd2\xcf \xff\xd9'
|
||||
|
||||
SMALLEST_PNG = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\nIDATx\x9cc\x00\x01\x00\x00\x05\x00\x01\r\n-\xb4\x00\x00\x00\x00IEND\xaeB`\x82'
|
||||
|
||||
SMALLEST_GIF = b'GIF89a\x01\x00\x01\x00\x80\x00\x00\xff\xff\xff\x00\x00\x00!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;'
|
||||
|
||||
for md_file_path in sys.argv[1:]:
|
||||
with open(md_file_path) as md_file:
|
||||
md_content = md_file.read()
|
||||
html = markdown(md_content)
|
||||
doc_root = html5lib.parse(html)
|
||||
for img in doc_root.iter('{http://www.w3.org/1999/xhtml}img'):
|
||||
img_url = img.attrib['src']
|
||||
if img_url.startswith('http'):
|
||||
continue
|
||||
os.makedirs(os.path.dirname(img_url), exist_ok=True)
|
||||
if img_url.lower().endswith('jpg') or img_url.lower().endswith('jpeg'):
|
||||
with open(img_url, 'wb') as img_file:
|
||||
img_file.write(SMALLEST_JPG)
|
||||
elif img_url.lower().endswith('png'):
|
||||
with open(img_url, 'wb') as img_file:
|
||||
img_file.write(SMALLEST_PNG)
|
||||
elif img_url.lower().endswith('gif'):
|
||||
with open(img_url, 'wb') as img_file:
|
||||
img_file.write(SMALLEST_GIF)
|
||||
else:
|
||||
print('Unknown image type:', img_url)
|
38
run.sh
Executable file
38
run.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# USAGE: ./run.sh ( install | test_ludochaordicn )
|
||||
|
||||
set -o pipefail -o errexit -o nounset -o xtrace
|
||||
|
||||
install () {
|
||||
npm install -g csslint eslint eslint-config-strict eslint-plugin-filenames htmlhint htmllint-cli lighthouse
|
||||
pip install html5validator pre-commit
|
||||
pre-commit install
|
||||
}
|
||||
|
||||
test_ludochaordic () {
|
||||
cd ..
|
||||
git clone https://github.com/getpelican/pelican-plugins.git
|
||||
cd pelican-plugins
|
||||
git submodule update --init image_process representative_image tag_cloud
|
||||
|
||||
cd ..
|
||||
git clone https://github.com/Lucas-C/ludochaordic.git
|
||||
cd ludochaordic
|
||||
|
||||
pip install pelican markdown beautifulsoup4 pillow html5lib
|
||||
../gen_imgs_from_mds.py *.md
|
||||
make DEBUG=1 OUTPUTDIR=output html
|
||||
|
||||
csslint --ignore=order-alphabetical output/theme/css/main.css
|
||||
|
||||
html5validator --root output/
|
||||
htmlhint output/
|
||||
htmllint output/
|
||||
|
||||
make devserver
|
||||
lighthouse http://localhost:
|
||||
make stopserver
|
||||
}
|
||||
|
||||
eval "$1"
|
@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o pipefail -o errexit -o nounset -o xtrace
|
||||
|
||||
cd ..
|
||||
git clone https://github.com/getpelican/pelican-plugins.git
|
||||
cd pelican-plugins
|
||||
git submodule update --init image_process representative_image tag_cloud
|
||||
|
||||
cd ..
|
||||
git clone https://github.com/Lucas-C/ludochaordic.git
|
||||
cd ludochaordic
|
||||
|
||||
pip install pelican markdown beautifulsoup4 pillow
|
||||
make DEBUG=1 OUTPUTDIR=output html
|
||||
# crash HERE because of missing imgs -> TODO:
|
||||
# - ./list_imgs_from_mds.py *.md -> currently incaple to extract img from content/2015-07-24-youtube_playlist_watcher
|
||||
# - create dummy jpg / png / gif files for each
|
||||
|
||||
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