luci-app-commands: fix link generation
[project/luci.git] / applications / luci-app-commands / luasrc / view / commands.htm
index 83792a9..4285f25 100644 (file)
@@ -1,13 +1,6 @@
 <%#
-LuCI - Lua Configuration Interface
-Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
+ Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
+ Licensed to the public under the Apache License 2.0.
 -%>
 
 <% css = [[
@@ -65,7 +58,7 @@ You may obtain a copy of the License at
                        legend.parentNode.style.display = 'block';
                        legend.style.display = 'inline';
 
-                       stxhr.get('<%=luci.dispatcher.build_url("admin", "system", "commands", "run")%>/' + id + (args ? '/' + args : ''), null,
+                       stxhr.get('<%=url('admin/system/commands/run')%>/' + id + (args ? '/' + args : ''), null,
                                function(x, st)
                                {
                                        if (st)
@@ -100,7 +93,7 @@ You may obtain a copy of the License at
                if (field)
                        args = encodeURIComponent(field.value);
 
-               location.href = '<%=luci.dispatcher.build_url("admin", "system", "commands", "download")%>/' + id + (args ? '/' + args : '');
+               location.href = '<%=url('admin/system/commands/download')%>/' + id + (args ? '/' + args : '');
        }
 
        function command_link(id)
@@ -115,16 +108,17 @@ You may obtain a copy of the License at
 
                if (legend && output)
                {
-                       var link = location.protocol + '//' + location.hostname +
-                                  (location.port ? ':' + location.port : '') +
-                                          location.pathname.split(';')[0] + 'command/' +
-                                          id + (args ? '/' + args : '');
-
+                       var prefix = location.protocol + '//' + location.host + '<%=url('command')%>/';
+                       var suffix = (args ? '/' + args : '');
+                       
+                       var link = prefix + id + suffix;
+                       var link_nodownload = prefix + id + "s" + suffix;
+                       
                        legend.style.display = 'none';
                        output.parentNode.style.display = 'block';
                        output.innerHTML = String.format(
-                               '<div class="alert-message"><%:Access command with%> <a href="%s">%s</a></div>',
-                               link, link
+                               '<div class="alert-message"><p><%:Download execution result%> <a href="%s">%s</a></p><p><%:Or display result%> <a href="%s">%s</a></p></div>',
+                               link, link, link_nodownload, link_nodownload
                        );
 
                        location.hash = '#output';
@@ -140,9 +134,9 @@ You may obtain a copy of the License at
        uci:foreach("luci", "command", function(s) commands[#commands+1] = s end)
 %>
 
-<form method="get" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
+<form method="get" action="<%=pcdata(FULL_REQUEST_URI)%>">
        <div class="cbi-map">
-               <h2><a id="content" name="content"><%:Custom Commands%></a></h2>
+               <h2 name="content"><%:Custom Commands%></h2>
 
                <fieldset class="cbi-section">
                        <% local _, command; for _, command in ipairs(commands) do %>