def main(): html_dir = sys.argv[1] html_files = get_files(html_dir, ['*.html'], exclude_patterns=[output_name, '*_graphical.html', 'graphical_index.html']) img_html_files = {} for filename in os.listdir(html_dir): if filename in img_blacklist: continue if file_matches(filename, img_patterns): for html_file in html_files: if img_in_html(os.path.join(html_dir, html_file), filename): img_html_files[filename] = html_file # for now suppose one image per html with open(os.path.join(html_dir, output_name), 'w') as output: output.write(header1_tmpl.substitute(title="GRASS GIS %s Reference " "Manual: Manual gallery" % grass_version)) output.write(header_graphical_index_tmpl) output.write('<ul class="img-list">\n') for image, html_file in img_html_files.iteritems(): name = get_module_name(html_file) title = title_from_names(name, image) output.write( '<li>' '<a href="{html}" title="{title}">' '<img src="{img}">' '<span class="name">{name}</span>' '</a>' '</li>\n' .format(html=html_file, img=image, title=title, name=name)) output.write('</ul>') write_html_footer(output, "index.html", year)
def generate_page_for_category(short_family, module_family, imgs, year, skip_no_image=False): filename = module_family + "_graphical.html" output = open(filename + ".tmp", 'wb') output.write(header1_tmpl.substitute( title="GRASS GIS %s Reference " "Manual: Graphical index" % grass_version)) output.write(header_graphical_index_tmpl) if module_family.lower() not in ['general', 'miscellaneous', 'postscript']: if module_family == 'raster3d': # covert keyword to nice form module_family = '3D raster' output.write(modclass_intro_tmpl.substitute( modclass=module_family, modclass_lower=module_family.lower())) if module_family == 'wxGUI': output.write("<h3>wxGUI components:</h3>") elif module_family == 'guimodules': output.write("<h3>g.gui.* modules:</h3>") else: output.write("<h3>{} modules:</h3>".format(to_title(module_family))) output.write('<ul class="img-list">') #for all modules: for cmd in html_files(short_family, ignore_gui=False): basename = os.path.splitext(cmd)[0] desc = check_for_desc_override(basename) if desc is None: desc = get_desc(cmd) img = get_module_image(basename, imgs) img_class = 'linkimg' if skip_no_image and not img: continue elif not img: img = 'grass_logo.png' img_class = 'default-img' if basename.startswith('wxGUI'): basename = basename.replace('.', ' ') output.write( '<li>' '<a href="{html}">' '<img class="{img_class}" src="{img}">' '<span class="name">{name}</span> ' '<span class="desc">{desc}</span>' '</a>' '</li>' .format(html=cmd, img=img, name=basename, desc=desc, img_class=img_class)) output.write('</ul>') write_html_footer(output, "index.html", year) output.close() replace_file(filename)
def main(): html_dir = sys.argv[1] with open(os.path.join(html_dir, output_name), 'w') as output: output.write(header1_tmpl.substitute(title="GRASS GIS %s Reference " "Manual: Graphical index" % grass_version)) output.write(header_graphical_index_tmpl) output.write('<ul class="img-list">\n') for html_file, image, label in index_items: output.write( '<li>' '<a href="{html}">' '<img src="{img}">' '<span class="name">{name}</span>' '</a>' '</li>\n' .format(html=html_file, img=image, name=label)) output.write('</ul>') write_html_footer(output, "index.html", year)
def generate_page_for_category(short_family, module_family, imgs, year, skip_no_image=False): filename = module_family + "_graphical.html" output = open(filename + ".tmp", "w") output.write( header1_tmpl.substitute(title="GRASS GIS %s Reference " "Manual: Graphical index" % grass_version)) output.write(header_graphical_index_tmpl) if module_family.lower() not in ["general", "postscript"]: if module_family == "raster3d": # covert keyword to nice form module_family = "3D raster" output.write( modclass_intro_tmpl.substitute( modclass=module_family, modclass_lower=module_family.lower())) if module_family == "wxGUI": output.write("<h3>wxGUI components:</h3>") elif module_family == "guimodules": output.write("<h3>g.gui.* modules:</h3>") else: output.write("<h3>{0} modules:</h3>".format(to_title(module_family))) output.write('<ul class="img-list">') # for all modules: for cmd in html_files(short_family, ignore_gui=False): basename = os.path.splitext(cmd)[0] desc = check_for_desc_override(basename) if desc is None: desc = get_desc(cmd) img = get_module_image(basename, imgs) img_class = "linkimg" if skip_no_image and not img: continue elif not img: img = "grass_logo.png" img_class = "default-img" if basename.startswith("wxGUI"): basename = basename.replace(".", " ") output.write("<li>" '<a href="{html}">' '<img class="{img_class}" src="{img}">' '<span class="name">{name}</span> ' '<span class="desc">{desc}</span>' "</a>" "</li>".format(html=cmd, img=img, name=basename, desc=desc, img_class=img_class)) output.write("</ul>") write_html_footer(output, "index.html", year) output.close() replace_file(filename)