diff --git a/config.example.ini b/config.example.ini new file mode 100644 index 0000000..352eaf7 --- /dev/null +++ b/config.example.ini @@ -0,0 +1,55 @@ +[sr.ht] +# +# The name of your network of sr.ht-based sites +site-name=sr.ht +# +# Contact information for the site owners +owner-name=Drew DeVault +owner-email=sir@cmpwn.com +# +# The source code for your fork of sr.ht +source-url=https://git.sr.ht/~sircmpwn/srht +# +# A secret key to encrypt session cookies with +secret-key=CHANGEME + +[mail] +# +# Outgoing SMTP settings +smtp-host= +smtp-port= +smtp-user= +smtp-password= +smtp-from= +# +# Application exceptions are emailed to this address +error-to= +error-from= +# +# Your PGP key information (DO NOT mix up pub and priv here) +# You must remove the password from your secret key, if present. +# You can do this with gpg --edit-key [key-id], then use the passwd +# command and do not enter a new password. +pgp-privkey= +pgp-pubkey= +pgp-key-id= + +[todo.sr.ht] +# +# URL todo.sr.ht is being served at (protocol://domain) +origin=http://todo.sr.ht.local +# +# Address and port to bind the debug server to +debug-host=0.0.0.0 +debug-port=5003 +# +# Configures the SQLAlchemy connection string for the database. +connection-string=postgresql://postgres@localhost/todo.sr.ht +# +# todo.sr.ht's OAuth client ID and secret for meta.sr.ht +# Register your client at meta.example.org/oauth +oauth-client-id=CHANGEME +oauth-client-secret=CHANGEME + +[meta.sr.ht] +origin=http://meta.sr.ht.local diff --git a/config.ini.example b/config.ini.example deleted file mode 100644 index e816ce7..0000000 --- a/config.ini.example +++ /dev/null @@ -1,43 +0,0 @@ -# -# todo.sr.ht config - -[server] -# -# Specifies the protocol (usually http or https) meta.sr.ht runs with. -protocol=http -# -# Specifies the domain name meta.sr.ht is running on. -domain=todo.sr.ht.local -# -# A secret key to encrypt session cookies with. -secret-key=CHANGEME - -[debug] -# -# Address and port to bind the debug server to. -debug-host=0.0.0.0 -debug-port=5003 - -[sr.ht] -# -# Configures the SQLAlchemy connection string for the database. -connection-string=postgresql://postgres@localhost/todo.sr.ht -# -# The name of your network of sr.ht-based sites -site-name=sr.ht - -[network] -# -# Location of other sites in your network -# -# This isn't a hardcoded list, add or remove entries as you like. The upstream -# sites do know about each other and will omit integrations if you leave out -# the relevant site. Only meta is required. -meta=http://meta.sr.ht.local -git=http://git.sr.ht.local -builds=http://builds.sr.ht.local -todo=http://todo.sr.ht.local - -[meta.sr.ht] -oauth-client-id=CHANGEME -oauth-client-secret=CHANGEME diff --git a/run.py b/run.py index 4e8666e..1e62535 100644 --- a/run.py +++ b/run.py @@ -6,6 +6,6 @@ import os app.static_folder = os.path.join(os.getcwd(), "static") if __name__ == '__main__': - app.run(host=cfg("debug", "debug-host"), - port=cfgi("debug", "debug-port"), + app.run(host=cfg("todo.sr.ht", "debug-host"), + port=cfgi("todo.sr.ht", "debug-port"), debug=True) diff --git a/todosrht/app.py b/todosrht/app.py index c99cb9c..b6b304d 100644 --- a/todosrht/app.py +++ b/todosrht/app.py @@ -1,19 +1,15 @@ from jinja2 import Markup from srht.flask import SrhtFlask -from srht.config import cfg, load_config -load_config("todo") - +from srht.config import cfg from srht.database import DbSession -db = DbSession(cfg("sr.ht", "connection-string")) + +db = DbSession(cfg("todo.sr.ht", "connection-string")) from todosrht.types import User from todosrht.types import TicketAccess, TicketStatus, TicketResolution from todosrht.types import TicketSeen -db.init() -from todosrht.blueprints.html import html -from todosrht.blueprints.tracker import tracker -from todosrht.blueprints.ticket import ticket +db.init() def render_status(ticket, access): if TicketAccess.edit in access: @@ -31,16 +27,20 @@ def render_status(ticket, access): class TodoApp(SrhtFlask): def __init__(self): - super().__init__("todo", __name__) + super().__init__("todo.sr.ht", __name__) self.url_map.strict_slashes = False + from todosrht.blueprints.html import html + from todosrht.blueprints.tracker import tracker + from todosrht.blueprints.ticket import ticket + self.register_blueprint(html) self.register_blueprint(tracker) self.register_blueprint(ticket) - meta_client_id = cfg("meta.sr.ht", "oauth-client-id") - meta_client_secret = cfg("meta.sr.ht", "oauth-client-secret") + meta_client_id = cfg("todo.sr.ht", "oauth-client-id") + meta_client_secret = cfg("todo.sr.ht", "oauth-client-secret") self.configure_meta_auth(meta_client_id, meta_client_secret) @self.context_processor diff --git a/todosrht/blueprints/html.py b/todosrht/blueprints/html.py index c8d475f..acb4430 100644 --- a/todosrht/blueprints/html.py +++ b/todosrht/blueprints/html.py @@ -10,7 +10,7 @@ import requests html = Blueprint('html', __name__) -meta_uri = cfg("network", "meta") +meta_uri = cfg("meta.sr.ht", "origin") def filter_authorized_events(events): events = (events diff --git a/todosrht/email.py b/todosrht/email.py index 30bfe31..155e4cd 100644 --- a/todosrht/email.py +++ b/todosrht/email.py @@ -5,8 +5,7 @@ import pystache from srht.config import cfg, cfgi from flask_login import current_user -protocol = cfg("server", "protocol") -domain = cfg("server", "domain") +origin = cfg("todo.sr.ht", "origin") def notify(sub, template, subject, headers, **kwargs): encrypt_key = None @@ -21,7 +20,7 @@ def notify(sub, template, subject, headers, **kwargs): body = html.parser.HTMLParser().unescape(\ pystache.render(f.read(), { 'user': current_user, - 'root': '{}://{}'.format(protocol, domain), + 'root': origin, **kwargs })) send_email(body, to, subject, encrypt_key=encrypt_key, **headers) diff --git a/todosrht/templates/index.html b/todosrht/templates/index.html index 20fa723..02a6557 100644 --- a/todosrht/templates/index.html +++ b/todosrht/templates/index.html @@ -4,14 +4,14 @@
- Welcome to {{cfg("server", "domain")}}. This is a part of the - + Welcome to {{domain}}. This is a part of the + {{cfg("sr.ht", "site-name")}} network and provides ticket tracking services to members. If you already have an account, you can log in here. New users can - register here. + register here.