lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Followup on solved bug reports. Was: lilypond ./ChangeLog lily/new-finge


From: Mats Bengtsson
Subject: Followup on solved bug reports. Was: lilypond ./ChangeLog lily/new-fingering-engrave... [lilypond_2_4]
Date: Tue, 15 Mar 2005 13:39:55 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Han-Wen,

Another of all these quick bug fixes! Thanks for your hard work!

It would be great if you (and others who fix bugs in CVS) could also
send a reply to the original bug report that the problem has been fixed.
I seem to recall that you sent the same request to me and others some
years ago and that you also followed it yourself. I'm not sure if it's
time limitations or that you expect Erik to handle the official
responses to all bug reports that has changed these good habits.

This information is useful both for the user who wrote the bug report,
for people who search for information on the mailing list archives and
just see a large number of unanswered bug reports and for me and others
who try to provide relevant answers on the lists and documentation
updates, for example.

   /Mats

Han-Wen Nienhuys wrote:
CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         lilypond_2_4
Changes by:     Han-Wen Nienhuys <address@hidden> 05/03/15 10:45:54

Modified files:
. : ChangeLog lily : new-fingering-engraver.cc stepmake/bin : add-html-footer.py
Log message:
        (position_scripts): take priority
        from head position. Backport.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?only_with_tag=lilypond_2_4&tr1=1.2780.2.32&tr2=1.2780.2.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/new-fingering-engraver.cc.diff?only_with_tag=lilypond_2_4&tr1=1.42&tr2=1.42.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/stepmake/bin/add-html-footer.py.diff?only_with_tag=lilypond_2_4&tr1=1.28&tr2=1.28.2.1&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.2780.2.32 lilypond/ChangeLog:1.2780.2.33
--- lilypond/ChangeLog:1.2780.2.32      Mon Mar 14 21:05:32 2005
+++ lilypond/ChangeLog  Tue Mar 15 10:45:53 2005
@@ -1,3 +1,8 @@
+2005-03-15  Han-Wen Nienhuys  <address@hidden>
+
+       * lily/new-fingering-engraver.cc (position_scripts): take priority
+       from head position. Backport.
+
 2005-03-14  Jan Nieuwenhuizen  <address@hidden>
* make/ly-rules.make ($(outdir)/%.nexi): Remove old makeinfo
Index: lilypond/lily/new-fingering-engraver.cc
diff -u /dev/null lilypond/lily/new-fingering-engraver.cc:1.42.2.1
--- /dev/null   Tue Mar 15 10:45:54 2005
+++ lilypond/lily/new-fingering-engraver.cc     Tue Mar 15 10:45:54 2005
@@ -0,0 +1,336 @@
+/* + fingering-engraver.cc -- implement New_fingering_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998--2004 Han-Wen Nienhuys <address@hidden> + + */
+
+#include "warn.hh"
+#include "engraver.hh"
+#include "side-position-interface.hh"
+#include "item.hh"
+#include "event.hh"
+#include "stem.hh"
+#include "rhythmic-head.hh"
+#include "self-alignment-interface.hh"
+#include "script-interface.hh"
+#include "stem.hh"
+
+struct Finger_tuple
+{
+  Grob *head_;
+  Grob *script_;
+  Music *note_event_;
+  Music *finger_event_;
+  bool follow_into_staff_;
+  int position_;
+
+  Finger_tuple ()
+  {
+    position_ = 0;
+    head_ = script_ = 0;
+    note_event_ = finger_event_ = 0;
+    follow_into_staff_ = false;
+  }
+  static int compare (Finger_tuple const & c1, Finger_tuple const & c2)
+  {
+    return c1.position_-  c2.position_;
+  }
+ +};
+
+class New_fingering_engraver : public Engraver
+{
+  Array<Finger_tuple> fingerings_;
+  Array<Finger_tuple> articulations_;
+  Link_array<Grob> heads_;
+  Grob *stem_;
+ +public:
+  TRANSLATOR_DECLARATIONS (New_fingering_engraver);
+protected:
+  virtual void stop_translation_timestep ();
+  virtual void acknowledge_grob (Grob_info);
+  void add_fingering (Grob*, Music*,Music*);
+  void add_script  (Grob*, Music*,Music*);
+  void position_scripts ();
+};
+
+void
+New_fingering_engraver::acknowledge_grob (Grob_info inf)
+{
+  if (Rhythmic_head::has_interface (inf.grob_))
+    {
+      Music * note_ev =inf.music_cause ();
+      if (!note_ev)
+       return;
+ + SCM arts = note_ev->get_property ("articulations");
+
+      for (SCM s = arts; scm_is_pair (s); s = scm_cdr  (s))
+       {
+         Music * m = unsmob_music (scm_car (s));
+
+         if (!m)
+           continue;
+ +
+         if (m->is_mus_type ("fingering-event"))
+           {
+             add_fingering (inf.grob_ , m, note_ev);
+           }
+         else if (m->is_mus_type ("text-script-event"))
+           {
+             m->origin ()->warning ("Can not add text scripts to individual note 
heads");
+           }
+         else if (m->is_mus_type ("script-event"))
+           {
+             add_script (inf.grob_, m, note_ev);
+           }
+         else if (m->is_mus_type ("harmonic-event"))
+           {
+             inf.grob_->set_property ("style", ly_symbol2scm ("harmonic"));
+             Grob * d = unsmob_grob (inf.grob_->get_property ("dot"));
+             if (d)
+ d->suicide (); + }
+       }
+
+      heads_.push (inf.grob_);
+    }
+  else if (Stem::has_interface (inf.grob_))
+    {
+      stem_ = inf.grob_;
+    }
+}
+
+void
+New_fingering_engraver::add_script (Grob * head,
+                                   Music * event,
+                                   Music * )
+{
+  Finger_tuple ft ;
+
+  Grob * g=  make_item ("Script", event->self_scm () );
+  make_script_from_event (g, &ft.follow_into_staff_, context (),
+                         event->get_property ("articulation-type"), 0);
+  if (g)
+    {
+      ft.script_ =g ;
+ + articulations_.push (ft); + + ft.script_->set_parent (head, X_AXIS);
+    }
+} + +
+void
+New_fingering_engraver::add_fingering (Grob * head,
+                                      Music * event,
+                                      Music *hevent)
+{
+  Finger_tuple ft;
+
+  ft.script_ = make_item ("Fingering", event->self_scm () );
+ + Side_position_interface::add_support (ft.script_, head);
+
+  int d = scm_to_int (event->get_property ("digit"));
+ + /*
+    TODO:
+ + Should add support for thumb. It's a little involved, since
+    the thumb lives in a different font. Maybe it should be moved?
+ + */
+  if (d > 5)
+    {
+      /*
+ music for the softenon children? + */
+      event->origin ()->warning (_("music for the martians."));
+    }
+  SCM sstr = scm_number_to_string (scm_int2num (d), scm_int2num (10)) ;
+  ft.script_->set_property ("text", sstr);
+ + ft.finger_event_ = event;
+  ft.note_event_ = hevent;
+  ft.head_ = head;
+
+  fingerings_.push (ft);
+}
+
+void
+New_fingering_engraver::position_scripts ()
+{
+
+  /*
+    This is not extremely elegant, but we have to do a little
+    formatting here, because the parent/child relations should be
+    known before we move on to the next time step.
+
+    A more sophisticated approach would be to set both X and Y parents
+    to the note head, and write a more flexible function for
+    positioning the fingerings, setting both X and Y coordinates.
+  */
+  for (int i = 0; i < fingerings_.size (); i++)
+ { + fingerings_[i].position_ = scm_to_int (fingerings_[i].head_ -> get_property ( "staff-position"));
+    }
+
+  for (int i = fingerings_.size (); i--;)
+    for (int j = heads_.size () ; j--;)
+      Side_position_interface::add_support (fingerings_[i].script_, heads_[j]);
+ + Array<Finger_tuple> up, down, horiz;
+  for (int i = fingerings_.size (); i--;)
+    {
+      SCM d = fingerings_[i].finger_event_->get_property ("direction");
+      if (to_dir (d))
+       {
+         ((to_dir (d) == UP) ? up : down ).push (fingerings_[i]);
+         fingerings_.del (i);
+       }
+    }
+ + fingerings_.sort (&Finger_tuple::compare);
+  SCM orientations = get_property ("fingeringOrientations");
+
+  bool up_p = scm_c_memq (ly_symbol2scm ("up"), orientations) != SCM_BOOL_F;
+  bool down_p = scm_c_memq (ly_symbol2scm ("down"), orientations) != 
SCM_BOOL_F;
+  bool left_p = scm_c_memq (ly_symbol2scm ("left"), orientations) != 
SCM_BOOL_F;
+  bool right_p = scm_c_memq (ly_symbol2scm ("right"), orientations) != 
SCM_BOOL_F;
+  Direction hordir = (right_p) ? RIGHT : LEFT;
+  if (left_p || right_p)
+    {
+      if (up_p && !up.size () && fingerings_.size ())
+       up.push (fingerings_.pop ());
+
+      if (down_p && !down.size () && fingerings_.size ())
+       {
+         down.push (fingerings_[0]);
+         fingerings_.del (0);
+       }
+
+      horiz.concat (fingerings_);
+    }
+  else if (up_p && down_p)
+    {
+      int center = fingerings_.size () / 2;
+      down.concat (fingerings_.slice (0,center));
+      up.concat (fingerings_.slice (center, fingerings_.size ()));
+    }
+  else if (up_p)
+    {
+      up.concat (fingerings_);
+      fingerings_ .clear ();
+    }
+  else
+    {
+      if (!down_p)
+       warning (_ ("Fingerings are also not down?! Putting them down 
anyway."));
+      down.concat (fingerings_);
+      fingerings_.clear ();
+    }
+ + for (int i = 0; i < horiz.size (); i++)
+    {
+      Finger_tuple ft = horiz[i];
+      Grob* f = ft.script_;
+      f->set_parent (ft.head_, X_AXIS);
+      f->set_parent (ft.head_, Y_AXIS);
+      f->add_offset_callback 
(Self_alignment_interface::centered_on_parent_proc, Y_AXIS);
+      f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, 
Y_AXIS);
+      f->add_offset_callback (Side_position_interface::aligned_side_proc, 
X_AXIS);
+
+      f->set_property ("direction", scm_int2num (hordir));
+    }
+
+  int finger_prio = 200;
+  for (int i = 0; i < up.size (); i++)
+    {
+      Finger_tuple ft = up[i];
+      Grob* f = ft.script_;
+      f->set_parent (ft.head_, X_AXIS);
+      f->set_property ("script-priority",
+                           scm_int2num (finger_prio + ft.position_));
+      f->add_offset_callback (Side_position_interface::aligned_side_proc, 
Y_AXIS);
+      f->add_offset_callback 
(Self_alignment_interface::centered_on_parent_proc, X_AXIS);
+      f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, 
X_AXIS);
+ + f->set_property ("direction", scm_int2num (UP));
+
+    }
+ + for (int i = 0; i < down.size (); i++)
+    {
+      Finger_tuple ft = down[i];
+      Grob* f = ft.script_;
+      f->set_parent (ft.head_, X_AXIS);
+      f->set_property ("script-priority",
+                           scm_int2num (finger_prio + down.size () - 
ft.position_));
+
+      f->add_offset_callback 
(Self_alignment_interface::centered_on_parent_proc, X_AXIS);
+      f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, 
X_AXIS);
+      f->add_offset_callback (Side_position_interface::aligned_side_proc, 
Y_AXIS);
+      f->set_property ("direction", scm_int2num (DOWN));
+    }
+}
+
+void
+New_fingering_engraver::stop_translation_timestep ()
+{
+  if (fingerings_.size ())
+    {
+      for (int i = 0;  i < fingerings_.size(); i++)
+       if (stem_ && to_boolean (fingerings_[i].script_->get_property 
("add-stem-support")))
+         Side_position_interface::add_support (fingerings_[i].script_, stem_);
+      position_scripts ();
+      fingerings_.clear ();
+    }
+ + for (int i = articulations_.size (); i--;)
+    {
+      Grob *script = articulations_[i].script_;
+ + for (int j = heads_.size () ; j--;)
+       Side_position_interface::add_support (script, heads_[j]);
+
+      if (stem_ && to_dir (script->get_property ("side-relative-direction")))
+       script->set_property ("direction-source", stem_->self_scm ());
+
+
+      if (stem_ && to_boolean (script->get_property ("add-stem-support")))
+       Side_position_interface::add_support (script, stem_);
+ + if (articulations_[i].follow_into_staff_)
+       {
+         script->add_offset_callback 
(Side_position_interface::quantised_position_proc, Y_AXIS);
+         script->set_property ("staff-padding" , SCM_EOL);
+       }
+    }
+
+  stem_ = 0;
+  heads_.clear ();
+  articulations_.clear ();
+}
+
+
+New_fingering_engraver::New_fingering_engraver ()
+{
+ stem_ = 0; +}
+
+ENTER_DESCRIPTION (New_fingering_engraver,
+/* descr */       "Create fingering-scripts for notes in a new chord.  "
+                 "This engraver is ill-named, since it "
+                 "also takes care of articulations and harmonic note heads",
+/* creats*/       "Fingering",
+/* accepts */     "",
+/* acks  */       "rhythmic-head-interface stem-interface",
+/* reads */       "fingeringOrientations",
+/* write */       "");
Index: lilypond/stepmake/bin/add-html-footer.py
diff -u /dev/null lilypond/stepmake/bin/add-html-footer.py:1.28.2.1
--- /dev/null   Tue Mar 15 10:45:54 2005
+++ lilypond/stepmake/bin/add-html-footer.py    Tue Mar 15 10:45:54 2005
@@ -0,0 +1,358 @@
address@hidden@
+
+"""
+Print a nice footer.  add the top of the ChangeLog file (up to the ********)
+"""
+import re
+import sys
+import os
+import time
+import string +import getopt
+
+gcos = "unknown"
+index_url=''
+top_url=''
+changelog_file=''
+package_name = ''
+package_version = ''
+
+mail_address = '(address unknown)'
+try:
+       mail_address= os.environ['MAILADDRESS']
+except KeyError:
+       pass
+
+webmaster= mail_address
+try:
+       webmaster= os.environ['WEBMASTER']
+except KeyError:
+       pass
+
+header_file = ''
+footer_file = ''
+default_header = r"""
+"""
+
+
+#wiki_base = 'http://afavant.elte.hu/lywiki/'
+wiki_base = None +
+
+default_footer = r"""<hr>Please take me <a address@hidden@>back to the 
index</a>
+of @PACKAGE_NAME@
+"""
+
+built = r"""
+<div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;">
+%(wiki_string)s
+<p>
+<font size="-1">
+This page is for %(package_name)s-%(package_version)s (%(branch_str)s). <br>
+</font>
+<address><font size="-1">
+Report errors to &lt;<a 
href="mailto:%(mail_address)s">%(mail_address)s</a>&gt;.</font></address>
+</div>
+
+
+"""
+
+
+def gulp_file (f):
+       try:
+               i = open(f)
+               i.seek (0, 2)
+               n = i.tell ()
+               i.seek (0,0)
+       except:
+               sys.stderr.write ("can't open file: %s\n" % f)
+               return ''
+       s = i.read (n)
+       if len (s) <= 0:
+               sys.stderr.write ("gulped empty file: %s\n" % f)
+       i.close ()
+       return s
+
+def help ():
+       sys.stdout.write (r"""Usage: add-html-footer [OPTIONS]... HTML-FILE
+Add header, footer and top of ChangLog file (up to the ********) to HTML-FILE
+
+Options:
+  --changelog=FILE          use FILE as ChangeLog [ChangeLog]
+  --footer=FILE             use FILE as footer
+  --header=FILE             use FILE as header
+  -h, --help                print this help
+  --index=URL               set homepage to URL
+  --name=NAME               set package_name to NAME
+  --version=VERSION         set package version to VERSION
+
+""")
+       sys.exit (0)
+
+(options, files) = getopt.getopt(sys.argv[1:], 'h', [
+       'changelog=', 'footer=', 'header=', 'help', 'index=',
+ 'name=', 'version=']) +
+for opt in options:
+       o = opt[0]
+       a = opt[1]
+       if o == '--changelog':
+               changelog_file = a
+       elif o == '--footer':
+               footer_file = a
+       elif o == '--header':
+               header_file = a
+       elif o == '-h' or o == '--help':
+               help ()
+       # urg, this is top!
+       elif o == '--index':
+               index_url = a
+       elif o == '--name':
+               package_name = a
+       elif o == '--version':
+               package_version = a
+       else:
+               raise 'unknown opt ', o
+
+#burp?
+def set_gcos ():
+       global gcos
+       os.environ["CONFIGSUFFIX"] = 'www';
+       if os.name == 'nt':
+               import ntpwd
+               pw = ntpwd.getpwname(os.environ['USERNAME'])
+       else:
+               import pwd
+               if os.environ.has_key('FAKEROOTKEY') and 
os.environ.has_key('LOGNAME'):
+                       pw = pwd.getpwnam (os.environ['LOGNAME'])
+               else:
+                       pw = pwd.getpwuid (os.getuid())
+
+       f = pw[4]
+       f = string.split (f, ',')[0]
+ gcos = f +
+def compose (default, file):
+       s = default
+       if file:
+               s = gulp_file (file)
+       return s
+
+set_gcos ()
+localtime = time.strftime ('%c %Z', time.localtime (time.time ()))
+
+if os.path.basename (index_url) != "index.html":
+       index_url = os.path.join (index_url , "index.html")
+top_url = os.path.dirname (index_url) + "/"
+
+header = compose (default_header, header_file)
+
+# compose (default_footer, footer_file)
+footer =  built
+header_tag = '<!-- header_tag -->'
+footer_tag = '<!-- footer_tag -->'
+
+# Python < 1.5.2 compatibility
+#
+# On most platforms, this is equivalent to
+#`normpath(join(os.getcwd()), PATH)'.  *Added in Python version 1.5.2*
+if os.path.__dict__.has_key ('abspath'):
+       abspath = os.path.abspath
+else:
+       def abspath (path):
+               return os.path.normpath (os.path.join (os.getcwd (), path))
+
+
+def remove_self_ref (s):       
+       self_url = abspath (os.getcwd () + '/' + f)
+       #sys.stderr.write ('url0: %s\n' % self_url)
+
+       # self_url = re.sub ('.*?' + string.lower (package_name) + '[^/]*/',
+       #                '', self_url)
+       # URG - this only works when source tree is unpacked in `src/' dir
+       # For some reason, .*? still eats away
+       #     
/home/fred/usr/src/lilypond-1.5.14/Documentation/user/out-www/lilypond/
+       # instead of just
+       #
+       #     /home/fred/usr/src/lilypond-1.5.14/
+       #
+       #     Tutorial.html
+       self_url = re.sub ('.*?src/' + string.lower (package_name) + '[^/]*/',
+                        '', self_url)
+
+       #sys.stderr.write ('url1: %s\n' % self_url)
+       
+       #urg, ugly lily-specific toplevel index hack
+       self_url = re.sub ('.*topdocs/out-www/index.html', 'index.html', 
self_url)
+       #sys.stderr.write ('url2: %s\n' % self_url)
+
+       # ugh, python2.[12] re is broken.
+       ## pat = re.compile ('.*?(<a href="[\./]*' + self_url + 
'#?[^"]*">)([^<]*)(</a>)', re.DOTALL)
+       pat = re.compile ('[.\n]*?(<a href="[\./]*' + self_url + 
'#?[^"]*">)([^<]*)(</a>)')
+       m = pat.search (s)
+       while m:
+               #sys.stderr.write ('self: %s\n' % m.group (2))
+               s = s[:m.start (1)] + m.group (2) + s[m.end (3):]
+               m = pat.search (s)
+       return s
+
+def do_file (f):
+       s = gulp_file (f)
+       s = re.sub ('%', '%%', s)
+
+
+       if re.search (header_tag, s) == None:
+               body = '<BODY BGCOLOR=WHITE TEXT=BLACK>'
+               s = re.sub ('(?i)<body>', body, s)
+               if re.search ('(?i)<BODY', s):
+                       s = re.sub ('(?i)<body[^>]*>', body + header, s, 1)
+               elif re.search ('(?i)<html', s):             
+                       s = re.sub ('(?i)<html>', '<HTML>' + header, s, 1)
+               else:
+                       s = header + s
+
+               s = header_tag + '\n' + s
+
+               if re.search ('(?i)<!DOCTYPE', s) == None:
+                       doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
Transitional//EN">\n'
+                       s = doctype + s
+
+       if re.search (footer_tag, s) == None:
+               s = s + footer_tag + '\n'
+
+               if re.search ('(?i)</body', s):
+                       s = re.sub ('(?i)</body>', footer + '</BODY>', s, 1)
+               elif re.search ('(?i)</html', s):            
+                       s = re.sub ('(?i)</html>', footer + '</HTML>', s, 1)
+               else:
+                       s = s + footer
+
+               s = i18n (f, s)
+
+       #URUGRGOUSNGUOUNRIU
+       index = index_url
+       top = top_url
+       if os.path.basename (f) == "index.html":
+               cwd = os.getcwd ()
+               if os.path.basename (cwd) == "topdocs":
+                       index = "index.html"
+                       top = ""
+
+               # don't cause ///////index.html entries in log files.
+               #       index = "./index.html"
+               #       top = "./"
+
+
+       versiontup = string.split(package_version, '.')
+       branch_str = 'stable-branch'
+       if string.atoi ( versiontup[1]) %  2:
+               branch_str = 'development-branch'
+
+       wiki_page = ('v%s.%s-' % (versiontup[0], versiontup[1]) +  f)
+       wiki_page = re.sub ('out-www/', '', wiki_page)
+ wiki_page = re.sub ('/', '-', wiki_page) + wiki_page = re.sub (r'\.-', '', wiki_page) + wiki_page = re.sub ('.html', '', wiki_page)
+
+       wiki_string = ''
+
+       if wiki_base:
+               wiki_string = (r'''<a href="%(wiki_base)s%(wiki_page)s">Read 
</a> comments on this page, or
+ <a href="%(wiki_base)s%(wiki_page)s?action=edit">add</a> one.''' % + { 'wiki_base': wiki_base,
+                                'wiki_page': wiki_page})
+               
+       subst = globals ()
+       subst.update (locals())
+       s = s % subst
+
+       # urg
+       # maybe find first node?
+       fallback_web_title = '-- --'
+
+       # ugh, python2.[12] re is broken.
+       #m = re.match ('.*?<title>\(.*?\)</title>', s, re.DOTALL)
+       m = re.match ('[.\n]*?<title>([.\n]*?)</title>', s)
+       if m:
+               fallback_web_title = m.group (1)
+       s = re.sub ('@WEB-TITLE@', fallback_web_title, s)
+       
+       s = remove_self_ref (s)
+
+       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)
+


_______________________________________________
Lilypond-cvs mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

--
=============================================
        Mats Bengtsson
        Signal Processing
        Signals, Sensors and Systems
        Royal Institute of Technology
        SE-100 44  STOCKHOLM
        Sweden
        Phone: (+46) 8 790 8463                         
        Fax:   (+46) 8 790 7260
        Email: address@hidden
        WWW: http://www.s3.kth.se/~mabe
=============================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]