+2
-2
@@ -275,8 +275,8 @@ module Precious
|
|||||||
end
|
end
|
||||||
committer.commit
|
committer.commit
|
||||||
|
|
||||||
wikip = wiki_page(rename)
|
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
|
||||||
page = wikip.page
|
page = wiki_page("#{rename}.#{Gollum::Page.format_to_ext(page.format)}").page
|
||||||
return if page.nil?
|
return if page.nil?
|
||||||
redirect to("/#{page.escaped_url_path}")
|
redirect to("/#{page.escaped_url_path}")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* BibTeX Language Definition
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.GollumEditor.defineLanguage('bib', {});
|
||||||
|
})(jQuery);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Plain Text Language Definition
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.GollumEditor.defineLanguage('txt', {});
|
||||||
|
})(jQuery);
|
||||||
@@ -10,9 +10,13 @@ function brokenAvatarImage(image){
|
|||||||
// Get path for named route, prefixing baseUrl if necessary
|
// Get path for named route, prefixing baseUrl if necessary
|
||||||
// Uses the route definitions in /lib/gollum/views/helpers.rb.
|
// Uses the route definitions in /lib/gollum/views/helpers.rb.
|
||||||
// For example, routePath('delete') is equivalent to 'delete_path' in the mustache templates.
|
// For example, routePath('delete') is equivalent to 'delete_path' in the mustache templates.
|
||||||
|
var gollumRoutes = $.parseJSON('<%= routes_to_json %>')
|
||||||
function routePath(name){
|
function routePath(name){
|
||||||
var routes = $.parseJSON('<%= routes_to_json %>')
|
path = gollumRoutes[name]
|
||||||
path = routes[name]
|
return prefixBaseUrl(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function prefixBaseUrl(path) {
|
||||||
if (baseUrl == undefined ) {
|
if (baseUrl == undefined ) {
|
||||||
console.log('Gollum error: baseUrl undefined')
|
console.log('Gollum error: baseUrl undefined')
|
||||||
} else if (path == undefined ) {
|
} else if (path == undefined ) {
|
||||||
@@ -72,6 +76,12 @@ function abspath(path, name){
|
|||||||
return [newPath, newName];
|
return [newPath, newName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var gollumFormats = $.parseJSON('<%= format_extensions %>');
|
||||||
|
function formatToExt(format) {
|
||||||
|
// 'markdown' -> .md, 'asciidoc' -> .asciidoc
|
||||||
|
return gollumFormats[format];
|
||||||
|
}
|
||||||
|
|
||||||
function setTextDirection () {
|
function setTextDirection () {
|
||||||
$('.markdown-body p, .markdown-body span, .markdown-body pre, .markdown-body table').attr('dir','auto');
|
$('.markdown-body p, .markdown-body span, .markdown-body pre, .markdown-body table').attr('dir','auto');
|
||||||
}
|
}
|
||||||
@@ -405,6 +415,7 @@ $(document).ready(function() {
|
|||||||
$(this).attr('disabled', true);
|
$(this).attr('disabled', true);
|
||||||
|
|
||||||
var formData = new FormData($('#gollum-editor-form').get(0));
|
var formData = new FormData($('#gollum-editor-form').get(0));
|
||||||
|
var newPath = prefixBaseUrl(pagePath() + '/' + pageName() + formatToExt($('#wiki_format')[0].value));
|
||||||
var endpoint = $('#gollum-editor-form').attr("action");
|
var endpoint = $('#gollum-editor-form').attr("action");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -414,7 +425,7 @@ $(document).ready(function() {
|
|||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
window.location = window.location.href.replace(/gollum\/edit\//, '')
|
window.location = newPath;
|
||||||
},
|
},
|
||||||
error: function(data, textStatus, errorThrown) {
|
error: function(data, textStatus, errorThrown) {
|
||||||
if (data.status == 412) {
|
if (data.status == 412) {
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ module Precious
|
|||||||
define_method :routes_to_json do
|
define_method :routes_to_json do
|
||||||
@@route_methods.to_json
|
@@route_methods.to_json
|
||||||
end
|
end
|
||||||
|
define_method :format_extensions do
|
||||||
|
Hash[Gollum::Markup.formats.to_a.map{|fmt| [fmt[0], ".#{Gollum::Page.format_to_ext(fmt[0])}"]}].to_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_route(page)
|
def page_route(page)
|
||||||
|
|||||||
+23
-2
@@ -173,6 +173,15 @@ context "Frontend" do
|
|||||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "rename preserves format" do
|
||||||
|
page_1 = @wiki.page("B")
|
||||||
|
post "/gollum/rename/B", :rename => "/C.rst", :message => 'def'
|
||||||
|
|
||||||
|
follow_redirect!
|
||||||
|
assert_equal '/C.rst.md', last_request.fullpath
|
||||||
|
assert last_response.ok?
|
||||||
|
end
|
||||||
|
|
||||||
test "renames page catches invalid page" do
|
test "renames page catches invalid page" do
|
||||||
# No such page
|
# No such page
|
||||||
post "/gollum/rename/no-such-file-here", :rename => "/C", :message => 'def'
|
post "/gollum/rename/no-such-file-here", :rename => "/C", :message => 'def'
|
||||||
@@ -194,7 +203,6 @@ context "Frontend" do
|
|||||||
assert_equal last_response.status, 500
|
assert_equal last_response.status, 500
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test "renames page in subdirectory" do
|
test "renames page in subdirectory" do
|
||||||
page_1 = @wiki.page("G/H")
|
page_1 = @wiki.page("G/H")
|
||||||
assert_not_equal page_1, nil
|
assert_not_equal page_1, nil
|
||||||
@@ -229,7 +237,6 @@ context "Frontend" do
|
|||||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test "creates page" do
|
test "creates page" do
|
||||||
post "/gollum/create", :content => 'abc', :page => "D",
|
post "/gollum/create", :content => 'abc', :page => "D",
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
@@ -330,6 +337,20 @@ context "Frontend" do
|
|||||||
assert_equal nil, page_e
|
assert_equal nil, page_e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "edit allows changing format" do
|
||||||
|
post '/gollum/create', :content => 'create_msg', :page => 'gandalf',
|
||||||
|
:path => '/', :format => 'markdown', :message => ''
|
||||||
|
page = @wiki.page('gandalf.md')
|
||||||
|
assert page
|
||||||
|
|
||||||
|
@wiki.clear_cache
|
||||||
|
|
||||||
|
post '/gollum/edit/', :content => 'new content', :format => 'txt', :page => 'gandalf', :path => '/', :message => '', :etag => page.sha
|
||||||
|
assert last_response.ok?
|
||||||
|
assert_nil @wiki.page('gandalf.md')
|
||||||
|
assert @wiki.page('gandalf.txt')
|
||||||
|
end
|
||||||
|
|
||||||
test "page create and edit with dash & page rev" do
|
test "page create and edit with dash & page rev" do
|
||||||
page = 'c-d-e'
|
page = 'c-d-e'
|
||||||
path = 'a/b/' # path must end with /
|
path = 'a/b/' # path must end with /
|
||||||
|
|||||||
Reference in New Issue
Block a user