Move new page dir logic to JS.

This commit is contained in:
bootstraponline
2012-08-01 01:49:26 -06:00
parent a0f05eaf67
commit 02539bfdd3
7 changed files with 8 additions and 26 deletions
-2
View File
@@ -344,8 +344,6 @@ module Precious
@content = page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
# Set @path for mustache :page new_page_data_variables
@path = path
mustache :page
elsif file = wiki.file(fullpath)
content_type file.mime_type
@@ -154,9 +154,12 @@ $(document).ready(function() {
$('#minibutton-new-page').click(function(e) {
e.preventDefault();
var path = $(this).data('path');
if (path) {
path = path + '/';
var path = location.pathname;
// ensure there's more than one slash in pathname.
if (path.split('/').length > 2) {
path = path.substr(path.lastIndexOf('/')+1) + '/';
} else {
path = '';
}
$.GollumDialog.init({
+1 -1
View File
@@ -10,7 +10,7 @@
<li class="minibutton"><a href="{{base_url}}fileview"
class="action-all-pages">Files</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page"{{{new_page_data_variables}}}>New</a></li>
<a href="#" id="minibutton-new-page">New</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-rename-page">Rename</a></li>
{{#editable}}
+1 -1
View File
@@ -8,7 +8,7 @@
<li class="minibutton"><a href="{{base_url}}"
class="action-edit-page">Home</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page"{{{new_page_data_variables}}}>New</a>
<a href="#" id="minibutton-new-page">New</a>
</li>
</ul>
</div>
-4
View File
@@ -7,10 +7,6 @@ module Precious
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
DEFAULT_AUTHOR = 'you'
def new_page_data_variables
%{ data-path="#{@path}"} if @path
end
def title
@page.url_path.gsub("-", " ")
end
-4
View File
@@ -9,10 +9,6 @@ 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)
-11
View File
@@ -34,15 +34,4 @@ context "Precious::Views::Pages" do
@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
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