Command option for content license

main
Bob Mottram 2021-11-08 16:17:07 +00:00
parent 3548b8795c
commit ebacc0e6f1
6 changed files with 60 additions and 21 deletions

View File

@ -420,7 +420,7 @@ def htmlBlogPost(session, authorized: bool,
postJsonObject: {},
peertubeInstances: [],
systemLanguage: str, personCache: {},
debug: bool) -> str:
debug: bool, contentLicenseUrl: str) -> str:
"""Returns a html blog post
"""
blogStr = ''
@ -442,7 +442,8 @@ def htmlBlogPost(session, authorized: bool,
blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle,
httpPrefix, domainFull, nickname,
systemLanguage, published, modified,
title, snippet, translate, url)
title, snippet, translate, url,
contentLicenseUrl)
_htmlBlogRemoveCwButton(blogStr, translate)
blogStr += _htmlBlogPostContent(debug, session, authorized, baseDir,

View File

@ -8758,7 +8758,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.sharedItemsFederatedDomains,
rolesList,
None, None, self.server.CWlists,
self.server.listsEnabled)
self.server.listsEnabled,
self.server.contentLicenseUrl)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -8873,7 +8874,8 @@ class PubServer(BaseHTTPRequestHandler):
skills,
None, None,
self.server.CWlists,
self.server.listsEnabled)
self.server.listsEnabled,
self.server.contentLicenseUrl)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10866,7 +10868,8 @@ class PubServer(BaseHTTPRequestHandler):
shares,
pageNumber, sharesPerPage,
self.server.CWlists,
self.server.listsEnabled)
self.server.listsEnabled,
self.server.contentLicenseUrl)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10958,6 +10961,8 @@ class PubServer(BaseHTTPRequestHandler):
city = getSpoofedCity(self.server.city,
baseDir, nickname, domain)
contentLicenseUrl = \
self.server.contentLicenseUrl
msg = \
htmlProfile(self.server.signingPrivateKeyPem,
self.server.rssIconAtTop,
@ -10992,7 +10997,8 @@ class PubServer(BaseHTTPRequestHandler):
pageNumber,
followsPerPage,
self.server.CWlists,
self.server.listsEnabled).encode('utf-8')
self.server.listsEnabled,
contentLicenseUrl).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html',
msglen, cookie, callingDomain, False)
@ -11082,6 +11088,8 @@ class PubServer(BaseHTTPRequestHandler):
city = getSpoofedCity(self.server.city,
baseDir, nickname, domain)
contentLicenseUrl = \
self.server.contentLicenseUrl
msg = \
htmlProfile(self.server.signingPrivateKeyPem,
self.server.rssIconAtTop,
@ -11117,7 +11125,8 @@ class PubServer(BaseHTTPRequestHandler):
pageNumber,
followsPerPage,
self.server.CWlists,
self.server.listsEnabled).encode('utf-8')
self.server.listsEnabled,
contentLicenseUrl).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain, False)
@ -11258,7 +11267,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.sharedItemsFederatedDomains,
None, None, None,
self.server.CWlists,
self.server.listsEnabled).encode('utf-8')
self.server.listsEnabled,
self.server.contentLicenseUrl).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain, False)
@ -13138,7 +13148,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
self.server.systemLanguage,
self.server.personCache,
self.server.debug)
self.server.debug,
self.server.contentLicenseUrl)
if msg is not None:
msg = msg.encode('utf-8')
msglen = len(msg)
@ -17179,7 +17190,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
break
def runDaemon(listsEnabled: str,
def runDaemon(contentLicenseUrl: str,
listsEnabled: str,
defaultReplyIntervalHours: int,
lowBandwidth: bool,
maxLikeCount: int,
@ -17267,6 +17279,11 @@ def runDaemon(listsEnabled: str,
# scan the theme directory for any svg files containing scripts
assert not scanThemesForScripts(baseDir)
# license for content of the instance
if not contentLicenseUrl:
contentLicenseUrl = 'https://creativecommons.org/licenses/by/4.0'
httpd.contentLicenseUrl = contentLicenseUrl
# fitness metrics
fitnessFilename = baseDir + '/accounts/fitness.json'
httpd.fitness = {}

View File

@ -112,6 +112,9 @@ def str2bool(v) -> bool:
parser = argparse.ArgumentParser(description='ActivityPub Server')
parser.add_argument('--contentLicenseUrl', type=str,
default='https://creativecommons.org/licenses/by/4.0',
help='Url of the license used for the instance content')
parser.add_argument('--listsEnabled', type=str,
default=None,
help='Names of content warning lists enabled. ' +
@ -2884,6 +2887,13 @@ minimumvotes = getConfigParam(baseDir, 'minvotes')
if minimumvotes:
args.minimumvotes = int(minimumvotes)
contentLicenseUrl = ''
if args.contentLicenseUrl:
contentLicenseUrl = args.contentLicenseUrl
setConfigParam(baseDir, 'contentLicenseUrl', contentLicenseUrl)
else:
contentLicenseUrl = getConfigParam(baseDir, 'contentLicenseUrl')
votingtime = getConfigParam(baseDir, 'votingtime')
if votingtime:
args.votingtime = votingtime
@ -3078,7 +3088,8 @@ if args.defaultCurrency:
print('Default currency set to ' + args.defaultCurrency)
if __name__ == "__main__":
runDaemon(listsEnabled,
runDaemon(contentLicenseUrl,
listsEnabled,
args.defaultReplyIntervalHours,
args.lowBandwidth, args.maxLikeCount,
sharedItemsFederatedDomains,

View File

@ -818,8 +818,10 @@ def createServerAlice(path: str, domain: str, port: int,
maxLikeCount = 10
defaultReplyIntervalHours = 9999999999
listsEnabled = ''
contentLicenseUrl = None
print('Server running: Alice')
runDaemon(listsEnabled, defaultReplyIntervalHours,
runDaemon(contentLicenseUrl,
listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains,
userAgentsBlocked,
@ -957,8 +959,10 @@ def createServerBob(path: str, domain: str, port: int,
maxLikeCount = 10
defaultReplyIntervalHours = 9999999999
listsEnabled = ''
contentLicenseUrl = None
print('Server running: Bob')
runDaemon(listsEnabled, defaultReplyIntervalHours,
runDaemon(contentLicenseUrl,
listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains,
userAgentsBlocked,
@ -1025,8 +1029,10 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
lowBandwidth = True
defaultReplyIntervalHours = 9999999999
listsEnabled = ''
contentLicenseUrl = None
print('Server running: Eve')
runDaemon(listsEnabled, defaultReplyIntervalHours,
runDaemon(contentLicenseUrl,
listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains,
userAgentsBlocked,
@ -1095,8 +1101,10 @@ def createServerGroup(path: str, domain: str, port: int,
lowBandwidth = True
defaultReplyIntervalHours = 9999999999
listsEnabled = ''
contentLicenseUrl = None
print('Server running: Group')
runDaemon(listsEnabled, defaultReplyIntervalHours,
runDaemon(contentLicenseUrl,
listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains,
userAgentsBlocked,

View File

@ -542,7 +542,8 @@ def htmlProfile(signingPrivateKeyPem: str,
sharedItemsFederatedDomains: [],
extraJson: {}, pageNumber: int,
maxItemsPerPage: int,
CWlists: {}, listsEnabled: str) -> str:
CWlists: {}, listsEnabled: str,
contentLicenseUrl: str) -> str:
"""Show the profile page as html
"""
nickname = profileJson['preferredUsername']
@ -985,7 +986,8 @@ def htmlProfile(signingPrivateKeyPem: str,
getConfigParam(baseDir, 'instanceTitle')
profileStr = \
htmlHeaderWithPersonMarkup(cssFilename, instanceTitle,
profileJson, city) + \
profileJson, city,
contentLicenseUrl) + \
profileStr + htmlFooter()
return profileStr

View File

@ -552,6 +552,7 @@ def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
actorJson: {}, city: str,
contentLicenseUrl: str,
lang='en') -> str:
"""html header which includes person markup
https://schema.org/Person
@ -665,7 +666,6 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
' "url": "' + actorJson['id'] + '"\n' + \
' },\n'
licenseUrl = 'https://creativecommons.org/licenses/by/4.0'
profileMarkup = \
' <script id="initial-state" type="application/ld+json">\n' + \
' {\n' + \
@ -686,7 +686,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
' "name": "' + nameStr + '",\n' + \
' "image": "' + actorJson['icon']['url'] + '",\n' + \
' "description": "' + description + '",\n' + \
' "license": "' + licenseUrl + '"\n' + \
' "license": "' + contentLicenseUrl + '"\n' + \
' }\n' + \
' </script>\n'
@ -798,7 +798,8 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
systemLanguage: str,
published: str, modified: str,
title: str, snippet: str,
translate: {}, url: str) -> str:
translate: {}, url: str,
contentLicenseUrl: str) -> str:
"""html header which includes blog post markup
https://schema.org/BlogPosting
"""
@ -807,7 +808,6 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
# license for content on the site may be different from
# the software license
contentLicenseUrl = 'https://creativecommons.org/licenses/by/3.0'
blogMarkup = \
' <script id="initial-state" type="application/ld+json">\n' + \