]> git.donarmstrong.com Git - lilypond.git/commitdiff
Build: rewrite hrefs to stay on translation pages.
authorGraham Percival <graham@percival-music.ca>
Thu, 4 Mar 2010 18:34:22 +0000 (18:34 +0000)
committerGraham Percival <graham@percival-music.ca>
Thu, 4 Mar 2010 18:34:22 +0000 (18:34 +0000)
I couldn't make head or tails out of the current www rewriting
python scripts, so I'm starting from scratch.

scripts/build/web_post.py [new file with mode: 0644]
website.make

diff --git a/scripts/build/web_post.py b/scripts/build/web_post.py
new file mode 100644 (file)
index 0000000..20a3bdb
--- /dev/null
@@ -0,0 +1,49 @@
+#!@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()
+
index 3170bc6f6a68afe8dfdf0b78db5d6b52f0e0b05e..a431d50550c868edaf755ed8ab70facb3e0e1286 100644 (file)
@@ -27,7 +27,7 @@ endif
 
 ################################################################
 OUT=out-website
-WEB_LANGS=es fr
+WEB_LANGS=es
 
 
 TEXI2HTML=ONLY_WEB=1 TOP_SRC_DIR=$(top-src-dir) DEPTH=$(depth) PERL_UNICODE=SD $(TEXI2HTML_PROGRAM)
@@ -36,6 +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
 
 SERVER_FILES=$(top-src-dir)/Documentation/web/server/
 
@@ -104,8 +105,12 @@ website-examples:
        mkdir -p $(OUT)/website/ly-examples
        cp $(EXAMPLES)/* $(OUT)/website/ly-examples
 
-website: website-texinfo website-css website-pictures website-examples
+web-post:
+       $(WEB_POST) $(OUT)/website/
+
+website: website-texinfo website-css website-pictures website-examples web-post
        cp $(SERVER_FILES)/favicon.ico $(OUT)/website/
        cp $(SERVER_FILES)/lilypond.org.htaccess $(OUT)/website/.htaccess
        cp $(SERVER_FILES)/robots.txt $(OUT)/website/
 
+