Skip to content

Commit

Permalink
js: Fix URLs linking to series
Browse files Browse the repository at this point in the history
Patchwork may not be installed at the root of a domain, but within a
sub-path. Relative links need to account for that. We were doing it
correctly for the API URLs but not for regular URLs, so fix that.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
  • Loading branch information
Damien Lespiau committed Nov 19, 2015
1 parent 1ee54fe commit 25d9935
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions htdocs/js/patchwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var pw = (function() {

var exports = {},
ctx = {
base_url: '',
api_base_url: '/api/1.0',
project: null,
user : {
Expand All @@ -68,7 +69,8 @@ var pw = (function() {
* *_writer() functions */

function series_writer(record) {
return '<a href="/series/' + record.id + '/">' +
var link = ctx.base_url + '/series/' + record.id + '/';
return '<a href="' + link + '">' +
record[this.id] + // jshint ignore:line
'</a>';
}
Expand All @@ -94,8 +96,9 @@ var pw = (function() {

this.amend_context(init_ctx);

if (ctx.api_base_url.endsWith('/'))
ctx.api_base_url = ctx.api_base_url.slice(0, -1);
if (ctx.base_url.endsWith('/'))
ctx.base_url = ctx.base_url.slice(0, -1);
ctx.api_base_url = ctx.base_url + '/api/1.0';

$.dynatableSetup({
features: {
Expand Down
2 changes: 1 addition & 1 deletion patchwork/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
(r'^api/1.0/', include(event_router.urls)),

# project view:
(r'^$', 'patchwork.views.projects'),
url(r'^$', 'patchwork.views.projects', name='root'),
(r'^project/(?P<project_id>[^/]+)/list/$', 'patchwork.views.patch.list'),
url(r'^project/(?P<project_id>[^/]+)/patches/$',
'patchwork.views.patch.list', name='patches_list'),
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script type="text/javascript">
$(function () {
pw.init({
api_base_url: '{% url 'api-root' %}'
base_url: '{% url 'root' %}'
{% if user.is_authenticated %}
, user: {
items_per_page: {{ user.profile.patches_per_page }}
Expand Down

0 comments on commit 25d9935

Please sign in to comment.