X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fwww_post.py;h=26cd613e4cdad36764c976bb424b124bc1638b08;hb=ece2e45d587f63565e81af44e1937ebe1f5e47a8;hp=1e182416c212da84631ac58eb2cf664c9ebbd733;hpb=af770f3440264c18ce01525dce1aa76b86ace0d5;p=lilypond.git diff --git a/buildscripts/www_post.py b/buildscripts/www_post.py index 1e182416c2..26cd613e4c 100644 --- a/buildscripts/www_post.py +++ b/buildscripts/www_post.py @@ -9,48 +9,96 @@ import sys import os import re +import gettext -package_name, package_version, buildscript_dir, outdir, targets = sys.argv[1:] +package_name, package_version, buildscript_dir, localedir, outdir, targets = sys.argv[1:] targets = targets.split (' ') outdir = os.path.normpath (outdir) doc_dirs = ['input', 'Documentation', outdir] target_pattern = os.path.join (outdir, '%s-root') -static_files = {os.path.join (outdir, 'index.html'): - ''' +# these redirection pages allow to go back to the documentation index +# from HTML manuals/snippets page +static_files = { + os.path.join (outdir, 'index.html'): + ''' Redirecting to the documentation index...\n''', - os.path.join (outdir, 'VERSION'): - package_version + '\n' } + os.path.join (outdir, 'VERSION'): + package_version + '\n', + os.path.join ('input', 'lsr', outdir, 'index.html'): + ''' +Redirecting to the documentation index...\n''' + } -for f in static_files.keys(): - open (f, 'w').write (static_files[f]) +import langdefs + +for l in langdefs.LANGUAGES: + static_files[os.path.join ('Documentation', 'user', outdir, l.file_name ('index', '.html'))] = \ + '\nRedirecting to the documentation index...\n' + +for f, contents in static_files.items (): + open (f, 'w').write (contents) sys.path.append (buildscript_dir) import mirrortree import add_html_footer -import langdefs sys.stderr.write ("Mirrorring...\n") -html_list = mirrortree.hardlink_tree (input_roots = doc_dirs, - process_dirs = outdir, - strip_dir_names = outdir, - exclude_dirs = '(' + - '|'.join ([l.code for l in langdefs.LANGUAGES]) + - r'|po|out|\w*?-root)(/|$)', - process_files = r'.*?\.(?:midi|pdf|png|txt|ly|signature)$|VERSION', - exclude_files = r'lily-[0-9a-f]+.*\.pdf', - target_pattern = target_pattern, - targets = targets) -html_dict = add_html_footer.build_pages_dict (html_list) +dirs, symlinks, files = mirrortree.walk_tree ( + tree_roots = doc_dirs, + process_dirs = outdir, + exclude_dirs = '(^|/)(' + '|'.join ([l.code for l in langdefs.LANGUAGES]) + r'|po|out|.*?[.]t2d|\w*?-root)(/|$)', + find_files = r'.*?\.(?:midi|html|pdf|png|txt|ly|signature)$|VERSION', + exclude_files = r'lily-[0-9a-f]+.*\.(pdf|txt)') + +# actual mirrorring stuff +html_files = [] +hardlinked_files = [] +for f in files: + if f.endswith ('.html'): + html_files.append (f) + else: + hardlinked_files.append (f) +dirs = [re.sub ('/' + outdir, '', d) for d in dirs] +while outdir in dirs: + dirs.remove (outdir) +dirs = list (set (dirs)) +dirs.sort () + +strip_file_name = {} strip_re = re.compile (outdir + '/') +for t in targets: + out_root = target_pattern % t + strip_file_name[t] = lambda s: os.path.join (target_pattern % t, (strip_re.sub ('', s))) + os.mkdir (out_root) + map (os.mkdir, [os.path.join (out_root, d) for d in dirs]) + for f in hardlinked_files: + os.link (f, strip_file_name[t] (f)) + for l in symlinks: + p = mirrortree.new_link_path (os.path.normpath (os.readlink (l)), os.path.dirname (l), strip_re) + os.symlink (p, strip_file_name[t] (l)) + +# need this for content negotiation with documentation index +if 'online' in targets: + f = open (os.path.join (target_pattern % 'online', 'Documentation/.htaccess'), 'w') + f.write ('#.htaccess\nDirectoryIndex index\n') + f.close () + +# load gettext messages catalogs +translation = {} +for l in langdefs.LANGUAGES: + if l.enabled and l.code != 'en': + translation[l.code] = gettext.translation('lilypond-doc', localedir, [l.code]).gettext + +add_html_footer.build_pages_dict (html_files) for t in targets: sys.stderr.write ("Processing HTML pages for %s target...\n" % t) add_html_footer.add_html_footer ( + translation = translation, package_name = package_name, package_version = package_version, target = t, - mail_address = 'http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs', - pages_dict = html_dict, - out_root = target_pattern % t, - name_filter = lambda s: strip_re.sub ('', s)) + name_filter = strip_file_name[t]) +