Provide JS with correct exts via template (#1437)
This commit is contained in:
@@ -181,8 +181,6 @@ end
|
||||
|
||||
desc 'Precompile assets'
|
||||
task :precompile do
|
||||
require 'gollum'
|
||||
require 'gollum-lib'
|
||||
require './lib/gollum/views/helpers.rb'
|
||||
require './lib/gollum/assets.rb'
|
||||
require 'sprockets'
|
||||
|
||||
@@ -82,12 +82,6 @@ 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');
|
||||
}
|
||||
@@ -444,7 +438,8 @@ $(document).ready(function() {
|
||||
$(this).attr('disabled', true);
|
||||
|
||||
var formData = new FormData($('#gollum-editor-form').get(0));
|
||||
var newPath = cleanPath(prefixBaseUrl(pagePath() + '/' + pageName() + formatToExt($('#wiki_format')[0].value)));
|
||||
var newExt = '.' + $('#wiki_format option:selected').attr('data-ext');
|
||||
var newPath = cleanPath(prefixBaseUrl(pagePath() + '/' + pageName() + newExt));
|
||||
var endpoint = $('#gollum-editor-form').attr("action");
|
||||
|
||||
$.ajax({
|
||||
|
||||
@@ -59,14 +59,14 @@
|
||||
<select id="wiki_format" name="format" class="form-select">
|
||||
{{#formats}}
|
||||
{{#enabled}}
|
||||
<option {{#selected}}selected="selected" {{/selected}}value="{{id}}">
|
||||
<option {{#selected}}selected="selected" {{/selected}}value="{{id}}" data-ext="{{ext}}">
|
||||
{{name}}
|
||||
</option>
|
||||
{{/enabled}}
|
||||
{{/formats}}
|
||||
{{#formats}}
|
||||
{{^enabled}}
|
||||
<option class="disabled" {{#selected}}selected="selected" {{/selected}}value="{{id}}">
|
||||
<option class="disabled" {{#selected}}selected="selected" {{/selected}}value="{{id}}" data-ext="{{ext}}">
|
||||
{{name}}
|
||||
</option>
|
||||
{{/enabled}}
|
||||
|
||||
@@ -9,6 +9,7 @@ module Precious
|
||||
{ :name => val[:name],
|
||||
:id => key.to_s,
|
||||
:enabled => val.fetch(:enabled, true),
|
||||
:ext => Gollum::Page.format_to_ext(key),
|
||||
:selected => selected == key }
|
||||
end.sort do |a, b|
|
||||
a[:name].downcase <=> b[:name].downcase
|
||||
|
||||
@@ -51,9 +51,6 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user