Sort posts by publish date
Makes the latest ones very quick to find
This commit is contained in:
parent
9df0425c4c
commit
7ec78419ee
1 changed files with 7 additions and 3 deletions
|
@ -3,6 +3,8 @@
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import operator
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
URL = "https://theorangeone.net/index.json"
|
URL = "https://theorangeone.net/index.json"
|
||||||
|
|
||||||
|
@ -10,10 +12,12 @@ def main():
|
||||||
with urllib.request.urlopen(URL) as response:
|
with urllib.request.urlopen(URL) as response:
|
||||||
data = json.load(response)
|
data = json.load(response)
|
||||||
|
|
||||||
url_mapping = {
|
data = sorted(data, key=operator.itemgetter("date"), reverse=True)
|
||||||
d['title']: d['url']
|
|
||||||
|
url_mapping = OrderedDict([
|
||||||
|
(d['title'], d['url'])
|
||||||
for d in data
|
for d in data
|
||||||
}
|
])
|
||||||
|
|
||||||
selected_page = subprocess.check_output(["rofi", "-dmenu", "-i", "-format", "s", "-p", "Post"], input="\n".join(url_mapping.keys()), universal_newlines=True)
|
selected_page = subprocess.check_output(["rofi", "-dmenu", "-i", "-format", "s", "-p", "Post"], input="\n".join(url_mapping.keys()), universal_newlines=True)
|
||||||
selected_page = selected_page.strip()
|
selected_page = selected_page.strip()
|
||||||
|
|
Loading…
Reference in a new issue