]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
webinterface: Add links to the configuration wiki
authorLeo-Andres Hofmann <hofmann@leo-andres.de>
Tue, 28 Sep 2021 11:09:04 +0000 (13:09 +0200)
committerPeter Müller <peter.mueller@ipfire.org>
Fri, 19 Nov 2021 06:18:20 +0000 (07:18 +0100)
This patch adds a little "help" icon to the page header.
If a manual entry exists for a configuration page, the icon
appears and offers a quick way to access the wiki.
Wiki pages can be configured in the "manualpages" file.

Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Tested-by: Bernhard Bitsch <bbitsch@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/header.pl
config/cfgroot/manualpages [new file with mode: 0644]
html/html/themes/ipfire/include/css/style.css
html/html/themes/ipfire/include/functions.pl

index 79accbe8a28aa3746c1bb66fa494ebc56eefc2c8..e97f90d67a8afa5cc99d8727751862f6d4824fa3 100644 (file)
@@ -91,7 +91,11 @@ if ( -d "/var/ipfire/langs/${language}/" ) {
     };
 };
 
+### Initialize user manual
+my %manualpages = ();
+&General::readhash("${General::swroot}/main/manualpages", \%manualpages);
 
+### Load selected language and theme functions
 require "${swroot}/langs/en.pl";
 require "${swroot}/langs/${language}.pl";
 eval `/bin/cat /srv/web/ipfire/html/themes/ipfire/include/functions.pl`;
@@ -553,3 +557,19 @@ sub colorize {
                return $string;
        }
 }
+
+# Get user manual URL for the specified configuration page, returns empty if no entry is configured
+sub get_manualpage_url() {
+       my ($cgi_page) = @_;
+
+       # Ensure base url is configured
+       return unless($manualpages{'BASE_URL'});
+
+       # Return URL
+       if($cgi_page && defined($manualpages{$cgi_page})) {
+               return "$manualpages{'BASE_URL'}/$manualpages{$cgi_page}";
+       }
+
+       # No manual page configured, return nothing
+       return;
+}
diff --git a/config/cfgroot/manualpages b/config/cfgroot/manualpages
new file mode 100644 (file)
index 0000000..e5ab1a1
--- /dev/null
@@ -0,0 +1,7 @@
+# User manual base URL (without trailing slash)
+BASE_URL=https://wiki.ipfire.org
+
+# Assign manual page URL path to CGI file ([cgi basename]=[path/to/page])
+index=configuration/system/startpage
+pppsetup=configuration/system/dial
+qos=configuration/services/qos
index b92f476c4f15bd711fdc901370a58c22908ab1f1..661773675d64cd681ab2edb798705ad3c191de54 100644 (file)
@@ -169,6 +169,19 @@ iframe {
        margin-bottom: 1em;
 }
 
+#main_header > * {
+       display: inline-block;
+       vertical-align: baseline;
+}
+
+#main_header > span {
+       margin-left: 0.8em;
+}
+
+#main_header img {
+       padding: 0;
+}
+
 #footer {
        height: 2.5em;
        margin-bottom: 1em;
index 9f12bbe5907a6861f9e2c685fb3184e153e01176..18931428ec71b9d0768c6cd4d6e01ecd5d734fa3 100644 (file)
@@ -170,7 +170,22 @@ END
 print <<END
        <div class="bigbox fixed">
                <div id="main_inner" class="fixed">
-                       <h1>$title</h1>
+                       <div id="main_header">
+                               <h1>$title</h1>
+END
+;
+
+# Print user manual link
+my $manual_url = &Header::get_manualpage_url($scriptName);
+if($manual_url) {
+       print <<END
+                               <span><a href="$manual_url" title="$Lang::tr{'online help en'}" target="_blank"><img src="/images/help-browser.png" alt="$Lang::tr{'online help en'}"></a></span>
+END
+;
+}
+
+print <<END
+                       </div>
 END
 ;
 }