made sort orders
This commit is contained in:
parent
9166af18d6
commit
1aa99618aa
25
column.py
25
column.py
@ -1,4 +1,5 @@
|
|||||||
import random
|
import random
|
||||||
|
from datetime import datetime
|
||||||
from parse_rss_feeds import parse_rss_feeds
|
from parse_rss_feeds import parse_rss_feeds
|
||||||
|
|
||||||
|
|
||||||
@ -17,10 +18,32 @@ class Column:
|
|||||||
self.limit = limit
|
self.limit = limit
|
||||||
|
|
||||||
def _sort_by_order(self):
|
def _sort_by_order(self):
|
||||||
|
entrylist = list(self.entries.items())
|
||||||
|
if self.sort_order.lower() == "reverse":
|
||||||
|
entrylist.reverse()
|
||||||
|
self.entries = dict(entrylist)
|
||||||
|
return
|
||||||
if self.sort_order.lower() == "random":
|
if self.sort_order.lower() == "random":
|
||||||
entrylist = list(self.entries.items())
|
|
||||||
random.shuffle(entrylist)
|
random.shuffle(entrylist)
|
||||||
self.entries = dict(entrylist)
|
self.entries = dict(entrylist)
|
||||||
|
return
|
||||||
|
if self.sort_order.lower() == "chronological":
|
||||||
|
entrylist.sort(
|
||||||
|
key=lambda x: datetime.strptime(
|
||||||
|
x[1][1], "%a, %d %b %Y %H:%M:%S %z"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.entries = dict(entrylist)
|
||||||
|
return
|
||||||
|
if self.sort_order.lower() == "reverse-chronological":
|
||||||
|
entrylist.sort(
|
||||||
|
key=lambda x: datetime.strptime(
|
||||||
|
x[1][1], "%a, %d %b %Y %H:%M:%S %z"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
entrylist.reverse()
|
||||||
|
self.entries = dict(entrylist)
|
||||||
|
return
|
||||||
|
|
||||||
def _enforce_limit(self):
|
def _enforce_limit(self):
|
||||||
while len(self.entries) > self.limit:
|
while len(self.entries) > self.limit:
|
||||||
|
10
columns.toml
10
columns.toml
@ -1,14 +1,10 @@
|
|||||||
[[column]]
|
[[column]]
|
||||||
urls = ["https://varia.zone/logs/x-y/feed.rss.xml","https://varia.zone/logs/x-y-protocols/feed.rss.xml"]
|
urls = ["https://varia.zone/logs/x-y/feed.rss.xml","https://varia.zone/logs/x-y-protocols/feed.rss.xml"]
|
||||||
title = "code"
|
title = "code"
|
||||||
limit = 20
|
limit = 40
|
||||||
sort_order = "random"
|
sort_order = "random"
|
||||||
|
|
||||||
[[column]]
|
[[column]]
|
||||||
urls = ["https://post.lurk.org/@cmos4040.rss"]
|
urls = ["https://post.lurk.org/@cmos4040.rss","https://post.lurk.org/tags/radio.rss"]
|
||||||
title = "circulations"
|
title = "circulations"
|
||||||
|
sort_order = "reverse-chronological"
|
||||||
[[column]]
|
|
||||||
urls = ["https://a-nourishing-network.radical-openness.org/feeds/feed.rss"]
|
|
||||||
title = "a-nourishing-network"
|
|
||||||
limit = 20
|
|
||||||
|
@ -14,7 +14,7 @@ def _parse_single_rss_feed(url, entries):
|
|||||||
entries[title] = []
|
entries[title] = []
|
||||||
entrylist = entries[title]
|
entrylist = entries[title]
|
||||||
entrylist.append(entry.description)
|
entrylist.append(entry.description)
|
||||||
|
entrylist.append(entry.published)
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user