molniya/config.py

32 lines
1.4 KiB
Python

# ------------------------------------------------------------------------------
# The configuration for the Molniya orbit software.
# Implemented as a Python library to allow for determine_capsule logic.
# ------------------------------------------------------------------------------
# The main page of the orbit.
# Is used to seed the orbit when it's first created, as well as to find new pages to include in the orbit.
MAIN_PAGE = "gemini://tilde.team/~khuxkm/leo/"
# The backlinks base page.
# Takes a URL as a query and returns a list of pages that backlink to it.
# In case GUS ever goes down, is replaced, or changes URL, this will allow for easy fixing of Zenit.
BACKLINKS = "gemini://gus.guru/backlinks"
# Determine a "capsule".
# Used to prevent one person from flooding the orbit with pages.
# One page is allowed in the list per "capsule".
# This function is passed a urllib.parse.ParseResult object, and returns a string that identifies which capsule the URL belongs to.
def determine_capsule(parsed):
capsule = parsed.netloc
if parsed.path.startswith("/~"): # allow for each userdir to be its own capsule
capsule+="/"+parsed.path.split("/")[1]
return capsule
# Required links.
# A site must have one of these links to be included in the orbit.
REQUIRED_LINKS = [
"gemini://tilde.team/~khuxkm/leo/next.cgi",
"gemini://tilde.team/~khuxkm/leo/prev.cgi",
"gemini://tilde.team/~khuxkm/leo/rand.cgi"
]