mirror of
https://github.com/offen/website.git
synced 2024-11-25 02:10:26 +01:00
Merge pull request #131 from offen/faster-dev
Improve build times in dev setup
This commit is contained in:
commit
f3d15cb7c0
1
.gitignore
vendored
1
.gitignore
vendored
@ -115,3 +115,4 @@ venv.bak/
|
||||
test.py
|
||||
*.json
|
||||
|
||||
homepage/cache
|
||||
|
@ -1,9 +1,13 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
homepage:
|
||||
proxy:
|
||||
image: nginx:1.17-alpine
|
||||
volumes:
|
||||
- output:/usr/share/nginx/html
|
||||
ports:
|
||||
- 8000:8000
|
||||
- 8000:80
|
||||
homepage:
|
||||
build:
|
||||
context: '.'
|
||||
dockerfile: ./Dockerfile.python
|
||||
@ -11,9 +15,11 @@ services:
|
||||
volumes:
|
||||
- .:/website
|
||||
- homepagedeps:/root/.local
|
||||
command: make devserver
|
||||
- output:/website/homepage/output
|
||||
command: make regenerate
|
||||
environment:
|
||||
DEBUG: 1
|
||||
|
||||
volumes:
|
||||
homepagedeps:
|
||||
output:
|
||||
|
@ -1,6 +1,5 @@
|
||||
import os
|
||||
from datetime import datetime
|
||||
from pelican_decorate_content import decorate_content
|
||||
# If your site is available via HTTPS, make sure SITEURL begins with https://
|
||||
RELATIVE_URLS = False
|
||||
|
||||
@ -27,7 +26,8 @@ DEFAULT_PAGINATION = False
|
||||
THEME = './theme'
|
||||
|
||||
# Delete the output directory before generating new files.
|
||||
DELETE_OUTPUT_DIRECTORY = True
|
||||
DELETE_OUTPUT_DIRECTORY = False
|
||||
CACHE_CONTENT = True
|
||||
|
||||
DIRECT_TEMPLATES = ['sitemap', 'archives']
|
||||
|
||||
@ -45,7 +45,7 @@ PAGE_SAVE_AS = '{slug}/index.html'
|
||||
ARTICLE_SAVE_AS = 'blog/{slug}/index.html'
|
||||
|
||||
PLUGIN_PATHS = ['./plugins']
|
||||
PLUGINS = [decorate_content, 'assets']
|
||||
PLUGINS = ['decorate_content', 'assets']
|
||||
|
||||
MARKDOWN = {
|
||||
'extension_configs': {
|
||||
|
1
homepage/plugins/decorate_content/__init__.py
Normal file
1
homepage/plugins/decorate_content/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .decorate_content import *
|
33
homepage/plugins/decorate_content/decorate_content.py
Normal file
33
homepage/plugins/decorate_content/decorate_content.py
Normal file
@ -0,0 +1,33 @@
|
||||
from json import loads
|
||||
|
||||
from pelican import signals
|
||||
from pelican.contents import Article, Page, Static
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def content_object_init(instance):
|
||||
if isinstance(instance, (Article, Page, Static)):
|
||||
plugin_settings = instance.settings.get("DECORATE_CONTENT", {})
|
||||
content_overrides = (
|
||||
instance.metadata.get("decorate_content", None)
|
||||
if instance.metadata is not None
|
||||
else None
|
||||
)
|
||||
|
||||
settings = plugin_settings.copy()
|
||||
settings.update(
|
||||
loads(content_overrides) if content_overrides is not None else {}
|
||||
)
|
||||
|
||||
soup = BeautifulSoup(instance._content, "html.parser")
|
||||
|
||||
for selector, class_names in settings.items():
|
||||
elems = soup.select(selector)
|
||||
for elem in elems:
|
||||
elem["class"] = elem.get("class", []) + class_names
|
||||
|
||||
instance._content = soup.decode()
|
||||
|
||||
|
||||
def register():
|
||||
signals.content_object_init.connect(content_object_init)
|
@ -1,5 +1,4 @@
|
||||
pelican==4.0.1
|
||||
pelican==4.5.3
|
||||
markdown==3.1.1
|
||||
git+git://github.com/miracle2k/webassets#d1f3455e383446ca4ab0c644f326ee937e68e809
|
||||
beautifulsoup4==4.8.1
|
||||
pelican-decorate-content==0.1.1
|
||||
|
Loading…
Reference in New Issue
Block a user