]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scripts/lilypond-book.py: Resurrect HTML links to .ly source.
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 31 Jan 2005 15:43:39 +0000 (15:43 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 31 Jan 2005 15:43:39 +0000 (15:43 +0000)
Bugfix: @include .tex (not .texi).  Small cleanups.

* stepmake/bin/add-html-footer.py (i18n): New function.

ChangeLog
scripts/lilypond-book.py
stepmake/bin/add-html-footer.py

index 9c8a76b158017dee38e71ff82473b3715c88ec0a..cfcacab43dcab24e6dfec33aeaf278f0b07459c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-01-31  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * scripts/lilypond-book.py: Resurrect HTML links to .ly source.
+       Bugfix: @include .tex (not .texi).  Small cleanups.
+
+       * stepmake/bin/add-html-footer.py (i18n): New function.
+
 2005-01-31  Werner Lemberg  <wl@gnu.org>
 
        * mf/feta-nummer.mf: Removed.  Unused.
index 7add63df5c145f34b8939d2ec7b57b026d7acb72..96a8113e51a9bab8afe90aad237157b410e05ba0 100644 (file)
@@ -489,14 +489,22 @@ output = {
 
                OUTPUT: r'''
 @iftex
-@include %(base)s-systems.texi
+@include %(base)s-systems.tex
 @end iftex
 ''',
 
                OUTPUTIMAGE: r'''@noindent
-@ifnottex
+@ifinfo
 @image{%(base)s,,,[image of music],%(ext)s}
-@end ifnottex
+@end ifinfo
+@html
+<p>
+  <a href="%(base)s.ly">
+    <img align="center" valign="center"
+        border="0" src="%(image)s" alt="[image of music]">
+  </a>
+</p>
+@end html
 ''',
 
                PRINTFILENAME: '''@file{%(filename)s}
@@ -878,7 +886,7 @@ class Lilypond_snippet (Snippet):
        def texstr_is_outdated (self):
                if backend == 'ps':
                        return 0
-               
+
                base = self.basename ()
                ok = self.ly_is_outdated ()
                ok = ok and (os.path.exists (base + '.texstr'))
@@ -939,8 +947,8 @@ class Lilypond_snippet (Snippet):
                        ext = ''
                        str += output[TEXINFO][OUTPUTIMAGE] % vars ()
 
-               base = self.basename()
-               str += output[format][OUTPUT] % vars()
+               base = self.basename ()
+               str += output[format][OUTPUT] % vars ()
                return str
 
        def output_latex (self):
@@ -985,10 +993,10 @@ class Lilypond_snippet (Snippet):
                        verb = verbatim_texinfo (self.substring ('code'))
                        str += (output[TEXINFO][VERBATIM] % vars ())
                        if not QUOTE in self.options:
-                               str = output[TEXINFO][NOQUOTE] % vars()
+                               str = output[TEXINFO][NOQUOTE] % vars ()
 
                str += self.output_info ()
-               
+
 #              str += ('@ifinfo\n' + self.output_info () + '\n@end ifinfo\n')
 #              str += ('@tex\n' + self.output_latex () + '\n@end tex\n')
 #              str += ('@html\n' + self.output_html () + '\n@end html\n')
@@ -1247,7 +1255,7 @@ def guess_format (input_filename):
                             % input_filename))
                ly.exit (1)
        return format
-       
+
 def do_file (input_filename):
        # Ugh.
        if not input_filename or input_filename == '-':
@@ -1429,7 +1437,7 @@ def main ():
        global process_cmd, format
        format = guess_format (files[0])
 
-       formats = "ps"
+       formats = 'ps'
        if format == TEXINFO:
                formats += ',png' 
        if process_cmd == '':
index 6d0d756c0aca69b4ad704518d1d82e0f2b27fdce..ec7cac2ab9c5ce650216267dd2574b0f97a8994f 100644 (file)
@@ -235,6 +235,7 @@ def do_file (f):
                else:
                        s = s + footer
 
+       s = i18n (f, s)
 
        #URUGRGOUSNGUOUNRIU
        index = index_url
@@ -263,10 +264,8 @@ def do_file (f):
 
        subst = globals ()
        subst.update (locals())
-       
-       
        s = s % subst
-       
+
        # urg
        # maybe find first node?
        fallback_web_title = '-- --'
@@ -283,6 +282,77 @@ def do_file (f):
        open (f, 'w').write (s)
 
 
+
+localedir = 'out/locale'
+try:
+       import gettext
+       gettext.bindtextdomain ('newweb', localedir)
+       gettext.textdomain ('newweb')
+       _ = gettext.gettext
+except:
+       def _ (s):
+               return s
+underscore = _
+
+
+LANGUAGES = (
+       ('site', 'English'),
+       ('nl', 'Nederlands'),
+       )
+
+language_available = _ ("Other languages: %s.") % "%(language_menu)s"
+browser_language = _ ("Using <A HREF='%s'>automatic language selection</A>.") \
+                     % "%(root_url)sabout/browser-language"
+
+LANGUAGES_TEMPLATE = '''\
+<P>
+  %(language_available)s
+  <BR>
+  %(browser_language)s
+</P>
+''' % vars ()
+
+def file_lang (file, lang):
+       (base, ext) = os.path.splitext (file)
+       base = os.path.splitext (base)[0]
+       if lang and lang != 'site':
+               return base + '.' + lang + ext
+       return base + ext
+
+
+def i18n (file_name, page):
+       # ugh
+       root_url = "/web/"
+
+       base_name = os.path.basename (file_name)
+
+       lang = ''
+       m = re.match ('.*[.]([^.]*).html', file_name)
+       if m:
+               lang = m.group (1)
+
+       # Find available translations of this page.
+       available = filter (lambda x: lang != x[0] \
+                           and os.path.exists (file_lang (file_name, x[0])),
+                           LANGUAGES)
+
+       # Strip .html, .png suffix for auto language selection.
+       page = re.sub ('''(href|src)=[\'"]([^/][.]*[^.:\'"]*)(.html(#[^"]*)|.png)[\'"]''',
+                      '\\1="\\2"', page)
+
+       # Create language menu.
+       language_menu = ''
+       for (prefix, name) in available:
+               lang_file = file_lang (base_name, prefix)
+               language_menu += '<a href="%(lang_file)s">%(name)s</a>' % vars ()
+
+       languages = ''
+       if language_menu:
+               languages = LANGUAGES_TEMPLATE % vars ()
+
+       return page + languages
+       ## end i18n
+
 for f in files:
        do_file (f)