def do_login(): """Returns login page/index content.""" return_data = '' top = '''<html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tasti</title> <link rel="stylesheet" type="text/css" href="main.css" /> </head> <body><div id="wrapper"> <div id="header">''' return_data += top return_data += header0() return_data += '''</div> <div id="faux"> <div id="leftcolumn">''' return_data += login() return_data += '''<div class="clear"></div> </div> <div id="rightcolumn"> ''' return_data += list_tags() return_data += '''<div class="clear"></div> </div> </div> <div id="footer">''' return_data += footer() bottom = '''</div> </div> </body> </html>''' return_data += bottom return return_data
def do_register(): """Returns registration page/index content.""" return_data = '' top = '''<html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tasti</title> <link rel="stylesheet" type="text/css" href="main.css" /> <link rel="stylesheet" type="text/css" href="jquery.validity.css" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.validity.js"></script> <script type="text/javascript"> $(function() {{ $("form").validity(function() {{ $("#username") .minLength(5, "Must be at least 5 characters") ; $("#password0") .minLength(6, "Must be at least 6 characters") ; $("#password1") .minLength(6, "Must be at least 6 characters") ; $("#email") .match("email","Requires an email address") .minLength(5, "Must be at least 5 characters"); }}); }}); </script> </head> <body><div id="wrapper"> <div id="header">''' return_data += top return_data += header0() return_data += '''</div> <div id="faux"> <div id="leftcolumn">''' return_data += register() return_data += '''<div class="clear"></div> </div> <div id="rightcolumn"> ''' return_data += list_tags() return_data += '''<div class="clear"></div> </div> </div> <div id="footer">''' return_data += footer() bottom = '''</div> </div> </body> </html>''' return_data += bottom return return_data
def get_edit_tags(): """Returns edit tags page/index content.""" return_data = '' top = '''<html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tasti</title> <link rel="stylesheet" type="text/css" href="main.css" />''' top += '''<script type="text/javascript"> function toggle(aId) { var collection = document.getElementById(aId).getElementsByTagName("input"); for (var x=0; x<collection.length; x++) { if (collection[x].type.toLowerCase() == "checkbox") { if (collection[x].checked) { collection[x].checked = false; } else {collection[x].checked = true} } } } </script> </head> <body><div id="wrapper"><div id="header">''' return_data += top return_data += header0() return_data += '''</div> <div id="faux"> <div id="leftcolumn">''' return_data += account_mgmt() return_data += '''<div class="clear"></div> </div> <div id="rightcolumn"> ''' return_data += list_tags() return_data += '''<div class="clear"></div> </div> </div> <div id="footer">''' return_data += footer() bottom = '''</div> </div> </body> </html>''' return_data += bottom return return_data
dbfile = sys.argv[1] conn = sqlite3.connect(dbfile) dbcursor = conn.cursor() subprocess.run(['mkdir', '-p', 'cats']) sql = ''' select distinct category from apis ''' dbcursor.execute(sql) cats = dbcursor.fetchall() for [cat] in cats: relpath = "../" with open('cats/{}.html'.format(cat), 'w') as f: f.write(index.header(relpath=relpath)) f.write('<h1>{}</h1>'.format(cat)) f.write('<h3>Last updated {}.</h3>'.format(datetime.date.today())) f.write(index.legend()) f.write(index.chart(dbcursor, cat=cat, relpath=relpath)) f.write(index.footer()) conn.close()