X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=biaweb_db.py;h=80e3915d2cea5366ac419336d4bc11a18d3e5cab;hp=dd3e333bdf6feea17979bb002d333331682852ed;hb=2687a3c3b18c3a267ca60ecdd3759ed0856471e0;hpb=c78ebaf4ae0e486c54907edf51159615f2b4f81e diff --git a/biaweb_db.py b/biaweb_db.py index dd3e333..80e3915 100644 --- a/biaweb_db.py +++ b/biaweb_db.py @@ -6,6 +6,19 @@ import os import os.path import time +# function to retrieve the templates from the database +def get_templates (dbname): + try: + conn = sqlite3.connect (dbname) + c = conn.cursor () + c.execute ("SELECT * FROM templates;") + conn.commit () + rows = c.fetchall () + conn.close () + return rows + except sqlite3.Error: + return False + # function to get an article from the database def get_article (dbname, artid): try: @@ -222,192 +235,192 @@ def create_db (dbname, site_title, site_url, keywords, description, copyright, templates (template_name TEXT, template_content);") template_main = """ - - - - ${site_title} - - - - - - - - - -
- ${contents_bit} -
- - - - """ + + + +${site_title} + + + + + + + + + +
+ ${contents_bit} +
+ + + +""" template_article_bit = """

${article_title}

-
Created: ${article_cdate} | Last modified: ${article_mdate}
-
Rating: ${rating}
-
${article_contents}
- """ +
Created: ${article_cdate} | Last modified: ${article_mdate}
+
Rating: ${rating}
+
${article_contents}
+""" template_news_item_bit = """

${news_title}

-
${news_datetime}
-
${news_description}
- """ +
${news_datetime}
+
${news_description}
+""" template_index_bit = """

Welcome to ${site_name}

-
- Welcome to my site, ${site_name}. -
-

Latest Articles

- ${news_updates} - """ +
+Welcome to my site, ${site_name}. +
+

Latest Articles

+${news_updates} +""" template_table_bit = """

${category_title}

-

${category_desc}

- - - - - - - - - - ${table_rows} - -
TitleCreated onRated
- """ +

${category_desc}

+ + + + + + + + + + ${table_rows} + +
TitleCreated onRated
+""" template_tablerow_bit = """ - ${title} - ${created} - ${rating} - - """ + ${title} + ${created} + ${rating} + +""" template_style = """body { - font-family: "Bitstream Vera Sans", Verdana, Arial, Sans Serif; - font-size: 0.9em; - background-color: #ffffff; - color: #000000; - margin: auto - } - #head { - width: 98%; - background-color: #efefef; - padding: 1%; - text-align: center; - } - - #main { - width: 73%; - padding: 1%; - float: left; - } - - #sidebar { - width: 23%; - padding: 1%; - float: right; - } - - #footer { - width: 100%; - padding-top: 5px; - padding-bottom: 5px; - font-size: 0.9em; - text-align: center; - float: left; - background-color: #efefef; - } - - .headerdesc { - font-variant: small-caps; - font-size: 1.1em; - } - - .content { - text-align: justify; - line-height: 1.1em; - } - - .categorytable { - width: 100%; - } - - .categorytable thead { - font-weight: bold; - } - - .modified { - font-size: 0.8em; - color: #666666; - } - - .rating { - font-size: 0.8em; - color: #666666; - } - - h1, h2, h3 { - font-family: "Bitstream Vera Serif", Serif; - padding: 0; - margin: 0; - margin-top: 5px; - margin-bottom: 5px; - } - - hr { - border: 0; - border-bottom: 1px solid; - border-color: #888888; - } - - h1 { - font-size: 2.4em; - color: #000099; - - } - h1 a, h1 a:hover, h1 a:visited, h2 a:active { - text-decoration: none; - } - h2 { - font-size: 1.4em; - background-color: #efefef; - } - h2 a, h2 a:hover, h2 a:visited, h2 a:active { - text-decoration: none; - } - h3 { - font-size: 1.2em; - a { - color: #0000dd; - } - a:visited { - color: #0000aa; - } - a:active, a:hover { - color: #0000ff; - }""" + font-family: "Bitstream Vera Sans", Verdana, Arial, Sans Serif; + font-size: 0.9em; + background-color: #ffffff; + color: #000000; + margin: auto +} +#head { + width: 98%; + background-color: #efefef; + padding: 1%; + text-align: center; +} + +#main { + width: 73%; + padding: 1%; + float: left; +} + +#sidebar { + width: 23%; + padding: 1%; + float: right; +} + +#footer { + width: 100%; + padding-top: 5px; + padding-bottom: 5px; + font-size: 0.9em; + text-align: center; + float: left; + background-color: #efefef; +} + +.headerdesc { + font-variant: small-caps; + font-size: 1.1em; +} + +.content { + text-align: justify; + line-height: 1.1em; +} + +.categorytable { + width: 100%; +} + +.categorytable thead { + font-weight: bold; +} + +.modified { + font-size: 0.8em; + color: #666666; +} + +.rating { + font-size: 0.8em; + color: #666666; +} + +h1, h2, h3 { + font-family: "Bitstream Vera Serif", Serif; + padding: 0; + margin: 0; + margin-top: 5px; + margin-bottom: 5px; +} + +hr { + border: 0; + border-bottom: 1px solid; + border-color: #888888; +} + +h1 { + font-size: 2.4em; + color: #000099; + +} +h1 a, h1 a:hover, h1 a:visited, h2 a:active { + text-decoration: none; +} +h2 { + font-size: 1.4em; + background-color: #efefef; +} +h2 a, h2 a:hover, h2 a:visited, h2 a:active { + text-decoration: none; +} +h3 { + font-size: 1.2em; +a { + color: #0000dd; +} +a:visited { + color: #0000aa; +} +a:active, a:hover { + color: #0000ff; +}""" c.executemany ("INSERT INTO templates (template_name, template_content) VALUES (?, ?);", [["main_template", template_main],