From e37f5ab15bc948c028302ce0654f23764dd8efb7 Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Tue, 24 Jan 2012 17:35:35 +0100 Subject: web-export: Import the script used to generate the website --- web-export/README | 9 ++++ web-export/specs.idx | 50 +++++++++++++++++++ web-export/update.py | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 web-export/README create mode 100644 web-export/specs.idx create mode 100755 web-export/update.py diff --git a/web-export/README b/web-export/README new file mode 100644 index 0000000..94cbdbc --- /dev/null +++ b/web-export/README @@ -0,0 +1,9 @@ +This directory contains the files used to export the specifications on + http://specifications.freedesktop.org/ + +It's mostly two files: + + - specs.idx: information on where to fetch specific versions of different + specifications (usually CVS or git) + + - update.py: hacky script that uses specs.idx and creates html pages diff --git a/web-export/specs.idx b/web-export/specs.idx new file mode 100644 index 0000000..f1fb1fd --- /dev/null +++ b/web-export/specs.idx @@ -0,0 +1,50 @@ +git:xdg/xdg-specs:basedir/basedir-spec.xml 5c950648d4e3b186bda82c0c27ef089ee6747cbd 0.7 basedir-spec +basedir/basedir-spec/basedir-spec.xml 1.3 0.6 basedir-spec +basedir/basedir-spec/basedir-spec.xml 1.1.2.1 0.5 basedir-spec +icccm-extensions/wm-spec/wm-spec.xml 1.30 1.4 wm-spec +icccm-extensions/wm-spec/wm-spec.xml 1.19 1.3 wm-spec +menus/desktop-entry-spec/desktop-entry-spec.xml HEAD 1.1 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.20 1.0 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.19 0.9.8 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.18 0.9.7 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.15 0.9.6 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.10 0.9.5 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.9 0.9.4 desktop-entry-spec +menus/desktop-entry-spec/desktop-entry-spec.xml 1.1.2.1 0.9.3 desktop-entry-spec +git:xdg/xdg-specs:menu/menu-spec.xml master 1.1 menu-spec +menus/menu-spec/menu-spec.xml 1.33 1.0 menu-spec +menus/menu-spec/menu-spec.xml 1.26 0.9 menu-spec +menus/menu-spec/menu-spec.xml 1.22 0.8 menu-spec +menus/menu-spec/menu-spec.xml 1.11 0.7 menu-spec +menus/menu-spec/menu.dtd 1.4 0.8 menu-spec +menus/autostart-spec/autostart-spec.xml HEAD 0.5 autostart-spec +git:xdg/shared-mime-info:shared-mime-info-spec.xml 2f909cff817a3f08d12321769173cac2de0da1b4 0.20 shared-mime-info-spec +git:xdg/shared-mime-info:shared-mime-info-spec.xml 30349a8810143c1f808a74c96bceba87d48e8364 0.19 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.63 0.18 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.60 0.17 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.57 0.16 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.56 0.15 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.55 0.14 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.53 0.13 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.50 0.12 shared-mime-info-spec +mime/shared-mime-info/shared-mime-info-spec.xml 1.43 0.11 shared-mime-info-spec +recent-files/recent-file-spec/recent-file-spec.xml 1.1 0.2 recent-file-spec +startup-notification/startup-notification/doc/startup-notification.txt HEAD 0.1 startup-notification-spec +systemtray/systemtray-spec/systemtray-spec.xml 1.3 0.3 systemtray-spec +systemtray/systemtray-spec/systemtray-spec.xml 1.2 0.2 systemtray-spec +systemtray/systemtray-spec/systemtray-spec.xml 1.1 0.1 systemtray-spec +icccm-extensions/selections/clipboards.txt 1.2 0.1 clipboards-spec +icccm-extensions/selections/clipboard-extensions.txt 1.1 0.1 clipboard-extensions-spec +xembed/xembed/spec/xembed-spec.xml 1.2 0.5 xembed-spec +icon-theme/default-icon-theme/spec/icon-theme-spec.xml 1.7 0.11 icon-theme-spec +icon-theme/default-icon-theme/spec/icon-theme-spec.xml 1.6 0.10 icon-theme-spec +icon-theme/default-icon-theme/spec/icon-theme-spec.xml 1.5 0.9 icon-theme-spec +icon-theme/default-icon-theme/spec/icon-theme-spec.xml 1.3 0.8 icon-theme-spec +icon-theme/default-icon-theme/spec/icon-theme-spec-0.7.xml 1.1 0.7 icon-theme-spec +icon-theme/default-icon-theme/spec/icon-theme-spec-0.6.xml 1.1 0.6 icon-theme-spec +icon-theme/default-icon-theme/spec/icon-naming-spec.xml HEAD 0.8.90 icon-naming-spec +icon-theme/default-icon-theme/spec/icon-naming-spec.xml 1.12 0.8 icon-naming-spec +icon-theme/default-icon-theme/spec/icon-naming-spec.xml 1.10 0.7 icon-naming-spec +icon-theme/default-icon-theme/spec/icon-naming-spec.xml 1.8 0.6 icon-naming-spec +icon-theme/default-icon-theme/spec/icon-naming-spec.xml 1.7 0.4 icon-naming-spec +dbus/dbus/doc/introspect.dtd 1.2 1.0 dbus diff --git a/web-export/update.py b/web-export/update.py new file mode 100755 index 0000000..764d345 --- /dev/null +++ b/web-export/update.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python + +import os,re,string + +xmlto = "/usr/bin/xmlto" +cvs = "http://cvs.freedesktop.org/" +git = "http://cgit.freedesktop.org/" +specindex = "specs.idx" + +try: + f = open(specindex, 'r') + lastname = '' + lastpath = '' + for line in f.readlines(): + (file, revision, version, path) = string.split(line) + use_git = False + if file.startswith("git:"): + use_git = True + git_data = file.split(":") + git_repo = git_data[1] + file = git_data[2] + name = os.path.splitext(os.path.split(file)[1])[0] + # Strip version from name + if re.search("\d\.\d+$", name): + name = re.sub("^(.*)-([^/]*)$", "\\1", name) + + if use_git: + url = '%s%s/plain/%s?id=%s' % (git, git_repo, file, revision) + else: + url = '%s%s?rev=%s' % (cvs, file, revision) + + if re.search("\.xml$", file): + os.system("mkdir %s 2> /dev/null" % (path)) + if lastpath != path and lastname != name: + os.system("rm -f %s/%s-latest.html" % (path, name)) + os.system("cd %s; ln -s %s-%s.html %s-latest.html" % (path,name,version,name)) + os.system("rm -f %s/latest" % (path)) + os.system("cd %s; ln -s %s latest" % (path,version)) + + # if ( lastpath == path and lastname == name and os.path.isfile("%s/%s-%s.xml" % (path, name, version))): + # print "Updating", file, "Version", version, "rev", revision, "skipped." + # continue + + if os.system("wget -q '%s' -O wget.xml && (diff -q wget.xml %s/%s-%s.xml || mv wget.xml %s/%s-%s.xml)" % (url, path, name, version, path, name, version)): + print "Updating", file, "Version", version, "rev", revision, "FAILED." + os.system("chmod g+w wget.xml"); + + print "Updating", file, "Version", version, "rev", revision, "ok" + + elif re.search("\.txt$", file): + os.system("mkdir %s 2> /dev/null" % (path)) + if lastpath != path and lastname != name: + os.system("rm -f %s/%s-latest.txt" % (path, name)) + os.system("cd %s; ln -s %s-%s.txt %s-latest.txt" % (path,name,version,name)) + + if ( lastpath == path and lastname == name and os.path.isfile("%s/%s-%s.txt" % (path, name, version))): + print "Updating", file, "Version", version, "rev", revision, "skipped." + continue + + if os.system("wget -q '%s' -O wget.txt && (diff -q wget.txt %s/%s-%s.txt || mv wget.txt %s/%s-%s.txt)" % (url, path, name, version, path, name, version)): + print "Updating", file, "Version", version, "rev", revision, "FAILED." + os.system("chmod g+w wget.txt"); + + print "Updating", file, "Version", version, "rev", revision, "ok" + + elif re.search("\.dtd$", file): + os.system("mkdir %s 2> /dev/null" % (path)) + if lastpath != path and lastname != name: + os.system("rm -f %s/%s-latest.dtd" % (path, name)) + os.system("cd %s; ln -s %s-%s.dtd %s-latest.dtd" % (path,name,version,name)) + + if ( lastpath == path and lastname == name and os.path.isfile("%s/%s-%s.dtd" % (path, name, version))): + print "Updating", file, "Version", version, "rev", revision, "skipped." + continue + + if os.system("wget -q '%s' -O wget.dtd && (diff -q wget.dtd %s/%s-%s.dtd || mv wget.dtd %s/%s-%s.dtd)" % (url, path, name, version, path, name, version)): + print "Updating", file, "Version", version, "rev", revision, "FAILED." + os.system("chmod g+w wget.dtd"); + + print "Updating", file, "Version", version, "rev", revision, "ok" + else: + print "Skipping", file, ", unknown file." + continue + + lastname = name + lastpath = path + +except IOError: + print "Can't open", specindex + + +specs = os.listdir(".") + +for spec in specs: + if not os.path.isdir(spec): + continue + versions = os.listdir(spec) + for file in versions: + if re.search("\.xml$", file): + tmp = re.sub("(.*)(\.xml)$", "\\1", file) + name = re.sub("^(.*)-([^/]*)$", "\\1", tmp) + ver = re.sub("^(.*)-([^/]*)$", "\\2", tmp) + + print "Check", os.path.join(spec,ver), os.path.isdir(os.path.join(spec,ver)) + print "Check", os.path.join(spec,name+"-"+ver+".html"), os.path.isfile(os.path.join(spec,name+"-"+ver+".html")) + + if ( not os.path.isdir(os.path.join(spec,ver)) + or not os.path.isfile(os.path.join(spec,name+"-"+ver+".html")) + or os.path.getmtime(os.path.join(spec,file)) > os.path.getmtime(os.path.join(spec,name+"-"+ver+".html"))): + os.system("rm -fR %s/%s" % (spec,ver)) + os.system("rm -f %s/%s-%s.html" % (spec,name,ver)) + os.system("mkdir %s/%s" % (spec,ver)) + os.system("cd %s/%s; %s html ../%s" % (spec,ver,xmlto,file)) + # os.system("mv index.html %s/%s-%s.html" % (spec,name,ver)) + # os.system("sed -i %s/%s-%s.html -e 's/index.html/%s-%s.html/;'" % (spec,name,ver,name,ver)) + os.system("cd %s;%s html-nochunks %s" % (spec,xmlto,file)) + elif re.search("(?