GNLT/gencode.py

18 lines
1.1 KiB
Python
Raw Normal View History

2022-09-23 14:58:23 +01:00
import pandas as pd
titleDF = pd.read_csv("title.csv")
linksDF = pd.read_csv("links.csv")
html = open("index.html", "w")
html.write("<!DOCTYPE html>\n<html lang='en'>\n<head>\n\t<title>Your Links</title>\n\t<meta charset='UTF-8'>\n\t<meta name='viewport' content='width=device-width, initial-scale=1'/>\n\t<link rel='stylesheet' href='styles.css'>\n</head>\n<body>\n")
html.write(f"<img src='{titleDF['logo'][0]}' class='top-logo'>\n\t<h2>{titleDF['description'][0]}</h2>\n<br>\n")
for i,x in linksDF.iterrows():
html.write(f"<div>\n<button class='menu' onclick='{x['name'].replace(' ','').lower()}.show()'><img src='{x['logo']}' class='small-logo'>&emsp; {x['name']}</button>\n\t</div>\n\t<br>\n")
html.write("\t<script src='script.js'></script>\n</body>\n</html>")
html.close()
script = open("script.js", "w")
2022-09-23 15:03:30 +01:00
script.write("class link{\n\tconstructor(url){\n\t\tthis.url= url;\n\t}\n\tshow(){\n\t\tvar win=window.open(this.url, '_blank');\n\t\twin.focus();\n\t}\n}\n")
2022-09-23 14:58:23 +01:00
for i,x in linksDF.iterrows():
script.write(f"var {x['name'].replace(' ','').lower()} = new link('{x['link']}')\n")
script.close()