def write_page(items, itempath, f, tmpImgDir): mapDict = ryw_philips.get_map(tmpImgDir) if mapDict == None: # raise('write_page: failed to get map.') pass f.write(ryw_view.begin_print_str()) f.write(ryw_view.begin_print_str2()) tempList = [] for item in items: make_DVDobject_list(item, itempath, tempList) if len(tempList) != 0 and mapDict == None: raise('write_page: unexpected empty map dict.') tempList.sort(key = temp_list_key, reverse = True) for listItem in tempList: meta,item,thisItemPath = listItem str = show_DVDobject_compact(meta, item, thisItemPath, mapDict) f.write(str.replace('SRC="/icons','SRC="./icons')) f.write(ryw_view.end_print_str())
def generate_html(items,itempath, repDir, tmpImgDir): ryw.give_news2('generating static html pages... ', logging.info) htmlDir = os.path.join(repDir, "html") if not ryw.try_mkdir(htmlDir, 'addRobotWriteRequest:generate_html'): return False try: f = open(os.path.join(htmlDir,"index.html"),"w") f.write(""" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Objects on this disk</title> """) f.write(ryw_view.css_str()) f.write(""" </head> <body> """) f.write(ryw_view.logo_str_for_disc()) f.write(""" <h3>Objects on Disk</h3><p>(you are on this page either because you are browsing the disc directly or were directed to it due to an error while merging it.) <BR> """) write_page(items,itempath,f, tmpImgDir) f.write(ryw_view.end_print_str()) f.write(ryw_view.footer2_str()) f.write(""" </body> </html> """) f.close() srcIconsDir = os.path.join(RepositoryRoot, "WWW", "icons") dstIconsDir = os.path.join(htmlDir, "icons") su.copytree(srcIconsDir, dstIconsDir) parentDir, repdirname = os.path.split(repDir) f = open(os.path.join(parentDir,"index.html"), "w") f.write(""" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title> Repository folders on this disk </title> <meta http-equiv="refresh" content="1;URL=.\%s\html\index.html"> </head> <body> loading page containing list of things on this disk.... </body> </html> """ % (repdirname,)) f.close() except: ryw.give_bad_news('addRobotWriteRequest: generate_html files: failed to write file: ',logging.critical) return False ryw.give_news2('done. ', logging.info) ryw.give_news2('<BR>', logging.info) return True