diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index cbedb6bc..951016fb 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -113,6 +113,48 @@ $(document).ready(function() { } } + if ($('#minibutton-rename-page').length) { + $('#minibutton-rename-page').removeClass('jaws'); + $('#minibutton-rename-page').click(function(e) { + e.preventDefault(); + + var path = $(this).data('path'); + if (path) { + path = path + '/'; + } + + $.GollumDialog.init({ + title: 'Rename Page', + fields: [ + { + id: 'name', + name: 'Rename to', + type: 'text', + defaultValue: path || '' + } + ], + OK: function( res ) { + var name = 'Rename Page'; + if ( res['name'] ) { + name = res['name']; + } + var path = window.location.pathname; + var oldName = path.substring(path.lastIndexOf('/')+1); + var msg = 'Renamed ' + oldName + ' to ' + name; + jQuery.ajax( { + type: 'POST', + url: '/edit/' + oldName, + // omit path: pathName until https://github.com/github/gollum/issues/446 is fixed. + data: { rename: name, page: oldName, message: msg }, + success: function() { + window.location = '/' + encodeURIComponent(name); + } + }); + } + }); + }); + } + if ($('#minibutton-new-page').length) { $('#minibutton-new-page').removeClass('jaws'); $('#minibutton-new-page').click(function(e) { diff --git a/lib/gollum/frontend/templates/page.mustache b/lib/gollum/frontend/templates/page.mustache index f226dad3..847b875a 100644 --- a/lib/gollum/frontend/templates/page.mustache +++ b/lib/gollum/frontend/templates/page.mustache @@ -11,6 +11,8 @@ class="action-all-pages">File View
  • New Page
  • +
  • + Rename Page
  • {{#editable}}
  • Edit Page