From 3203cffb998ff14d618ae695d7c84f6be3ab82d6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 17 Dec 2019 09:58:22 +0000 Subject: [PATCH] Show the newest hashtags first --- manualapprove.py | 1 - webinterface.py | 30 ++++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manualapprove.py b/manualapprove.py index 0673d160..5b85e991 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -114,7 +114,6 @@ def manualApproveFollowRequest(session,baseDir: str, \ sendThreads,postLog, \ cachedWebfingers,personCache, \ debug,projectVersion) - os.remove(followActivityfilename) updateApprovedFollowers=True else: approvefilenew.write(handle) diff --git a/webinterface.py b/webinterface.py index 53c49ef2..3a5ce482 100644 --- a/webinterface.py +++ b/webinterface.py @@ -370,6 +370,8 @@ def htmlHashtagSearch(nickname: str,domain: str,port: int, \ # read the index with open(hashtagIndexFile, "r") as f: lines = f.readlines() + + # read the css cssFilename=baseDir+'/epicyon-profile.css' if os.path.isfile(baseDir+'/epicyon.css'): cssFilename=baseDir+'/epicyon.css' @@ -378,17 +380,25 @@ def htmlHashtagSearch(nickname: str,domain: str,port: int, \ if httpPrefix!='https': hashtagSearchCSS=hashtagSearchCSS.replace('https://',httpPrefix+'://') - startIndex=len(lines)-1-int(pageNumber*postsPerPage) - if startIndex<0: - startIndex=len(lines)-1 - endIndex=startIndex-postsPerPage - if endIndex<0: - endIndex=0 - + # ensure that the page number is in bounds + if not pageNumber: + pageNumber=1 + elif pageNumber<1: + pageNumber=1 + + # get the start end end within the index file + startIndex=int((pageNumber-1)*postsPerPage) + endIndex=startIndex+postsPerPage + noOfLines=len(lines) + if endIndex>=noOfLines and noOfLines>0: + endIndex=noOfLines-1 + + # add the page title hashtagSearchForm=htmlHeader(cssFilename,hashtagSearchCSS) hashtagSearchForm+='' hashtagSearchForm+='

#'+hashtag+'

' - if startIndex!=len(lines)-1: + + if startIndex>0: # previous page link hashtagSearchForm+= \ '