Skip to content
This repository was archived by the owner on Oct 21, 2018. It is now read-only.

Commit 3e77065

Browse files
committed
Merge pull request #30 from markuslindenberg/master
use script_root in absolute links to support subdirectory URLs
2 parents 37101ff + 4d733b8 commit 3e77065

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

static/scripts/editor.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function getSelectedTheme() {
77
theme = this.value;
88
return false;
99
}
10-
})
10+
});
1111
return theme;
1212
}
1313

@@ -101,7 +101,7 @@ function genPreview() {
101101
}
102102
lastContent = rstContent;
103103
activeXhr = $.ajax({
104-
'url': '/srv/rst2html/',
104+
'url': script_root + '/srv/rst2html/',
105105
'data': {'rst': rstContent, 'theme': getSelectedTheme()},
106106
'type': 'POST',
107107
'error': function(xhr) {
@@ -119,9 +119,9 @@ var timerId = null;
119119

120120
function getCurrentLink(res) {
121121
if (!res) {
122-
return 'http://' + window.location.host + '/?theme=' + getSelectedTheme();
122+
return '//' + window.location.host + script_root + '/?theme=' + getSelectedTheme();
123123
}
124-
return 'http://' + window.location.host + '/?n=' + res + '&theme=' + getSelectedTheme();
124+
return '//' + window.location.host + script_root + '/?n=' + res + '&theme=' + getSelectedTheme();
125125
}
126126

127127
function adjustBrowse() {
@@ -153,7 +153,7 @@ $(function() {
153153
$('#save_link').click(function(e) {
154154

155155
$.ajax({
156-
'url': '/srv/save_rst/',
156+
'url': script_root + '/srv/save_rst/',
157157
'type': 'POST',
158158
'data': {'rst': $('textarea#editor').val()},
159159
'success': function(response) {
@@ -169,7 +169,7 @@ $(function() {
169169

170170
$('#del_link').click(function(e) {
171171
$.ajax({
172-
'url': '/srv/del_rst/',
172+
'url': script_root + '/srv/del_rst/',
173173
'type': 'GET',
174174
'data': {'n': getCurrentDocument()},
175175
'success': function(response) {

templates/base.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
<meta charset="UTF-8">
66
<title>{% block title %}Online reStructuredText editor{% endblock %}</title>
77

8-
<link rel="stylesheet" href="{{ MEDIA_URL }}style/base.css"/>
9-
<link rel="stylesheet" href="{{ MEDIA_URL }}style/site.css"/>
10-
<link rel="stylesheet" href="{{ MEDIA_URL }}style/menu.css"/>
8+
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/base.css"/>
9+
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/site.css"/>
10+
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/menu.css"/>
1111

12-
<link rel="stylesheet" href="{{ MEDIA_URL }}style/overcast/jquery-ui-1.8.16.custom.css" />
12+
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/overcast/jquery-ui-1.8.16.custom.css" />
1313

1414

15-
<script src="{{ MEDIA_URL }}scripts/jquery-1.6.4.min.js"></script>
16-
<script src="{{ MEDIA_URL }}scripts/jquery-ui-1.8.16.custom.min.js"></script>
17-
<script src="{{ MEDIA_URL }}scripts/jquery.layout.min-1.2.0.js"></script>
15+
<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery-1.6.4.min.js"></script>
16+
<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery-ui-1.8.16.custom.min.js"></script>
17+
<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery.layout.min-1.2.0.js"></script>
1818

1919
{% endblock %}
2020
</head>
@@ -35,6 +35,7 @@ <h1>{% block site_title %}Online reStructuredText editor{% endblock %}</h1>
3535
</menu>
3636
</header>
3737
<script type="text/javascript">
38+
var script_root = {{ request.script_root|tojson|safe }};
3839
$('#navigation').find("li.active a").click(function(evt) {
3940
evt.preventDefault();
4041
});

templates/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
{% block head %}
44
{{ super() }}
5-
<script type="text/javascript" src="{{ MEDIA_URL }}markit/jquery.markitup.js"></script>
6-
<script type="text/javascript" src="{{ MEDIA_URL }}markit/sets/rest/set.js"></script>
5+
<script type="text/javascript" src="{{ request.script_root }}{{ MEDIA_URL }}markit/jquery.markitup.js"></script>
6+
<script type="text/javascript" src="{{ request.script_root }}{{ MEDIA_URL }}markit/sets/rest/set.js"></script>
77

8-
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}markit/skins/simple/style.css" />
9-
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}markit/sets/rest/style.css" />
8+
<link rel="stylesheet" type="text/css" href="{{ request.script_root }}{{ MEDIA_URL }}markit/skins/simple/style.css" />
9+
<link rel="stylesheet" type="text/css" href="{{ request.script_root }}{{ MEDIA_URL }}markit/sets/rest/style.css" />
1010

11-
<script type="text/javascript" src="{{ MEDIA_URL }}scripts/editor.js"></script>
11+
<script type="text/javascript" src="{{ request.script_root }}{{ MEDIA_URL }}scripts/editor.js"></script>
1212

1313
<script type="text/javascript">
1414
var js_params = {{ js_params|tojson|safe }};
@@ -64,13 +64,13 @@
6464
</div>
6565

6666

67-
<iframe src="/srv/rst2html/" id="browse"></iframe>
67+
<iframe src="{{ request.script_root }}/srv/rst2html/" id="browse"></iframe>
6868
</div>
6969
</div>
7070

7171
</div>
7272

73-
<form id="save_as_pdf" method="POST" action="/srv/rst2pdf/">
73+
<form id="save_as_pdf" method="POST" action="{{ request.script_root }}/srv/rst2pdf/">
7474
<input type="hidden" id="as_pdf_rst" name="rst" />
7575
<input type="hidden" id="as_pdf_theme" name="theme"/>
7676
</form>

0 commit comments

Comments
 (0)