forked from indymedia/epicyon
Maximum newswire posts per source is configurable
parent
5c5a25e534
commit
876b29b7be
|
@ -11951,7 +11951,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
tokensLookup[token] = nickname
|
tokensLookup[token] = nickname
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(showPublishedDateOnly: bool,
|
def runDaemon(maxNewswirePostsPerSource: int,
|
||||||
|
showPublishedDateOnly: bool,
|
||||||
votingTimeMins: int,
|
votingTimeMins: int,
|
||||||
positiveVoting: bool,
|
positiveVoting: bool,
|
||||||
newswireVotesThreshold: int,
|
newswireVotesThreshold: int,
|
||||||
|
@ -12072,6 +12073,12 @@ def runDaemon(showPublishedDateOnly: bool,
|
||||||
# or if positive voting is anabled to add the item to the news timeline
|
# or if positive voting is anabled to add the item to the news timeline
|
||||||
httpd.newswireVotesThreshold = newswireVotesThreshold
|
httpd.newswireVotesThreshold = newswireVotesThreshold
|
||||||
|
|
||||||
|
# For each newswire source (account or rss feed)
|
||||||
|
# this is the maximum number of posts to show for each.
|
||||||
|
# This avoids one or two sources from dominating the news,
|
||||||
|
# and also prevents big feeds from slowing down page load times
|
||||||
|
httpd.maxNewswirePostsPerSource = maxNewswirePostsPerSource
|
||||||
|
|
||||||
# Show only the date at the bottom of posts, and not the time
|
# Show only the date at the bottom of posts, and not the time
|
||||||
httpd.showPublishedDateOnly = showPublishedDateOnly
|
httpd.showPublishedDateOnly = showPublishedDateOnly
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,10 @@ parser.add_argument('--i2pDomain', dest='i2pDomain', type=str,
|
||||||
parser.add_argument('-p', '--port', dest='port', type=int,
|
parser.add_argument('-p', '--port', dest='port', type=int,
|
||||||
default=None,
|
default=None,
|
||||||
help='Port number to run on')
|
help='Port number to run on')
|
||||||
|
parser.add_argument('--postsPerSource',
|
||||||
|
dest='maxNewswirePostsPerSource', type=int,
|
||||||
|
default=5,
|
||||||
|
help='Maximum newswire posts per feed or account')
|
||||||
parser.add_argument('--postcache', dest='maxRecentPosts', type=int,
|
parser.add_argument('--postcache', dest='maxRecentPosts', type=int,
|
||||||
default=512,
|
default=512,
|
||||||
help='The maximum number of recent posts to store in RAM')
|
help='The maximum number of recent posts to store in RAM')
|
||||||
|
@ -1938,7 +1942,8 @@ if setTheme(baseDir, themeName, domain):
|
||||||
print('Theme set to ' + themeName)
|
print('Theme set to ' + themeName)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(args.dateonly,
|
runDaemon(args.maxNewswirePostsPerSource,
|
||||||
|
args.dateonly,
|
||||||
args.votingtime,
|
args.votingtime,
|
||||||
args.positivevoting,
|
args.positivevoting,
|
||||||
args.minimumvotes,
|
args.minimumvotes,
|
||||||
|
|
|
@ -225,7 +225,9 @@ def runNewswireDaemon(baseDir: str, httpd,
|
||||||
# try to update the feeds
|
# try to update the feeds
|
||||||
newNewswire = None
|
newNewswire = None
|
||||||
try:
|
try:
|
||||||
newNewswire = getDictFromNewswire(httpd.session, baseDir)
|
newNewswire = \
|
||||||
|
getDictFromNewswire(httpd.session, baseDir,
|
||||||
|
httpd.maxNewswirePostsPerSource)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: unable to update newswire ' + str(e))
|
print('WARN: unable to update newswire ' + str(e))
|
||||||
time.sleep(120)
|
time.sleep(120)
|
||||||
|
|
|
@ -396,7 +396,7 @@ def addBlogsToNewswire(baseDir: str, newswire: {},
|
||||||
os.remove(newswireModerationFilename)
|
os.remove(newswireModerationFilename)
|
||||||
|
|
||||||
|
|
||||||
def getDictFromNewswire(session, baseDir: str) -> {}:
|
def getDictFromNewswire(session, baseDir: str, maxPostsPerSource: int) -> {}:
|
||||||
"""Gets rss feeds as a dictionary from newswire file
|
"""Gets rss feeds as a dictionary from newswire file
|
||||||
"""
|
"""
|
||||||
subscriptionsFilename = baseDir + '/accounts/newswire.txt'
|
subscriptionsFilename = baseDir + '/accounts/newswire.txt'
|
||||||
|
|
6
tests.py
6
tests.py
|
@ -288,7 +288,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(False, 0, False, 1, False, False, False,
|
runDaemon(5, False, 0, False, 1, False, False, False,
|
||||||
5, True, True, 'en', __version__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
|
@ -351,7 +351,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(False, 0, False, 1, False, False, False,
|
runDaemon(5, False, 0, False, 1, False, False, False,
|
||||||
5, True, True, 'en', __version__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
|
@ -388,7 +388,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(False, 0, False, 1, False, False, False,
|
runDaemon(5, False, 0, False, 1, False, False, False,
|
||||||
5, True, True, 'en', __version__,
|
5, True, True, 'en', __version__,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
|
|
Loading…
Reference in New Issue