Skip to content

Commit

Permalink
Merge pull request anru#30 from markuslindenberg/master
Browse files Browse the repository at this point in the history
use script_root in absolute links to support subdirectory URLs
  • Loading branch information
anru committed Sep 8, 2014
2 parents 37101ff + 4d733b8 commit 3e77065
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions static/scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function getSelectedTheme() {
theme = this.value;
return false;
}
})
});
return theme;
}

Expand Down Expand Up @@ -101,7 +101,7 @@ function genPreview() {
}
lastContent = rstContent;
activeXhr = $.ajax({
'url': '/srv/rst2html/',
'url': script_root + '/srv/rst2html/',
'data': {'rst': rstContent, 'theme': getSelectedTheme()},
'type': 'POST',
'error': function(xhr) {
Expand All @@ -119,9 +119,9 @@ var timerId = null;

function getCurrentLink(res) {
if (!res) {
return 'http://' + window.location.host + '/?theme=' + getSelectedTheme();
return '//' + window.location.host + script_root + '/?theme=' + getSelectedTheme();
}
return 'http://' + window.location.host + '/?n=' + res + '&theme=' + getSelectedTheme();
return '//' + window.location.host + script_root + '/?n=' + res + '&theme=' + getSelectedTheme();
}

function adjustBrowse() {
Expand Down Expand Up @@ -153,7 +153,7 @@ $(function() {
$('#save_link').click(function(e) {

$.ajax({
'url': '/srv/save_rst/',
'url': script_root + '/srv/save_rst/',
'type': 'POST',
'data': {'rst': $('textarea#editor').val()},
'success': function(response) {
Expand All @@ -169,7 +169,7 @@ $(function() {

$('#del_link').click(function(e) {
$.ajax({
'url': '/srv/del_rst/',
'url': script_root + '/srv/del_rst/',
'type': 'GET',
'data': {'n': getCurrentDocument()},
'success': function(response) {
Expand Down
15 changes: 8 additions & 7 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<meta charset="UTF-8">
<title>{% block title %}Online reStructuredText editor{% endblock %}</title>

<link rel="stylesheet" href="{{ MEDIA_URL }}style/base.css"/>
<link rel="stylesheet" href="{{ MEDIA_URL }}style/site.css"/>
<link rel="stylesheet" href="{{ MEDIA_URL }}style/menu.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/base.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/site.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/menu.css"/>

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


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

{% endblock %}
</head>
Expand All @@ -35,6 +35,7 @@ <h1>{% block site_title %}Online reStructuredText editor{% endblock %}</h1>
</menu>
</header>
<script type="text/javascript">
var script_root = {{ request.script_root|tojson|safe }};
$('#navigation').find("li.active a").click(function(evt) {
evt.preventDefault();
});
Expand Down
14 changes: 7 additions & 7 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

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

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

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

<script type="text/javascript">
var js_params = {{ js_params|tojson|safe }};
Expand Down Expand Up @@ -64,13 +64,13 @@
</div>


<iframe src="/srv/rst2html/" id="browse"></iframe>
<iframe src="{{ request.script_root }}/srv/rst2html/" id="browse"></iframe>
</div>
</div>

</div>

<form id="save_as_pdf" method="POST" action="/srv/rst2pdf/">
<form id="save_as_pdf" method="POST" action="{{ request.script_root }}/srv/rst2pdf/">
<input type="hidden" id="as_pdf_rst" name="rst" />
<input type="hidden" id="as_pdf_theme" name="theme"/>
</form>
Expand Down

0 comments on commit 3e77065

Please sign in to comment.