1
0
Fork 0
mirror of https://codeberg.org/Reuh/feather.git synced 2025-10-27 10:09:32 +00:00

fix: properly keep category order

This commit is contained in:
Étienne Fildadut 2025-10-10 16:57:34 +02:00
parent b100d8f0b8
commit 2557db7502
2 changed files with 12 additions and 6 deletions

View file

@ -1,4 +1,6 @@
[server]
# Server API to use. Either "googlereader" for the Google Reader API (FreshRSS, Miniflux, etc.) or "ttrss" for the TinyTiny-RSS API.
# The Google Reader API do not support nested categories.
api = "googlereader"
# (Required) URL of your server's Google Reader API endpoint
# Can be set through the environment variable SERVER_URL.
@ -10,7 +12,8 @@ user = "username"
# Can be set through the environment variable SERVER_PASSWORD.
password = "password"
# How many items to retrieve at most from the server in a single request. Lower values will make synchronization slower, higher values might make the server complain.
# Most servers are supposedly okay with up to 1000, but tt-rss complained so I dropped it to 500 here.
# If you are using the Google Reader API: servers should be okay with up to 1000.
# If you are using the ttrss API: servers should be okay with up to 200.
# Can be set through the environment variable SERVER_ITEMS_PER_REQUEST.
items_per_request = 500
@ -66,7 +69,9 @@ template = '''
# Filename template for generated HTML files.
# Can be set through the environment variable HTML_FILENAME_TEMPLATE.
filename_template = "[{{ feed_title }}]\t{{ title }} ({{ published_formatted }}).html"
category_template = "{{ title }}"
# Category directory name template for generated HTML files.
# Can be set through the environment variable HTML_CATEGORY_TEMPLATE.
category_template = "{% if order %}{{ '%02d' % order }} {% endif %}{{ title }}"
# Maximum allowed filename length (in bytes assuming UTF-8 encoding) before truncating. Depending on your filesystem filename's limits it may be possible to increase the value, ask Wikipedia for details.
# Can be set through the environment variable HTML_MAX_FILENAME_LENGTH.
max_filename_length = 250

View file

@ -235,20 +235,21 @@ class TRRSession(ClientSession):
self.feeds = {}
def get_categories_recursive(parent_category, parent_categories=[]):
categories = []
for i in range(len(parent_category["items"])):
item = parent_category["items"][i]
index = 0
for item in parent_category["items"]:
# skip special categories and feeds
if item["bare_id"] <= 0:
continue
# category
elif item.get("type") == "category":
category = Category(id=item["bare_id"], parents=parent_categories, title=item["name"], order=i)
category = Category(id=item["bare_id"], parents=parent_categories, title=item["name"], order=index)
categories.append(category)
categories += get_categories_recursive(item, parent_categories+[category])
# feeds
elif "type" not in item:
self.feeds[item["bare_id"]] = item
self.feeds[item["bare_id"]]["order"] = i
self.feeds[item["bare_id"]]["order"] = index
index += 1
return categories
tree = self.ttrss.get_feed_tree()
return get_categories_recursive(tree["categories"])