commit ccf7b4d331b3df56241d763343e6aa08e50ebd6e Author: Frédéric Péters Date: Sun Aug 11 23:17:36 2013 +0200 initial commit diff --git a/doceo.modules b/doceo.modules new file mode 100644 index 0000000..0c31769 --- /dev/null +++ b/doceo.modules @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/index_template.html b/index_template.html new file mode 100644 index 0000000..2889224 --- /dev/null +++ b/index_template.html @@ -0,0 +1,19 @@ + + + + +Documentation + + + + +

+Entr'ouvert Entr'ouvert Documentation

+
+{% for module in modules|dictsort:"title" %} +
{{ module.title }}
+

{{ module.description }}

+{% endfor %} +
+ + diff --git a/jhbuildrc b/jhbuildrc new file mode 100644 index 0000000..d700cbf --- /dev/null +++ b/jhbuildrc @@ -0,0 +1,7 @@ +import os + +prefix = os.path.abspath(os.path.join(os.path.dirname(__file__), 'jhbuild')) +checkoutroot = os.path.join(prefix, 'src') +use_lib64 = False + +moduleset = 'doceo.modules' diff --git a/modules.json b/modules.json new file mode 100644 index 0000000..741ecff --- /dev/null +++ b/modules.json @@ -0,0 +1,25 @@ +[ + {"name": "wcs", + "title": "w.c.s.", + "description": "Web application to design and set up online forms" + }, + {"name": "univnautes", + "title": "UnivNautes", + "description": "Captive portal with SAMLv2 authentication" + }, + {"name": "polynum", + "title": "Polynum", + "description": "Application de gestion de la reproduction des documents pédagogiques" + }, + {"name": "portail-citoyen", + "title": "Portail Citoyen", + "description": "Plate-forme dans laquelle sont agrégées des informations provenant de sources web diverses." + }, + {"name": "lasso", + "title": "Lasso", + "description": "C library wich implements SAML 2.0 and Liberty Alliance standards; it defines processes for federated identities, single sign-on and related protocols.", + "type": "tarball", + "url": "https://dev.entrouvert.org/lasso/lasso-2.3.6.tar.gz", + "directory": "lasso-2.3.6/docs/reference/lasso/html" + } +] diff --git a/publish.py b/publish.py new file mode 100755 index 0000000..0837a86 --- /dev/null +++ b/publish.py @@ -0,0 +1,120 @@ +#! /usr/bin/env python + +import json +import os +import subprocess +import tarfile +import urllib2 +import urlparse + +from django.template import Template, Context +from django.conf import settings +settings.configure() + +jhbuildrc = os.path.join(os.getcwd(), 'jhbuildrc') +checkouts_directory = os.path.join(os.getcwd(), 'src') +web_directory = os.path.join(os.getcwd(), 'web') + +if not os.path.exists('jhbuild'): + os.system('jhbuild -f jhbuildrc -m doceo.modules buildone itstool yelp-xsl yelp-tools') + +if not os.path.exists(checkouts_directory): + os.mkdir(checkouts_directory) + +def checkout(module): + checkout_dir = os.path.join(checkouts_directory, module) + + kws = {} + kws['stdout'] = subprocess.PIPE + kws['stderr'] = subprocess.STDOUT + if not os.path.exists(checkout_dir): + # full clone + cmd = ['git', 'clone', 'http://repos.entrouvert.org/%s.git' % module] + kws['cwd'] = checkouts_directory + else: + # pull + cmd = ['git', 'pull'] + kws['cwd'] = checkout_dir + + subprocess.call(cmd, **kws) + +def download(url): + filename = os.path.split(urlparse.urlparse(url)[2])[-1] + if not os.path.exists(os.path.join(checkouts_directory, filename)): + fd = file(os.path.join(checkouts_directory, filename), 'w') + fd.write(urllib2.urlopen(url).read()) + fd.close() + + +def publish_mallard(module, branch, directory): + checkout_dir = os.path.join(checkouts_directory, module) + + kws = {} + kws['stdout'] = subprocess.PIPE + kws['stderr'] = subprocess.STDOUT + cmd = ['git', 'checkout', branch] + subprocess.call(cmd, cwd=checkout_dir, **kws) + + help_dir = os.path.join(checkout_dir, 'help', 'fr') + if not os.path.exists(help_dir): + return + output_dir = os.path.join(web_directory, module, directory) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + index_html = os.path.join(output_dir, 'index.html') + if os.path.islink(index_html): + os.unlink(index_html) + + cmd = ['jhbuild', '-f', jhbuildrc, 'run', 'yelp-build', 'html', '-o', output_dir] + cmd.extend([os.path.join(help_dir, x) for x in os.listdir(help_dir) if x.endswith('.page')]) + subprocess.call(cmd, **kws) + + if not os.path.exists(index_html): + html_files = [x for x in os.listdir(output_dir) if x.endswith('.html')] + if html_files: + os.symlink(html_files[0], index_html) + + +def publish_tarball(module): + output_dir = os.path.join(web_directory, module.get('name'), 'stable') + url = module.get('url') + directory = module.get('directory') + filename = os.path.split(urlparse.urlparse(url)[2])[-1] + tar = tarfile.open(os.path.join(checkouts_directory, filename), 'r') + for tarinfo in tar: + if not tarinfo.name.startswith(directory): + continue + output_filename = os.path.join(output_dir, tarinfo.name[len(directory):].strip('/')) + if tarinfo.isdir(): + if not os.path.exists(output_filename): + os.makedirs(output_filename) + else: + fd = tar.extractfile(tarinfo) + file(output_filename, 'w').write(fd.read()) + + +def create_index(modules): + index_html = os.path.join(web_directory, 'index.html') + t = Template(unicode(file('index_template.html').read(), 'utf-8')) + c = Context({'modules': modules}) + fd = file(index_html, 'w') + fd.write(t.render(c).encode('utf-8')) + fd.close() + + +modules = json.load(file('modules.json')) + +for module in modules: + if module.get('type') == 'tarball': + download(module.get('url')) + else: + checkout(module.get('name')) + + if module.get('directory'): + module['branch'] = 'stable' + publish_tarball(module) + else: + module['branch'] = 'dev' + publish_mallard(module.get('name'), 'master', 'dev') + +create_index(modules)