Skip to content

Commit 71b2804

Browse files
committed
Use relative URLs
Use relative URLs for all links to that the application can be run behind a reverse proxy such as nginx. Fixes #181.
1 parent 576dba4 commit 71b2804

File tree

11 files changed

+65
-65
lines changed

11 files changed

+65
-65
lines changed

web/static/scripts/redisCommander.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var foldingCharacter = ":";
33

44
var CmdParser = require('cmdparser');
55
function loadTree () {
6-
$.get('/apiv1/connection', function (isConnected) {
6+
$.get('apiv1/connection', function (isConnected) {
77
if (isConnected) {
88
$('#keyTree').bind("loaded.jstree", function () {
99
var tree = getKeyTree();
@@ -41,43 +41,43 @@ function loadTree () {
4141
if (node !== -1) {
4242
var path = getFullKeyPath(node);
4343
var root = getRootConnection(node);
44-
return '/apiv1/keystree/' + encodeURIComponent(root) + '/' + encodeURIComponent(path) + '?absolute=false';
44+
return 'apiv1/keystree/' + encodeURIComponent(root) + '/' + encodeURIComponent(path) + '?absolute=false';
4545
}
4646
var root = getRootConnection(node);
47-
return '/apiv1/keystree/' + encodeURIComponent(root);
47+
return 'apiv1/keystree/' + encodeURIComponent(root);
4848
}
4949
}
5050
},
5151
types: {
5252
types: {
5353
"root": {
5454
icon: {
55-
image: '/images/treeRoot.png'
55+
image: 'images/treeRoot.png'
5656
}
5757
},
5858
"string": {
5959
icon: {
60-
image: '/images/treeString.png'
60+
image: 'images/treeString.png'
6161
}
6262
},
6363
"hash": {
6464
icon: {
65-
image: '/images/treeHash.png'
65+
image: 'images/treeHash.png'
6666
}
6767
},
6868
"set": {
6969
icon: {
70-
image: '/images/treeSet.png'
70+
image: 'images/treeSet.png'
7171
}
7272
},
7373
"list": {
7474
icon: {
75-
image: '/images/treeList.png'
75+
image: 'images/treeList.png'
7676
}
7777
},
7878
"zset": {
7979
icon: {
80-
image: '/images/treeZSet.png'
80+
image: 'images/treeZSet.png'
8181
}
8282
}
8383
}
@@ -141,15 +141,15 @@ function treeNodeSelected (event, data) {
141141
var connectionId = pathParts.slice(0, 1)[0];
142142
if (pathParts.length === 1) {
143143
var hostAndPort = pathParts[0].split(':');
144-
$.get('/apiv1/server/info', function (data, status) {
144+
$.get('apiv1/server/info', function (data, status) {
145145
if (status != 'success') {
146146
return alert("Could not load server info");
147147
}
148148
data = JSON.parse(data);
149149
data.forEach(function (instance) {
150150
if (instance.host == hostAndPort[0] && instance.port == hostAndPort[1]) {
151151
instance.connectionId = connectionId;
152-
var html = new EJS({ url: '/templates/serverInfo.ejs' }).render(instance);
152+
var html = new EJS({ url: 'templates/serverInfo.ejs' }).render(instance);
153153
$('#body').html(html);
154154
return setupAddKeyButton();
155155
}
@@ -170,9 +170,9 @@ function getRootConnection (node) {
170170

171171
function loadKey (connectionId, key, index) {
172172
if (index) {
173-
$.get('/apiv1/key/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(key) + "/" + index, processData);
173+
$.get('apiv1/key/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(key) + "/" + index, processData);
174174
} else {
175-
$.get('/apiv1/key/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(key), processData);
175+
$.get('apiv1/key/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(key), processData);
176176
}
177177
function processData (data, status) {
178178
if (status != 'success') {
@@ -210,7 +210,7 @@ function loadKey (connectionId, key, index) {
210210
}
211211
}
212212
function selectTreeNodeBranch (data) {
213-
var html = new EJS({ url: '/templates/editBranch.ejs' }).render(data);
213+
var html = new EJS({ url: 'templates/editBranch.ejs' }).render(data);
214214
$('#body').html(html);
215215
}
216216
function setupEditListButton () {
@@ -295,7 +295,7 @@ function setupEditZSetButton () {
295295

296296
function setupAddKeyButton (connectionId) {
297297
$('#keyValue').keyup(function () {
298-
var action = "/apiv1/key/" + encodeURIComponent(connectionId) + "/" + encodeURIComponent($(this).val());
298+
var action = "apiv1/key/" + encodeURIComponent(connectionId) + "/" + encodeURIComponent($(this).val());
299299
$('#addKeyForm').attr("action", action);
300300
});
301301
$('#keyType').change(function () {
@@ -361,7 +361,7 @@ function setupEditHashButton () {
361361
}
362362

363363
function selectTreeNodeString (data) {
364-
var html = new EJS({ url: '/templates/editString.ejs' }).render(data);
364+
var html = new EJS({ url: 'templates/editString.ejs' }).render(data);
365365
$('#body').html(html);
366366

367367
try {
@@ -374,7 +374,7 @@ function selectTreeNodeString (data) {
374374
$('#stringValue').val(data.value);
375375
$('#jqtree_string_div').html(JSONTree.create(JSON.parse(data.value)));
376376
$('#stringValue').keyup(function () {
377-
$('#stringValueClippy').clippy({'text': $(this).val(), clippy_path: "/clippy-jquery/clippy.swf"});
377+
$('#stringValueClippy').clippy({'text': $(this).val(), clippy_path: "clippy-jquery/clippy.swf"});
378378
var dataTree;
379379
try {
380380
dataTree = JSONTree.create(JSON.parse($(this).val()));
@@ -412,12 +412,12 @@ function selectTreeNodeString (data) {
412412
}
413413

414414
function selectTreeNodeHash (data) {
415-
var html = new EJS({ url: '/templates/editHash.ejs' }).render(data);
415+
var html = new EJS({ url: 'templates/editHash.ejs' }).render(data);
416416
$('#body').html(html);
417417
}
418418

419419
function selectTreeNodeSet (data) {
420-
var html = new EJS({ url: '/templates/editSet.ejs' }).render(data);
420+
var html = new EJS({ url: 'templates/editSet.ejs' }).render(data);
421421
$('#body').html(html);
422422
$('#addSetMemberForm').ajaxForm({
423423
beforeSubmit: function () {
@@ -445,7 +445,7 @@ function selectTreeNodeSet (data) {
445445

446446
function selectTreeNodeList (data) {
447447
if (data.items.length > 0) {
448-
var html = new EJS({ url: '/templates/editList.ejs' }).render(data);
448+
var html = new EJS({ url: 'templates/editList.ejs' }).render(data);
449449
$('#body').html(html);
450450
$('#addListValueForm').ajaxForm({
451451
beforeSubmit: function () {
@@ -476,7 +476,7 @@ function selectTreeNodeList (data) {
476476

477477
function selectTreeNodeZSet (data) {
478478
if (data.items.length > 0) {
479-
var html = new EJS({ url: '/templates/editZSet.ejs' }).render(data);
479+
var html = new EJS({ url: 'templates/editZSet.ejs' }).render(data);
480480
$('#body').html(html);
481481
} else {
482482
alert('Index out of bounds');
@@ -500,7 +500,7 @@ function addKey (connectionId, key) {
500500
var pathParts = getKeyTree().get_path(connectionId, true);
501501
connectionId = pathParts.slice(0, 1)[0];
502502
}
503-
$('#addKeyForm').attr('action', '/apiv1/key/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(key));
503+
$('#addKeyForm').attr('action', 'apiv1/key/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(key));
504504
$('#keyValue').val(key);
505505
$('#addKeyModal').modal('show');
506506
setupAddKeyButton(connectionId);
@@ -513,7 +513,7 @@ function deleteKey (connectionId, key) {
513513
}
514514
var result = confirm('Are you sure you want to delete "' + key + ' from ' + connectionId + '"?');
515515
if (result) {
516-
$.post('/apiv1/key/' + encodeURIComponent(connectionId) + '/' + encodeURIComponent(key) + '?action=delete', function (data, status) {
516+
$.post('apiv1/key/' + encodeURIComponent(connectionId) + '/' + encodeURIComponent(key) + '?action=delete', function (data, status) {
517517
if (status != 'success') {
518518
return alert("Could not delete key");
519519
}
@@ -530,7 +530,7 @@ function deleteBranch (connectionId, branchPrefix) {
530530
var query = branchPrefix + ':*';
531531
var result = confirm('Are you sure you want to delete "' + query + ' from ' + connectionId + '"? This will delete all children as well!');
532532
if (result) {
533-
$.post('/apiv1/keys/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(query) + '?action=delete', function (data, status) {
533+
$.post('apiv1/keys/' + encodeURIComponent(connectionId) + "/" + encodeURIComponent(query) + '?action=delete', function (data, status) {
534534
if (status != 'success') {
535535
return alert("Could not delete branch");
536536
}
@@ -669,7 +669,7 @@ function loadCommandLine () {
669669
refreshTree();
670670
rl.write("OK");
671671
} else {
672-
$.post('/apiv1/exec', { cmd: line, connection: $('#selectedConnection').val() }, function (data, status) {
672+
$.post('apiv1/exec', { cmd: line, connection: $('#selectedConnection').val() }, function (data, status) {
673673
rl.prompt();
674674

675675
if (status != 'success') {
@@ -856,7 +856,7 @@ var cmdparser = new CmdParser([
856856
], {
857857
key: function (partial, callback) {
858858
var redisConnection = $('#selectedConnection').val();
859-
$.get('/apiv1/keys/' + encodeURIComponent(redisConnection) + "/" + partial + '*?limit=20', function (data, status) {
859+
$.get('apiv1/keys/' + encodeURIComponent(redisConnection) + "/" + partial + '*?limit=20', function (data, status) {
860860
if (status != 'success') {
861861
return callback(new Error("Could not get keys"));
862862
}
@@ -876,7 +876,7 @@ var prevCLIOpen;
876876
var configLoaded = false;
877877

878878
function getServerInfo (callback) {
879-
$.get('/apiv1/server/info', function (data, status) {
879+
$.get('apiv1/server/info', function (data, status) {
880880
callback(JSON.parse(data))
881881
});
882882
}
@@ -888,7 +888,7 @@ function removeServer (connectionId) {
888888
}
889889
var result = confirm('Are you sure you want to disconnect from "' + connectionId + '"?');
890890
if (result) {
891-
$.post('/logout/' + encodeURIComponent(connectionId), function (err, status) {
891+
$.post('logout/' + encodeURIComponent(connectionId), function (err, status) {
892892
if (status != 'success') {
893893
return alert("Could not remove instance");
894894
}
@@ -936,13 +936,13 @@ function saveConfig () {
936936
var sidebarWidth = $('#sideBar').width();
937937
var locked = !$('#lockCommandButton').hasClass('disabled');
938938
var CLIHeight = $('#commandLineContainer').height();
939-
$.get('/config', function (config) {
939+
$.get('config', function (config) {
940940
if (config) {
941941
config["sidebarWidth"] = sidebarWidth;
942942
config["locked"] = locked;
943943
config["CLIHeight"] = CLIHeight;
944944
config["CLIOpen"] = CLIOpen;
945-
$.post('/config', config, function (data, status) {
945+
$.post('config', config, function (data, status) {
946946
});
947947
} else {
948948
var config = {
@@ -952,13 +952,13 @@ function saveConfig () {
952952
"CLIOpen": CLIOpen,
953953
"default_connections": []
954954
};
955-
$.post('/config', config, function (data, status) {
955+
$.post('config', config, function (data, status) {
956956
});
957957
}
958958
});
959959
}
960960
function loadConfig (callback) {
961-
$.get('/config', function (data) {
961+
$.get('config', function (data) {
962962
if (data) {
963963
if (data['sidebarWidth']) {
964964
$('#sideBar').width(data['sidebarWidth']);
@@ -1085,7 +1085,7 @@ $(function() {
10851085
* Export redis data.
10861086
*/
10871087
$('#app-container').on('submit', '#redisExportForm', function () {
1088-
window.open("/tools/export?" + $(this).serialize(), '_blank');
1088+
window.open("tools/export?" + $(this).serialize(), '_blank');
10891089
return false;
10901090
});
10911091

@@ -1097,7 +1097,7 @@ $(function() {
10971097

10981098
$.ajax({
10991099
type: 'POST',
1100-
url: '/tools/import',
1100+
url: 'tools/import',
11011101
data: $(this).serialize(),
11021102
dataType: 'JSON',
11031103
success: function (res) {
@@ -1117,7 +1117,7 @@ $(function() {
11171117
$('#redisImportData').on('click', function () {
11181118
$.ajax({
11191119
type: 'POST',
1120-
url: '/tools/forms/import',
1120+
url: 'tools/forms/import',
11211121
success: function (res) {
11221122
$('#body').html(res);
11231123
}
@@ -1130,7 +1130,7 @@ $(function() {
11301130
$('#redisExportData').on('click', function () {
11311131
$.ajax({
11321132
type: 'POST',
1133-
url: '/tools/forms/export',
1133+
url: 'tools/forms/export',
11341134
success: function (res) {
11351135
$('#body').html(res);
11361136
}

web/static/templates/editString.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<button id="vieModeTreeButton" class="btn" onclick="$('#stringValue').css('display','none');$('#jqtree_string_div').css('display','inline-block');$('#vieModeEditButton').css('display','inline');$('#vieModeTreeButton').css('display','none')">view mode tree</button>
55
</div>
66
<div id="itemData">
7-
<form id="editStringForm" action="/apiv1/key/<%= connectionId %>/<%= key %>" method="POST" class="form-vertical">
7+
<form id="editStringForm" action="apiv1/key/<%= connectionId %>/<%= key %>" method="POST" class="form-vertical">
88
<label>Key: <b><%= key %></b></label>
99
<label>Value:</label>
1010
<input type="hidden" id="isJson" name="isJson">
@@ -16,4 +16,4 @@
1616
<br>
1717
<button id="saveKeyButton" class="btn" onclick="$('#editStringForm').submit()">Save</button>
1818
</form>
19-
</div>
19+
</div>

web/views/home/home.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</a>
1313
<ul class="dropdown-menu">
1414
<li><a data-toggle="modal" id="redisImportData" href="#"><b class="icon-arrow-right"></b><b class="icon-th"></b> Import</a></li>
15-
<li><a data-toggle="modal" id="redisExportData" href="#"><b class="icon-arrow-left"></b></b><b class="icon-th"></b> Export</a></li>
15+
<li><a data-toggle="modal" id="redisExportData" href="#"><b class="icon-arrow-left"></b><b class="icon-th"></b> Export</a></li>
1616
<li><a data-toggle="modal" href="#addServerModal"><b class="icon-plus-sign"></b> Add Server</a></li>
1717
</ul>
1818
</div>

web/views/layout.ejs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
<title>Redis Commander: <%= title %></title>
55
<link rel="icon"
66
href="favicon.png">
7-
<link href="/bootstrap/css/bootstrap.css" rel="stylesheet"/>
7+
<link href="bootstrap/css/bootstrap.css" rel="stylesheet"/>
88
<style type="text/css">
99
body {
1010
padding-top: 60px;
1111
padding-bottom: 40px;
1212
}
1313
</style>
14-
<link href="/css/default.css" rel="stylesheet"/>
15-
<link rel="stylesheet" href="/json-tree/css/jsontree.css">
16-
<script type="text/javascript" src="/browserify.js"></script>
17-
<script type="text/javascript" src="/scripts/jquery-1.7.2.js"></script>
18-
<script type="text/javascript" src="/jstree/jquery.jstree.js"></script>
19-
<script type="text/javascript" src="/json-tree/jsontree.min.js"></script>
20-
<script type="text/javascript" src="/scripts/jquery.form.js"></script>
21-
<script type="text/javascript" src="/scripts/jquery.resize.min.js"></script>
22-
<script type="text/javascript" src="/clippy-jquery/jquery.clippy.js"></script>
23-
<script type="text/javascript" src="/scripts/ejs.js"></script>
24-
<script type="text/javascript" src="/scripts/dateformat.js"></script>
25-
<script type="text/javascript" src="/scripts/countdown.js"></script>
26-
<script type="text/javascript" src="/scripts/redisCommander.js"></script>
27-
<script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
14+
<link href="css/default.css" rel="stylesheet"/>
15+
<link rel="stylesheet" href="json-tree/css/jsontree.css">
16+
<script type="text/javascript" src="browserify.js"></script>
17+
<script type="text/javascript" src="scripts/jquery-1.7.2.js"></script>
18+
<script type="text/javascript" src="jstree/jquery.jstree.js"></script>
19+
<script type="text/javascript" src="json-tree/jsontree.min.js"></script>
20+
<script type="text/javascript" src="scripts/jquery.form.js"></script>
21+
<script type="text/javascript" src="scripts/jquery.resize.min.js"></script>
22+
<script type="text/javascript" src="clippy-jquery/jquery.clippy.js"></script>
23+
<script type="text/javascript" src="scripts/ejs.js"></script>
24+
<script type="text/javascript" src="scripts/dateformat.js"></script>
25+
<script type="text/javascript" src="scripts/countdown.js"></script>
26+
<script type="text/javascript" src="scripts/redisCommander.js"></script>
27+
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
2828
</head>
2929
<body>
3030
<div class="navbar navbar-fixed-top">
3131
<div class="navbar-inner">
3232
<div class="container">
33-
<a class="brand" href="/"><img src="images/RedisCommandLogo.png"/></a>
33+
<a class="brand" href="./"><img src="images/RedisCommandLogo.png"/></a>
3434

3535
<ul class="nav">
3636
</ul>
@@ -49,7 +49,7 @@
4949
<% } %>
5050

5151
<%- body %>
52-
</div>
52+
</div>
5353
<% include modals/addListValueModal %>
5454
<% include modals/addSetMemberModal %>
5555
<% include modals/editZSetRowModal %>

web/views/modals/addKeyModal.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h3>Add Key</h3>
55
</div>
66
<div class="modal-body">
7-
<form id="addKeyForm" action="/apiv1/key/" method="POST" class="form-vertical">
7+
<form id="addKeyForm" action="apiv1/key/" method="POST" class="form-vertical">
88
<div class="control-group">
99
<label class="control-label">Key</label>
1010
<div class="controls">
@@ -26,9 +26,9 @@
2626
</div>
2727
</div>
2828
<div class="control-group" style="display:inline;">
29-
29+
3030
<div class="controls">
31-
31+
3232
</div>
3333
</div>
3434
<label>Value</label>

0 commit comments

Comments
 (0)