diff --git a/Netdisco/lib/Netdisco/Web.pm b/Netdisco/lib/Netdisco/Web.pm index 08c82c82..88353072 100644 --- a/Netdisco/lib/Netdisco/Web.pm +++ b/Netdisco/lib/Netdisco/Web.pm @@ -11,6 +11,11 @@ use Netdisco::Web::AuthN; use Netdisco::Web::Search; use Netdisco::Web::Device; +hook 'before_template' => sub { + my $tokens = shift; + $tokens->{uri_base} = request->base->path; +}; + get '/' => sub { template 'index'; }; diff --git a/Netdisco/views/ajax/device/addresses.tt b/Netdisco/views/ajax/device/addresses.tt index 1db6fe8f..2a3805ff 100644 --- a/Netdisco/views/ajax/device/addresses.tt +++ b/Netdisco/views/ajax/device/addresses.tt @@ -14,10 +14,10 @@ [% row.alias %] [% row.dns.remove(settings.domain_suffix) %] [% row.port %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.port %]">[% row.port %] [% row.device_port.name %] [% row.subnet %] + href="[% uri_base %]/search?tab=node&q=[% row.subnet %]">[% row.subnet %] [% END %] diff --git a/Netdisco/views/ajax/device/details.tt b/Netdisco/views/ajax/device/details.tt index 417664d3..2ff9becf 100644 --- a/Netdisco/views/ajax/device/details.tt +++ b/Netdisco/views/ajax/device/details.tt @@ -8,7 +8,7 @@ Location [% d.location %] + href="[% uri_base %]/search?[% vars.query_defaults.device %]&q=[% d.dns | uri %]&location=[% d.location | uri %]">[% d.location %] @@ -19,10 +19,10 @@ Vendor / Model [% d.vendor %] + href="[% uri_base %]/search?[% vars.query_defaults.device %]&q=[% d.dns | uri %]&vendor=[% d.vendor | uri %]">[% d.vendor %] / [% d.model %] + href="[% uri_base %]/search?[% vars.query_defaults.device %]&q=[% d.dns | uri %]&model=[% d.model | uri %]">[% d.model %] @@ -30,7 +30,7 @@ [% d.os %] / [% d.os_ver %] + href="[% uri_base %]/search?[% vars.query_defaults.device %]&q=[% d.dns | uri %]&os_ver=[% d.os_ver | uri %]">[% d.os_ver %] diff --git a/Netdisco/views/ajax/device/ports.tt b/Netdisco/views/ajax/device/ports.tt index 74245d11..02ad669e 100644 --- a/Netdisco/views/ajax/device/ports.tt +++ b/Netdisco/views/ajax/device/ports.tt @@ -58,7 +58,7 @@ [% IF params.c_vlan %] [% row.vlan | html_entity %] + href="[% uri_base %]/search?tab=vlan&q=[% row.vlan | uri %]">[% row.vlan | html_entity %] [% END %] [% IF params.c_vmember %] @@ -69,7 +69,7 @@ [% SET count = 0 %] [% FOREACH vlan IN row.tagged_vlans %] [% SET output = output _ - '' _ vlan.vlan _ '' %] + '' _ vlan.vlan _ '' %] [% SET output = output _ ', ' IF NOT loop.last %] [% SET count = count + 1 %] [% END %] @@ -85,28 +85,28 @@ [% IF row.remote_ip %] [% IF row.neighbor %] - + [% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip %] ([% row.remote_port | html_entity %]) [% ELSE %] n - [% row.remote_ip %] ([% row.remote_port %]) + [% row.remote_ip %] ([% row.remote_port %])
  ([% row.remote_type %]) / ([% row.remote_id %])
[% END %] [% END %] [% FOREACH node IN row.get_nodes(params.n_archived) %] [% '
' IF row.remote_ip OR NOT loop.first %] [% 'a  ' IF NOT node.active %] - [% node.mac %] + [% node.mac %] [% ' (' _ node.time_last _ ')' IF params.n_age %] [% IF params.n_ip %] [% FOREACH ip IN node.ips %]
  [% 'a  ' IF NOT ip.active %] [% SET dns = ip.dns %] [% IF dns %] - [% ip.dns %] ([% ip.ip %]) + [% ip.dns %] ([% ip.ip %]) [% ELSE %] - [% ip.ip %] + [% ip.ip %] [% END %] [% END %] [% END %] diff --git a/Netdisco/views/ajax/search/device.tt b/Netdisco/views/ajax/search/device.tt index 28b3f3b3..08a17b0e 100644 --- a/Netdisco/views/ajax/search/device.tt +++ b/Netdisco/views/ajax/search/device.tt @@ -14,7 +14,7 @@ [% WHILE (row = results.next) %] - [% row.dns.remove(settings.domain_suffix) %] + [% row.dns.remove(settings.domain_suffix) %] [% row.contact %] [% row.location %] [% row.name %] diff --git a/Netdisco/views/ajax/search/node_by_ip.tt b/Netdisco/views/ajax/search/node_by_ip.tt index 2f27e542..bbaa4bdc 100644 --- a/Netdisco/views/ajax/search/node_by_ip.tt +++ b/Netdisco/views/ajax/search/node_by_ip.tt @@ -17,12 +17,12 @@ [% WHILE (row = results.next) %] [% row.mac %] + href="[% uri_base %]/search?[% vars.query_defaults.node %]&q=[% row.mac | uri %]">[% row.mac %] [% IF params.vendor %] [% row.oui.company %] [% END %] IP → MAC - [% row.ip %] + [% row.ip %] [% ' (' _ row.dns.remove(settings.domain_suffix) _ ')' IF row.dns %] [% ' a' IF NOT row.active %] @@ -38,7 +38,7 @@   [% END %] Switch Port - [% node.switch %] [ [% node.port %] ] + [% node.switch %] [ [% node.port %] ] [% ' (' _ node.device.dns.remove(settings.domain_suffix) _ ')' IF node.device.dns %] [% ' a' IF NOT node.active %] @@ -55,7 +55,7 @@   [% END %] MAC → IP - [% nodeip.ip %] + [% nodeip.ip %] [% ' (' _ nodeip.dns.remove(settings.domain_suffix) _ ')' IF nodeip.dns %] [% ' a' IF NOT nodeip.active %] diff --git a/Netdisco/views/ajax/search/node_by_mac.tt b/Netdisco/views/ajax/search/node_by_mac.tt index f9b0d012..b41e55df 100644 --- a/Netdisco/views/ajax/search/node_by_mac.tt +++ b/Netdisco/views/ajax/search/node_by_mac.tt @@ -20,7 +20,7 @@ [% IF first_row %] [% row.mac %] + href="[% uri_base %]/search?[% vars.query_defaults.node %]&q=[% row.mac | uri %]">[% row.mac %] [% ELSE %]   [% END %] @@ -35,7 +35,7 @@ [% END %] MAC → IP - [% row.ip %] + [% row.ip %] [% ' (' _ row.dns.remove(settings.domain_suffix) _ ')' IF row.dns %] [% ' a' IF NOT row.active %] @@ -51,7 +51,7 @@ [% IF first_row %] [% node.mac %] + href="[% uri_base %]/search?[% vars.query_defaults.node %]&q=[% node.mac | uri %]">[% node.mac %] [% ELSE %]   [% END %] @@ -66,7 +66,7 @@ [% END %] Switch Port - [% node.switch %] [ [% node.port %] ] + [% node.switch %] [ [% node.port %] ] [% ' (' _ node.device.dns.remove(settings.domain_suffix) _ ')' IF node.device.dns %] [% ' a' IF NOT node.active %] @@ -82,7 +82,7 @@ [% IF first_row %] [% port.mac %] + href="[% uri_base %]/search?[% vars.query_defaults.node %]&q=[% port.mac | uri %]">[% port.mac %] [% ELSE %]   [% END %] @@ -97,7 +97,7 @@ [% END %] Switch Port - [% port.ip %] [ [% port.port %] ] + [% port.ip %] [ [% port.port %] ] [% ' (' _ port.device.dns.remove(settings.domain_suffix) _ ')' IF port.device.dns %] [% IF params.stamps %] diff --git a/Netdisco/views/ajax/search/port.tt b/Netdisco/views/ajax/search/port.tt index e8a7f9c8..86dacd16 100644 --- a/Netdisco/views/ajax/search/port.tt +++ b/Netdisco/views/ajax/search/port.tt @@ -11,7 +11,7 @@ [% WHILE (row = results.next) %] [% row.name %] - [% row.ip %] [ [% row.port %] ] + [% row.ip %] [ [% row.port %] ] [% ' (' _ row.device.dns.remove(settings.domain_suffix) _ ')' IF row.device.dns %] [% row.descr %] diff --git a/Netdisco/views/ajax/search/vlan.tt b/Netdisco/views/ajax/search/vlan.tt index cddf3e76..c57f1f63 100644 --- a/Netdisco/views/ajax/search/vlan.tt +++ b/Netdisco/views/ajax/search/vlan.tt @@ -13,17 +13,17 @@ [% WHILE (row = results.next) %] [% row.vlan.vlan %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.vlan.vlan %] [% row.dns %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.dns %] [% row.vlan.description %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.vlan.description %] [% row.model %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.model %] [% row.os %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.os %] [% row.vendor %] + href="[% uri_base %]/device?tab=ports&ip=[% row.ip %]&q=[% row.vlan.vlan %]">[% row.vendor %] [% END %] diff --git a/Netdisco/views/inc/device/addresses.tt b/Netdisco/views/inc/device/addresses.tt index 6237226e..4dd5238a 100644 --- a/Netdisco/views/inc/device/addresses.tt +++ b/Netdisco/views/inc/device/addresses.tt @@ -1,5 +1,5 @@ -
+
diff --git a/Netdisco/views/inc/device/details.tt b/Netdisco/views/inc/device/details.tt index 6237226e..4dd5238a 100644 --- a/Netdisco/views/inc/device/details.tt +++ b/Netdisco/views/inc/device/details.tt @@ -1,5 +1,5 @@ -
+
diff --git a/Netdisco/views/inc/device/modules.tt b/Netdisco/views/inc/device/modules.tt index 6237226e..4dd5238a 100644 --- a/Netdisco/views/inc/device/modules.tt +++ b/Netdisco/views/inc/device/modules.tt @@ -1,5 +1,5 @@ -
+
diff --git a/Netdisco/views/inc/device/ports.tt b/Netdisco/views/inc/device/ports.tt index 649e4713..534213e6 100644 --- a/Netdisco/views/inc/device/ports.tt +++ b/Netdisco/views/inc/device/ports.tt @@ -1,5 +1,5 @@ -
+
diff --git a/Netdisco/views/inc/js/device.js b/Netdisco/views/inc/js/device.js index 4ea9c90a..e1ad0848 100644 --- a/Netdisco/views/inc/js/device.js +++ b/Netdisco/views/inc/js/device.js @@ -50,7 +50,7 @@ ); // submit the query and put results into the tab pane - $(target).load( '/ajax/content/device/' + tab + '?' + query, + $(target).load( '[% uri_base %]/ajax/content/device/' + tab + '?' + query, function(response, status, xhr) { if (status !== "success") { $(target).html( @@ -65,7 +65,7 @@ ); } // looks good, update the bookmark for this search - $(mark).attr('href', '/device?' + query); + $(mark).attr('href', '[% uri_base %]/device?' + query); // enable collapser on any large vlan lists $('.nd_collapse_vlans').collapser({ diff --git a/Netdisco/views/inc/js/search.js b/Netdisco/views/inc/js/search.js index 8a274ca7..e926a2fe 100644 --- a/Netdisco/views/inc/js/search.js +++ b/Netdisco/views/inc/js/search.js @@ -18,7 +18,7 @@ ); // submit the query and put results into the tab pane - $(target).load( '/ajax/content/search/' + tab + '?' + query, + $(target).load( '[% uri_base %]/ajax/content/search/' + tab + '?' + query, function(response, status, xhr) { if (status !== "success") { $(target).html( @@ -33,7 +33,7 @@ ); } // looks good, update the bookmark for this search - $(mark).attr('href', '/search?' + query); + $(mark).attr('href', '[% uri_base %]/search?' + query); } ); } diff --git a/Netdisco/views/index.tt b/Netdisco/views/index.tt index fd8d5a40..bbf97ad7 100644 --- a/Netdisco/views/index.tt +++ b/Netdisco/views/index.tt @@ -30,7 +30,7 @@

Welcome to Netdisco

Netdisco is an Open Source web-based network management tool. [% IF NOT session.user %] - +
diff --git a/Netdisco/views/layouts/main.tt b/Netdisco/views/layouts/main.tt index 67d36493..adb4d7fa 100644 --- a/Netdisco/views/layouts/main.tt +++ b/Netdisco/views/layouts/main.tt @@ -11,12 +11,12 @@ - - - - - - + + + + + + - - + + @@ -41,22 +41,22 @@
- Netdisco + Netdisco [% IF session.user %] - +