From: signal9 Date: Sat, 4 Jan 2025 20:57:23 +0000 (-0700) Subject: first commit, getting set up X-Git-Url: https://git.vexinglabs.com/?a=commitdiff_plain;h=ff8e176e37d25bd80d67cddc3cc9959a2d3125ac;p=vexingworkshop.git first commit, getting set up --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6ca0b6f --- /dev/null +++ b/Makefile @@ -0,0 +1,89 @@ +PY?= +PELICAN?=pelican +PELICANOPTS= + +BASEDIR=$(CURDIR) +INPUTDIR=$(BASEDIR)/content +OUTPUTDIR=$(BASEDIR)/output +CONFFILE=$(BASEDIR)/pelicanconf.py +PUBLISHCONF=$(BASEDIR)/publishconf.py + +SSH_HOST=localhost +SSH_PORT=22 +SSH_USER=signal9 +SSH_TARGET_DIR=/var/www + + +DEBUG ?= 0 +ifeq ($(DEBUG), 1) + PELICANOPTS += -D +endif + +RELATIVE ?= 0 +ifeq ($(RELATIVE), 1) + PELICANOPTS += --relative-urls +endif + +SERVER ?= "0.0.0.0" + +PORT ?= 0 +ifneq ($(PORT), 0) + PELICANOPTS += -p $(PORT) +endif + + +help: + @echo 'Makefile for a pelican Web site ' + @echo ' ' + @echo 'Usage: ' + @echo ' make html (re)generate the web site ' + @echo ' make clean remove the generated files ' + @echo ' make regenerate regenerate files upon modification ' + @echo ' make publish generate using production settings ' + @echo ' make serve [PORT=8000] serve site at http://localhost:8000' + @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 ' + @echo ' make devserver [PORT=8000] serve and regenerate together ' + @echo ' make devserver-global regenerate and serve on 0.0.0.0 ' + @echo ' make ssh_upload upload the web site via SSH ' + @echo ' make sftp_upload upload the web site via SFTP ' + @echo ' make rsync_upload upload the web site via rsync+ssh ' + @echo ' ' + @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html ' + @echo 'Set the RELATIVE variable to 1 to enable relative urls ' + @echo ' ' + +html: + "$(PELICAN)" "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) + +clean: + [ ! -d "$(OUTPUTDIR)" ] || rm -rf "$(OUTPUTDIR)" + +regenerate: + "$(PELICAN)" -r "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) + +serve: + "$(PELICAN)" -l "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) + +serve-global: + "$(PELICAN)" -l "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) -b $(SERVER) + +devserver: + "$(PELICAN)" -lr "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) + +devserver-global: + "$(PELICAN)" -lr "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) -b 0.0.0.0 + +publish: + "$(PELICAN)" "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(PUBLISHCONF)" $(PELICANOPTS) + +ssh_upload: publish + scp -P $(SSH_PORT) -r "$(OUTPUTDIR)"/* "$(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)" + +sftp_upload: publish + printf 'put -r $(OUTPUTDIR)/*' | sftp $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) + +rsync_upload: publish + rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --include tags --cvs-exclude --delete "$(OUTPUTDIR)"/ "$(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)" + + +.PHONY: html help clean regenerate serve serve-global devserver devserver-global publish ssh_upload sftp_upload rsync_upload diff --git a/README.md b/README.md index ac97134..482076f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # Vexing Workshop -The personal blog of signal9, of Vexing Workshop. +The online presense of Vexing Workshop + +## Goals + +* blog +* gallery +* shop +* events calendar +* link tree + +## Tasks diff --git a/pelicanconf.py b/pelicanconf.py new file mode 100644 index 0000000..6a3928d --- /dev/null +++ b/pelicanconf.py @@ -0,0 +1,35 @@ +AUTHOR = 'Adam' +SITENAME = 'VexingWorkshop' +SITEURL = "" + +PATH = "content" + +TIMEZONE = 'America/Denver' + +DEFAULT_LANG = 'en' + +# Feed generation is usually not desired when developing +FEED_ALL_ATOM = None +CATEGORY_FEED_ATOM = None +TRANSLATION_FEED_ATOM = None +AUTHOR_FEED_ATOM = None +AUTHOR_FEED_RSS = None + +# Blogroll +LINKS = ( + ("Pelican", "https://getpelican.com/"), + ("Python.org", "https://www.python.org/"), + ("Jinja2", "https://palletsprojects.com/p/jinja/"), + ("You can modify those links in your config file", "#"), +) + +# Social widget +SOCIAL = ( + ("You can add links in your config file", "#"), + ("Another social link", "#"), +) + +DEFAULT_PAGINATION = 10 + +# Uncomment following line if you want document-relative URLs when developing +# RELATIVE_URLS = True diff --git a/publishconf.py b/publishconf.py new file mode 100644 index 0000000..6f1308b --- /dev/null +++ b/publishconf.py @@ -0,0 +1,22 @@ +# This file is only used if you use `make publish` or +# explicitly specify it as your config file. + +import os +import sys + +sys.path.append(os.curdir) +from pelicanconf import * + +# If your site is available via HTTPS, make sure SITEURL begins with https:// +SITEURL = "" +RELATIVE_URLS = False + +FEED_ALL_ATOM = "feeds/all.atom.xml" +CATEGORY_FEED_ATOM = "feeds/{slug}.atom.xml" + +DELETE_OUTPUT_DIRECTORY = True + +# Following items are often useful when publishing + +# DISQUS_SITENAME = "" +# GOOGLE_ANALYTICS = "" diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..80944f2 --- /dev/null +++ b/tasks.py @@ -0,0 +1,150 @@ +import os +import shlex +import shutil +import sys + +from invoke import task +from invoke.main import program +from pelican import main as pelican_main +from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer +from pelican.settings import DEFAULT_CONFIG, get_settings_from_file + +OPEN_BROWSER_ON_SERVE = True +SETTINGS_FILE_BASE = "pelicanconf.py" +SETTINGS = {} +SETTINGS.update(DEFAULT_CONFIG) +LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE) +SETTINGS.update(LOCAL_SETTINGS) + +CONFIG = { + "settings_base": SETTINGS_FILE_BASE, + "settings_publish": "publishconf.py", + # Output path. Can be absolute or relative to tasks.py. Default: 'output' + "deploy_path": SETTINGS["OUTPUT_PATH"], + # Remote server configuration + "ssh_user": "signal9", + "ssh_host": "localhost", + "ssh_port": "22", + "ssh_path": "/var/www", + # Host and port for `serve` + "host": "localhost", + "port": 8000, +} + + +@task +def clean(c): + """Remove generated files""" + if os.path.isdir(CONFIG["deploy_path"]): + shutil.rmtree(CONFIG["deploy_path"]) + os.makedirs(CONFIG["deploy_path"]) + + +@task +def build(c): + """Build local version of site""" + pelican_run("-s {settings_base}".format(**CONFIG)) + + +@task +def rebuild(c): + """`build` with the delete switch""" + pelican_run("-d -s {settings_base}".format(**CONFIG)) + + +@task +def regenerate(c): + """Automatically regenerate site upon file modification""" + pelican_run("-r -s {settings_base}".format(**CONFIG)) + + +@task +def serve(c): + """Serve site at http://$HOST:$PORT/ (default is localhost:8000)""" + + class AddressReuseTCPServer(RootedHTTPServer): + allow_reuse_address = True + + server = AddressReuseTCPServer( + CONFIG["deploy_path"], + (CONFIG["host"], CONFIG["port"]), + ComplexHTTPRequestHandler, + ) + + if OPEN_BROWSER_ON_SERVE: + # Open site in default browser + import webbrowser + + webbrowser.open("http://{host}:{port}".format(**CONFIG)) + + sys.stderr.write("Serving at {host}:{port} ...\n".format(**CONFIG)) + server.serve_forever() + + +@task +def reserve(c): + """`build`, then `serve`""" + build(c) + serve(c) + + +@task +def preview(c): + """Build production version of site""" + pelican_run("-s {settings_publish}".format(**CONFIG)) + +@task +def livereload(c): + """Automatically reload browser tab upon file modification.""" + from livereload import Server + + def cached_build(): + cmd = "-s {settings_base} -e CACHE_CONTENT=true LOAD_CONTENT_CACHE=true" + pelican_run(cmd.format(**CONFIG)) + + cached_build() + server = Server() + theme_path = SETTINGS["THEME"] + watched_globs = [ + CONFIG["settings_base"], + f"{theme_path}/templates/**/*.html", + ] + + content_file_extensions = [".md", ".rst"] + for extension in content_file_extensions: + content_glob = "{}/**/*{}".format(SETTINGS["PATH"], extension) + watched_globs.append(content_glob) + + static_file_extensions = [".css", ".js"] + for extension in static_file_extensions: + static_file_glob = f"{theme_path}/static/**/*{extension}" + watched_globs.append(static_file_glob) + + for glob in watched_globs: + server.watch(glob, cached_build) + + if OPEN_BROWSER_ON_SERVE: + # Open site in default browser + import webbrowser + + webbrowser.open("http://{host}:{port}".format(**CONFIG)) + + server.serve(host=CONFIG["host"], port=CONFIG["port"], root=CONFIG["deploy_path"]) + + +@task +def publish(c): + """Publish to production via rsync""" + pelican_run("-s {settings_publish}".format(**CONFIG)) + c.run( + 'rsync --delete --exclude ".DS_Store" -pthrvz -c ' + '-e "ssh -p {ssh_port}" ' + "{} {ssh_user}@{ssh_host}:{ssh_path}".format( + CONFIG["deploy_path"].rstrip("/") + "/", **CONFIG + ) + ) + + +def pelican_run(cmd): + cmd += " " + program.core.remainder # allows to pass-through args to pelican + pelican_main(shlex.split(cmd)) diff --git a/themes/vexingworkshop/templates/archives.html b/themes/vexingworkshop/templates/archives.html new file mode 100644 index 0000000..a61bf3c --- /dev/null +++ b/themes/vexingworkshop/templates/archives.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %}{{ SITENAME|striptags }} - Archives{% endblock %} + +{% block content %} +

Archives for {{ SITENAME }}

+ +
+ {% for article in dates %} +
{{ article.locale_date }}
+
{{ article.title }}
+ {% endfor %} +
+{% endblock %} diff --git a/themes/vexingworkshop/templates/article.html b/themes/vexingworkshop/templates/article.html new file mode 100644 index 0000000..a01de10 --- /dev/null +++ b/themes/vexingworkshop/templates/article.html @@ -0,0 +1,65 @@ +{% extends "base.html" %} +{% block html_lang %}{{ article.lang }}{% endblock %} + +{% block title %}{{ SITENAME|striptags }} - {{ article.title|striptags }}{% endblock %} + +{% block head %} + {{ super() }} + + {% import 'translations.html' as translations with context %} + {% if translations.entry_hreflang(article) %} + {{ translations.entry_hreflang(article) }} + {% endif %} + + {% if article.description %} + + {% endif %} + + {% for tag in article.tags %} + + {% endfor %} + +{% endblock %} + +{% block content %} +
+
+

+ {{ article.title }}

+ {% import 'translations.html' as translations with context %} + {{ translations.translations_for(article) }} +
+ {{ article.content }} +
+

Published:

+ {% if article.modified %} +

Last updated:

+ {% endif %} + {% if article.authors %} +
+ By {% for author in article.authors %} + {{ author }} + {% endfor %} +
+ {% endif %} + {% if article.category %} +

+ Category: {{ article.category }} +

+ {% endif %} + {% if article.tags %} +

+ Tags: + {% for tag in article.tags %} + {{ tag }} + {% endfor %} +

+ {% endif %} +
+
+{% endblock %} diff --git a/themes/vexingworkshop/templates/author.html b/themes/vexingworkshop/templates/author.html new file mode 100644 index 0000000..06f871d --- /dev/null +++ b/themes/vexingworkshop/templates/author.html @@ -0,0 +1,7 @@ +{% extends "index.html" %} + +{% block title %}{{ SITENAME|striptags }} - Articles by {{ author }}{% endblock %} + +{% block content_title %} +

Articles by {{ author }}

+{% endblock %} diff --git a/themes/vexingworkshop/templates/authors.html b/themes/vexingworkshop/templates/authors.html new file mode 100644 index 0000000..97a7457 --- /dev/null +++ b/themes/vexingworkshop/templates/authors.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}{{ SITENAME|striptags }} - Authors{% endblock %} + +{% block content %} +

Authors on {{ SITENAME }}

+ +{% endblock %} diff --git a/themes/vexingworkshop/templates/base.html b/themes/vexingworkshop/templates/base.html new file mode 100644 index 0000000..e9461fd --- /dev/null +++ b/themes/vexingworkshop/templates/base.html @@ -0,0 +1,72 @@ + + + + {% block head %} + {% block title %}{{ SITENAME|striptags }}{% endblock title %} + + + + {% if SITESUBTITLE %} + + {% endif %} + {% if STYLESHEET_URL %} + + {% endif %} + {% if FEED_ALL_ATOM %} + + {% endif %} + {% if FEED_ALL_RSS %} + + {% endif %} + {% if FEED_ATOM %} + + {% endif %} + {% if FEED_RSS %} + + {% endif %} + {% if CATEGORY_FEED_ATOM and category %} + + {% endif %} + {% if CATEGORY_FEED_RSS and category %} + + {% endif %} + {% if TAG_FEED_ATOM and tag %} + + {% endif %} + {% if TAG_FEED_RSS and tag %} + + {% endif %} + {% endblock head %} + + + +
+

{{ SITENAME }}

{% if SITESUBTITLE %}

{{ SITESUBTITLE }}

{% endif %}
+ +
+
+ {% block content %} + {% endblock %} +
+ + + diff --git a/themes/vexingworkshop/templates/categories.html b/themes/vexingworkshop/templates/categories.html new file mode 100644 index 0000000..c723f8a --- /dev/null +++ b/themes/vexingworkshop/templates/categories.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}{{ SITENAME|striptags }} - Categories{% endblock %} + +{% block content %} +

Categories on {{ SITENAME }}

+ +{% endblock %} diff --git a/themes/vexingworkshop/templates/category.html b/themes/vexingworkshop/templates/category.html new file mode 100644 index 0000000..bfad391 --- /dev/null +++ b/themes/vexingworkshop/templates/category.html @@ -0,0 +1,7 @@ +{% extends "index.html" %} + +{% block title %}{{ SITENAME|striptags }} - {{ category }} category{% endblock %} + +{% block content_title %} +

Articles in the {{ category }} category

+{% endblock %} diff --git a/themes/vexingworkshop/templates/index.html b/themes/vexingworkshop/templates/index.html new file mode 100644 index 0000000..97caac6 --- /dev/null +++ b/themes/vexingworkshop/templates/index.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} +{% block content %} + {% block content_title %} +

All articles

+ {% endblock %} + + + {% for article in articles_page.object_list %} +
+

{{ article.title }}

+
{{ article.summary }}
+
+

Published:

+
By + {% for author in article.authors %} + {{ author }} + {% endfor %} +
+
+
+ {% endfor %} + + {% if articles_page.has_other_pages() %} + {% include 'pagination.html' %} + {% endif %} + +{% endblock content %} diff --git a/themes/vexingworkshop/templates/page.html b/themes/vexingworkshop/templates/page.html new file mode 100644 index 0000000..0eefc7e --- /dev/null +++ b/themes/vexingworkshop/templates/page.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% block html_lang %}{{ page.lang }}{% endblock %} + +{% block title %}{{ SITENAME|striptags }} - {{ page.title|striptags }}{%endblock%} + +{% block head %} + {{ super() }} + + {% import 'translations.html' as translations with context %} + {% if translations.entry_hreflang(page) %} + {{ translations.entry_hreflang(page) }} + {% endif %} +{% endblock %} + +{% block content %} +
+
+

{{ page.title }}

+
+ {% import 'translations.html' as translations with context %} + {{ translations.translations_for(page) }} + + {{ page.content }} + + {% if page.modified %} +
+

+ Last updated: {{ page.locale_modified }} +

+
+ {% endif %} +
+{% endblock %} diff --git a/themes/vexingworkshop/templates/pagination.html b/themes/vexingworkshop/templates/pagination.html new file mode 100644 index 0000000..9511fdb --- /dev/null +++ b/themes/vexingworkshop/templates/pagination.html @@ -0,0 +1,17 @@ +{% if DEFAULT_PAGINATION %} + {% set first_page = articles_paginator.page(1) %} + {% set last_page = articles_paginator.page(articles_paginator.num_pages) %} + +{% endif %} diff --git a/themes/vexingworkshop/templates/period_archives.html b/themes/vexingworkshop/templates/period_archives.html new file mode 100644 index 0000000..181f493 --- /dev/null +++ b/themes/vexingworkshop/templates/period_archives.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %}{{ SITENAME|striptags }} - {{ period | reverse | join(' ') }} archives{% endblock %} + +{% block content %} +

Archives for {{ period | reverse | join(' ') }}

+ +
+ {% for article in dates %} +
{{ article.locale_date }}
+
{{ article.title }}
+ {% endfor %} +
+{% endblock %} diff --git a/themes/vexingworkshop/templates/tag.html b/themes/vexingworkshop/templates/tag.html new file mode 100644 index 0000000..be21778 --- /dev/null +++ b/themes/vexingworkshop/templates/tag.html @@ -0,0 +1,7 @@ +{% extends "index.html" %} + +{% block title %}{{ SITENAME|striptags }} - {{ tag }} tag{% endblock %} + +{% block content_title %} +

Articles tagged with {{ tag }}

+{% endblock %} diff --git a/themes/vexingworkshop/templates/tags.html b/themes/vexingworkshop/templates/tags.html new file mode 100644 index 0000000..b21e5b5 --- /dev/null +++ b/themes/vexingworkshop/templates/tags.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}{{ SITENAME|striptags }} - Tags{% endblock %} + +{% block content %} +

Tags for {{ SITENAME }}

+ +{% endblock %} diff --git a/themes/vexingworkshop/templates/translations.html b/themes/vexingworkshop/templates/translations.html new file mode 100644 index 0000000..eed0703 --- /dev/null +++ b/themes/vexingworkshop/templates/translations.html @@ -0,0 +1,16 @@ +{% macro translations_for(article) %} + {% if article.translations %} + Translations: + {% for translation in article.translations %} + {{ translation.lang }} + {% endfor %} + {% endif %} +{% endmacro %} + +{% macro entry_hreflang(entry) %} + {% if entry.translations %} + {% for translation in entry.translations %} + + {% endfor %} + {% endif %} +{% endmacro %}