From f8ed6e56c826c4fa868a61d2dc1c957ad29a550b Mon Sep 17 00:00:00 2001 From: BlenderDumbass Date: Fri, 6 Dec 2024 16:50:00 +0200 Subject: [PATCH] Setting up rows of tabs --- modules/Help.py | 3 ++- modules/Render.py | 6 +++++- modules/Set.py | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/Help.py b/modules/Help.py index d7d717a..f34e159 100644 --- a/modules/Help.py +++ b/modules/Help.py @@ -40,10 +40,11 @@ def Set(): print(clr["tdyl"]+"--favicon"+clr["norm"]+" - Set a favicon file.") print(clr["tdyl"]+"--add_tab"+clr["norm"]+" - Adds a category of articles.") print(clr["tdyl"]+"--edit_tab"+clr["norm"]+" - Edit the config of a category.") + print(clr["tdyl"]+"--tab_rows"+clr["norm"]+" - Set in how many rows to draw the tabs.") print() print(clr["tdyl"]+"--editor"+clr["norm"]+" - Set editor. Default nano.") print() - + def Accounts(): print() diff --git a/modules/Render.py b/modules/Render.py index 7c9cb79..b92255a 100644 --- a/modules/Render.py +++ b/modules/Render.py @@ -334,6 +334,7 @@ def MainPage(server): # Reading config config = Set.Load() + tab_rows = config.get("tab_rows", 1) # Generating html = head(title = config.get("title", "Website"), @@ -374,12 +375,15 @@ def MainPage(server): """ Tabs = tabs() - for tab in Tabs: + for n, tab in enumerate(Tabs): html = html + Button(Tabs[tab].get("title", tab), "/"+tab, Tabs[tab].get("icon", "folder")) + if n % int(len(Tabs) / tab_rows) == 0 and n: + html = html + "
" + html = html + "" # Trending articles diff --git a/modules/Set.py b/modules/Set.py index 77d1df4..2c114ab 100644 --- a/modules/Set.py +++ b/modules/Set.py @@ -140,6 +140,15 @@ def Set(): print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Tab Name Wasn't Specified!") print('Use: $ python3 run.py --set --edit_tab "Articles"') + if "--tab_rows" in sys.argv: + try: + tab_rows = int(sys.argv[ sys.argv.index("--tab_rows") + 1]) + TabRows(tab_rows) + + except Exception as e: + print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Number Wasn't Specified Correctly!") + print('Use: $ python3 run.py --set --tab_rows 2') + if "--css" in sys.argv: try: filename = sys.argv[ sys.argv.index("--css") + 1] @@ -313,3 +322,13 @@ def Email(): Save(config) print("Email credentials saved!") + +def TabRows(tab_rows): + + data = Load() + data["tab_rows"] = tab_rows + + Save(data) + + print(clr["bold"]+clr["tbyl"]+str(tab_rows)+clr["norm"]+" is set as amount of rows to render tabs.") +