Setting up rows of tabs
This commit is contained in:
parent
c3eb4964eb
commit
f8ed6e56c8
3 changed files with 26 additions and 2 deletions
|
@ -40,6 +40,7 @@ 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()
|
||||
|
|
|
@ -334,6 +334,7 @@ def MainPage(server):
|
|||
|
||||
# Reading config
|
||||
config = Set.Load()
|
||||
tab_rows = config.get("tab_rows", 1)
|
||||
|
||||
# Generating <head>
|
||||
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 + "<br>"
|
||||
|
||||
html = html + "</center>"
|
||||
|
||||
# Trending articles
|
||||
|
|
|
@ -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.")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue