forked from solderpunk/AV-98
New theme option: new_link
In gemtext and RSS rendering, if a link point to a page which is considered as "new" (it has been cached less than 60 seconds after the page itself), we display it differently (by default in bold white). This feature allows to quickcly see new links in RSS pages or aggregator such as antenna.
This commit is contained in:
parent
b03cbd9c64
commit
6e09f0264b
|
@ -1,7 +1,9 @@
|
|||
# Offpunk History
|
||||
|
||||
## 2.1 - Unreleased
|
||||
- ansicat: freshly updated gemtext/rss links are highlighted ("new_link" theme option)
|
||||
- ansicat: added "--mode" option
|
||||
- ansicat: avoid a crash when urllib.parse.urljoin fails
|
||||
|
||||
## 2.0 - November 16th 2023
|
||||
Changes since 1.10
|
||||
|
|
16
ansicat.py
16
ansicat.py
|
@ -512,7 +512,12 @@ class AbstractRenderer():
|
|||
self.rendered_text[mode] += results[0] + "\n"
|
||||
#we should absolutize all URLs here
|
||||
for l in results[1]:
|
||||
abs_l = urllib.parse.urljoin(self.url,l.split()[0])
|
||||
ll = l.split()[0]
|
||||
try:
|
||||
abs_l = urllib.parse.urljoin(self.url,ll)
|
||||
except Exception as err:
|
||||
print("Urljoin Error: Could not make an URL out of %s and %s"%(self.url,ll))
|
||||
abs_l = ll
|
||||
self.links[mode].append(abs_l)
|
||||
for l in self.get_subscribe_links()[1:]:
|
||||
self.links[mode].append(l[0])
|
||||
|
@ -642,7 +647,14 @@ class GemtextRenderer(AbstractRenderer):
|
|||
if len(splitted) > 1:
|
||||
name = splitted[1]
|
||||
link = format_link(url,len(links)+startlinks,name=name)
|
||||
if r.open_theme("oneline_link"):
|
||||
# If the link point to a page that has been cached less than
|
||||
# 60 seconds after this page, we consider it as a new_link
|
||||
current_modif = netcache.cache_last_modified(self.url)
|
||||
link_modif = netcache.cache_last_modified(url)
|
||||
if current_modif and link_modif and current_modif - link_modif < 60 and\
|
||||
r.open_theme("new_link"):
|
||||
theme = "new_link"
|
||||
elif r.open_theme("oneline_link"):
|
||||
theme = "oneline_link"
|
||||
else:
|
||||
theme = "link"
|
||||
|
|
|
@ -91,10 +91,9 @@ def cache_last_modified(url):
|
|||
if not url:
|
||||
return None
|
||||
path = get_cache_path(url)
|
||||
if path:
|
||||
if path and os.path.isfile(path):
|
||||
return os.path.getmtime(path)
|
||||
else:
|
||||
print("ERROR : NO CACHE in cache_last_modified")
|
||||
return None
|
||||
|
||||
def is_cache_valid(url,validity=0):
|
||||
|
|
|
@ -37,6 +37,7 @@ offpunk1 = {
|
|||
"subtitle" : ["blue"],
|
||||
"subsubtitle" : ["blue","faint"], #fallback to subtitle if none
|
||||
"link" : ["blue","faint"],
|
||||
"new_link": ["bold"],
|
||||
"oneline_link": [], #for gopher/gemini. fallback to link if none
|
||||
"image_link" : ["yellow","faint"],
|
||||
"preformatted": ["faint"],
|
||||
|
|
Loading…
Reference in New Issue