Fix redirect location for editor submit (#1430)
This commit is contained in:
@@ -33,6 +33,12 @@ function prefixBaseUrl(path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure one slash at the beginning, no trailing slash.
|
||||||
|
function cleanPath (path){
|
||||||
|
var result = '/' + path.replace(/\/$/,'');
|
||||||
|
return result.replace(/\/{2}/g, '/');
|
||||||
|
}
|
||||||
|
|
||||||
function pageName(){
|
function pageName(){
|
||||||
// "my/dir/file.md" => "file"
|
// "my/dir/file.md" => "file"
|
||||||
if (typeof(pageFullPath) == 'undefined') {
|
if (typeof(pageFullPath) == 'undefined') {
|
||||||
@@ -207,7 +213,7 @@ $(document).ready(function() {
|
|||||||
var oldName = pageName();
|
var oldName = pageName();
|
||||||
var context_blurb =
|
var context_blurb =
|
||||||
"Renamed page will be under " +
|
"Renamed page will be under " +
|
||||||
"<span class='path'>" + htmlEscape('/' + path) + "</span>" +
|
"<span class='path'>" + htmlEscape(cleanPath(path)) + "</span>" +
|
||||||
" unless an absolute path is given."
|
" unless an absolute path is given."
|
||||||
|
|
||||||
$.GollumDialog.init({
|
$.GollumDialog.init({
|
||||||
@@ -246,19 +252,17 @@ $(document).ready(function() {
|
|||||||
$('#minibutton-new-page').parent().removeClass('jaws');
|
$('#minibutton-new-page').parent().removeClass('jaws');
|
||||||
$('#minibutton-new-page').click(function(e) {
|
$('#minibutton-new-page').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var path = pagePath();
|
var path = pagePath();
|
||||||
if( path === undefined && $('#file-browser').length != 0 ){
|
if( path === undefined && $('#file-browser').length != 0 ){
|
||||||
// In the pages view, pageFullPath isn't defined.
|
// In the pages view, pageFullPath isn't defined.
|
||||||
// The new button will still expect a value however.
|
// The new button will still expect a value however.
|
||||||
// So we try to figure one out from window.location
|
// So we try to figure one out from window.location
|
||||||
path = window.location.pathname.replace(routePath('overview'), '')
|
path = window.location.pathname.replace(routePath('overview'), '')
|
||||||
// For consistency remove the trailing /
|
|
||||||
path = path.replace(/\/$/,'')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var context_blurb =
|
var context_blurb =
|
||||||
"Page will be created under " +
|
"Page will be created under " +
|
||||||
"<span class='path'>" + htmlEscape('/' + path) + "</span>" +
|
"<span class='path'>" + htmlEscape(cleanPath(path)) + "</span>" +
|
||||||
" unless an absolute path is given."
|
" unless an absolute path is given."
|
||||||
|
|
||||||
$.GollumDialog.init({
|
$.GollumDialog.init({
|
||||||
@@ -425,7 +429,7 @@ $(document).ready(function() {
|
|||||||
$(this).attr('disabled', true);
|
$(this).attr('disabled', true);
|
||||||
|
|
||||||
var formData = new FormData($('#gollum-editor-form').get(0));
|
var formData = new FormData($('#gollum-editor-form').get(0));
|
||||||
var newPath = prefixBaseUrl(pagePath() + '/' + pageName() + formatToExt($('#wiki_format')[0].value));
|
var newPath = cleanPath(prefixBaseUrl(pagePath() + '/' + pageName() + formatToExt($('#wiki_format')[0].value)));
|
||||||
var endpoint = $('#gollum-editor-form').attr("action");
|
var endpoint = $('#gollum-editor-form').attr("action");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
Reference in New Issue
Block a user