edit: page name fallback for subdirectory index
[minimedit.git] / edit.js
diff --git a/edit.js b/edit.js
index 95a512efb776fca604edacf4dd986493f8e1b2c8..8359c687ceb8fafd144f82e14726374b2137c675 100644 (file)
--- a/edit.js
+++ b/edit.js
@@ -2,10 +2,10 @@ CKEDITOR.plugins.add('inlinesave', {
        init: function(editor) {
                editor.addCommand( 'inlinesave', {
                        exec: function (editor) {
-                               var pagename = window.location.pathname.replace(/^\//, '') || 'index';
+                               var pagename = window.location.pathname.replace(/^\/(?:\.html)?/, '') || 'index';
                                var data = 'page='+encodeURIComponent(pagename)+'&body='+encodeURIComponent(editor.getData());
                                ajaxpost = new XMLHttpRequest();
-                               ajaxpost.open('POST', 'edit.php', true);
+                               ajaxpost.open('POST', '/edit.php', true);
                                ajaxpost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                                ajaxpost.onreadystatechange = function () {
                                        if (ajaxpost.readyState != 4)
@@ -50,7 +50,7 @@ CKEDITOR.on('instanceCreated', function (event) {
                        ['Inlinesave', '-', 'ShowBlocks', 'Sourcedialog', '-', 'Undo', 'Redo'],
                        ['Format'],
                        ['BulletedList', 'NumberedList', '-', 'Blockquote'],
-                       ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Link'],
+                       ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', '-', 'Link'],
                        ['HorizontalRule', 'Table', 'Image'],
                ];