Merge pull request #400 from nature/new_page_within_dir
Add a 'New Page' button to the /pages browser.
This commit is contained in:
@@ -299,6 +299,7 @@ module Precious
|
|||||||
file.raw_data
|
file.raw_data
|
||||||
else
|
else
|
||||||
@name = name
|
@name = name
|
||||||
|
@path = path
|
||||||
mustache :create
|
mustache :create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ a {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#gollum-editor .path_note {
|
||||||
|
text-align: right;
|
||||||
|
font-size: small;
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
#gollum-editor-title-field input#gollum-editor-page-title {
|
#gollum-editor-title-field input#gollum-editor-page-title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
|
|||||||
@@ -102,22 +102,28 @@ $(document).ready(function() {
|
|||||||
$('#minibutton-new-page').click(function(e) {
|
$('#minibutton-new-page').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$.GollumDialog.init({
|
$.GollumDialog.init({
|
||||||
title: 'Create New Page',
|
title: 'Create New Page',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
id: 'name',
|
id: 'name',
|
||||||
name: 'Page Name',
|
name: 'Page Name',
|
||||||
type: 'text'
|
type: 'text'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
OK: function( res ) {
|
OK: function( res ) {
|
||||||
var n = 'New Page';
|
var name = 'New Page';
|
||||||
if ( res['name'] )
|
if ( res['name'] ) {
|
||||||
var n = res['name'];
|
var name = res['name'];
|
||||||
n = encodeURIComponent( n );
|
}
|
||||||
window.location = '/' + n;
|
|
||||||
}
|
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">
|
<div id="gollum-editor-title-field" class="singleline">
|
||||||
<label for="page" class="jaws">Page Title</label>
|
<label for="page" class="jaws">Page Title</label>
|
||||||
<input type="text" name="page" id="gollum-editor-page-title" value="{{page_name}}">
|
<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 "<strong>{{path}}</strong>" directory</p>
|
||||||
|
{{/has_path}}
|
||||||
</div>
|
</div>
|
||||||
{{/is_create_page}}
|
{{/is_create_page}}
|
||||||
{{#is_edit_page}}
|
{{#is_edit_page}}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="minibutton"><a href="/"
|
<li class="minibutton"><a href="/"
|
||||||
class="action-edit-page">Home</a></li>
|
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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="pages">
|
<div id="pages">
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ module Precious
|
|||||||
def title
|
def title
|
||||||
"Home"
|
"Home"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_path
|
||||||
|
!@path.nil?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ module Precious
|
|||||||
"All pages in #{@ref}"
|
"All pages in #{@ref}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_page_data_variables
|
||||||
|
%{ data-path="#{@path}"} if @path
|
||||||
|
end
|
||||||
|
|
||||||
def breadcrumb
|
def breadcrumb
|
||||||
if @path
|
if @path
|
||||||
path = Pathname.new(@path)
|
path = Pathname.new(@path)
|
||||||
|
|||||||
@@ -32,4 +32,15 @@ context "Precious::Views::Pages" do
|
|||||||
@page.instance_variable_set("@results", results)
|
@page.instance_variable_set("@results", results)
|
||||||
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "new_page_data_variables within Home directory" do
|
||||||
|
assert_equal nil, @page.new_page_data_variables
|
||||||
|
end
|
||||||
|
|
||||||
|
test "new_page_data_variables within subdirectory" do
|
||||||
|
@page.instance_variable_set("@path", "Mordor")
|
||||||
|
assert_equal ' data-path="Mordor"', @page.new_page_data_variables
|
||||||
|
@page.instance_variable_set("@path", "Mordor/Eye-Of-Sauron")
|
||||||
|
assert_equal ' data-path="Mordor/Eye-Of-Sauron"', @page.new_page_data_variables
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user