// AUTHOR: rberinger
// Version: 0.9b (Currently Beta)
// Date: 11/18/2009
dekiapi();
var PageToMove = ($0 ?? $page ?? page.path);
var NewPageTitle = ($1 ?? $title ?? '');
var MoveTo = ($2 ?? $moveto ?? '');
var Action = ($3 ?? $action ?? 'follow'); // refresh, follow, ''
var ButtonText = ($4 ?? $text ?? 'Move Page');
if(string.startswith(PageToMove, '/')) {
let PageToMove = string.substr(PageToMove, 1);
}
// Get the page that we are moving
var p = wiki.getpage(PageToMove);
// The new page path
if(string.LastIndexOf(MoveTo, '/') != (#MoveTo - 1) ) {
let MoveTo ..= '/';
}
// We need to get our page title whether new or old
var ttl = ((NewPageTitle != '') ? NewPageTitle : p.title);
// The pageid of the page to be moved
var pageID = p.id;
// Account for special characters
let ttl = string.replace(ttl, ' ', '_');
let ttl = string.replace(ttl, '/', '//');
// Append the page title to the path
var NewTitle = MoveTo ..ttl;
// Lets make sure we are not trying to move the page again
// We have to check this way due to possible page redirects that may exist
if(p.path != NewTitle) {
<input id=(@id) class="MoveButton" type="button" value=(ButtonText) ctor="when($this.click) { MovePage(PageToMoveID, NewLoc, MoveAction) }" />
}
<html><head>
<script type="text/javascript">"
var NewLoc = "..json.emit(NewTitle)..";
var PageToMoveID = "..json.emit(pageID)..";
var MoveAction = "..json.emit(string.ToLower(Action))..";
"</script>
<script type="text/javascript">"
var MovePage = function(pidToMove, NewPath, ActionAfterMove) {
var Site_API = "..json.emit(site.api)..";
var Site_URI = "..json.emit(site.uri)..";
var Url = Site_API + '/pages/' + pidToMove + '/move?to=' + NewPath;
Deki.$.ajax({
type: 'POST',
url: Url,
complete: function(data, result){
if(result == 'success') {
if(ActionAfterMove == 'refresh') {
window.location = window.location;
} else if(ActionAfterMove == 'follow') {
location.replace( Site_URI + NewPath );
} else if(ActionAfterMove == '') {
}
} else {
alert( 'Move Failed' );
}
}
});
}
"</script>
</head></html> | Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by