Setting up rows of tabs

This commit is contained in:
BlenderDumbass 2024-12-06 16:50:00 +02:00
parent c3eb4964eb
commit f8ed6e56c8
3 changed files with 26 additions and 2 deletions

View file

@ -40,6 +40,7 @@ def Set():
print(clr["tdyl"]+"--favicon"+clr["norm"]+" - Set a favicon file.") 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"]+"--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"]+"--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()
print(clr["tdyl"]+"--editor"+clr["norm"]+" - Set editor. Default nano.") print(clr["tdyl"]+"--editor"+clr["norm"]+" - Set editor. Default nano.")
print() print()

View file

@ -334,6 +334,7 @@ def MainPage(server):
# Reading config # Reading config
config = Set.Load() config = Set.Load()
tab_rows = config.get("tab_rows", 1)
# Generating <head> # Generating <head>
html = head(title = config.get("title", "Website"), html = head(title = config.get("title", "Website"),
@ -374,12 +375,15 @@ def MainPage(server):
""" """
Tabs = tabs() Tabs = tabs()
for tab in Tabs: for n, tab in enumerate(Tabs):
html = html + Button(Tabs[tab].get("title", tab), html = html + Button(Tabs[tab].get("title", tab),
"/"+tab, "/"+tab,
Tabs[tab].get("icon", "folder")) Tabs[tab].get("icon", "folder"))
if n % int(len(Tabs) / tab_rows) == 0 and n:
html = html + "<br>"
html = html + "</center>" html = html + "</center>"
# Trending articles # Trending articles

View file

@ -140,6 +140,15 @@ def Set():
print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Tab Name Wasn't Specified!") print(clr["bold"]+clr["tdrd"]+"Error:"+clr["norm"]+" Tab Name Wasn't Specified!")
print('Use: $ python3 run.py --set --edit_tab "Articles"') 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: if "--css" in sys.argv:
try: try:
filename = sys.argv[ sys.argv.index("--css") + 1] filename = sys.argv[ sys.argv.index("--css") + 1]
@ -313,3 +322,13 @@ def Email():
Save(config) Save(config)
print("Email credentials saved!") 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.")