Send path when renaming pages.
Fix nil error on editing a non-existent page. Use baseURL on delete.
This commit is contained in:
@@ -143,7 +143,7 @@ module Precious
|
|||||||
|
|
||||||
page = wiki.page(rename) if rename
|
page = wiki.page(rename) if rename
|
||||||
|
|
||||||
redirect to("/#{page.escaped_url_path}")
|
redirect to("/#{page.escaped_url_path}") unless page.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/delete/*' do
|
get '/delete/*' do
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ $(document).ready(function() {
|
|||||||
var ok = confirm($(this).data('confirm'));
|
var ok = confirm($(this).data('confirm'));
|
||||||
if ( ok ) {
|
if ( ok ) {
|
||||||
var loc = window.location;
|
var loc = window.location;
|
||||||
loc = loc.protocol + '//' + loc.host + '/delete' + loc.pathname
|
loc = baseUrl + 'delete' + loc.pathname
|
||||||
window.location = loc;
|
window.location = loc;
|
||||||
}
|
}
|
||||||
// Don't navigate on cancel.
|
// Don't navigate on cancel.
|
||||||
@@ -113,8 +113,11 @@ $(document).ready(function() {
|
|||||||
$('#minibutton-rename-page').click(function(e) {
|
$('#minibutton-rename-page').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var path = window.location.pathname;
|
// Path name without the leading slash.
|
||||||
var oldName = path.substring(path.lastIndexOf('/')+1);
|
var pathname = window.location.pathname.substr(1);
|
||||||
|
var slashIndex = pathname.lastIndexOf('/');
|
||||||
|
var oldName = pathname.substr(slashIndex + 1)
|
||||||
|
var path = pathname.substr(0, slashIndex);
|
||||||
|
|
||||||
$.GollumDialog.init({
|
$.GollumDialog.init({
|
||||||
title: 'Rename Page',
|
title: 'Rename Page',
|
||||||
@@ -127,19 +130,19 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
OK: function( res ) {
|
OK: function( res ) {
|
||||||
var name = 'Rename Page';
|
var newName = 'Rename Page';
|
||||||
if ( res['name'] ) {
|
if ( res['name'] ) {
|
||||||
name = res['name'];
|
newName = res['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = 'Renamed ' + oldName + ' to ' + name;
|
var msg = 'Renamed ' + oldName + ' to ' + newName;
|
||||||
jQuery.ajax( {
|
jQuery.ajax( {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: baseUrl + '/edit/' + oldName,
|
url: baseUrl + 'edit/' + oldName,
|
||||||
// omit path: pathName until https://github.com/github/gollum/issues/446 is fixed.
|
// omit path: pathName until https://github.com/github/gollum/issues/446 is fixed.
|
||||||
data: { rename: name, page: oldName, message: msg },
|
data: { path: path, rename: newName, page: oldName, message: msg },
|
||||||
success: function() {
|
success: function() {
|
||||||
window.location = baseUrl + '/' + encodeURIComponent(name);
|
window.location = baseUrl + encodeURIComponent(newName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -172,7 +175,7 @@ $(document).ready(function() {
|
|||||||
if ( res['name'] ) {
|
if ( res['name'] ) {
|
||||||
name = res['name'];
|
name = res['name'];
|
||||||
}
|
}
|
||||||
window.location = baseUrl + '/' + encodeURIComponent(name);
|
window.location = baseUrl + encodeURIComponent(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user