From f308ac796b6e24b216b68aeac0d456d21c3b37f3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 23 Nov 2016 00:12:05 -0500 Subject: Make the instance name and domain configurable. --- aurweb/git/serve.py | 4 +++- aurweb/scripts/mkpkglists.py | 6 +++--- aurweb/scripts/notify.py | 40 ++++++++++++++++++++---------------- conf/config.proto | 3 +++ web/html/home.php | 28 +++++++++++++++---------- web/html/login.php | 4 ++-- web/html/pkgdel.php | 4 ++-- web/html/rss.php | 8 ++++---- web/lib/DB.class.php | 2 +- web/template/account_delete.php | 3 ++- web/template/account_edit_form.php | 2 +- web/template/footer.php | 2 +- web/template/header.php | 8 ++++---- web/template/stats/updates_table.php | 2 +- 14 files changed, 66 insertions(+), 50 deletions(-) diff --git a/aurweb/git/serve.py b/aurweb/git/serve.py index 476aea8..1d7d38d 100755 --- a/aurweb/git/serve.py +++ b/aurweb/git/serve.py @@ -10,6 +10,8 @@ import time import aurweb.config import aurweb.db +branding_shortname = aurweb.config.get('options', 'branding_shortname'); + notify_cmd = aurweb.config.get('notifications', 'notify-cmd') repo_path = aurweb.config.get('serve', 'repo-path') @@ -345,7 +347,7 @@ def main(): if enable_maintenance: if remote_addr not in maintenance_exc: - die("The AUR is down due to maintenance. We will be back soon.") + die("The %s is down due to maintenance. We will be back soon." % (branding_shortname)) if action == 'git' and cmdargv[1] in ('upload-pack', 'receive-pack'): action = action + '-' + cmdargv[1] diff --git a/aurweb/scripts/mkpkglists.py b/aurweb/scripts/mkpkglists.py index 8a0f2e9..4c5c2fb 100755 --- a/aurweb/scripts/mkpkglists.py +++ b/aurweb/scripts/mkpkglists.py @@ -8,14 +8,14 @@ import aurweb.db packagesfile = aurweb.config.get('mkpkglists', 'packagesfile') pkgbasefile = aurweb.config.get('mkpkglists', 'pkgbasefile') - +branding_name = aurweb.config.get('options', 'branding_shortname'); def main(): conn = aurweb.db.Connection() datestr = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT") - pkglist_header = "# AUR package list, generated on " + datestr - pkgbaselist_header = "# AUR package base list, generated on " + datestr + pkglist_header = "# " + branding_name + " package list, generated on " + datestr + pkgbaselist_header = "# " + branding_name + " package base list, generated on " + datestr with gzip.open(packagesfile, "w") as f: f.write(bytes(pkglist_header + "\n", "UTF-8")) diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py index ddd6e49..9341026 100755 --- a/aurweb/scripts/notify.py +++ b/aurweb/scripts/notify.py @@ -11,6 +11,10 @@ import aurweb.db aur_location = aurweb.config.get('options', 'aur_location') aur_request_ml = aurweb.config.get('options', 'aur_request_ml') +email_domain = aurweb.config.get('options', 'email_domain'); +branding_shortname = aurweb.config.get('options', 'branding_shortname'); +branding_longname = aurweb.config.get('options', 'branding_longname'); + sendmail = aurweb.config.get('notifications', 'sendmail') sender = aurweb.config.get('notifications', 'sender') reply_to = aurweb.config.get('notifications', 'reply-to') @@ -174,7 +178,7 @@ def send_resetkey(conn, uid): 'WHERE ID = ?', [uid]) username, to, resetkey = cur.fetchone() - subject = 'AUR Password Reset' + subject = '%s Password Reset' % (branding_shortname) body = 'A password reset request was submitted for the account %s ' \ 'associated with your email address. If you wish to reset your ' \ 'password follow the link [1] below, otherwise ignore this ' \ @@ -189,11 +193,11 @@ def welcome(conn, uid): 'WHERE ID = ?', [uid]) username, to, resetkey = cur.fetchone() - subject = 'Welcome to the Arch User Repository' - body = 'Welcome to the Arch User Repository! In order to set an initial ' \ + subject = 'Welcome to the %s' % (branding_longname) + body = 'Welcome to the %s! In order to set an initial ' \ 'password for your new account, please click the link [1] below. ' \ 'If the link does not work, try copying and pasting it into your ' \ - 'browser.' + 'browser.' % (branding_longname) refs = '[1] ' + aur_location + '/passreset/?resetkey=' + resetkey send_notification([to], subject, body, refs) @@ -208,7 +212,7 @@ def comment(conn, uid, pkgbase_id, comment_id): user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Comment for %s' % (pkgbase) + subject = '%s Comment for %s' % (branding_shortname, pkgbase) body = '%s [1] added the following comment to %s [2]:' % (user, pkgbase) body += '\n\n' + text + '\n\n' body += 'If you no longer wish to receive notifications about this ' \ @@ -216,7 +220,7 @@ def comment(conn, uid, pkgbase_id, comment_id): ('Disable notifications') refs = '[1] ' + user_uri + '\n' refs += '[2] ' + pkgbase_uri - thread_id = '' + thread_id = '' headers = headers_reply(thread_id) send_notification(to, subject, body, refs, headers) @@ -230,7 +234,7 @@ def update(conn, uid, pkgbase_id): user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Package Update: %s' % (pkgbase) + subject = '%s Package Update: %s' % (branding_shortname, pkgbase) body = '%s [1] pushed a new commit to %s [2].' % (user, pkgbase) body += '\n\n' body += 'If you no longer wish to receive notifications about this ' \ @@ -238,7 +242,7 @@ def update(conn, uid, pkgbase_id): ('Disable notifications') refs = '[1] ' + user_uri + '\n' refs += '[2] ' + pkgbase_uri - thread_id = '' + thread_id = '' headers = headers_reply(thread_id) send_notification(to, subject, body, refs, headers) @@ -253,7 +257,7 @@ def flag(conn, uid, pkgbase_id): user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Out-of-date Notification for %s' % (pkgbase) + subject = '%s Out-of-date Notification for %s' % (branding_shortname, pkgbase) body = 'Your package %s [1] has been flagged out-of-date by %s [2]:' % \ (pkgbase, user) body += '\n\n' + text @@ -271,7 +275,7 @@ def adopt(conn, pkgbase_id, uid): user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Ownership Notification for %s' % (pkgbase) + subject = '%s Ownership Notification for %s' % (branding_shortname, pkgbase) body = 'The package %s [1] was adopted by %s [2].' % (pkgbase, user) refs = '[1] ' + pkgbase_uri + '\n' refs += '[2] ' + user_uri @@ -287,7 +291,7 @@ def disown(conn, pkgbase_id, uid): user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Ownership Notification for %s' % (pkgbase) + subject = '%s Ownership Notification for %s' % (branding_shortname, pkgbase) body = 'The package %s [1] was disowned by %s [2].' % (pkgbase, user) refs = '[1] ' + pkgbase_uri + '\n' refs += '[2] ' + user_uri @@ -301,7 +305,7 @@ def comaintainer_add(conn, pkgbase_id, uid): pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Co-Maintainer Notification for %s' % (pkgbase) + subject = '%s Co-Maintainer Notification for %s' % (branding_shortname, pkgbase) body = 'You were added to the co-maintainer list of %s [1].' % (pkgbase) refs = '[1] ' + pkgbase_uri + '\n' @@ -314,7 +318,7 @@ def comaintainer_remove(conn, pkgbase_id, uid): pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' - subject = 'AUR Co-Maintainer Notification for %s' % (pkgbase) + subject = '%s Co-Maintainer Notification for %s' % (branding_shortname, pkgbase) body = ('You were removed from the co-maintainer list of %s [1].' % (pkgbase)) refs = '[1] ' + pkgbase_uri + '\n' @@ -332,7 +336,7 @@ def delete(conn, uid, old_pkgbase_id, new_pkgbase_id=None): user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + old_pkgbase + '/' - subject = 'AUR Package deleted: %s' % (old_pkgbase) + subject = '%s Package deleted: %s' % (branding_shortname, old_pkgbase) if new_pkgbase_id: new_pkgbase_uri = aur_location + '/pkgbase/' + new_pkgbase + '/' body = '%s [1] merged %s [2] into %s [3].\n\n' \ @@ -378,7 +382,7 @@ def request_open(conn, uid, reqid, reqtype, pkgbase_id, merge_into=None): body += '\n\n' + text refs = '[1] ' + user_uri + '\n' refs += '[2] ' + pkgbase_uri + '\n' - thread_id = '' + thread_id = '' # Use a deterministic Message-ID for the first email referencing a request. headers = headers_msgid(thread_id) headers.update(headers_cc(cc)) @@ -398,14 +402,14 @@ def request_close(conn, uid, reqid, reason): body = 'Request #%d has been %s by %s [1]' % (int(reqid), reason, user) refs = '[1] ' + user_uri else: - body = 'Request #%d has been %s automatically by the Arch User ' \ - 'Repository package request system' % (int(reqid), reason) + body = 'Request #%d has been %s automatically by the %s ' \ + 'package request system' % (int(reqid), reason, branding_longname) refs = None if text.strip() == '': body += '.' else: body += ':\n\n' + text - thread_id = '' + thread_id = '' headers = headers_reply(thread_id) headers.update(headers_cc(cc)) diff --git a/conf/config.proto b/conf/config.proto index 96fad80..c82980b 100644 --- a/conf/config.proto +++ b/conf/config.proto @@ -31,6 +31,9 @@ log_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s snapshot_uri = /cgit/aur.git/snapshot/%s.tar.gz enable-maintenance = 1 maintenance-exceptions = 127.0.0.1 +email_domain = aur.parabola.nu +branding_shortname = AUR +branding_longname = Arch User Repository [notifications] notify-cmd = /srv/http/aurweb/scripts/notify.py diff --git a/web/html/home.php b/web/html/home.php index 475370b..204e00d 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -15,14 +15,17 @@ html_header( __("Home") );
-

AUR

+

', + config_get('options', 'branding_shortname'), '', '', + config_get('options', 'branding_shortname'), '' ); ?> @@ -58,7 +61,7 @@ html_header( __("Home") );

  • :
  • -
  • :
  • +
  • :
  • :

@@ -76,7 +79,8 @@ html_header( __("Home") );

', '' ); @@ -84,7 +88,7 @@ html_header( __("Home") );

- +

    $fingerprint): ?> @@ -98,11 +102,12 @@ html_header( __("Home") );

    ', - '', - '', - '' + 'General discussion regarding the %s (%s) and Trusted User structure takes place on %s. For discussion relating to the development of the %s web interface (aurweb), use the %s mailing list.', + config_get('options', 'branding_longname'), + config_get('options', 'branding_shortname'), + 'aur-general', + config_get('options', 'branding_shortname'), + 'aur-dev' ); ?>

    @@ -112,7 +117,8 @@ html_header( __("Home") );

    ', '', '', diff --git a/web/html/login.php b/web/html/login.php index 7345439..f6b5b87 100644 --- a/web/html/login.php +++ b/web/html/login.php @@ -11,10 +11,10 @@ if (!$disable_http_login || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])) { $login_error = $login['error']; } -html_header('AUR ' . __("Login")); +html_header(config_get('options', 'branding_shortname') . ' ' . __("Login")); ?>

    -

    AUR

    +

    ' . username_from_sid($_COOKIE["AURSID"]) . ''); ?> diff --git a/web/html/pkgdel.php b/web/html/pkgdel.php index 21a2677..f32ff47 100644 --- a/web/html/pkgdel.php +++ b/web/html/pkgdel.php @@ -14,8 +14,8 @@ if (has_credential(CRED_PKGBASE_DELETE)): ?>

    :

    - ', htmlspecialchars($pkgbase_name), ''); ?> + ', htmlspecialchars($pkgbase_name), '', config_get('options', 'branding_shortname')); ?>

      diff --git a/web/html/rss.php b/web/html/rss.php index 8585d81..2ecf218 100644 --- a/web/html/rss.php +++ b/web/html/rss.php @@ -26,15 +26,15 @@ $rss->xslStyleSheet = false; $rss->encoding = "UTF-8"; #All the general RSS setup -$rss->title = "AUR Newest Packages"; -$rss->description = "The latest and greatest packages in the AUR"; +$rss->title = config_get('options', 'branding_shortname') . " Newest Packages"; +$rss->description = "The latest and greatest packages in the " . config_get('options', 'branding_shortname'); $rss->link = "${protocol}://{$host}"; $rss->syndicationURL = "{$protocol}://{$host}" . get_uri('/rss/'); $image = new FeedImage(); -$image->title = "AUR"; +$image->title = config_get('options', 'branding_shortname'); $image->url = "{$protocol}://{$host}/css/archnavbar/aurlogo.png"; $image->link = $rss->link; -$image->description = "AUR Newest Packages Feed"; +$image->description = config_get('options', 'branding_shortname') . " Newest Packages Feed"; $rss->image = $image; #Get the latest packages and add items for them diff --git a/web/lib/DB.class.php b/web/lib/DB.class.php index b538e0d..4c58c3c 100644 --- a/web/lib/DB.class.php +++ b/web/lib/DB.class.php @@ -32,7 +32,7 @@ class DB { self::$dbh = new PDO($dsn, $user, $password); self::$dbh->exec("SET NAMES 'utf8' COLLATE 'utf8_general_ci';"); } catch (PDOException $e) { - die('Error - Could not connect to AUR database'); + die('Error - Could not connect to ' . config_get('options', 'branding_shortname') . ' database'); } } diff --git a/web/template/account_delete.php b/web/template/account_delete.php index 74f386d..6a874f5 100644 --- a/web/template/account_delete.php +++ b/web/template/account_delete.php @@ -1,5 +1,6 @@

      - ' . htmlspecialchars($username) . '') ?> + ' . htmlspecialchars($username) . '') ?>

      ', '') ?> diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php index 19821a0..fda5a28 100644 --- a/web/template/account_edit_form.php +++ b/web/template/account_edit_form.php @@ -132,7 +132,7 @@

      - +

      diff --git a/web/template/footer.php b/web/template/footer.php index 572dbb2..0e96870 100644 --- a/web/template/footer.php +++ b/web/template/footer.php @@ -6,7 +6,7 @@

      aurweb

      -

      +

    diff --git a/web/template/header.php b/web/template/header.php index 874109a..2ab1d6b 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -4,7 +4,7 @@ - AUR (<?= htmlspecialchars($LANG); ?>)<?php if ($title != "") { print " - " . htmlspecialchars($title); } ?> + <?= config_get('options', 'branding_shortname'); ?> (<?= htmlspecialchars($LANG); ?>)<?php if ($title != "") { print " - " . htmlspecialchars($title); } ?> @@ -16,7 +16,7 @@
    - +
    @@ -53,7 +53,7 @@
      -
    • AUR
    • +
    • ">
    • diff --git a/web/template/stats/updates_table.php b/web/template/stats/updates_table.php index 580583b..4bc8a63 100644 --- a/web/template/stats/updates_table.php +++ b/web/template/stats/updates_table.php @@ -1,6 +1,6 @@

      ()

      -RSS Feed +RSS Feed -- cgit v1.2.3-54-g00ecf