Restore path support to livepreview.js.
This commit is contained in:
@@ -74,8 +74,13 @@ $.key = function( key ) {
|
||||
|
||||
// True if &create=true
|
||||
var create = $.key( 'create' );
|
||||
// The name of the page being edited.
|
||||
// The path and name of the page being edited.
|
||||
var pageName = $.key( 'page' );
|
||||
var pathName = $.key( 'path' );
|
||||
|
||||
if ( pathName === 0 ) {
|
||||
pathName = undefined;
|
||||
}
|
||||
|
||||
defaultCommitMessage = function() {
|
||||
var msg = pageName + ' (markdown)';
|
||||
@@ -97,14 +102,20 @@ $.save = function( commitMessage ) {
|
||||
var markdown = 'markdown';
|
||||
var txt = editorSession.getValue();
|
||||
var msg = defaultCommitMessage();
|
||||
var newLocation = location.protocol + '//' + location.host + '/' + pageName;
|
||||
var newLocation = location.protocol + '//' + location.host;
|
||||
|
||||
if (pathName) {
|
||||
newLocation += '/' + pathName;
|
||||
}
|
||||
|
||||
newLocation += '/' + pageName;
|
||||
|
||||
// if &create=true then handle create instead of edit.
|
||||
if ( create ) {
|
||||
jQuery.ajax( {
|
||||
type: POST,
|
||||
url: '/create',
|
||||
data: { page: pageName, format: markdown, content: txt, message: commitMessage || msg },
|
||||
data: { path: pathName, page: pageName, format: markdown, content: txt, message: commitMessage || msg },
|
||||
success: function() {
|
||||
win.location = newLocation;
|
||||
}
|
||||
@@ -113,7 +124,7 @@ $.save = function( commitMessage ) {
|
||||
jQuery.ajax( {
|
||||
type: POST,
|
||||
url: '/edit/' + pageName,
|
||||
data: { format: markdown, content: txt, message: commitMessage || msg },
|
||||
data: { path: pathName, page: pageName, format: markdown, content: txt, message: commitMessage || msg },
|
||||
success: function() {
|
||||
win.location = newLocation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user