Skip to content

Commit

Permalink
Merge pull request #151 from CloudBytes-Academy/settings
Browse files Browse the repository at this point in the history
Modified settings.py to organise better
  • Loading branch information
rehanhaider authored Oct 15, 2023
2 parents 9d00093 + 255a6de commit b19a7e5
Showing 1 changed file with 34 additions and 33 deletions.
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

0 comments on commit b19a7e5

Please sign in to comment.