Skip to content

Commit

Permalink
Format .py files
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed May 22, 2024
1 parent fa74e25 commit b36dac0
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 84 deletions.
36 changes: 20 additions & 16 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import nox

nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ['build'] # default session
nox.options.sessions = ["build"] # default session
nox.options.stop_on_first_error = True

BUILD_CFG = 'pelicanconf.py'
PUBLISH_CFG = 'publishconf.py'
BUILD_CFG = "pelicanconf.py"
PUBLISH_CFG = "publishconf.py"


@nox.session
def build(session):
""" Build local version of site """
session.install('-r', 'requirements.txt')
session.run('pelican', '-s', BUILD_CFG, *session.posargs)
"""Build local version of site"""
session.install("-r", "requirements.txt")
session.run("pelican", "-s", BUILD_CFG, *session.posargs)


@nox.session
def rebuild(session):
""" `build` with the delete switch """
session.install('-r', 'requirements.txt')
session.run('pelican', '-d', '-s', BUILD_CFG, *session.posargs)
"""`build` with the delete switch"""
session.install("-r", "requirements.txt")
session.run("pelican", "-d", "-s", BUILD_CFG, *session.posargs)


@nox.session
def serve(session):
""" Build the site and then serve it locally, watching for changes """
session.install('-r', 'requirements.txt')
"""Build the site and then serve it locally, watching for changes"""
session.install("-r", "requirements.txt")
# It appears that -r causes a build implicitly
#session.run('pelican', '-s', BUILD_CFG, *session.posargs)
session.run('pelican', '-lr', '-s', BUILD_CFG)
# session.run('pelican', '-s', BUILD_CFG, *session.posargs)
session.run("pelican", "-lr", "-s", BUILD_CFG)


@nox.session
def publish(session):
""" Build published version of site """
session.install('-r', 'requirements.txt')
session.run('pelican', '-s', PUBLISH_CFG, *session.posargs)
"""Build published version of site"""
session.install("-r", "requirements.txt")
session.run("pelican", "-s", PUBLISH_CFG, *session.posargs)
122 changes: 61 additions & 61 deletions pelicanconf.py
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
from datetime import date

# Site metadata
SITENAME = 'Knowledge Bits'
SITENAME = "Knowledge Bits"
SITESUBTITLE = "References I wish I'd already found"
AUTHOR = 'John T. Wodder II'
DEFAULT_LANG = 'en'
TIMEZONE = 'America/New_York'
LOCALE = 'en_US.UTF-8'
AUTHOR = "John T. Wodder II"
DEFAULT_LANG = "en"
TIMEZONE = "America/New_York"
LOCALE = "en_US.UTF-8"


# Site input layout
PATH = 'src'
ARTICLE_PATHS = ['posts']
STATIC_PATHS = ['static']
IGNORE_FILES = ['.*.swp']
PATH = "src"
ARTICLE_PATHS = ["posts"]
STATIC_PATHS = ["static"]
IGNORE_FILES = [".*.swp"]
USE_FOLDER_AS_CATEGORY = False


# Site output layout
OUTPUT_PATH = 'build'
OUTPUT_PATH = "build"

ARTICLE_URL = 'posts/{slug}/'
ARTICLE_SAVE_AS = ARTICLE_URL + 'index.html'
ARTICLE_LANG_URL = 'posts/{slug}/{lang}/'
ARTICLE_LANG_SAVE_AS = ARTICLE_LANG_URL + 'index.html'
ARTICLE_URL = "posts/{slug}/"
ARTICLE_SAVE_AS = ARTICLE_URL + "index.html"
ARTICLE_LANG_URL = "posts/{slug}/{lang}/"
ARTICLE_LANG_SAVE_AS = ARTICLE_LANG_URL + "index.html"

ARCHIVES_SAVE_AS = 'posts/index.html'
ARCHIVES_SAVE_AS = "posts/index.html"

DRAFT_URL = 'drafts/{slug}/'
DRAFT_SAVE_AS = DRAFT_URL + 'index.html'
DRAFT_LANG_URL = 'drafts/{slug}/{lang}/'
DRAFT_LANG_SAVE_AS = DRAFT_LANG_URL + 'index.html'
DRAFT_URL = "drafts/{slug}/"
DRAFT_SAVE_AS = DRAFT_URL + "index.html"
DRAFT_LANG_URL = "drafts/{slug}/{lang}/"
DRAFT_LANG_SAVE_AS = DRAFT_LANG_URL + "index.html"

PAGE_URL = '{slug}/'
PAGE_SAVE_AS = PAGE_URL + 'index.html'
PAGE_LANG_URL = '{slug}/{lang}/'
PAGE_LANG_SAVE_AS = PAGE_LANG_URL + 'index.html'
PAGE_URL = "{slug}/"
PAGE_SAVE_AS = PAGE_URL + "index.html"
PAGE_LANG_URL = "{slug}/{lang}/"
PAGE_LANG_SAVE_AS = PAGE_LANG_URL + "index.html"

DRAFT_PAGE_URL = 'drafts/{slug}/'
DRAFT_PAGE_SAVE_AS = DRAFT_PAGE_URL + 'index.html'
DRAFT_PAGE_LANG_URL = 'drafts/{slug}/{lang}/'
DRAFT_PAGE_LANG_SAVE_AS = DRAFT_PAGE_LANG_URL + 'index.html'
DRAFT_PAGE_URL = "drafts/{slug}/"
DRAFT_PAGE_SAVE_AS = DRAFT_PAGE_URL + "index.html"
DRAFT_PAGE_LANG_URL = "drafts/{slug}/{lang}/"
DRAFT_PAGE_LANG_SAVE_AS = DRAFT_PAGE_LANG_URL + "index.html"

#AUTHOR_URL = 'authors/{slug}/'
#AUTHOR_SAVE_AS = AUTHOR_URL + 'index.html'
AUTHOR_URL = '' # Disable author pages
AUTHOR_SAVE_AS = '' # Disable author pages
#AUTHORS_SAVE_AS = 'authors/index.html'
AUTHORS_SAVE_AS = '' # Disable authors listing
# AUTHOR_URL = 'authors/{slug}/'
# AUTHOR_SAVE_AS = AUTHOR_URL + 'index.html'
AUTHOR_URL = "" # Disable author pages
AUTHOR_SAVE_AS = "" # Disable author pages
# AUTHORS_SAVE_AS = 'authors/index.html'
AUTHORS_SAVE_AS = "" # Disable authors listing

CATEGORY_URL = 'categories/{slug}/'
CATEGORY_SAVE_AS = CATEGORY_URL + 'index.html'
CATEGORIES_SAVE_AS = 'categories/index.html'
CATEGORY_URL = "categories/{slug}/"
CATEGORY_SAVE_AS = CATEGORY_URL + "index.html"
CATEGORIES_SAVE_AS = "categories/index.html"

TAG_URL = 'tags/{slug}/'
TAG_SAVE_AS = TAG_URL + 'index.html'
TAGS_SAVE_AS = 'tags/index.html'
TAG_URL = "tags/{slug}/"
TAG_SAVE_AS = TAG_URL + "index.html"
TAGS_SAVE_AS = "tags/index.html"

DEFAULT_PAGINATION = 20

PAGINATION_PATTERNS = [
(1, '{url}', '{save_as}'),
(2, '{base_name}/{number}/', '{base_name}/{number}/index.html'),
(1, "{url}", "{save_as}"),
(2, "{base_name}/{number}/", "{base_name}/{number}/index.html"),
]


Expand All @@ -78,41 +78,41 @@
"toc_backlinks": "top",
}

SLUGIFY_SOURCE = 'basename'
PAGE_ORDER_BY = 'title'
DEFAULT_CATEGORY = 'Miscellanea'
DEFAULT_DATE_FORMAT = '%Y-%m-%d'
SLUGIFY_SOURCE = "basename"
PAGE_ORDER_BY = "title"
DEFAULT_CATEGORY = "Miscellanea"
DEFAULT_DATE_FORMAT = "%Y-%m-%d"


# Plugins
PLUGINS = ['plugins.autopages']
PLUGINS = ["plugins.autopages"]

# autopages
AUTHOR_PAGE_PATH = f'{PATH}/authors'
CATEGORY_PAGE_PATH = f'{PATH}/categories'
TAG_PAGE_PATH = f'{PATH}/tags'
AUTHOR_PAGE_PATH = f"{PATH}/authors"
CATEGORY_PAGE_PATH = f"{PATH}/categories"
TAG_PAGE_PATH = f"{PATH}/tags"


# Themes
THEME = './theme'
THEME = "./theme"


# Theme variables
USE_MATHJAX = True
GITHUB_SOURCE_URL = 'https://github.com/jwodder/kbits'
GITHUB_SOURCE_URL = "https://github.com/jwodder/kbits"
PATH_IN_REPO = PATH # PATH relative to root of repository
SHOW_AUTHOR = True
SHOW_AUTHOR_IN_LISTINGS = False

author_footer_link = 'https://github.com/jwodder'
author_footer_link = "https://github.com/jwodder"
site_creation_year = 2020
this_year = date.today().year
if this_year == site_creation_year:
copyright_years = site_creation_year
else:
copyright_years = f'{site_creation_year}{this_year}'
copyright_years = f"{site_creation_year}{this_year}"

FOOTER_HTML = f'''
FOOTER_HTML = f"""
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/">
<img alt="Creative Commons License" style="border-width: 0; vertical-align: middle;" src="https://i.creativecommons.org/l/by/4.0/80x15.png" />
</a>
Expand All @@ -122,21 +122,21 @@
rel="cc:attributionURL">{AUTHOR}</a>. This site's content is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative
Commons Attribution 4.0 International License</a>.
'''
"""

DISPLAY_CATEGORIES_ON_MENU = False
DISPLAY_PAGES_ON_MENU = False

MENUITEMS = [
('About This Site', 'about/'),
('Categories', 'categories/'),
('Tags', 'tags/'),
('Site Repository', 'https://github.com/jwodder/kbits'),
("About This Site", "about/"),
("Categories", "categories/"),
("Tags", "tags/"),
("Site Repository", "https://github.com/jwodder/kbits"),
]


# Variables to leave unset during development:
SITEURL = ''
SITEURL = ""
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
Expand All @@ -145,4 +145,4 @@


# Other
BIND = '127.0.0.1'
BIND = "127.0.0.1"
15 changes: 8 additions & 7 deletions publishconf.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import os
import sys

sys.path.append(os.curdir)
from pelicanconf import *

# Publication settings
SITEURL = 'https://jwodder.github.io/kbits'
SITEURL = "https://jwodder.github.io/kbits"
RELATIVE_URLS = False

FEED_DOMAIN = SITEURL

FEED_ALL_ATOM = 'feeds/posts.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/category.{slug}.atom.xml'
TAG_FEED_ATOM = 'feeds/tag.{slug}.atom.xml'
FEED_ALL_ATOM = "feeds/posts.atom.xml"
CATEGORY_FEED_ATOM = "feeds/category.{slug}.atom.xml"
TAG_FEED_ATOM = "feeds/tag.{slug}.atom.xml"
AUTHOR_FEED_ATOM = None

FEED_ALL_RSS = 'feeds/posts.rss'
CATEGORY_FEED_RSS = 'feeds/category.{slug}.rss'
TAG_FEED_RSS = 'feeds/tag.{slug}.rss'
FEED_ALL_RSS = "feeds/posts.rss"
CATEGORY_FEED_RSS = "feeds/category.{slug}.rss"
TAG_FEED_RSS = "feeds/tag.{slug}.rss"
AUTHOR_FEED_RSS = None

DELETE_OUTPUT_DIRECTORY = True

0 comments on commit b36dac0

Please sign in to comment.