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