def genPage(content_obj, folder_obj, forFolder): forget_dict = { 'content_str': content_obj.get_content_str(folder_obj), 'title_img': folder_obj.sTitleImg, 'NavBar': genNavBar(content_obj, folder_obj.iFolderTotal, forFolder), } page_str = forget.form('template.html', forget_dict) return page_str
def genItemRSS(content_obj): forget_dict = {} forget_dict['url'] = str(content_obj.iSiteNumber) + '.html' forget_dict['title'] = content_obj.sTitle t = time.strptime(content_obj.dtCreated, '%Y-%m-%d %H:%M:%S') nowtimestamp = time.mktime(t) forget_dict['date'] = utils.formatdate(nowtimestamp) desc = content_obj.sToolText if desc: forget_dict['desc'] = desc item_str = forget.form('item.rss', forget_dict) return item_str
def genNavBar(content_obj, total_pages, forFolder): if forFolder: index = content_obj.iFolderNumber else: index = content_obj.iSiteNumber prev = index - 1 if prev < 1: prev = 1 nextp = index + 1 if nextp > total_pages: nextp = total_pages navbar_dict = {'next': nextp, 'prev': prev} navbar_str = forget.form('navbar.html', navbar_dict) return navbar_str
#import statements import forget import tagg #-------------------- #usercode goes here: #e.g. my_dict = {'color': 'blue'} t_str = forget.form('test_form', my_dict) t = tagg.Tagg(t_str) t_str = t.t_str #export data: from pathlib import Path root_folder = Path.cwd().parent output_file = 'test' output_file = root_folder / 'output' / output_file with open(output_file, 'w') as fout: fout.write(t_str)
def genArchivePage(link_list_str, sTitleImg): forget_dict = {'link_list': link_list_str, 'title_img': sTitleImg} page_str = forget.form('archive.html', forget_dict) return page_str
def genArchiveLink(date, title, number): forget_dict = {'date': date, 'title': title, 'number': number} link_str = forget.form('archive_link.html', forget_dict) return link_str
def genRandomPage(total_pages): forget_dict = {'rand_max': total_pages} page_str = forget.form('random.html', forget_dict) return page_str
import forget import datetime import time from email import utils from setup import Setup from get_data_fns import * from page_gen_fns import * cur = Setup.cur dest_folder = Setup.dest_folder folder_dict = {} getFolderData('SELECT * FROM tblFolders',cur,folder_dict, {}) sql_str = 'SELECT * FROM tblContent ORDER BY iSiteNumber DESC LIMIT 5' content_list = getContentData(sql_str,cur) item_str = '' for content_obj in content_list: item_str += genItemRSS(content_obj) + '\n' rss_page = forget.form('WLT.rss',{'item_list': item_str}) filename = 'WLT.rss' writePage(dest_folder, filename, rss_page)