X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fadd_html_footer.py;h=da827c130164de217acb3ae553191f28c6d4d287;hb=91708b30fba67f8fd589980e03ff420c26473a5a;hp=3e35952c426cad818cb48af6c50a1f8585c24f3d;hpb=5516a43e8bc85c3f58b3c004a9a7fde626408939;p=lilypond.git
diff --git a/buildscripts/add_html_footer.py b/buildscripts/add_html_footer.py
index 3e35952c42..da827c1301 100644
--- a/buildscripts/add_html_footer.py
+++ b/buildscripts/add_html_footer.py
@@ -15,50 +15,54 @@ non_copied_pages = ['Documentation/user/out-www/lilypond-big-page',
'Documentation/user/out-www/lilypond-internals-big-page',
'Documentation/user/out-www/music-glossary-big-page',
'out-www/examples',
- 'Documentation/topdocs/out-www/NEWS',
- 'Documentation/topdocs/out-www/INSTALL',
- 'Documentation/bibliography/out-www/index',
- 'Documentation/bibliography/out-www/engraving',
- 'Documentation/bibliography/out-www/colorado',
- 'Documentation/bibliography/out-www/computer-notation'
+ 'Documentation/topdocs',
+ 'Documentation/bibliography',
'Documentation/out-www/THANKS',
'Documentation/out-www/DEDICATION',
- 'Documentation/topdocs/out-www/AUTHORS']
+ 'input/']
+
+def _doc (s):
+ return s
header = r"""
"""
-footer = r'''
+footer = '''
-This page is for %(package_name)s-%(package_version)s (%(branch_str)s).
+%(footer_name_version)s
+
+
+%(footer_report_errors)s
+
+%(footer_suggest_docs)s
-
-Report errors to %(mail_address)s.
'''
+footer_name_version = _doc ('This page is for %(package_name)s-%(package_version)s (%(branch_str)s).')
+footer_report_errors = _doc ('Report errors to %(mail_address)s.')
+# ugh, must not have "_doc" in strings because it is naively replaced with "_" in hacked gettext process
+footer_suggest_docs = _doc ('Your suggestions for the documentation are welcome.')
mail_address = 'http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs'
+suggest_Docs_url = 'http://lilypond.org/web/devel/participating/documentation-adding'
header_tag = ''
footer_tag = ''
-def _ (s):
- return s
+lang_available = _doc ("Other languages: %s.")
+browser_lang = _doc ('About automatic language selection.')
+browser_language_url = "/web/about/browser-language"
-language_available = _ ("Other languages: %s.") % "%(language_menu)s"
-browser_language = _ ("Using automatic language selection.") \
- % "/web/about/browser-language"
-
-LANGUAGES_TEMPLATE = '''\
+LANGUAGES_TEMPLATE = '''
%(language_available)s
%(browser_language)s
-''' % vars ()
+'''
html_re = re.compile ('(.*?)(?:[.]([^/.]*))?[.]html$')
@@ -80,6 +84,30 @@ def build_pages_dict (filelist):
else:
pages_dict[g[0]].append (e)
+def source_links_replace (m, source_val):
+ return 'href="' + os.path.join (source_val, m.group (1)) + '"'
+
+splitted_docs_re = re.compile ('(input/lsr/out-www/snippets|Documentation/user/out-www/(lilypond|music-glossary|lilypond-program|lilypond-learning))/')
+
+snippets_ref_re = re.compile (r'href="(\.\./)?lilypond-snippets')
+
+## Windows does not support symlinks.
+# This function avoids creating symlinks for splitted HTML manuals
+# Get rid of symlinks in GNUmakefile.in (local-WWW-post)
+# this also fixes missing PNGs only present in translated docs
+def _urls (s, prefix):
+ if splitted_docs_re.match (prefix):
+ s = re.sub ('(href|src)="(lily-.*?|.*?[.]png)"', '\\1="../\\2"', s)
+
+ # fix Snippets xrefs ad hoc
+ s = snippets_ref_re.sub ('href="source/input/lsr/lilypond-snippets', s)
+
+ source_path = os.path.join (os.path.dirname (prefix), 'source')
+ if not os.path.islink (source_path):
+ return s
+ source_val = os.readlink (source_path)
+ return re.sub ('href="source/(.*?)"', lambda m: source_links_replace (m, source_val), s)
+
def add_header (s):
"""Add header ( and doctype)"""
if re.search (header_tag, s) == None:
@@ -87,7 +115,7 @@ def add_header (s):
s = re.sub ('(?i)', body, s)
if re.search ('(?i)]*>', body + header, s, 1)
- elif re.search ('(?i)', '' + header, s, 1)
else:
s = header + s
@@ -99,10 +127,6 @@ def add_header (s):
s = doctype + s
return s
-def info_external_ref_remove (s):
- """Remove info's annoying's indication of referencing external document"""
- return re.sub (' \((lilypond|lilypond-internals|music-glossary)\)', '', s)
-
def add_title (s):
# urg
# maybe find first node?
@@ -114,6 +138,7 @@ def add_title (s):
return s
info_nav_bar = re.compile (r'', re.M | re.S)
+info_footnote_hr = re.compile (r'
\s*()?\s*', re.M | re.I)
def add_footer (s):
"""add footer
@@ -121,7 +146,11 @@ def add_footer (s):
also add navigation bar to bottom of Info HTML pages"""
m = info_nav_bar.search (s)
if m:
- custom_footer = '
\n\n' + footer
+ # avoid duplicate
in case there are footnotes at the end of the Info HTML page
+ if info_footnote_hr.search (s):
+ custom_footer = '\n' + footer
+ else:
+ custom_footer = '
\n\n' + footer
else:
custom_footer = footer
if re.search ('(?i)%s' % (lang_file, lang.name)
-
- languages = ''
- if language_menu:
- languages = LANGUAGES_TEMPLATE % vars ()
-
- # put language menu before '' and '' tags
+def add_menu (page_flavors, prefix, available, target, translation):
for k in page_flavors.keys():
- if re.search ('(?i)', languages + '