Commits

Anonymous committed df07850

use external stylesheet, export to html

Comments (0)

Files changed (1)

 from gimpfu import *
-from random import *
+from string import Template
 import gtk
 import os
 import collections
 import ctypes
 import unicodedata
 import re
+import pprint
 
-PROC_CSS = "body{width=100%;}\n"
-PROC_TEMPLATE = ""
+PROC_CSS = """html, body
+{
+        width:100%;
+        height:100%;
+        margin:0px;
+}
+
+body
+{
+        width:578px;
+        margin:0px auto 0px 36px;
+}
+
+p, table
+{
+        margin:0px 0px 0px 12px;
+}
+
+nav
+{
+        display:block;
+        margin-bottom:6px;
+        text-align:center;
+}
+
+h1, h4
+{
+        margin-bottom:0px;
+}
+
+div#author
+{
+        text-align:right;
+        font-style:italic;
+}
+
+span.date
+{
+        font:bold 14px Monospace,small-caps;
+}
+
+table
+{
+        font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;
+        width:100%;
+        border-collapse:collapse;
+}
+
+table td, table th 
+{
+        font-size:1em;
+        border:1px solid SlateGray;
+        padding:3px 7px 2px 7px;
+}
+
+table th
+{
+        font-size:1.1em;
+        text-align:left;
+        padding-top:5px;
+        padding-bottom:4px;
+        background-color:LightSlateGray;
+        color:#ffffff;
+}
+
+table tr.alt td 
+{
+        color:#000000;
+        background-color:#C9CFD6;
+}
+"""
+PROC_HTML = """<!DOCTYPE html>
+<html>
+        <head>
+                <title>pdb: ${proc_name}</title>
+
+                <meta name="description" content="${proc_blurb}">
+                <meta name="author" content="Code Fox">
+                <meta charset="UTF-8">
+
+                <link rel="stylesheet" type="text/css" href="proc.css">
+        </head>
+        <body>
+                <div style="display:inline-block;">
+                        <h1>
+                                ${proc_name}
+                        </h1>
+                        <div id="author">
+                                ${proc_author}
+                        </div>
+                </div>
+                <hr style="margin-bottom:0px;"/>
+                <nav>
+                        <a href="${prev_link}" style="float:left;">previous</a>
+                        <a href="${index_link}">index</a>
+                        <a href="${next_link}" style="float:right;">next</a>
+                </nav>
+                <p id="copyright" style="margin:0">
+                        <span class="date">${proc_date}</span><br>
+                        ${proc_copyright}
+                </p>
+                <h4>Description</h4>
+                <p id="description">
+                        ${proc_blurb}
+                </p>
+                <h4>Help</h4>
+                <p id="help">
+                        ${proc_help}
+                </p>
+                <hr />
+                <h4>Type</h4>
+                <p id="type">
+                        ${proc_type}
+                </p>
+                <h4>Parameters</h4>
+                <table id="parameters">
+                        <thead>
+                                <tr>
+                                        <th>Type</th>
+                                        <th>Name</th>
+                                        <th>Description</th>
+                                </tr>
+                        </thead>
+                        <tbody>
+                                ${parameters}
+                        </tbody>
+                </table>
+                <h4>Return</h4>
+                <table id="return">
+                        <thead>
+                                <tr>
+                                        <th>type</th>
+                                        <th>name</th>
+                                        <th>description</th>
+                                </tr>
+                        </thead>
+                        <tbody>
+                                ${results}
+                        </tbody>
+                </table>
+                <hr style="margin-bottom:0px;" />
+                <nav>
+                        <a href="${index_link}" style="width:100%; text-align:center;">index</a>
+                </nav>
+        </body>
+</html>
+"""
 INDEX_TEMPLATE = ""
 
 def slugify(value):
 
 def dump_proc(proc, outFile, mode) :
 
+        from gimpfu import *
+
+        d = dict()
+        d["proc_name"] = proc.proc_name
+        d["proc_author"] = proc.proc_author
+        d["proc_date"] = proc.proc_date
+        d["proc_copyright"] = proc.proc_copyright
+        d["proc_blurb"] = proc.proc_blurb
+        d["proc_help"] = proc.proc_help
+
+        d["proc_type"] = "unknown"
+        if (PLUGIN == proc.proc_type) :
+                d["proc_type"] = "PROC_PLUG_IN"
+        elif (EXTENSION == proc.proc_type) :
+                d["proc_type"] = "PROC_EXTENSION"
+        elif (TEMPORARY == proc.proc_type) :
+                d["proc_type"] = "PROC_TEMPORARY"
+
         with open(outFile, mode) as f :
-                f.write("author:\n%s\n"%proc.proc_author)
-                f.write("date:\n%s\n"%proc.proc_date)
-                f.write("cpy:\n%s\n"%proc.proc_copyright)
-                f.write("blurb:\n%s\n"%proc.proc_blurb)
-                f.write("help:\n%s\n"%proc.proc_help)
+                f.write(Template(PROC_HTML).safe_substitute(d))
 
         return None
 
                 )
 
                 dump_proc(pdb[name], outFile, 'w+')
+                break
 
         # write index file