From 0edb99b36632d8fd9363ad604b5ba5d5a5d65421 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Fri, 11 Oct 2024 14:59:39 +0300 Subject: [PATCH] =?UTF-8?q?Correct=20broken=20URLs=E2=80=99=20base=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Did not happen when the site was hosted directly on its domain root. One possible advantage of this bug is that it seems the FAQ individual pages look better without the extra CSS rules. https://www.amazon.com/Fortune-Failure-Missed-Opportunities-Discoveries/dp/0631160876 "fortune or failure" --- .../Tests/content-script-tag-hyperlinks.py | 22 ++++++++++++++++--- .../wml/lib/split-html/faq_splitter_prog.py | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/fc-solve/site/wml/Tests/content-script-tag-hyperlinks.py b/fc-solve/site/wml/Tests/content-script-tag-hyperlinks.py index 731dc23e0..5f351d32a 100644 --- a/fc-solve/site/wml/Tests/content-script-tag-hyperlinks.py +++ b/fc-solve/site/wml/Tests/content-script-tag-hyperlinks.py @@ -12,9 +12,6 @@ class MyTests(unittest.TestCase): def test_main(self): - def _count_jquery_ui(root): - return len(root.xpath( - ".//script[contains(@src, 'js/jquery-ui/jquery-ui.min.js')]")) input_fn = './dest/js-fc-solve/text/index.html' with open(input_fn, "rb") as fh: root = etree.HTML(fh.read()) @@ -31,6 +28,25 @@ def _count_jquery_ui(root): [], "all are ok") + def test_individual_faq_pages(self): + input_fn = './dest/faq-indiv-nodes/a_move_seems_wrong.xhtml' + with open(input_fn, "rb") as fh: + root = etree.HTML(fh.read()) + matches = root.xpath( + ".//link[ @rel = 'stylesheet' and @media = 'screen' and @href]" + ) + filtered = [] + for x in matches: + m = re.match('^((?:\\.\\./)*style.css)\\Z', x.get('href')) + if m: + filtered.append(m.group(1)) + + self.assertTrue(len(filtered), "matches") + self.assertEqual( + [x for x in filtered if re.match('\\.\\./\\.\\./', x)], + [], + "all are ok") + if __name__ == '__main__': from pycotap import TAPTestRunner diff --git a/fc-solve/site/wml/lib/split-html/faq_splitter_prog.py b/fc-solve/site/wml/lib/split-html/faq_splitter_prog.py index 31e3f919c..b0476bb09 100644 --- a/fc-solve/site/wml/lib/split-html/faq_splitter_prog.py +++ b/fc-solve/site/wml/lib/split-html/faq_splitter_prog.py @@ -129,6 +129,7 @@ def _faq_gen(dest_dir): splitter = XhtmlSplitter( **COMMON_TITLE_CALLBACKS, back_to_source_page_css_class=BACK_TO_SOURCE_PAGE_CSS_CLASS, + base_path="../", individual_node_css_class=INDIVIDUAL_NODE_CSS_CLASS, input_fn=input_fn, output_dirname=OUT_DN,