gnucash-htdocs beta: Adjust help document loading to accomodate ghelp2help changes in gnucash-docs

Geert Janssens gjanssens at code.gnucash.org
Sat Aug 13 09:46:19 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash-htdocs/commit/8b93f2e3 (commit)
	from  https://github.com/Gnucash/gnucash-htdocs/commit/0489c962 (commit)



commit 8b93f2e39d7275ee1bb846e35b00540b5c62f3ca
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Aug 13 15:44:28 2022 +0200

    Adjust help document loading to accomodate ghelp2help changes in gnucash-docs
    
    The issue to deal with is that the help manual's main page gets renamed from help.html to index.html.
    But only for documentation from gnucash 5 and up.
    To handle this, delay document selection until after version selection.
    Use the version selection to set the proper name for the main page.

diff --git a/viewdoc.phtml b/viewdoc.phtml
index c37bca0..da2b093 100644
--- a/viewdoc.phtml
+++ b/viewdoc.phtml
@@ -13,7 +13,7 @@ include("externals/menu.phtml");
 
 # Some base parameters used later on
 $basepath       = \DEFAULT_URL."docs";
-$helpdoc        = "gnucash-help/help.html";
+$helpdoc        = "gnucash-help/index.html";
 $tcdoc          = "gnucash-guide/index.html";
 $current_stable = $major_stable;
 
@@ -32,23 +32,6 @@ if (in_array($get_lang, $doc_languages, true)) {
     $showlang = $locale;
 }
 
-
-# Parse requested document
-$doc_to_show = filter_input(INPUT_GET, 'doc', FILTER_SANITIZE_STRING);
-if ($doc_to_show) {
-    switch ($doc_to_show) {
-        case "help":
-            $showdoc = $helpdoc;
-            break;
-        case "guide":
-            $showdoc = $tcdoc;
-            break;
-        default:  /* unknown document requested, will present guide by default */
-            $req_doc_ok = false;
-            break;
-    }
-}
-
 # Parse requested version
 $rev_to_show = filter_input(INPUT_GET, 'rev', FILTER_SANITIZE_STRING);
 if ($rev_to_show) {
@@ -87,6 +70,40 @@ if ($rev_to_show) {
             $req_rev_ok = false;
             break;
     }
+
+    # Adjust name of gnucash-help start page for older versions
+    switch ($rev_to_show) {
+        case "1.8":
+        case "2.0":
+        case "2.2":
+        case "2.4":
+        case "2.6":
+        case "3":
+        case "4":
+        # Once gnucash 5 is out, the three cases below should be removed from the switch statement
+        case "current":
+        case "maint":
+        case "nightly":
+            $helpdoc = "gnucash-help/help.html";
+            break;
+    }
+}
+
+
+# Parse requested document
+$doc_to_show = filter_input(INPUT_GET, 'doc', FILTER_SANITIZE_STRING);
+if ($doc_to_show) {
+    switch ($doc_to_show) {
+        case "help":
+            $showdoc = $helpdoc;
+            break;
+        case "guide":
+            $showdoc = $tcdoc;
+            break;
+        default:  /* unknown document requested, will present guide by default */
+            $req_doc_ok = false;
+            break;
+    }
 }
 # Now check if the requested combination of doc, revision and language actually exists
 # If not, try the default C locale instead.



Summary of changes:
 viewdoc.phtml | 53 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 18 deletions(-)



More information about the gnucash-changes mailing list