]> git.donarmstrong.com Git - lilypond.git/commitdiff
Web build: add footer for language selection.
authorGraham Percival <graham@percival-music.ca>
Thu, 4 Mar 2010 20:54:18 +0000 (20:54 +0000)
committerGraham Percival <graham@percival-music.ca>
Thu, 4 Mar 2010 20:54:18 +0000 (20:54 +0000)
Documentation/contributor/website-work.itexi
scripts/build/web_post.py [deleted file]
scripts/build/website_post.py [new file with mode: 0644]
website.make

index b27d9bbf062d21df1a6f1e4e6b3a7e8ed8f7ab99..14b6b301b02ed84842fcbe4ea3b880c797dadb22 100644 (file)
@@ -80,7 +80,7 @@ diff -u $DEST/extract_texi_filenames.py $GIT/scripts/build/extract_texi_filename
 diff -u $DEST/create-version-itexi.py $GIT/scripts/build/create-version-itexi.py
 diff -u $DEST/create-weblinks-itexi.py $GIT/scripts/build/create-weblinks-itexi.py
 diff -u $DEST/mass-link.py $GIT/scripts/build/mass-link.py
-diff -u $DEST/web_post.py $GIT/scripts/build/web_post.py
+diff -u $DEST/website_post.py $GIT/scripts/build/website_post.py
 @end verbatim
 
 If the changes look ok, make them trusted:
@@ -96,7 +96,7 @@ cp $GIT/scripts/build/extract_texi_filenames.py $DEST/extract_texi_filenames.py
 cp $GIT/scripts/build/create-version-itexi.py $DEST/create-version-itexi.py
 cp $GIT/scripts/build/create-weblinks-itexi.py $DEST/create-weblinks-itexi.py
 cp $GIT/scripts/build/mass-link.py $DEST/mass-link.py
-cp $GIT/scripts/build/web_post.py $DEST/web_post.py
+cp $GIT/scripts/build/website_post.py $DEST/website_post.py
 @end verbatim
 
 Build the website:
diff --git a/scripts/build/web_post.py b/scripts/build/web_post.py
deleted file mode 100644 (file)
index 20a3bdb..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#!@PYTHON@
-
-## This is web_post.py. This script deals with translations
-## in the "make website" target.
-
-import sys
-import os
-import glob
-
-#indir, outdir = sys.argv[1:]
-
-# FIXME: looks dangerous!
-indir = sys.argv[1]
-outdir=indir
-
-html_files = glob.glob( os.path.join(indir, '*.html') )
-
-
-for file in html_files:
-       file_split = file.split('.')
-       # we want to strip the .html
-       out_filename = os.path.basename(file_split[0])
-       if (len(file_split) == 2):
-               # it's English
-               lang = ''
-       else:
-               # it's a translation
-               lang = file_split[1]
-       out_filename += '.'+lang
-
-# I can't get the previous name to work
-       out_filename = os.path.basename(file)
-
-       # translation links should point to translations
-       lines = open(file).readlines()
-       # ick
-       os.remove(file)
-
-       outfile = open( os.path.join(outdir, out_filename), 'w')
-       for line in lines:
-               # avoid external links
-               if ((line.find("href") > 0) and (line.find("http")==-1)):
-# eventually we want to do this, but I can't get it to work.
-# waiting for help with apache (?)
-#                      line = line.replace(".html", "."+lang)
-                       line = line.replace(".html", "."+lang+".html")
-               outfile.write(line)
-       outfile.close()
-
diff --git a/scripts/build/website_post.py b/scripts/build/website_post.py
new file mode 100644 (file)
index 0000000..8018f3a
--- /dev/null
@@ -0,0 +1,96 @@
+#!@PYTHON@
+#-*- coding: utf-8 -*-
+
+## This is web_post.py. This script deals with translations
+## in the "make website" target.
+
+import sys
+import os
+import glob
+
+lang_lookup = {
+  'fr': 'français',
+  'es': 'español',
+  '': 'english'
+}
+
+#indir, outdir = sys.argv[1:]
+
+# FIXME: looks dangerous!
+indir = sys.argv[1]
+outdir=indir
+
+html_files = glob.glob( os.path.join(indir, '*.html') )
+
+# messy way to get all languages
+langs_set = set()
+for file in html_files:
+       file_split = file.split('.')
+       if (len(file_split) == 2):
+               # it's English
+               lang = ''
+       else:
+               # it's a translation
+               lang = file_split[1]
+       langs_set.add(lang)
+langs = list(langs_set)
+langs.sort()
+
+def makeFooter(currentLang):
+       text = "<p id=\"languages\">\n"
+       text += "Other languages: "
+       for i in range(len(langs)):
+               l = langs[i]
+               if (l == currentLang):
+                       continue
+               text += "<a href=\"index"
+               if (not (l=='')):
+                       text += "." + l
+               text += ".html\">"
+               text += lang_lookup[l]
+               text += "</a>"
+               if (i < len(langs)-2):
+                       text += ", "
+               else:
+                       text += ".\n"
+       # TODO: add link to automatic language selection?
+       # still need to include this page in the new webpages somewhere
+       text += "</p>\n"
+       return text
+
+
+for file in html_files:
+       file_split = file.split('.')
+       # we want to strip the .html
+       out_filename = os.path.basename(file_split[0])
+       if (len(file_split) == 2):
+               # it's English
+               lang = ''
+       else:
+               # it's a translation
+               lang = file_split[1]
+       out_filename += '.'+lang
+
+# I can't get the previous name to work
+       out_filename = os.path.basename(file)
+
+       # translation links should point to translations
+       lines = open(file).readlines()
+       # ick
+       os.remove(file)
+
+       lang_footer = makeFooter(lang)
+       
+       outfile = open( os.path.join(outdir, out_filename), 'w')
+       for line in lines:
+               # avoid external links
+               if ((line.find("href") >= 0) and (line.find("http")==-1)):
+# eventually we want to do this, but I can't get it to work.
+# waiting for help with apache (?)
+#                      line = line.replace(".html", "."+lang)
+                       line = line.replace(".html", "."+lang+".html")
+               if (line.find("<!-- FOOTER -->") >= 0):
+                       outfile.write( lang_footer )
+               outfile.write(line)
+       outfile.close()
+
index a431d50550c868edaf755ed8ab70facb3e0e1286..465757862073fbb97a870d0bb0e585de2b816131 100644 (file)
@@ -36,7 +36,7 @@ EXTRACT_TEXI_FILENAMES=python $(script-dir)/extract_texi_filenames.py
 CREATE_VERSION=python $(script-dir)/create-version-itexi.py
 CREATE_WEBLINKS=python $(script-dir)/create-weblinks-itexi.py
 MASS_LINK=python $(script-dir)/mass-link.py
-WEB_POST=python $(script-dir)/web_post.py
+WEB_POST=python $(script-dir)/website_post.py
 
 SERVER_FILES=$(top-src-dir)/Documentation/web/server/