#!/usr/bin/env python3 import sys import sqlite3 import time i_file_name = 0 i_menu_title = 1 i_menu_pos = 2 i_menu_level = 3 i_page_title = 4 i_pic1 = 5 i_pic2 = 6 i_pic3 = 7 i_body = 8 print(""" pigpio library """) page = sys.argv[1] menuH = "" menuV = "" sitemap = "" header = 'pigpio library' footer1 = "© 2012-2020"; footer2 = "e-mail: pigpio @ abyz.me.uk"; footer3 = "Updated: " + time.strftime("%d/%m/%Y") + ""; db=sqlite3.connect("dbase/pigpio.sqlite") c=db.cursor() def menu_titles(): global menuV, menuH c.execute( "SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos") recs = c.fetchall() menuV = "" menuH = "" for r in recs: if r[2] == 1: menuV += '' + r[1] + '\n' menuH += '[' + r[1] + ']\n' def sitemap(): c.execute( "SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos") recs = c.fetchall() stemap = "" for r in recs: if r[2] > 0: s = "----" * (r[2]-1) stemap += s + '' + r[1] + '
\n' return stemap def check_image(d): img = "images/" + d try: with open("HTML/" + img) as f: print('') except: pass titles = menu_titles() s_sidebar = 'style="background:#EAF2E6 url(\'images/sidebar.gif\') repeat-y; width:35px; height:100%"' s_header = 'style="background:url(\'images/topbar.gif\') repeat-x; height: 70px; font-size:1.5em; vertical-align: top;"' s_menuV = 'style="vertical-align: top; background-color: #98bf21;"' c.execute("SELECT * FROM pigpio WHERE file_name=?", (page,)) rec = c.fetchone() if page == "sitemap": body = sitemap() else: body = rec[i_body] c.close() db.close() print('') print('') print('') print('
') print('') print('
' + header + '
') print('
') print('
') check_image(rec[i_pic1]) check_image(rec[i_pic2]) check_image(rec[i_pic3]) print('
') print("") print('') print('') print('
' + menuV + '

' + rec[i_page_title] + '

' + body + '
') print('
' + menuH + '
') print('') print('') print('') print('') print('
' + footer1 + '
' + footer2 + '
' + footer3 + '
') print('
') print('\n')