add Liberapay: field with username as data

Liberapay was originally included using a numeric ID, since they had
not yet finalized the public URLs.  Now it is a username.  So this
logic prefers the username in Liberapay: field, and keeps the old
LiberapayID: to ease migration.  LiberapayID: will not override
Liberapay:.  Clients are expected to prefer Liberapay: over LiberapayID:
This commit is contained in:
Hans-Christoph Steiner 2020-06-16 14:39:46 +02:00
parent 0183592526
commit 62c8fd5999
No known key found for this signature in database
GPG key ID: 3E177817BA1B9BFA
13 changed files with 28 additions and 4 deletions

View file

@ -141,9 +141,11 @@ regex_checks = {
],
'Donate': http_checks + [
(re.compile(r'.*flattr\.com'),
_("Flattr donation methods belong in the FlattrID flag")),
_("Flattr donation methods belong in the FlattrID: field")),
(re.compile(r'.*liberapay\.com'),
_("Liberapay donation methods belong in the LiberapayID flag")),
_("Liberapay donation methods belong in the Liberapay: field")),
(re.compile(r'.*opencollective\.com'),
_("OpenCollective donation methods belong in the OpenCollective: field")),
],
'Changelog': http_checks,
'Author Name': [

View file

@ -77,6 +77,7 @@ app_fields = set([
'Changelog',
'Donate',
'FlattrID',
'Liberapay',
'LiberapayID',
'OpenCollective',
'Bitcoin',
@ -121,6 +122,7 @@ yaml_app_field_order = [
'Changelog',
'Donate',
'FlattrID',
'Liberapay',
'LiberapayID',
'OpenCollective',
'Bitcoin',
@ -181,6 +183,7 @@ class App(dict):
self.Changelog = ''
self.Donate = None
self.FlattrID = None
self.Liberapay = None
self.LiberapayID = None
self.OpenCollective = None
self.Bitcoin = None
@ -454,6 +457,10 @@ valuetypes = {
r'^[0-9a-z]+$',
['FlattrID']),
FieldValidator("Liberapay",
VALID_USERNAME_REGEX,
['Liberapay']),
FieldValidator("Liberapay ID",
r'^[0-9]+$',
['LiberapayID']),

View file

@ -927,6 +927,10 @@ def insert_funding_yml_donation_links(apps):
logging.error(e)
if not data or type(data) != dict:
continue
if not app.get('Liberapay') and 'liberapay' in data:
s = sanitize_funding_yml_name(data['liberapay'])
if s:
app['Liberapay'] = s
if not app.get('OpenCollective') and 'open_collective' in data:
s = sanitize_funding_yml_name(data['open_collective'])
if s: