Merge pull request #847 from hardywu/master

add --mathjax-config to inject root-repo/mathjax.config.js. Closes #842.
This commit is contained in:
Dawa Ometto
2014-10-05 12:41:03 +02:00
5 changed files with 19 additions and 3 deletions
+1
View File
@@ -112,6 +112,7 @@ Options:
--live-preview Enables livepreview. --live-preview Enables livepreview.
--allow-uploads [MODE] Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page). --allow-uploads [MODE] Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page).
--mathjax Enables mathjax. --mathjax Enables mathjax.
--mathjax-config [SOURCE] Inject custom mathjax config. Uses mathjax.config.js from root repository by default
--user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none. --user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none.
--show-all Shows all files in file view. By default only valid pages are shown. --show-all Shows all files in file view. By default only valid pages are shown.
--collapse-tree Collapse file view tree. By default, expanded tree is shown. --collapse-tree Collapse file view tree. By default, expanded tree is shown.
+4
View File
@@ -93,6 +93,10 @@ opts = OptionParser.new do |opts|
wiki_options[:mathjax] = true wiki_options[:mathjax] = true
end end
opts.on("--mathjax-config [SOURCE]", "Inject custom mathjax config file. Uses mathjax.config.js from root repository by default") do |source|
wiki_options[:mathjax_config] = source || 'mathjax.config.js'
end
opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source| opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
wiki_options[:user_icons] = source wiki_options[:user_icons] = source
end end
+1
View File
@@ -91,6 +91,7 @@ module Precious
settings.wiki_options.merge!({ :base_path => @base_url }) settings.wiki_options.merge!({ :base_path => @base_url })
@css = settings.wiki_options[:css] @css = settings.wiki_options[:css]
@js = settings.wiki_options[:js] @js = settings.wiki_options[:js]
@mathjax_config = settings.wiki_options[:mathjax_config]
end end
get '/' do get '/' do
+9 -3
View File
@@ -31,15 +31,21 @@
<script type="text/javascript" src="{{base_url}}/javascript/identicon_canvas.js"></script> <script type="text/javascript" src="{{base_url}}/javascript/identicon_canvas.js"></script>
{{/use_identicon}} {{/use_identicon}}
{{#mathjax}} {{#mathjax}}
<script type="text/x-mathjax-config"> {{^mathjax_config}}
MathJax.Hub.Config({ <script type="text/javascript">
window.MathJax = {
tex2jax: { tex2jax: {
inlineMath: [ ['\\(','\\)'] ], inlineMath: [ ['\\(','\\)'] ],
displayMath: [ ['$$','$$'], ['\\[','\\]'] ], displayMath: [ ['$$','$$'], ['\\[','\\]'] ],
processEscapes: true processEscapes: true
}, },
TeX: { extensions: ["autoload-all.js"] }}); TeX: { extensions: ["autoload-all.js"] }
};
</script> </script>
{{/mathjax_config}}
{{#mathjax_config}}
<script type="text/javascript" src="{{base_url}}/{{mathjax_config}}"></script>
{{/mathjax_config}}
<script>(function(d,j){ <script>(function(d,j){
j = d.createElement('script'); j = d.createElement('script');
j.src = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; j.src = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
+4
View File
@@ -110,6 +110,10 @@ module Precious
@mathjax @mathjax
end end
def mathjax_config
@mathjax_config
end
def use_identicon def use_identicon
@page.wiki.user_icons == 'identicon' @page.wiki.user_icons == 'identicon'
end end