Browse Source

Added a simple html templating system + removed old files

master
Bofh 10 months ago
parent
commit
da564cc43f
  1. BIN
      files/dummyvideo.mp4
  2. 6
      igmirror.py
  3. 77
      server.py
  4. 74
      templates/mirrors.html

BIN
files/dummyvideo.mp4

Binary file not shown.

6
igmirror.py

@ -589,6 +589,12 @@ def db_set(table, acc_id, accdata):
def db_get(table, acc_id):
return json.loads(readf('./db/{}/{}'.format(table, acc_id)))
def template(name):
tplfile = './templates/{}.html'.format(name)
if not os.path.exists(tplfile):
return False
return readf(tplfile)
def config():
global CONFIG
if len(CONFIG.keys()) == 0:

77
server.py

@ -29,82 +29,7 @@ class MyServer(BaseHTTPRequestHandler):
# lists accounts on a pretty HTML + CSS
# making sure there is no XSS possible on account names
elif action == 'mirrors':
html = """<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{instance} - Mirrors</title>
</head>
<body>
<style type="text/css">
body {
font-family: Arial;
}
div#content {
max-width: 40em;
margin: auto;
}
div#content > div:nth-child(1) {
display: flex;
margin: 2em 1em;
border-bottom: 3px solid #dbdbdb;
padding-bottom: 2em;
}
div#content > div:nth-child(1) > h3 {
margin: 0;
width: 100%;
}
div#content > div:nth-child(1) > span {
min-width: 6em;
}
div.item {
padding: 1em;
box-shadow: 0px 2px .2em #acacac;
margin-bottom: 1em;
}
div.item > h3.name {
font-weight: initial;
}
div.item > div.links {
display: flex;
height: 2.5em;
margin-top: 2em;
}
div.item > div.links > div {
display: flex;
width: 100%;
}
div.item > div.links > div > a {
margin: auto;
text-decoration: none;
}
div.item > div.links > div:nth-child(1) {
background: #ffdade;
}
div.item > div.links > div:nth-child(1) > a {
font-weight: bold;
color: #ce0680;
}
div.item > div.links > div:nth-child(2) {
background: #f2f2f2;
}
div.item > div.links > div:nth-child(2) > a {
color: #367280;
font-style: italic;
}
</style>
<div id="content">
<div>
<h3>{instance}</h3>
<span>{item_count} accounts</span>
</div>
{mirrors}
</div>
</body>
</html>
"""
html = igmirror.pixelfed_htmlfill_mirrors(html)
html = igmirror.pixelfed_htmlfill_mirrors( igmirror.template('mirrors') )
echo(self, html)
return

74
templates/mirrors.html

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{instance} - Mirrors</title>
</head>
<body>
<style type="text/css">
body {
font-family: Arial;
}
div#content {
max-width: 40em;
margin: auto;
}
div#content > div:nth-child(1) {
display: flex;
margin: 2em 1em;
border-bottom: 3px solid #dbdbdb;
padding-bottom: 2em;
}
div#content > div:nth-child(1) > h3 {
margin: 0;
width: 100%;
}
div#content > div:nth-child(1) > span {
min-width: 6em;
}
div.item {
padding: 1em;
box-shadow: 0px 2px .2em #acacac;
margin-bottom: 1em;
}
div.item > h3.name {
font-weight: initial;
}
div.item > div.links {
display: flex;
height: 2.5em;
margin-top: 2em;
}
div.item > div.links > div {
display: flex;
width: 100%;
}
div.item > div.links > div > a {
margin: auto;
text-decoration: none;
}
div.item > div.links > div:nth-child(1) {
background: #ffdade;
}
div.item > div.links > div:nth-child(1) > a {
font-weight: bold;
color: #ce0680;
}
div.item > div.links > div:nth-child(2) {
background: #f2f2f2;
}
div.item > div.links > div:nth-child(2) > a {
color: #367280;
font-style: italic;
}
</style>
<div id="content">
<div>
<h3>{instance}</h3>
<span>{item_count} accounts</span>
</div>
{mirrors}
</div>
</body>
</html>
Loading…
Cancel
Save