Update for sr.ht unified config

access-overhaul 0.20.0
Drew DeVault 4 years ago
parent 324fba48c0
commit 66c22baf60
  1. 55
      config.example.ini
  2. 43
      config.ini.example
  3. 4
      run.py
  4. 22
      todosrht/app.py
  5. 2
      todosrht/blueprints/html.py
  6. 5
      todosrht/email.py
  7. 6
      todosrht/templates/index.html

@ -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

@ -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

@ -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)

@ -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

@ -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

@ -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)

@ -4,14 +4,14 @@
<div class="row">
<div class="col-md-6">
<p>
Welcome to {{cfg("server", "domain")}}. This is a part of the
<a href="{{cfg("network", "meta")}}">
Welcome to {{domain}}. This is a part of the
<a href="{{cfg("meta.sr.ht", "origin")}}">
{{cfg("sr.ht", "site-name")}} network
</a>
and provides ticket tracking services to members. If you already have
an account, you can
<a href="{{oauth_url}}">log in here</a>. New users can
<a href="{{cfg("network", "meta")}}">register here</a>.
<a href="{{cfg("meta.sr.ht", "origin")}}">register here</a>.
</p>
</div>
</div>

Loading…
Cancel
Save