Add a 'New Page' button to the /pages browser that allows users to create a new page within a subdirectory.

This commit is contained in:
Darren Oakley
2012-06-22 11:41:42 +01:00
parent 8fd11e8fdb
commit 6e35a09abd
8 changed files with 54 additions and 16 deletions
+1
View File
@@ -299,6 +299,7 @@ module Precious
file.raw_data
else
@name = name
@path = path
mustache :create
end
end
@@ -64,6 +64,12 @@ a {
color: #999;
}
#gollum-editor .path_note {
text-align: right;
font-size: small;
padding-right: 5px;
}
#gollum-editor-title-field input#gollum-editor-page-title {
font-weight: bold;
margin-top: 0;
@@ -102,22 +102,28 @@ $(document).ready(function() {
$('#minibutton-new-page').click(function(e) {
e.preventDefault();
$.GollumDialog.init({
title: 'Create New Page',
fields: [
{
id: 'name',
name: 'Page Name',
type: 'text'
}
],
OK: function( res ) {
var n = 'New Page';
if ( res['name'] )
var n = res['name'];
n = encodeURIComponent( n );
window.location = '/' + n;
}
});
title: 'Create New Page',
fields: [
{
id: 'name',
name: 'Page Name',
type: 'text'
}
],
OK: function( res ) {
var name = 'New Page';
if ( res['name'] ) {
var name = res['name'];
}
var url = '';
var path = $('#minibutton-new-page').data('path');
if (path) {
url += '/' + encodeURIComponent(path)
}
window.location = url + '/' + encodeURIComponent(name);
}
});
});
}
@@ -10,6 +10,9 @@
<div id="gollum-editor-title-field" class="singleline">
<label for="page" class="jaws">Page Title</label>
<input type="text" name="page" id="gollum-editor-page-title" value="{{page_name}}">
{{#has_path}}
<p class="path_note"><strong>NOTE:</strong> This page will be created within the &quot;<strong>{{path}}</strong>&quot; directory</p>
{{/has_path}}
</div>
{{/is_create_page}}
{{#is_edit_page}}
@@ -7,6 +7,9 @@
</li>
<li class="minibutton"><a href="/"
class="action-edit-page">Home</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page"{{{new_page_data_variables}}}>New Page</a>
</li>
</ul>
</div>
<div id="pages">
+4
View File
@@ -15,6 +15,10 @@ module Precious
def title
"Home"
end
def has_path
!@path.nil?
end
end
end
end
+4
View File
@@ -9,6 +9,10 @@ module Precious
"All pages in #{@ref}"
end
def new_page_data_variables
%{ data-path="#{@path}"} if @path
end
def breadcrumb
if @path
path = Pathname.new(@path)