X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fwww_post.py;h=29f80cf09fa2bb208995e7c5094974782c6ee566;hb=5c14a087ca6cbd665fd631452b7b1283ba0387c3;hp=6dded57b341238cd99fdded2875c7a16f1c4b3cb;hpb=a0df7dcd3b849dd7284f9325704584d916b8f485;p=lilypond.git diff --git a/buildscripts/www_post.py b/buildscripts/www_post.py index 6dded57b34..29f80cf09f 100644 --- a/buildscripts/www_post.py +++ b/buildscripts/www_post.py @@ -3,47 +3,52 @@ ## This is www_post.py. This script is the main stage ## of toplevel GNUmakefile local-WWW-post target. -# USAGE: www_post PACKAGE_NAME TOPLEVEL_VERSION BUILDSCRIPT-DIR OUTDIR TARGETS +# USAGE: www_post PACKAGE_NAME TOPLEVEL_VERSION OUTDIR TARGETS # please call me from top of the source directory import sys import os import re -package_name, package_version, buildscript_dir, outdir, targets = sys.argv[1:] +import langdefs + +import mirrortree +import postprocess_html + +package_name, package_version, 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') +# these redirection pages allow to go back to the documentation index +# from HTML manuals/snippets page static_files = { - # ugly hack: the following overwrites HTML Info dir with a link to - # the (more useful) documentation index - os.path.join ('Documentation/user', outdir, 'index.html'): - ''' -Redirecting to the documentation index...\n''', os.path.join (outdir, 'index.html'): - ''' + ''' Redirecting to the documentation index...\n''', os.path.join (outdir, 'VERSION'): - package_version + '\n' } + package_version + '\n', + os.path.join ('input', 'lsr', outdir, 'index.html'): + ''' +Redirecting to the documentation index...\n''' + } + +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") 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|\w*?-root)(/|$)', - find_files = r'.*?\.(?:midi|html|pdf|png|txt|ly|signature)$|VERSION', - exclude_files = r'lily-[0-9a-f]+.*\.pdf') + exclude_dirs = '(^|/)(' + r'|po|out|out-test|.*?[.]t2d|\w*?-root)(/|$)|Documentation/(' + '|'.join ([l.code for l in langdefs.LANGUAGES]) + ')', + find_files = r'.*?\.(?:midi|html|pdf|png|txt|i?ly|signature|css)$|VERSION', + exclude_files = r'lily-[0-9a-f]+.*\.(pdf|txt)') # actual mirrorring stuff html_files = [] @@ -56,7 +61,7 @@ for f in files: dirs = [re.sub ('/' + outdir, '', d) for d in dirs] while outdir in dirs: dirs.remove (outdir) -dirs = list( set (dirs)) +dirs = list (set (dirs)) dirs.sort () strip_file_name = {} @@ -70,7 +75,13 @@ for t in targets: 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)) + dest = strip_file_name[t] (l) + if not os.path.exists (dest): + os.symlink (p, dest) + + ## ad-hoc renaming to make xrefs between PDFs work + os.rename (os.path.join (out_root, 'input/lsr/lilypond-snippets.pdf'), + os.path.join (out_root, 'Documentation/user/lilypond-snippets.pdf')) # need this for content negotiation with documentation index if 'online' in targets: @@ -78,21 +89,10 @@ if 'online' in targets: f.write ('#.htaccess\nDirectoryIndex index\n') f.close () -# load gettext messages catalogs -t = {} -localedir = os.path.join (buildscript_dir, '../Documentation/po', outdir) -for l in langdefs.LANGUAGES: - if l.enabled and l.code != 'en': - try: - t[l.code] = gettext.translation('lilypond-doc', localedir, [l.code]).gettext - except: - t[l.code] = lambda s: s - -add_html_footer.build_pages_dict (html_files) +postprocess_html.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 = t + postprocess_html.process_html_files ( package_name = package_name, package_version = package_version, target = t,