[Skencil-commits] r665 - in website/trunk: . pages pages/faq

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Apr 11 16:00:50 CEST 2006


Author: torsten
Date: 2006-04-11 16:00:50 +0200 (Tue, 11 Apr 2006)
New Revision: 665

Added:
   website/trunk/pages/faq/textformatter.pyc
   website/trunk/pages/template.xhtml
   website/trunk/updatepages.py
Removed:
   website/trunk/template.xhtml
Log:
Added first version of the new updatepages.py script. It is now
adopted to the new repository layout and should be much more
userfriendly.


Added: website/trunk/pages/faq/textformatter.pyc
===================================================================
(Binary files differ)


Property changes on: website/trunk/pages/faq/textformatter.pyc
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: website/trunk/pages/template.xhtml (from rev 664, website/trunk/template.xhtml)

Deleted: website/trunk/template.xhtml
===================================================================
--- website/trunk/template.xhtml	2006-04-11 10:32:09 UTC (rev 664)
+++ website/trunk/template.xhtml	2006-04-11 14:00:50 UTC (rev 665)
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<!--fileinfo-->
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title><!--title--></title>
- <link rel="stylesheet" href="skencil.css" type="text/css" />
- <meta name="description" content="Skencil, an interactive drawing program based on Python" />
- <meta name="keywords" content="skencil, graphics, python, drawing, linux, sketch, program, vector graphics, postscript, home page" />
-</head>
-
-<body>
-<table border="0" cellspacing="0" width="100%" id="maintable">
-<tr>
- <td id="lefttitle" class="title">
-  <a href="index.html"><img src="images/skencil-logo.png" alt="Skencil logo" /></a>
- </td>
-
- <td id="righttitle" class="title" colspan="2">
-  <h1><!--title--></h1>
- </td>
-</tr>
-
-<tr>
- <td id="menu" valign="top">
-  <a href="index.html">Home</a><br />
-  <a href="news.html">News</a><br />
-  <a href="download.html">Download</a><br />
-  <span><a href="scripts.html">Python Scripts</a><br /></span>
-  <span><a href="addon.html">Add-Ons</a><br /></span>
-  <span><a href="relnotes.html">Release Notes</a><br /></span>
-  <a href="features.html">Features</a><br />
-  <span><a href="screenshots.html">Screenshots</a><br /></span>
-  <span><a href="platforms.html">Portability</a><br /></span>
-  <a href="doc.html">Documentation</a><br />
-  <span><a href="faq.html">FAQ</a><br /></span>
-  <a href="devel.html">Development</a><br />
-  <span><a href="bugs.html">Bugs/Patches</a><br /></span>
-  <span><a href="devnotes.html">Dev. Rel. Notes</a><br /></span>
-  <a href="gallery.html">Gallery</a><br />
-  <a href="mailinglists.html">Mailing Lists</a><br />
-  <a href="payments.html">Paying</a><br />
-  <a href="links.html">Links</a>
- </td>
-
- <td id="main" colspan="2">
-<!--body text-->
- </td>
-</tr>
-
-<tr>
- <td> </td>
-
- <td id="leftfooter" class="footer">
-  <span class="lastmodified">Last updated <!--last updated-->
-  &nbsp;&middot;&nbsp;
-  Webpage Design: Joonas Paalasmaa
-  &nbsp;&middot;&nbsp;
-  Logo: Taiabati <!-- Claudio Bettio -->
-  </span>
- </td>
- <td id="rightfooter" class="footer">
-  <a href="http://www.python.org/">
-   <img src="images/PythonPowered.png" alt="Python Powered" />
-  </a>
- </td>
-</tr>
-</table>
-</body>
-</html>

Added: website/trunk/updatepages.py
===================================================================
--- website/trunk/updatepages.py	2006-04-11 10:32:09 UTC (rev 664)
+++ website/trunk/updatepages.py	2006-04-11 14:00:50 UTC (rev 665)
@@ -0,0 +1,272 @@
+#!/usr/bin/env python
+
+# updatepages.py - Simple web site templating system
+# Copyright (C) 2004  Joonas Paalasmaa
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+#"""Format webpages from templates.
+
+#Update a file only if it does not exist or when the sources are newer.
+#You can also use "-f" or "--force" which does what you think it does.
+#"""
+
+
+"""\n
+Generate Skencil website from templates into a given directory. If no
+directory is set, a directory "skencil-webiste" will be created in 
+this directory.
+
+On default only changed sites will be generated but you can force to 
+generate all pages by providing -f option. 
+
+Usage: updatepages.py [Option] target
+
+Possible targets are 
+
+    all - generate all
+    pages - generate website and images
+    gallery - generate the gallery
+    screenshots - generate screenshots
+	
+Options:
+    -h / --help     Print this message and exit.
+
+    -f force generation of all pages 
+        
+    -d dir
+    --dest-dir=dir
+       skencil website will be generated in this directory 
+
+    --gen-gallery
+       you may want to generate the gallery files. 
+
+    --gen-screenshots
+       you may want to generate the screenshot files.
+
+"""
+
+__version__="$Revison:$"[9:-1]
+
+
+import glob, os, time, string, getopt, sys, shutil, re
+
+templatefile = "pages/template.xhtml"
+template = file(templatefile).read()
+includeformat = "<!--%s-->"
+destdir = "skencil-website"
+
+globaldata = {
+"fileinfo":
+    "<!-- This file was generated by updatepages.py. Please don't modify. -->",
+"download root":
+    "http://wald.intevation.de/projects/skecil"}
+
+def main():
+    global destdir
+
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "fd:",
+        ["force","dest-dir","gen-screenshots","gen-gallery"])
+    except getopt.GetoptError:
+        sys.exit(2)
+    
+    if len (args) < 1:
+        usage(1)
+        
+    force = False
+    gen_gallery = False
+    gen_screenshots = False
+    
+    for o, a in opts:
+        if o in ("-f", "--force"):
+            force = True
+        if o in ("-d", "--dest-dir"):
+            destdir = a
+        if o == "--gen-gallery":
+            gen_gallery = True
+        if o == "--gen-screenshots":
+            gen_screenshots = True
+    doit(force,gen_gallery,gen_screenshots,args)
+
+
+def usage(code, msg=''):
+    print >> sys.stderr, __doc__
+    if msg:
+        print >> sys.stderr, msg
+    sys.exit(code)
+
+def newer(filename1, filename2):
+    """Check if filename1 was modified after filename2."""
+    if not os.path.isfile(filename2):
+        return True
+    return ( os.path.getmtime(filename1) > os.path.getmtime(filename2) )
+
+def parseheader(header):
+    d = {}
+    for line in header.split("\n"):
+        name, value = line.split(": ")
+        d[name] = value
+        
+    return d
+        
+def doit(force=False,gen_gallery=False,gen_screenshots=False,args=[]):
+    
+    print "\n"
+    print "###########################################"
+    print "# Generation                              #"
+    print "###########################################\n"
+    print "Webpages will be generated now.\n"
+    
+    genpages_flag = False
+    genscreens_flag = False
+    gengallery_flag = False
+
+    for target in args:
+        if target == "all":
+            genpages_flag = True
+            genscreens_flag = True
+            gengallery_flag= True
+        if target == "pages":
+            genpages_flag = True
+        if target == "screenshots":
+            genscreens_flag = True
+        if target == "gallery":
+            gengallery_flag = True
+
+    #generate pages
+    if genpages_flag:
+        print("Generating html files... "),
+        genpages(force)
+        print("Done.")
+        #copy common file (.css,license...)
+        copycommon()
+
+    #copy screenshots
+    if genscreens_flag:
+        if os.path.isdir("screenshots"):
+            print("Copying screenshots... "),
+            genscreenshots(force,gen_screenshots)
+            print("Done.")
+        else:
+            print("No screenshot directory found. Nothing to be done.")
+    
+    #copy gallery
+    if gengallery_flag:
+        if os.path.isdir("gallery"):
+            print("Generating gallery... "),
+            gengallery(force,gen_gallery)
+            print("Done.")
+        else:
+            print("No gallery directory found. Nothing to be done.")
+    
+    print("All files generated. You can now rsync them to the server")
+
+def copycommon():
+    common_files = ("pages/LGPL","pages/skencil.css")
+    for file in common_files:
+        shutil.copy(file,destdir)
+
+def genpages(force):
+    
+    faq_xml = 'pages/faq/faq.xml'
+    #generate faq
+    faq_html = os.path.join('pages/','faq.html')
+    if newer(faq_xml,faq_html):
+        os.chdir('pages/faq')
+        output = os.popen('python faqdom.py -x faq.xml ../faq.html')
+        os.chdir('../../')
+
+    #create destination dir
+    if not os.path.isdir(destdir):
+        os.mkdir(destdir)
+    
+    #generate files
+    pagefiles = glob.glob("pages/*.html")
+    for pagefile in pagefiles:
+        destfile = os.path.splitext(os.path.split(pagefile)[-1])[0]+".html"
+        destpath = os.path.join(destdir, destfile)
+
+        if newer(templatefile, destpath) or newer(pagefile, destpath) or force:
+
+            header, body = file(pagefile).read().split("\n\n", 1)
+            metadata = parseheader(header)
+            pagedata = {}
+            pagedata["body text"] = body
+            pagedata["last updated"] = time.ctime(os.path.getmtime(pagefile))
+            pagedata.update(globaldata)
+            pagedata.update(metadata)
+
+            page = template
+            for type, value in pagedata.items():
+                page = page.replace(includeformat % type, value)
+
+            file(destpath, "w").write(page)
+            #print destpath
+
+    #copy images
+    images = glob.glob("pages/images/*")
+    destpath = os.path.join(destdir,"images/")
+    if not os.path.isdir(destpath):
+        os.mkdir(destpath)
+    
+    for image in images:
+        destpath_ = os.path.join(destpath,image)
+        if newer(image,destpath_) or force:
+            shutil.copy(image,destpath)
+
+def genscreenshots(force,gen_screenshots):
+    """Copy screenshot to the dest directory"""
+    destpath = os.path.join(destdir, "screenshots/")
+    screenshots = glob.glob("screenshots/*")
+    if not os.path.isdir(destpath):
+    	os.mkdir(destpath)
+
+    for picture in screenshots:
+    	destpath_ = os.path.join(destpath,picture)
+        if newer(picture,destpath_) or force:
+            shutil.copy(picture,destpath)
+        
+
+def gengallery(force,gen_gallery):
+    """Copy gallery files in the dest directory after generating"""
+    #First we need to generate the image files from source
+    if gen_gallery:
+        os.chdir("gallery")
+        os.system("make")
+        os.chdir("..")
+         
+    destpath = os.path.join(destdir, "gallery/")
+    
+    # read all files from  gallery directory
+    matchobject = re.compile("^.*\\.[jpg|tar.gz|ppm]")
+    allfiles = os.listdir("gallery/")
+    gallery = filter(matchobject.match, allfiles)
+    if not os.path.isdir(destpath):
+    	os.mkdir(destpath)
+
+    for file in gallery:
+        if not os.path.isdir(file):
+    	    destpath_ = os.path.join(destpath,file)
+    	    srcpath = os.path.join("gallery",file)
+            if newer(srcpath,destpath_) or force:
+                #as wen do not want any leave additional files 
+                #in the repository we will move instead of copying the
+                #files into destdir.
+                shutil.move(srcpath,destpath)
+
+if __name__ == "__main__":
+    main()
+


Property changes on: website/trunk/updatepages.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the Skencil-commits mailing list