[pve-devel] [PATCH manager 3/4] use Template::Toolkit instead of [ExtJs|Touch|NoVnc]Index.pm
Dominik Csapak
d.csapak at proxmox.com
Tue Mar 7 11:18:22 CET 2017
this makes it easier to change the html if needed and seperates
it from the perl code
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/Service/pveproxy.pm | 36 +++++++++++++++++++++++++++---------
debian/control.in | 2 +-
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index 98e3647..3ca84fe 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -18,9 +18,7 @@ use PVE::APIServer::Formatter::HTML;
use PVE::APIServer::AnyEvent;
use PVE::HTTPServer;
-use PVE::ExtJSIndex;
-use PVE::NoVncIndex;
-use PVE::TouchIndex;
+use Template;
use PVE::Tools;
@@ -192,16 +190,36 @@ sub get_index {
$mobile = $args->{mobile} ? 1 : 0;
}
- my $page;
+ my $page = '';
+ my $template = Template->new({ABSOLUTE => 1});
+
+ my $langfile = 0;
+
+ if (-f "$basedirs->{manager}/locale/pve-lang-$lang.js") {
+ $langfile = 1;
+ }
+
+ my $vars = {
+ lang => $lang,
+ langfile => $langfile,
+ username => $username,
+ token => $token,
+ console => $args->{console},
+ nodename => $nodename,
+ debug => $server->{debug},
+ };
+
+ # by default, load the normal index
+ my $dir = $basedirs->{manager};
if (defined($args->{console}) && $args->{novnc}) {
- $page = PVE::NoVncIndex::get_index($lang, $username, $token, $args->{console}, $nodename);
+ $dir = $basedirs->{novnc};
} elsif ($mobile) {
- $page = PVE::TouchIndex::get_index($lang, $username, $token, $args->{console}, $nodename);
- } else {
- $page = PVE::ExtJSIndex::get_index($lang, $username, $token, $args->{console}, $nodename,
- $server->{debug});
+ $dir = "$basedirs->{manager}/touch";
}
+
+ $template->process("$dir/index.html.tpl", $vars, \$page)
+ || die $template->error(), "\n";
my $headers = HTTP::Headers->new(Content_Type => "text/html; charset=utf-8");
my $resp = HTTP::Response->new(200, "OK", $headers, $page);
diff --git a/debian/control.in b/debian/control.in
index e159de2..091aa67 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -3,7 +3,7 @@ Version: @VERSION at -@PACKAGERELEASE@
Section: admin
Priority: optional
Architecture: amd64
-Depends: perl (>= 5.10.0-19), libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, ifenslave (>= 2.6), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control (>= 3.0-2), libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libpve-http-server-perl, liburi-perl, logrotate, apt-transport-https, ca-certificates, libapt-pkg-perl, libcrypt-ssleay-perl, liblwp-protocol-https-perl, spiceterm, libuuid-perl, hdparm, gdisk, librados2-perl, pve-firewall, novnc-pve, libev-perl, systemd, pve-ha-manager, pve-container, pve-docs, libjs-extjs (>= 6.0.1)
+Depends: perl (>= 5.10.0-19), libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, ifenslave (>= 2.6), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control (>= 3.0-2), libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libpve-http-server-perl, liburi-perl, logrotate, apt-transport-https, ca-certificates, libapt-pkg-perl, libcrypt-ssleay-perl, liblwp-protocol-https-perl, spiceterm, libuuid-perl, hdparm, gdisk, librados2-perl, pve-firewall, novnc-pve, libev-perl, systemd, pve-ha-manager, pve-container, pve-docs, libjs-extjs (>= 6.0.1), libtemplate-perl
Build-Depends: liblocale-po-perl
Conflicts: netcat-openbsd, vzdump, vlan
Replaces: vzdump, vlan
--
2.1.4
More information about the pve-devel
mailing list