Please find attached the missing patch file.

My excuses.

El jue., 23 jul. 2020 a las 16:09, Fioddor Superconcentrado (<
[email protected]>) escribió:

> Hi all.
> Following instructions of the wiki
> <https://wiki.debian.org/FreedomBox/Contribute/Code> I send attached a
> patch for issue #1908
> <https://salsa.debian.org/freedombox-team/freedombox/-/issues/1908> for
> review.
> Best regards
>
From 8a82136aee358479bec268a83c7f74d8ba7592b7 Mon Sep 17 00:00:00 2001
From: Fioddor Superconcentrado <[email protected]>
Date: Thu, 23 Jul 2020 15:38:16 +0200
Subject: [PATCH] post-processor: Solve 1908 fixing the wiki links fix

The previous logic of the wiki links fix didn't work for translated pages.

Signed-off-by: Fioddor Superconcentrado <[email protected]>
---
 doc/scripts/post-processor | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/doc/scripts/post-processor b/doc/scripts/post-processor
index a97be25d..99d3aa5e 100755
--- a/doc/scripts/post-processor
+++ b/doc/scripts/post-processor
@@ -23,14 +23,24 @@ def parse_arguments():
 
 
 def subcommand_fix_wiki_urls(arguments):
-    file_name = arguments.filename
+    """ Rebase the wiki urls.
+    
+    The base for relative links in Debian wiki is the wiki's URL but our
+    extraction process rebases the relative links to the page containing
+    the link. This function fixes that.
+    """
+    WIKI_URL = 'https://wiki.debian.org' 
+    bah, lang, file_name = arguments.filename.split('/')
     page_name = file_name.split('.')[0]
 
-    with open(file_name, 'r') as xml_file:
+    with open(arguments.filename, 'r') as xml_file:
         lines = xml_file.readlines()
 
-    pattern = f'FreedomBox/Manual/{page_name}/FreedomBox'
-    lines = list(map(lambda s: s.replace(pattern, 'FreedomBox'), lines))
+    if 'en' == lang:
+        pattern = f'{WIKI_URL}/FreedomBox/Manual/{page_name}'
+    else:
+        pattern = f'{WIKI_URL}/{lang}/FreedomBox/Manual/{page_name}'
+    lines = list(map(lambda s: s.replace(pattern, f'{WIKI_URL}'), lines))
 
     with open(file_name, 'w') as xml_file:
         xml_file.writelines(lines)
-- 
2.27.0

_______________________________________________
Freedombox-discuss mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/freedombox-discuss

Reply via email to