From 65018e0569e4d663ba64a261f4915a112961b499 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Thu, 4 Mar 2010 18:34:22 +0000 Subject: [PATCH] Build: rewrite hrefs to stay on translation pages. 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 | 49 +++++++++++++++++++++++++++++++++++++++ website.make | 9 +++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 scripts/build/web_post.py diff --git a/scripts/build/web_post.py b/scripts/build/web_post.py new file mode 100644 index 0000000000..20a3bdb3d6 --- /dev/null +++ b/scripts/build/web_post.py @@ -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() + diff --git a/website.make b/website.make index 3170bc6f6a..a431d50550 100644 --- a/website.make +++ b/website.make @@ -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/ + -- 2.39.5