From 0376b7e16e6906c3b66f07e3b92886b6f1048994 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 23 Mar 2024 16:28:38 +0100 Subject: [PATCH] web-user-interface: Move theme functions back into header.pl Since we no longer support other themes, the web UI should load quicker if not importing too many other files. Signed-off-by: Michael Tremer --- config/cfgroot/header.pl | 236 +++++++++++++++- config/rootfiles/common/web-user-interface | 1 - html/html/themes/ipfire/include/functions.pl | 267 ------------------- 3 files changed, 235 insertions(+), 269 deletions(-) delete mode 100644 html/html/themes/ipfire/include/functions.pl diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index 2d2d603764..7aaf6f94fc 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -142,7 +142,241 @@ my %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`; + +############################################################################### +# +# print menu html elements for submenu entries +# @param submenu entries +sub showsubmenu() { + my $submenus = shift; + + print "" +} + +############################################################################### +# +# print menu html elements +sub showmenu() { + print '
'; + + if ($settings{'SPEED'} ne 'off') { + print < + $Lang::tr{'traffic stat title'}: + $Lang::tr{'traffic stat in'} --.-- bit/s   + $Lang::tr{'traffic stat out'} --.-- bit/s +
+EOF + } + + print ""; +} + +############################################################################### +# +# print page opening html layout +# @param page title +# @param boh +# @param extra html code for html head section +# @param suppress menu option, can be numeric 1 or nothing. +# menu will be suppressed if param is 1 +sub openpage { + my $title = shift; + my $boh = shift; + my $extrahead = shift; + my $suppressMenu = shift // 0; + + my $headline = "IPFire"; + if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) { + $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}"; + } + +print < + + + $headline - $title + + + + + + $extrahead + +END + + +print "\n"; + + +if ($settings{'SPEED'} ne 'off') { +print < +END +; +} + +print < + + +END +; + +unless($suppressMenu) { + &genmenu(); + &showmenu(); +} + +print < +
+
+

$title

+END +; + +# Print user manual link +my $manual_url = &get_manualpage_url(); +if($manual_url) { + print <$Lang::tr{'online help en'} +END +; +} + +print < +END +; +} + +############################################################################### +# +# print page opening html layout without menu +# @param page title +# @param boh +# @param extra html code for html head section +sub openpagewithoutmenu { + openpage(shift,shift,shift,1); + return; +} + +############################################################################### +# +# print page closing html layout + +sub closepage () { + open(FILE, "; + $system_release =~ s/core/$Lang::tr{'core update'} /; + close(FILE); + +print < +
+ + + + +END +; +} + +############################################################################### +# +# print big box opening html layout +sub openbigbox { +} + +############################################################################### +# +# print big box closing html layout +sub closebigbox { +} + +############################################################################### +# +# print box opening html layout +# @param page width +# @param page align +# @param page caption +sub openbox { + $width = $_[0]; + $align = $_[1]; + $caption = $_[2]; + + if($align eq 'center') { + print "
\n" + } + else { + print "
\n"; + } + + if ($caption) { + print "

$caption

\n"; + } +} + +############################################################################### +# +# print box closing html layout +sub closebox { + print "
"; +} sub green_used() { if ($ethsettings{'GREEN_DEV'} && $ethsettings{'GREEN_DEV'} ne "") { diff --git a/config/rootfiles/common/web-user-interface b/config/rootfiles/common/web-user-interface index d2ef6ab103..7ec076d2d8 100644 --- a/config/rootfiles/common/web-user-interface +++ b/config/rootfiles/common/web-user-interface @@ -355,7 +355,6 @@ srv/web/ipfire/html/themes/ipfire/include/css/style.css srv/web/ipfire/html/themes/ipfire/include/fonts/Prompt-Bold.ttf srv/web/ipfire/html/themes/ipfire/include/fonts/Prompt-Medium.ttf srv/web/ipfire/html/themes/ipfire/include/fonts/Prompt-Regular.ttf -srv/web/ipfire/html/themes/ipfire/include/functions.pl srv/web/ipfire/html/themes/ipfire/include/js srv/web/ipfire/html/themes/ipfire/include/js/refreshInetInfo.js var/updatecache diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl deleted file mode 100644 index 5ea3f9fa77..0000000000 --- a/html/html/themes/ipfire/include/functions.pl +++ /dev/null @@ -1,267 +0,0 @@ -#!/usr/bin/perl -############################################################################### -# # -# IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -############################################################################### -# # -# Theme file for IPfire (based on ipfire theme) # -# Author kay-michael köhler kmk # -# # -# Version 1.0 March, 6th 2013 # -############################################################################### -# # -# Modyfied theme by a.marx@ipfire.org January 2014 # -# # -# Cleanup code, deleted unused code and rewrote the rest to get a new working # -# IPFire default theme. # -############################################################################### - -############################################################################### -# -# print menu html elements for submenu entries -# @param submenu entries -sub showsubmenu() { - my $submenus = shift; - - print "
    "; - foreach my $item (sort keys %$submenus) { - $link = getlink($submenus->{$item}); - next if (!is_menu_visible($link) or $link eq ''); - - my $subsubmenus = $submenus->{$item}->{'subMenu'}; - - if ($subsubmenus) { - print '
  • '; - } else { - print '
  • '; - } - print ''.$submenus->{$item}->{'caption'}.''; - - &showsubmenu($subsubmenus) if ($subsubmenus); - print '
  • '; - } - print "
" -} - -############################################################################### -# -# print menu html elements -sub showmenu() { - print '
'; - - if ($settings{'SPEED'} ne 'off') { - print < - $Lang::tr{'traffic stat title'}: - $Lang::tr{'traffic stat in'} --.-- bit/s   - $Lang::tr{'traffic stat out'} --.-- bit/s -
-EOF - } - - print "
    "; - foreach my $k1 ( sort keys %$menu ) { - $link = getlink($menu->{$k1}); - next if (!is_menu_visible($link) or $link eq ''); - print '
  • '.$menu->{$k1}->{'caption'}.''; - my $submenus = $menu->{$k1}->{'subMenu'}; - &showsubmenu($submenus) if ($submenus); - print "
  • "; - } - - print "
"; -} - -############################################################################### -# -# print page opening html layout -# @param page title -# @param boh -# @param extra html code for html head section -# @param suppress menu option, can be numeric 1 or nothing. -# menu will be suppressed if param is 1 -sub openpage { - my $title = shift; - my $boh = shift; - my $extrahead = shift; - my $suppressMenu = shift // 0; - - my $headline = "IPFire"; - if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) { - $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}"; - } - -print < - - - $headline - $title - - - - - - $extrahead - -END - - -print "\n"; - - -if ($settings{'SPEED'} ne 'off') { -print < -END -; -} - -print < - - -END -; - -unless($suppressMenu) { - &genmenu(); - &showmenu(); -} - -print < -
-
-

$title

-END -; - -# Print user manual link -my $manual_url = &Header::get_manualpage_url(); -if($manual_url) { - print <$Lang::tr{'online help en'} -END -; -} - -print < -END -; -} - -############################################################################### -# -# print page opening html layout without menu -# @param page title -# @param boh -# @param extra html code for html head section -sub openpagewithoutmenu { - openpage(shift,shift,shift,1); - return; -} - -############################################################################### -# -# print page closing html layout - -sub closepage () { - open(FILE, "; - $system_release =~ s/core/$Lang::tr{'core update'} /; - close(FILE); - -print < -
- - - - -END -; -} - -############################################################################### -# -# print big box opening html layout -sub openbigbox { -} - -############################################################################### -# -# print big box closing html layout -sub closebigbox { -} - -############################################################################### -# -# print box opening html layout -# @param page width -# @param page align -# @param page caption -sub openbox { - $width = $_[0]; - $align = $_[1]; - $caption = $_[2]; - - if($align eq 'center') { - print "
\n" - } - else { - print "
\n"; - } - - if ($caption) { - print "

$caption

\n"; - } -} - -############################################################################### -# -# print box closing html layout -sub closebox { - print "
"; -} -- 2.39.5