mirror of https://gitlab.com/bashrc2/epicyon
Command option for content license
parent
3548b8795c
commit
ebacc0e6f1
5
blog.py
5
blog.py
|
@ -420,7 +420,7 @@ def htmlBlogPost(session, authorized: bool,
|
||||||
postJsonObject: {},
|
postJsonObject: {},
|
||||||
peertubeInstances: [],
|
peertubeInstances: [],
|
||||||
systemLanguage: str, personCache: {},
|
systemLanguage: str, personCache: {},
|
||||||
debug: bool) -> str:
|
debug: bool, contentLicenseUrl: str) -> str:
|
||||||
"""Returns a html blog post
|
"""Returns a html blog post
|
||||||
"""
|
"""
|
||||||
blogStr = ''
|
blogStr = ''
|
||||||
|
@ -442,7 +442,8 @@ def htmlBlogPost(session, authorized: bool,
|
||||||
blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle,
|
blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle,
|
||||||
httpPrefix, domainFull, nickname,
|
httpPrefix, domainFull, nickname,
|
||||||
systemLanguage, published, modified,
|
systemLanguage, published, modified,
|
||||||
title, snippet, translate, url)
|
title, snippet, translate, url,
|
||||||
|
contentLicenseUrl)
|
||||||
_htmlBlogRemoveCwButton(blogStr, translate)
|
_htmlBlogRemoveCwButton(blogStr, translate)
|
||||||
|
|
||||||
blogStr += _htmlBlogPostContent(debug, session, authorized, baseDir,
|
blogStr += _htmlBlogPostContent(debug, session, authorized, baseDir,
|
||||||
|
|
33
daemon.py
33
daemon.py
|
@ -8758,7 +8758,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.sharedItemsFederatedDomains,
|
self.server.sharedItemsFederatedDomains,
|
||||||
rolesList,
|
rolesList,
|
||||||
None, None, self.server.CWlists,
|
None, None, self.server.CWlists,
|
||||||
self.server.listsEnabled)
|
self.server.listsEnabled,
|
||||||
|
self.server.contentLicenseUrl)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html', msglen,
|
self._set_headers('text/html', msglen,
|
||||||
|
@ -8873,7 +8874,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
skills,
|
skills,
|
||||||
None, None,
|
None, None,
|
||||||
self.server.CWlists,
|
self.server.CWlists,
|
||||||
self.server.listsEnabled)
|
self.server.listsEnabled,
|
||||||
|
self.server.contentLicenseUrl)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html', msglen,
|
self._set_headers('text/html', msglen,
|
||||||
|
@ -10866,7 +10868,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
shares,
|
shares,
|
||||||
pageNumber, sharesPerPage,
|
pageNumber, sharesPerPage,
|
||||||
self.server.CWlists,
|
self.server.CWlists,
|
||||||
self.server.listsEnabled)
|
self.server.listsEnabled,
|
||||||
|
self.server.contentLicenseUrl)
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html', msglen,
|
self._set_headers('text/html', msglen,
|
||||||
|
@ -10958,6 +10961,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
city = getSpoofedCity(self.server.city,
|
city = getSpoofedCity(self.server.city,
|
||||||
baseDir, nickname, domain)
|
baseDir, nickname, domain)
|
||||||
|
contentLicenseUrl = \
|
||||||
|
self.server.contentLicenseUrl
|
||||||
msg = \
|
msg = \
|
||||||
htmlProfile(self.server.signingPrivateKeyPem,
|
htmlProfile(self.server.signingPrivateKeyPem,
|
||||||
self.server.rssIconAtTop,
|
self.server.rssIconAtTop,
|
||||||
|
@ -10992,7 +10997,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
pageNumber,
|
pageNumber,
|
||||||
followsPerPage,
|
followsPerPage,
|
||||||
self.server.CWlists,
|
self.server.CWlists,
|
||||||
self.server.listsEnabled).encode('utf-8')
|
self.server.listsEnabled,
|
||||||
|
contentLicenseUrl).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html',
|
self._set_headers('text/html',
|
||||||
msglen, cookie, callingDomain, False)
|
msglen, cookie, callingDomain, False)
|
||||||
|
@ -11082,6 +11088,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
city = getSpoofedCity(self.server.city,
|
city = getSpoofedCity(self.server.city,
|
||||||
baseDir, nickname, domain)
|
baseDir, nickname, domain)
|
||||||
|
contentLicenseUrl = \
|
||||||
|
self.server.contentLicenseUrl
|
||||||
msg = \
|
msg = \
|
||||||
htmlProfile(self.server.signingPrivateKeyPem,
|
htmlProfile(self.server.signingPrivateKeyPem,
|
||||||
self.server.rssIconAtTop,
|
self.server.rssIconAtTop,
|
||||||
|
@ -11117,7 +11125,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
pageNumber,
|
pageNumber,
|
||||||
followsPerPage,
|
followsPerPage,
|
||||||
self.server.CWlists,
|
self.server.CWlists,
|
||||||
self.server.listsEnabled).encode('utf-8')
|
self.server.listsEnabled,
|
||||||
|
contentLicenseUrl).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html', msglen,
|
self._set_headers('text/html', msglen,
|
||||||
cookie, callingDomain, False)
|
cookie, callingDomain, False)
|
||||||
|
@ -11258,7 +11267,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.sharedItemsFederatedDomains,
|
self.server.sharedItemsFederatedDomains,
|
||||||
None, None, None,
|
None, None, None,
|
||||||
self.server.CWlists,
|
self.server.CWlists,
|
||||||
self.server.listsEnabled).encode('utf-8')
|
self.server.listsEnabled,
|
||||||
|
self.server.contentLicenseUrl).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/html', msglen,
|
self._set_headers('text/html', msglen,
|
||||||
cookie, callingDomain, False)
|
cookie, callingDomain, False)
|
||||||
|
@ -13138,7 +13148,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances,
|
self.server.peertubeInstances,
|
||||||
self.server.systemLanguage,
|
self.server.systemLanguage,
|
||||||
self.server.personCache,
|
self.server.personCache,
|
||||||
self.server.debug)
|
self.server.debug,
|
||||||
|
self.server.contentLicenseUrl)
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -17179,7 +17190,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(listsEnabled: str,
|
def runDaemon(contentLicenseUrl: str,
|
||||||
|
listsEnabled: str,
|
||||||
defaultReplyIntervalHours: int,
|
defaultReplyIntervalHours: int,
|
||||||
lowBandwidth: bool,
|
lowBandwidth: bool,
|
||||||
maxLikeCount: int,
|
maxLikeCount: int,
|
||||||
|
@ -17267,6 +17279,11 @@ def runDaemon(listsEnabled: str,
|
||||||
# scan the theme directory for any svg files containing scripts
|
# scan the theme directory for any svg files containing scripts
|
||||||
assert not scanThemesForScripts(baseDir)
|
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
|
# fitness metrics
|
||||||
fitnessFilename = baseDir + '/accounts/fitness.json'
|
fitnessFilename = baseDir + '/accounts/fitness.json'
|
||||||
httpd.fitness = {}
|
httpd.fitness = {}
|
||||||
|
|
13
epicyon.py
13
epicyon.py
|
@ -112,6 +112,9 @@ def str2bool(v) -> bool:
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='ActivityPub Server')
|
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,
|
parser.add_argument('--listsEnabled', type=str,
|
||||||
default=None,
|
default=None,
|
||||||
help='Names of content warning lists enabled. ' +
|
help='Names of content warning lists enabled. ' +
|
||||||
|
@ -2884,6 +2887,13 @@ minimumvotes = getConfigParam(baseDir, 'minvotes')
|
||||||
if minimumvotes:
|
if minimumvotes:
|
||||||
args.minimumvotes = int(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')
|
votingtime = getConfigParam(baseDir, 'votingtime')
|
||||||
if votingtime:
|
if votingtime:
|
||||||
args.votingtime = votingtime
|
args.votingtime = votingtime
|
||||||
|
@ -3078,7 +3088,8 @@ if args.defaultCurrency:
|
||||||
print('Default currency set to ' + args.defaultCurrency)
|
print('Default currency set to ' + args.defaultCurrency)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(listsEnabled,
|
runDaemon(contentLicenseUrl,
|
||||||
|
listsEnabled,
|
||||||
args.defaultReplyIntervalHours,
|
args.defaultReplyIntervalHours,
|
||||||
args.lowBandwidth, args.maxLikeCount,
|
args.lowBandwidth, args.maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
|
|
16
tests.py
16
tests.py
|
@ -818,8 +818,10 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
maxLikeCount = 10
|
maxLikeCount = 10
|
||||||
defaultReplyIntervalHours = 9999999999
|
defaultReplyIntervalHours = 9999999999
|
||||||
listsEnabled = ''
|
listsEnabled = ''
|
||||||
|
contentLicenseUrl = None
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(listsEnabled, defaultReplyIntervalHours,
|
runDaemon(contentLicenseUrl,
|
||||||
|
listsEnabled, defaultReplyIntervalHours,
|
||||||
lowBandwidth, maxLikeCount,
|
lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
|
@ -957,8 +959,10 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
maxLikeCount = 10
|
maxLikeCount = 10
|
||||||
defaultReplyIntervalHours = 9999999999
|
defaultReplyIntervalHours = 9999999999
|
||||||
listsEnabled = ''
|
listsEnabled = ''
|
||||||
|
contentLicenseUrl = None
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(listsEnabled, defaultReplyIntervalHours,
|
runDaemon(contentLicenseUrl,
|
||||||
|
listsEnabled, defaultReplyIntervalHours,
|
||||||
lowBandwidth, maxLikeCount,
|
lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
|
@ -1025,8 +1029,10 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
lowBandwidth = True
|
lowBandwidth = True
|
||||||
defaultReplyIntervalHours = 9999999999
|
defaultReplyIntervalHours = 9999999999
|
||||||
listsEnabled = ''
|
listsEnabled = ''
|
||||||
|
contentLicenseUrl = None
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(listsEnabled, defaultReplyIntervalHours,
|
runDaemon(contentLicenseUrl,
|
||||||
|
listsEnabled, defaultReplyIntervalHours,
|
||||||
lowBandwidth, maxLikeCount,
|
lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
|
@ -1095,8 +1101,10 @@ def createServerGroup(path: str, domain: str, port: int,
|
||||||
lowBandwidth = True
|
lowBandwidth = True
|
||||||
defaultReplyIntervalHours = 9999999999
|
defaultReplyIntervalHours = 9999999999
|
||||||
listsEnabled = ''
|
listsEnabled = ''
|
||||||
|
contentLicenseUrl = None
|
||||||
print('Server running: Group')
|
print('Server running: Group')
|
||||||
runDaemon(listsEnabled, defaultReplyIntervalHours,
|
runDaemon(contentLicenseUrl,
|
||||||
|
listsEnabled, defaultReplyIntervalHours,
|
||||||
lowBandwidth, maxLikeCount,
|
lowBandwidth, maxLikeCount,
|
||||||
sharedItemsFederatedDomains,
|
sharedItemsFederatedDomains,
|
||||||
userAgentsBlocked,
|
userAgentsBlocked,
|
||||||
|
|
|
@ -542,7 +542,8 @@ def htmlProfile(signingPrivateKeyPem: str,
|
||||||
sharedItemsFederatedDomains: [],
|
sharedItemsFederatedDomains: [],
|
||||||
extraJson: {}, pageNumber: int,
|
extraJson: {}, pageNumber: int,
|
||||||
maxItemsPerPage: int,
|
maxItemsPerPage: int,
|
||||||
CWlists: {}, listsEnabled: str) -> str:
|
CWlists: {}, listsEnabled: str,
|
||||||
|
contentLicenseUrl: str) -> str:
|
||||||
"""Show the profile page as html
|
"""Show the profile page as html
|
||||||
"""
|
"""
|
||||||
nickname = profileJson['preferredUsername']
|
nickname = profileJson['preferredUsername']
|
||||||
|
@ -985,7 +986,8 @@ def htmlProfile(signingPrivateKeyPem: str,
|
||||||
getConfigParam(baseDir, 'instanceTitle')
|
getConfigParam(baseDir, 'instanceTitle')
|
||||||
profileStr = \
|
profileStr = \
|
||||||
htmlHeaderWithPersonMarkup(cssFilename, instanceTitle,
|
htmlHeaderWithPersonMarkup(cssFilename, instanceTitle,
|
||||||
profileJson, city) + \
|
profileJson, city,
|
||||||
|
contentLicenseUrl) + \
|
||||||
profileStr + htmlFooter()
|
profileStr + htmlFooter()
|
||||||
return profileStr
|
return profileStr
|
||||||
|
|
||||||
|
|
|
@ -552,6 +552,7 @@ def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
|
||||||
|
|
||||||
def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
actorJson: {}, city: str,
|
actorJson: {}, city: str,
|
||||||
|
contentLicenseUrl: str,
|
||||||
lang='en') -> str:
|
lang='en') -> str:
|
||||||
"""html header which includes person markup
|
"""html header which includes person markup
|
||||||
https://schema.org/Person
|
https://schema.org/Person
|
||||||
|
@ -665,7 +666,6 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' "url": "' + actorJson['id'] + '"\n' + \
|
' "url": "' + actorJson['id'] + '"\n' + \
|
||||||
' },\n'
|
' },\n'
|
||||||
|
|
||||||
licenseUrl = 'https://creativecommons.org/licenses/by/4.0'
|
|
||||||
profileMarkup = \
|
profileMarkup = \
|
||||||
' <script id="initial-state" type="application/ld+json">\n' + \
|
' <script id="initial-state" type="application/ld+json">\n' + \
|
||||||
' {\n' + \
|
' {\n' + \
|
||||||
|
@ -686,7 +686,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' "name": "' + nameStr + '",\n' + \
|
' "name": "' + nameStr + '",\n' + \
|
||||||
' "image": "' + actorJson['icon']['url'] + '",\n' + \
|
' "image": "' + actorJson['icon']['url'] + '",\n' + \
|
||||||
' "description": "' + description + '",\n' + \
|
' "description": "' + description + '",\n' + \
|
||||||
' "license": "' + licenseUrl + '"\n' + \
|
' "license": "' + contentLicenseUrl + '"\n' + \
|
||||||
' }\n' + \
|
' }\n' + \
|
||||||
' </script>\n'
|
' </script>\n'
|
||||||
|
|
||||||
|
@ -798,7 +798,8 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
|
||||||
systemLanguage: str,
|
systemLanguage: str,
|
||||||
published: str, modified: str,
|
published: str, modified: str,
|
||||||
title: str, snippet: str,
|
title: str, snippet: str,
|
||||||
translate: {}, url: str) -> str:
|
translate: {}, url: str,
|
||||||
|
contentLicenseUrl: str) -> str:
|
||||||
"""html header which includes blog post markup
|
"""html header which includes blog post markup
|
||||||
https://schema.org/BlogPosting
|
https://schema.org/BlogPosting
|
||||||
"""
|
"""
|
||||||
|
@ -807,7 +808,6 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
|
||||||
|
|
||||||
# license for content on the site may be different from
|
# license for content on the site may be different from
|
||||||
# the software license
|
# the software license
|
||||||
contentLicenseUrl = 'https://creativecommons.org/licenses/by/3.0'
|
|
||||||
|
|
||||||
blogMarkup = \
|
blogMarkup = \
|
||||||
' <script id="initial-state" type="application/ld+json">\n' + \
|
' <script id="initial-state" type="application/ld+json">\n' + \
|
||||||
|
|
Loading…
Reference in New Issue