molniya/config.py

43 lines
1.9 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://geminispace.info/backlinks"
# Domains that refer to the same capsule.
# For instance, tilde.team has several domains.
DUPLICATED_DOMAINS = {
"tilde.team": ['fuckup.club', 'nand.sh', 'ttm.sh', 'tild3.org', 'tilde.life', 'tilde.site', 'tildeteam.net', 'tildeteam.org']
}
# 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][1:]
if parsed.path.startswith("/users/"): # gemini.circumlunar.space uses this format as well
capsule+="/"+parsed.path.split("/",3)[2]
for domain in DUPLICATED_DOMAINS:
for alt in DUPLICATED_DOMAINS[domain]:
capsule.replace(alt,domain)
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"
]