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
|
||||
|
||||
redirect to("/#{page.escaped_url_path}")
|
||||
redirect to("/#{page.escaped_url_path}") unless page.nil?
|
||||
end
|
||||
|
||||
get '/delete/*' do
|
||||
|
||||
@@ -4,7 +4,7 @@ $(document).ready(function() {
|
||||
var ok = confirm($(this).data('confirm'));
|
||||
if ( ok ) {
|
||||
var loc = window.location;
|
||||
loc = loc.protocol + '//' + loc.host + '/delete' + loc.pathname
|
||||
loc = baseUrl + 'delete' + loc.pathname
|
||||
window.location = loc;
|
||||
}
|
||||
// Don't navigate on cancel.
|
||||
@@ -113,8 +113,11 @@ $(document).ready(function() {
|
||||
$('#minibutton-rename-page').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var path = window.location.pathname;
|
||||
var oldName = path.substring(path.lastIndexOf('/')+1);
|
||||
// Path name without the leading slash.
|
||||
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({
|
||||
title: 'Rename Page',
|
||||
@@ -127,19 +130,19 @@ $(document).ready(function() {
|
||||
}
|
||||
],
|
||||
OK: function( res ) {
|
||||
var name = 'Rename Page';
|
||||
var newName = 'Rename Page';
|
||||
if ( res['name'] ) {
|
||||
name = res['name'];
|
||||
newName = res['name'];
|
||||
}
|
||||
|
||||
var msg = 'Renamed ' + oldName + ' to ' + name;
|
||||
var msg = 'Renamed ' + oldName + ' to ' + newName;
|
||||
jQuery.ajax( {
|
||||
type: 'POST',
|
||||
url: baseUrl + '/edit/' + oldName,
|
||||
url: baseUrl + 'edit/' + oldName,
|
||||
// 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() {
|
||||
window.location = baseUrl + '/' + encodeURIComponent(name);
|
||||
window.location = baseUrl + encodeURIComponent(newName);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -172,7 +175,7 @@ $(document).ready(function() {
|
||||
if ( res['name'] ) {
|
||||
name = res['name'];
|
||||
}
|
||||
window.location = baseUrl + '/' + encodeURIComponent(name);
|
||||
window.location = baseUrl + encodeURIComponent(name);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user