From eed73392fab2c8be17372c8459090f90cf2a16a5 Mon Sep 17 00:00:00 2001 From: MrHeadwar Date: Thu, 10 Nov 2022 15:13:11 +0100 Subject: [PATCH] Update the build system to easily fix broken links --- README.md | 9 ++++++++- build.py | 25 +++++++++++++++++++++++++ uri_to_fix.txt | 48 +++++++++++++++++++++--------------------------- 3 files changed, 54 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index b98b033..8427cab 100644 --- a/README.md +++ b/README.md @@ -117,4 +117,11 @@ The `build.py` script that builds the manual accepts the following options: - '-q', or '--quiet', to suppress all output (overrides -v) - '-d', or '--devmode', to add content to pages to help developers debug them (link, file name, URL) -- '-n', or '--nopdf', to prevent the build script from generate a PDF from the content +- '-p', or '--pdf', to automatically generate a PDF from the content + +### Redirects + +the uri_to_fix.txt file is a structured file that is read at build time +to generate redirects HTML pages, and avoid dead links when a page is moved +or removed. The syntax is old/and/obsolete/uri | @@link, reusing the 'link' +keyword of the master document. diff --git a/build.py b/build.py index fdead7e..0e0bf44 100755 --- a/build.py +++ b/build.py @@ -30,6 +30,7 @@ global_master_doc = 'master-doc.txt' global_pdflink = '' from datetime import datetime global_today = datetime.today().strftime('%Y-%m-%d') +global_redirects_file = 'uri_to_fix.txt' # This matches all *non* letter/number, ' ', '.', '-', and '_' chars cleanString = re.compile(r'[^a-zA-Z0-9 \._-]+') @@ -728,6 +729,30 @@ if pdf: doc = HTML(string = pdfpage, base_url = global_site_dir) doc.write_pdf(global_site_dir + 'manual.pdf', font_config = html_font_config) +# URI redirects +if os.path.exists(global_redirects_file): + with open(global_redirects_file) as f: + cpt = 0; + for line in f: + line = line.strip(); + if line == '': + continue #empty line + if line.startswith('//'): + continue #comment + params = line.split('|'); + params[0] = params[0].strip(' \t/') + params[1] = params[1].strip(' \t') + # write an HTML the file with a refresh redirect + os.makedirs(global_site_dir + params[0], 0o775, exist_ok=True) + destFile = open(global_site_dir + params[0] + '/index.html', 'w') + newlink = FixInternalLinks(links, '"'+params[1]+'"', global_redirects_file) + newlink = newlink.strip('"') + page = '

The page has moved to:this page

' + destFile.write(page) + destFile.close() +if noisy: + print('Generated ' + str(cpt) + ' redirection files.') + if noisy: print('Processed ' + str(fileCount) + ' files.') diff --git a/uri_to_fix.txt b/uri_to_fix.txt index 2c56c58..d038cd1 100644 --- a/uri_to_fix.txt +++ b/uri_to_fix.txt @@ -1,27 +1,21 @@ -URLs that are currently 404 (Feb/14) -- add 301 redirects or re-instantiate the old URI - -MUST fix: - -... - - -Should fix: - -[FIXED?] http://www.manual.ardour.org/ardours-interface/using-ardour-clock-displays/ -> ardours-interface/transport-clocks - - -Maybe fix: - -http://www.manual.ardour.org/editing-and-arranging/creating-regionfades-and-crossfades/ -http://www.manual.ardour.org/editing-and-arranging/editing-midi/midi_region_cloning/ -http://www.manual.ardour.org/editing-and-arranging/editing-midi/changing-note-properties/ -http://www.manual.ardour.org/editing-and-arranging/editing-midi/quantizing-midi/ -http://www.manual.ardour.org/working-with-plugins/the-processor-box/ -http://www.manual.ardour.org/ardours-interface/basic-gui-operations/selection-techniques/ -http://www.manual.ardour.org/ardours-interface/basic-gui-operations/using-the-mouse/ -http://www.manual.ardour.org/ardours-interface/introducing-the-editor-window/the-editing-toolbar/ -http://www.manual.ardour.org/ardours-interface/introducing-the-editor-window/the-transport-bar/ -http://www.manual.ardour.org/working-with-markers/getting-to-know-the-rangesmarks-list/ -http://www.manual.ardour.org/working-with-markers/the-punch-range/ -http://www.manual.ardour.org/signal-routing/role-of-jack/ -http://www.manual.ardour.org/editing-and-arranging/move-regions/move-regions-with-the-mouse +// URLs that are currently 404 (Feb/14) -- add 301 redirects or re-instantiate the old URI +// +// These URIs are no longer relevant, and are redirected by a meta refresh +// +// format : old/URI/to/replace |@@link (cf master-donc.txt) +// +default-keyboard-bindings/mnemonic-bindings-for-os-x/ |@@default-shortcuts +default-keyboard-bindings/mnemonic-bindings-for-linux/ |@@default-shortcuts +introduction-to-ardour/keyboard-and-mouse-shortcuts/ |@@keyboard-shortcuts +editing-and-arranging/creating-regionfades-and-crossfades/ |@@create-region-fades-and-crossfades +editing-and-arranging/editing-midi/midi_region_cloning/ |@@independent-and-dependent-midi-region-copies +editing-and-arranging/editing-midi/quantizing-midi/ |@@quantize-midi +working-with-plugins/the-processor-box/ |@@audiomidi-mixer-strips#audio-midi-processor-box +ardours-interface/basic-gui-operations/selection-techniques/ |@@using-the-mouse +ardours-interface/basic-gui-operations/using-the-mouse/ |@@using-the-mouse +ardours-interface/introducing-the-editor-window/the-editing-toolbar/ |@@toolbox +ardours-interface/introducing-the-editor-window/the-transport-bar/ |@@transport-bar +working-with-markers/getting-to-know-the-rangesmarks-list/ |@@the-ranges-and-marks-lists +working-with-markers/the-punch-range/ |@@selection-and-punch-clocks +signal-routing/role-of-jack/ |@@starting-ardour +editing-and-arranging/move-regions/move-regions-with-the-mouse |@@move-regions-with-the-mouse