#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os, optparse, codecs basic = u""" qx.log.Logger.ROOT_LOGGER.removeAllAppenders(); qx.log.Logger.ROOT_LOGGER.addAppender(new qx.log.DivAppender("demoDebug")); document.write('
qooxdoo: The new era of web development
'); document.write('
'); document.write('[Global Pollution]  '); document.write('[Object Summary]  '); document.write('
'); document.write('
'); document.write('
 
'); (function(sitemap) { document.write(''); document.write('
'); if (index > 0) { document.write(""); } if (index < pages.length-1) { document.write(""); } document.write('
'); })(%s); (function() { var url = location.href; var pos = url.indexOf("/html/")+6; var split = url.substring(pos).split("/"); var category = split[0]; category = category.charAt(0).toUpperCase() + category.substring(1); var pagename = split[1].replace(".html", "").replace(/_/g, " "); pagename = pagename.charAt(0).toUpperCase() + pagename.substring(1); document.title = "qooxdoo » Demo » Sample » " + category + " » " + pagename; if (window.location.href.indexOf("demo.qooxdoo.org") != -1) { document.write(''); document.write(''); document.write(''); document.write(''); } })(); """ def main(dist, scan): res = "" res += "{" firstCategory = True # for category in os.listdir(scan): for category in [ "example", "test", "performance" ]: if category == ".svn": continue if not firstCategory: res += "," res += category + ":[" firstItem = True for item in os.listdir(os.path.join(scan, category)): if item == ".svn": continue if os.path.splitext(item)[1] != ".html": continue if item == "index.html": continue if not firstItem: res += "," res += '"%s"' % item firstItem = False res += "]" firstCategory = False res += "}" distdir = os.path.dirname(dist) if not os.path.exists(distdir): os.makedirs(distdir) content = basic % res outputFile = codecs.open(dist, encoding="utf-8", mode="w", errors="replace") outputFile.write(content) outputFile.flush() outputFile.close() if __name__ == '__main__': try: parser = optparse.OptionParser() (options, args) = parser.parse_args() dist = args[0] scan = args[1] main(dist, scan) except KeyboardInterrupt: print print " * Keyboard Interrupt" sys.exit(1)