forked from indymedia/epicyon
Set a maximum number of posts to appear in the newswire column
parent
0e2a5e0965
commit
7a01f422cf
|
@ -12388,7 +12388,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
tokensLookup[token] = nickname
|
tokensLookup[token] = nickname
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(allowLocalNetworkAccess: bool,
|
def runDaemon(maxNewswirePosts: int,
|
||||||
|
allowLocalNetworkAccess: bool,
|
||||||
maxFeedItemSizeKb: int,
|
maxFeedItemSizeKb: int,
|
||||||
publishButtonAtTop: bool,
|
publishButtonAtTop: bool,
|
||||||
rssIconAtTop: bool,
|
rssIconAtTop: bool,
|
||||||
|
@ -12463,6 +12464,9 @@ def runDaemon(allowLocalNetworkAccess: bool,
|
||||||
# newswire storing rss feeds
|
# newswire storing rss feeds
|
||||||
httpd.newswire = {}
|
httpd.newswire = {}
|
||||||
|
|
||||||
|
# maximum number of posts to appear in the newswire on the right column
|
||||||
|
httpd.maxNewswirePosts = maxNewswirePosts
|
||||||
|
|
||||||
# This counter is used to update the list of blocked domains in memory.
|
# This counter is used to update the list of blocked domains in memory.
|
||||||
# It helps to avoid touching the disk and so improves flooding resistance
|
# It helps to avoid touching the disk and so improves flooding resistance
|
||||||
httpd.blocklistUpdateCtr = 0
|
httpd.blocklistUpdateCtr = 0
|
||||||
|
|
13
epicyon.py
13
epicyon.py
|
@ -116,6 +116,10 @@ parser.add_argument('--postsPerSource',
|
||||||
dest='maxNewswirePostsPerSource', type=int,
|
dest='maxNewswirePostsPerSource', type=int,
|
||||||
default=4,
|
default=4,
|
||||||
help='Maximum newswire posts per feed or account')
|
help='Maximum newswire posts per feed or account')
|
||||||
|
parser.add_argument('--maxNewswirePosts',
|
||||||
|
dest='maxNewswirePosts', type=int,
|
||||||
|
default=20,
|
||||||
|
help='Maximum newswire posts in the right column')
|
||||||
parser.add_argument('--maxFeedSize',
|
parser.add_argument('--maxFeedSize',
|
||||||
dest='maxNewswireFeedSizeKb', type=int,
|
dest='maxNewswireFeedSizeKb', type=int,
|
||||||
default=10240,
|
default=10240,
|
||||||
|
@ -2001,6 +2005,12 @@ maxNewswirePostsPerSource = \
|
||||||
if maxNewswirePostsPerSource:
|
if maxNewswirePostsPerSource:
|
||||||
args.maxNewswirePostsPerSource = int(maxNewswirePostsPerSource)
|
args.maxNewswirePostsPerSource = int(maxNewswirePostsPerSource)
|
||||||
|
|
||||||
|
# set the maximum number of newswire posts appearing in the right column
|
||||||
|
maxNewswirePosts = \
|
||||||
|
getConfigParam(baseDir, 'maxNewswirePosts')
|
||||||
|
if maxNewswirePosts:
|
||||||
|
args.maxNewswirePosts = int(maxNewswirePosts)
|
||||||
|
|
||||||
# set the maximum size of a newswire rss/atom feed in Kilobytes
|
# set the maximum size of a newswire rss/atom feed in Kilobytes
|
||||||
maxNewswireFeedSizeKb = \
|
maxNewswireFeedSizeKb = \
|
||||||
getConfigParam(baseDir, 'maxNewswireFeedSizeKb')
|
getConfigParam(baseDir, 'maxNewswireFeedSizeKb')
|
||||||
|
@ -2075,7 +2085,8 @@ if setTheme(baseDir, themeName, domain, args.allowLocalNetworkAccess):
|
||||||
print('Theme set to ' + themeName)
|
print('Theme set to ' + themeName)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(args.allowLocalNetworkAccess,
|
runDaemon(args.maxNewswirePosts,
|
||||||
|
args.allowLocalNetworkAccess,
|
||||||
args.maxFeedItemSizeKb,
|
args.maxFeedItemSizeKb,
|
||||||
args.publishButtonAtTop,
|
args.publishButtonAtTop,
|
||||||
args.rssIconAtTop,
|
args.rssIconAtTop,
|
||||||
|
|
|
@ -718,7 +718,8 @@ def runNewswireDaemon(baseDir: str, httpd,
|
||||||
httpd.maxNewswirePostsPerSource,
|
httpd.maxNewswirePostsPerSource,
|
||||||
httpd.maxNewswireFeedSizeKb,
|
httpd.maxNewswireFeedSizeKb,
|
||||||
httpd.maxTags,
|
httpd.maxTags,
|
||||||
httpd.maxFeedItemSizeKb)
|
httpd.maxFeedItemSizeKb,
|
||||||
|
httpd.maxNewswirePosts)
|
||||||
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)
|
||||||
|
|
10
newswire.py
10
newswire.py
|
@ -677,7 +677,8 @@ def addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
|
||||||
|
|
||||||
def getDictFromNewswire(session, baseDir: str, domain: str,
|
def getDictFromNewswire(session, baseDir: str, domain: str,
|
||||||
maxPostsPerSource: int, maxFeedSizeKb: int,
|
maxPostsPerSource: int, maxFeedSizeKb: int,
|
||||||
maxTags: int, maxFeedItemSizeKb: int) -> {}:
|
maxTags: int, maxFeedItemSizeKb: int,
|
||||||
|
maxNewswirePosts: 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'
|
||||||
|
@ -728,4 +729,11 @@ def getDictFromNewswire(session, baseDir: str, domain: str,
|
||||||
|
|
||||||
# sort into chronological order, latest first
|
# sort into chronological order, latest first
|
||||||
sortedResult = OrderedDict(sorted(result.items(), reverse=True))
|
sortedResult = OrderedDict(sorted(result.items(), reverse=True))
|
||||||
|
|
||||||
|
# are there too many posts? If so then remove the oldest ones
|
||||||
|
noOfPosts = len(sortedResult.items())
|
||||||
|
if noOfPosts > maxNewswirePosts:
|
||||||
|
for n in range(noOfPosts - maxNewswirePosts):
|
||||||
|
sortedResult.pop()
|
||||||
|
|
||||||
return sortedResult
|
return sortedResult
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -292,8 +292,9 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
allowLocalNetworkAccess = True
|
allowLocalNetworkAccess = True
|
||||||
|
maxNewswirePosts = 20
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(allowLocalNetworkAccess,
|
runDaemon(maxNewswirePosts, allowLocalNetworkAccess,
|
||||||
2048, False, True, False, False, True, 10, False,
|
2048, False, True, False, False, True, 10, False,
|
||||||
0, 100, 1024, 5, False,
|
0, 100, 1024, 5, False,
|
||||||
0, False, 1, False, False, False,
|
0, False, 1, False, False, False,
|
||||||
|
@ -359,8 +360,9 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
allowLocalNetworkAccess = True
|
allowLocalNetworkAccess = True
|
||||||
|
maxNewswirePosts = 20
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(allowLocalNetworkAccess,
|
runDaemon(maxNewswirePosts, allowLocalNetworkAccess,
|
||||||
2048, False, True, False, False, True, 10, False,
|
2048, False, True, False, False, True, 10, False,
|
||||||
0, 100, 1024, 5, False, 0,
|
0, 100, 1024, 5, False, 0,
|
||||||
False, 1, False, False, False,
|
False, 1, False, False, False,
|
||||||
|
@ -400,8 +402,9 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
onionDomain = None
|
onionDomain = None
|
||||||
i2pDomain = None
|
i2pDomain = None
|
||||||
allowLocalNetworkAccess = True
|
allowLocalNetworkAccess = True
|
||||||
|
maxNewswirePosts = 20
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(allowLocalNetworkAccess,
|
runDaemon(maxNewswirePosts, allowLocalNetworkAccess,
|
||||||
2048, False, True, False, False, True, 10, False,
|
2048, False, True, False, False, True, 10, False,
|
||||||
0, 100, 1024, 5, False, 0,
|
0, 100, 1024, 5, False, 0,
|
||||||
False, 1, False, False, False,
|
False, 1, False, False, False,
|
||||||
|
|
Loading…
Reference in New Issue