From 3169af30026a2390ca4882e27f4d0b358ff2675b Mon Sep 17 00:00:00 2001 From: Jason Schwarzenberger Date: Wed, 11 Nov 2020 09:46:27 +1300 Subject: [PATCH] hostname from settings. --- apiserver/feeds/manual.py | 4 +++- apiserver/server.py | 4 ++-- apiserver/settings.py.example | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apiserver/feeds/manual.py b/apiserver/feeds/manual.py index c23ed70..f31588b 100644 --- a/apiserver/feeds/manual.py +++ b/apiserver/feeds/manual.py @@ -7,6 +7,8 @@ import requests import time from bs4 import BeautifulSoup +import settings + USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0' def api(route): @@ -33,7 +35,7 @@ def story(ref): s = {} s['author'] = 'manual submission' - s['author_link'] = 'https://news.t0.vc' + s['author_link'] = 'https://{}'.format(settings.HOSTNAME) s['score'] = 0 s['date'] = int(time.time()) s['title'] = str(soup.title.string) if soup.title else ref diff --git a/apiserver/server.py b/apiserver/server.py index f522534..7d35ffb 100644 --- a/apiserver/server.py +++ b/apiserver/server.py @@ -70,7 +70,7 @@ def submit(): elif 'reddit.com' in parse.hostname and 'comments' in url: source = 'reddit' ref = parse.path.split('/')[4] - elif 'news.t0.vc' in parse.hostname: + elif settings.HOSTNAME in parse.hostname: raise Exception('Invalid article') else: source = 'manual' @@ -112,7 +112,7 @@ def story(sid): def index(): return render_template('index.html', title='Feed', - url='news.t0.vc', + url=settings.HOSTNAME, description='Reddit, Hacker News, and Tildes combined, then pre-rendered in reader mode') @flask_app.route('/', strict_slashes=False) diff --git a/apiserver/settings.py.example b/apiserver/settings.py.example index e571688..089a559 100644 --- a/apiserver/settings.py.example +++ b/apiserver/settings.py.example @@ -1,6 +1,7 @@ # QotNews settings # edit this file and save it as settings.py +HOSTNAME = 'news.t0.vc' MAX_STORY_AGE = 3*24*60*60 # Feed Lengths