Fix change of format (#1419)

* Add empty language def for bibtex
This commit is contained in:
Dawa Ometto
2019-09-25 11:44:42 +02:00
committed by GitHub
parent 88c624877e
commit bbe609974a
6 changed files with 58 additions and 7 deletions
+2 -2
View File
@@ -275,8 +275,8 @@ module Precious
end
committer.commit
wikip = wiki_page(rename)
page = wikip.page
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
page = wiki_page("#{rename}.#{Gollum::Page.format_to_ext(page.format)}").page
return if page.nil?
redirect to("/#{page.escaped_url_path}")
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
// Uses the route definitions in /lib/gollum/views/helpers.rb.
// For example, routePath('delete') is equivalent to 'delete_path' in the mustache templates.
var gollumRoutes = $.parseJSON('<%= routes_to_json %>')
function routePath(name){
var routes = $.parseJSON('<%= routes_to_json %>')
path = routes[name]
path = gollumRoutes[name]
return prefixBaseUrl(path);
}
function prefixBaseUrl(path) {
if (baseUrl == undefined ) {
console.log('Gollum error: baseUrl undefined')
} else if (path == undefined ) {
@@ -72,6 +76,12 @@ function abspath(path, name){
return [newPath, newName];
}
var gollumFormats = $.parseJSON('<%= format_extensions %>');
function formatToExt(format) {
// 'markdown' -> .md, 'asciidoc' -> .asciidoc
return gollumFormats[format];
}
function setTextDirection () {
$('.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);
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");
$.ajax({
@@ -414,7 +425,7 @@ $(document).ready(function() {
processData: false,
contentType: false,
success: function(data) {
window.location = window.location.href.replace(/gollum\/edit\//, '')
window.location = newPath;
},
error: function(data, textStatus, errorThrown) {
if (data.status == 412) {
+3
View File
@@ -51,6 +51,9 @@ module Precious
define_method :routes_to_json do
@@route_methods.to_json
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
def page_route(page)