forked from indymedia/epicyon
Tidying
parent
6ea5e0cf80
commit
d6e16c9b5d
|
@ -1712,13 +1712,28 @@ def postContainsPublic(postJsonObject: {}) -> bool:
|
||||||
break
|
break
|
||||||
return containsPublic
|
return containsPublic
|
||||||
|
|
||||||
|
def getCachedPostDirectory(baseDir: str,nickname: str,domain: str) -> str:
|
||||||
|
"""Returns the directory where the html post cache exists
|
||||||
|
"""
|
||||||
|
htmlPostCacheDir=baseDir+'/accounts/'+nickname+'@'+domain+'/postcache'
|
||||||
|
return htmlPostCacheDir
|
||||||
|
|
||||||
|
def getCachedPostFilename(baseDir: str,nickname: str,domain: str, \
|
||||||
|
postJsonObject: {}) -> str:
|
||||||
|
"""Returns the html cache filename for the given post
|
||||||
|
"""
|
||||||
|
cachedPostFilename= \
|
||||||
|
getCachedPostDirectory(baseDir,nickname,domain)+ \
|
||||||
|
'/'+postJsonObject['id'].replace('/activity','').replace('/','#')+'.html'
|
||||||
|
return cachedPostFilename
|
||||||
|
|
||||||
def loadIndividualPostAsHtmlFromCache(baseDir: str,nickname: str,domain: str, \
|
def loadIndividualPostAsHtmlFromCache(baseDir: str,nickname: str,domain: str, \
|
||||||
postJsonObject: {}) -> str:
|
postJsonObject: {}) -> str:
|
||||||
"""If a cached html version of the given post exists then load it and
|
"""If a cached html version of the given post exists then load it and
|
||||||
return the html text
|
return the html text
|
||||||
"""
|
"""
|
||||||
htmlPostCacheDir=baseDir+'/accounts/'+nickname+'@'+domain+'/postcache'
|
cachedPostFilename=getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
|
||||||
cachedPostFilename=htmlPostCacheDir+'/'+postJsonObject['id'].replace('/activity','').replace('/','#')+'.html'
|
|
||||||
postHtml=''
|
postHtml=''
|
||||||
if not os.path.isfile(cachedPostFilename):
|
if not os.path.isfile(cachedPostFilename):
|
||||||
return postHtml
|
return postHtml
|
||||||
|
@ -1741,8 +1756,8 @@ def saveIndividualPostAsHtmlToCache(baseDir: str,nickname: str,domain: str, \
|
||||||
"""Saves the given html for a post to a cache file
|
"""Saves the given html for a post to a cache file
|
||||||
This is so that it can be quickly reloaded on subsequent refresh of the timeline
|
This is so that it can be quickly reloaded on subsequent refresh of the timeline
|
||||||
"""
|
"""
|
||||||
htmlPostCacheDir=baseDir+'/accounts/'+nickname+'@'+domain+'/postcache'
|
htmlPostCacheDir=getCachedPostDirectory(baseDir,nickname,domain)
|
||||||
cachedPostFilename=htmlPostCacheDir+'/'+postJsonObject['id'].replace('/activity','').replace('/','#')+'.html'
|
cachedPostFilename=getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
|
||||||
|
|
||||||
# create the cache directory if needed
|
# create the cache directory if needed
|
||||||
if not os.path.isdir(htmlPostCacheDir):
|
if not os.path.isdir(htmlPostCacheDir):
|
||||||
|
|
Loading…
Reference in New Issue