Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified settings.py to organise better #151

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
# -*- coding: utf-8 -*- #
# Pelican configuration file
"""

# --- Imports ---
from datetime import date
import os
import csv

# ENVIRONMENT
# --- Environmental Variables ---
PUBLISH = os.environ.get("PUBLISH")
print(f"PUBLISH: {PUBLISH}")
CURRENTYEAR = date.today().year

# General settings
# --- Basic Settings ---
TIMEZONE = "UTC"
DEFAULT_LANG = "en"
AUTHOR = "CloudBytes"
SITENAME = "CloudBytes/dev>"
SITEURL = "https://cloudbytes.dev" if PUBLISH else "http://localhost:8080"
# Delete output directory before build
DELETE_OUTPUT_DIRECTORY = True


# Paths
# --- Paths & Directories ---
THEME_STATIC_DIR = "assets"
THEME = "design/alexis"
# Path to blog content
PATH = "content"
# Path to static folders
PATH = "content" # Path to blog content
STATIC_PATHS = [
"images",
"extra/SW.js",
Expand All @@ -37,7 +38,7 @@
"extra/ads.txt": {"path": "ads.txt"},
}

# Page naming convention
# --- URL & Save Patterns ---
ARTICLE_URL = "{category}/{slug}"
ARTICLE_SAVE_AS = "{category}/{slug}/index.html"
AUTHOR_URL = "authors/{slug}"
Expand All @@ -49,19 +50,16 @@
PAGE_URL = "{slug}.html"
PAGE_SAVE_AS = "{slug}.html"


# Feed generation is usually not desired when developing
# --- Feed Settings ---
FEED_ALL_ATOM = "feeds/all.atom.xml"
CATEGORY_FEED_ATOM = "feeds/{slug}.atom.xml"
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
HOME_HIDE_TAGS = True

# Delete output directory before build
DELETE_OUTPUT_DIRECTORY = True

# Pagination settings
# --- Pagination Settings ---
DEFAULT_PAGINATION = 6
PAGINATION_PATTERNS = (
(1, "{url}", "{save_as}"),
Expand All @@ -74,7 +72,7 @@
# RELATIVE_URLS = True


# Python-Markdown extension configuration
# --- Markdown Extensions ---
MARKDOWN = {
"extension_configs": {
# Needed for code syntax highlighting
Expand All @@ -91,60 +89,63 @@
}


# Plugin Settings
# ----------------
# --- Plugin Settings ---
# ---------------------------------------------

# Tag Cloud settings
# --- Tag Cloud Settings ---
TAG_CLOUD_STEPS = 4
TAG_CLOUD_MAX_ITEMS = 100
TAG_CLOUD_SORTING = "size"
TAG_CLOUD_BADGE = True

# Sitemap configuration
# --- Sitemap Settings ---
SITEMAP = {
"format": "xml",
"priorities": {"articles": 1, "indexes": 1, "pages": 0.25},
"changefreqs": {"articles": "weekly", "indexes": "daily", "pages": "monthly"},
}


# Algolia Publish Data
# --- Algolia Settings ---
ALGOLIA_APP_ID = "XE8PCLJHAE"
ALGOLIA_SEARCH_API_KEY = "ec75de1d8ce87dee234a2fd47cec2d76"
ALGOLIA_INDEX_NAME = "cloudbytes_dev"
ALGOLIA_ADMIN_API_KEY = os.environ.get("ALGOLIA_ADMIN_API_KEY")

# Related Post Settings
# --- Related Posts Settings ---
RELATED_POSTS_MAX = 5
# ---------------------------------------------

# --- Google Analytics Settings ---
# Following items are often useful when publishing

GTAG = "G-9VKX48YDBH" if PUBLISH else None

# Active Plugins
dev_plugins = [

# --- Active Plugins ---
# Plugin configuration
# ---------------------------------------------
common_plugins = [
"pelican.plugins.sitemap",
"pelican.plugins.tag_cloud",
"pelican.plugins.related_posts",
"plugins.fix_sitemap",
"pelican.plugins.series",
# "plugins.minify",
]
prod_plugins = [
"pelican.plugins.sitemap",
"pelican.plugins.tag_cloud",
"pelican.plugins.related_posts",
"plugins.fix_sitemap",
]

dev_plugins = common_plugins.copy()

prod_extra_plugins = [
"plugins.search",
"pelican.plugins.series",
"plugins.minify",
]

prod_plugins = common_plugins + prod_extra_plugins

PLUGINS = prod_plugins if PUBLISH else dev_plugins


# Load courses
# ------------
# --- Udemy Affiliate Settings ---
# ---------------------------------------------
with open("resources/courses.csv") as csvfile:
reader = csv.DictReader(csvfile)
courses = list(reader)
Expand Down