mirror of
https://github.com/c0de-archive/pelican-mg.git
synced 2024-12-21 07:52:40 +00:00
cleanup of unused assets
This commit is contained in:
parent
20e4732072
commit
7fc12014f0
12
.eslintrc
12
.eslintrc
@ -1,12 +0,0 @@
|
||||
{
|
||||
"extends": ["strict"],
|
||||
"globals": {
|
||||
"document": false,
|
||||
"langs": true,
|
||||
"window": false,
|
||||
"$": false
|
||||
},
|
||||
"rules": {
|
||||
"no-undefined": 0
|
||||
}
|
||||
}
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
/node_modules
|
||||
*~~
|
||||
venv
|
||||
.vscode
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"attr-value-double-quotes": false
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||
sha: v1.1.1
|
||||
hooks:
|
||||
- id: check-merge-conflict
|
||||
- id: trailing-whitespace
|
||||
args: [--no-markdown-linebreak-ext]
|
||||
exclude: ^static/(csslibs/|jslibs/|bundle-)
|
||||
- repo: git://github.com/Lucas-C/pre-commit-hooks
|
||||
sha: v1.1.4
|
||||
hooks:
|
||||
- id: remove-crlf
|
||||
- id: remove-tabs
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: gen_statics_bundles
|
||||
name: gen_statics_bundles
|
||||
language: system
|
||||
entry: ./gen_statics_bundles.py
|
||||
files: ^static/(main.css$|js/)
|
||||
- id: eslint
|
||||
name: eslint
|
||||
language: system
|
||||
entry: sh -c 'eslint static/js/*.js'
|
||||
files: ^static/js/
|
||||
- id: stylelint
|
||||
name: stylelint
|
||||
language: system
|
||||
entry: sh -c 'stylelint static/main.css'
|
||||
files: ^static/js/main.css$
|
13
.stylelintrc
13
.stylelintrc
@ -1,13 +0,0 @@
|
||||
{
|
||||
"extends": "stylelint-config-standard",
|
||||
"rules": {
|
||||
"at-rule-empty-line-before": null,
|
||||
"block-closing-brace-newline-before": null,
|
||||
"color-hex-case": null,
|
||||
"max-empty-lines": 2,
|
||||
"no-descending-specificity": null,
|
||||
"indentation": null,
|
||||
"rule-empty-line-before": null,
|
||||
"selector-list-comma-newline-after": null
|
||||
}
|
||||
}
|
15
.travis.yml
15
.travis.yml
@ -1,15 +0,0 @@
|
||||
language: python
|
||||
python: 3.6
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.cache/pip"
|
||||
- node_modules
|
||||
install:
|
||||
- ./run.sh install
|
||||
- ./run.sh install_dev
|
||||
script:
|
||||
- pre-commit run --all-files
|
||||
- ./run.sh test_ludochaordic
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import html5lib, os, sys
|
||||
from markdown import markdown
|
||||
|
||||
SMALLEST = {}
|
||||
SMALLEST['gif'] = b'GIF89a\x01\x00\x01\x00\x00\x00\x00!\xf9\x04\x01\n\x00\x01\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02L\x01\x00;'
|
||||
SMALLEST['jpg'] = SMALLEST['jpeg'] = 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\x00\x00\x00\x00:~\x9bU\x00\x00\x00\nIDATx\x9cc\xfa\x0f\x00\x01\x05\x01\x02\xcf\xa0.\xcd\x00\x00\x00\x00IEND\xaeB`\x82'
|
||||
|
||||
def gen_img(img_url):
|
||||
if img_url[0] == '/':
|
||||
img_url = img_url[1:]
|
||||
if os.path.exists(img_url):
|
||||
return
|
||||
os.makedirs(os.path.dirname(img_url), exist_ok=True)
|
||||
ext = img_url.split('.')[-1].lower()
|
||||
with open(img_url, 'wb') as img_file:
|
||||
img_file.write(SMALLEST[ext])
|
||||
|
||||
def enumerate_imgs(md_file_paths):
|
||||
for md_file_path in md_file_paths:
|
||||
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
|
||||
yield os.path.join('content', img_url)
|
||||
# Adding also images from "Image:" pelican metadata entries
|
||||
for line in md_content.splitlines()[:6]:
|
||||
if not line.startswith('Image: '):
|
||||
continue
|
||||
yield os.path.join('content', line.replace('Image: ', '').strip())
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1:
|
||||
if len(sys.argv) > 2 and sys.argv[1] == '--list':
|
||||
for img_path in enumerate_imgs(sys.argv[2:]):
|
||||
print(img_path)
|
||||
else:
|
||||
for img_path in enumerate_imgs(sys.argv[1:]):
|
||||
gen_img(img_path)
|
||||
else:
|
||||
print('Checking that pelican plugin image_process.scale works OK on those imgs')
|
||||
from PIL import Image
|
||||
sys.path.append('../pelican-plugins/image_process/')
|
||||
from image_process import scale
|
||||
for ext, content in sorted(SMALLEST.items()):
|
||||
print('- Testing {} img'.format(ext))
|
||||
small_img_filename = 'img.{}'.format(ext)
|
||||
with open(small_img_filename, 'wb') as small_img:
|
||||
small_img.write(content)
|
||||
scale(Image.open(small_img_filename), '300', '300', False, False) # raise an exception if img.getbbox() returns None
|
32
run.sh
32
run.sh
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# USAGE: ./run.sh ( install | test_ludochaordic )
|
||||
# USAGE: ./run.sh ( install )
|
||||
|
||||
set -o pipefail -o errexit -o nounset -o xtrace
|
||||
|
||||
@ -9,34 +9,4 @@ install () {
|
||||
./gen_statics_bundles.py || true
|
||||
}
|
||||
|
||||
install_dev () {
|
||||
npm install -g eslint eslint-config-strict eslint-plugin-filenames htmlhint stylelint
|
||||
npm install stylelint-config-standard
|
||||
pip install html5lib html5validator pre-commit
|
||||
pre-commit install
|
||||
}
|
||||
|
||||
test_ludochaordic () {
|
||||
cd ..
|
||||
if ! [ -d pelican-plugins ]; then
|
||||
git clone https://github.com/getpelican/pelican-plugins.git
|
||||
cd pelican-plugins
|
||||
git submodule update --init image_process representative_image tag_cloud
|
||||
cd ..
|
||||
fi
|
||||
[ -d ludochaordic ] || git clone https://github.com/Lucas-C/ludochaordic.git
|
||||
cd ludochaordic
|
||||
|
||||
../pelican-mg/gen_imgs_from_mds.py content/*.md
|
||||
make DEBUG=1 OUTPUTDIR=output publish
|
||||
|
||||
# Too many missing img alt attributes in thoses:
|
||||
rm output/street-art-and-hedonogeolostism-in-london.html output/variante-2-joueurs-pour-bang-le-jeu-de-des.html
|
||||
|
||||
html5validator --root output/ --ignore-re='.*(Element "eof" not allowed as child of element "p" in this context.|Element "style" not allowed as child of element.*|Text not allowed in element "iframe" in this context.|Attribute "allow" not allowed on element "iframe" at this point.|No "p" element in scope but a "p" end tag seen.|End tag "p" implied, but there were open elements.|Unclosed element "a".|End tag "div" seen, but there were open elements.)' # issue with pelican renderer: <p> contains legally only inline-/inline-block-elements
|
||||
|
||||
cp ../pelican-mg/.htmlhintrc output/
|
||||
htmlhint output/
|
||||
}
|
||||
|
||||
eval "$1"
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user