From mboxrd@z Thu Jan  1 00:00:00 1970
From: Bernhard Bitsch <bbitsch@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] webinterface: Add links to the configuration wiki
Date: Sun, 19 Sep 2021 19:35:33 +0200
Message-ID: <e4596f30-a0bd-2008-d72c-9f3500af5786@ipfire.org>
In-Reply-To: <20210919143444.1739-1-hofmann@leo-andres.de>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============1152044300745662208=="
List-Id: <development.lists.ipfire.org>

--===============1152044300745662208==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Reviewed-by: Bernhard Bitsch <bbitsch(a)ipfire.org>


Am 19.09.2021 um 16:34 schrieb Leo-Andres Hofmann:
> 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.
>=20
> Signed-off-by: Leo-Andres Hofmann <hofmann(a)leo-andres.de>
> ---
>=20
> Hi all,
>=20
> This patch is not yet complete, but I would like to present the idea.
> What do you think, would this get more people to read the wiki?
>=20
> To test this, move the new file "manualpages" to /var/ipfire/main/ and CTRL=
+F5 reload the webif to refresh the CSS cache.
>=20
> Still -to do- and where I could use some help:
> Add "manualpages" file to the updater/installer - how, and should this file=
 be read-only?
> Collect and match all wiki pages to the CGIs.
>=20
> Kind regards
> Leo
>=20
>   config/cfgroot/general-functions.pl           | 18 +++++++++++++++++-
>   config/cfgroot/manualpages                    |  3 +++
>   html/html/themes/ipfire/include/css/style.css | 13 +++++++++++++
>   html/html/themes/ipfire/include/functions.pl  | 17 ++++++++++++++++-
>   4 files changed, 49 insertions(+), 2 deletions(-)
>   create mode 100644 config/cfgroot/manualpages
>=20
> diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-f=
unctions.pl
> index de608e38b..54e23a535 100644
> --- a/config/cfgroot/general-functions.pl
> +++ b/config/cfgroot/general-functions.pl
> @@ -24,7 +24,9 @@ $|=3D1; # line buffering
>   $General::version =3D 'VERSION';
>   $General::swroot =3D 'CONFIG_ROOT';
>   $General::noipprefix =3D 'noipg-';
> -$General::adminmanualurl =3D 'http://wiki.ipfire.org';

A quick search shows, that this object isn't used anymore. So it is=20
okay, to delete it.

> +
> +# Base URL of the user manual
> +my $usermanual_base_url =3D 'https://wiki.ipfire.org';
>  =20
>   require "${General::swroot}/network-functions.pl";
>  =20
> @@ -1421,4 +1423,18 @@ sub running_on_gcp() {
>   	return 0;
>   }
>  =20
> +# Get user manual url for the specified configuration page, returns "" if =
no entry is configured
> +sub get_usermanual_url() {
> +	my ($config_page) =3D @_;
> +
> +	my %manual_pages =3D ();
> +	&readhash("${General::swroot}/main/manualpages", \%manual_pages);
> +
> +	if($config_page && defined($manual_pages{$config_page})) {
> +		return $usermanual_base_url . '/' . $manual_pages{$config_page};
> +	}
> +
> +	return "";
> +}
> +
>   1;
> diff --git a/config/cfgroot/manualpages b/config/cfgroot/manualpages
> new file mode 100644
> index 000000000..02dac5be6
> --- /dev/null
> +++ b/config/cfgroot/manualpages
> @@ -0,0 +1,3 @@
> +index=3Dconfiguration/system/startpage
> +pppsetup=3Dconfiguration/system/dial
> +qos=3Dconfiguration/services/qos
> diff --git a/html/html/themes/ipfire/include/css/style.css b/html/html/them=
es/ipfire/include/css/style.css
> index b92f476c4..661773675 100644
> --- a/html/html/themes/ipfire/include/css/style.css
> +++ b/html/html/themes/ipfire/include/css/style.css
> @@ -169,6 +169,19 @@ iframe {
>   	margin-bottom: 1em;
>   }
>  =20
> +#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;
> diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/theme=
s/ipfire/include/functions.pl
> index 9f12bbe59..d352a7d96 100644
> --- a/html/html/themes/ipfire/include/functions.pl
> +++ b/html/html/themes/ipfire/include/functions.pl
> @@ -170,7 +170,22 @@ END
>   print <<END
>   	<div class=3D"bigbox fixed">
>   		<div id=3D"main_inner" class=3D"fixed">
> -			<h1>$title</h1>
> +			<div id=3D"main_header">
> +				<h1>$title</h1>
> +END
> +;
> +
> +# Print user manual link
> +my $manual_url =3D &General::get_usermanual_url($scriptName);
> +if($manual_url ne "") {
> +	print <<END
> +				<span><a href=3D"$manual_url" title=3D"$Lang::tr{'online help en'}" ta=
rget=3D"_blank"><img src=3D"/images/help-browser.png" alt=3D"$Lang::tr{'onlin=
e help en'}"></a></span>
> +END
> +;
> +}
> +
> +print <<END
> +			</div>
>   END
>   ;
>   }
>=20

--===============1152044300745662208==--