Package assets (#1493)
* Package static assets * Fixed cancel button in editor * Fix rake compilation task * Add asset path helper * Serve MathJax statically * Fix mathjax in preview
This commit is contained in:
+10
-6
@@ -91,8 +91,9 @@ module Precious
|
||||
@mathjax_config = settings.wiki_options[:mathjax_config]
|
||||
|
||||
@use_static_assets = settings.wiki_options.fetch(:static, settings.environment == :production || settings.environment == :staging)
|
||||
@static_assets_path = settings.wiki_options.fetch(:static_assets_path, './public/assets')
|
||||
|
||||
@static_assets_path = settings.wiki_options.fetch(:static_assets_path, ::File.join(File.dirname(__FILE__), 'public/assets'))
|
||||
@mathjax_path = ::File.join(File.dirname(__FILE__), 'public/gollum/javascript/MathJax')
|
||||
|
||||
Sprockets::Helpers.configure do |config|
|
||||
config.environment = settings.sprockets
|
||||
config.environment.context_class.class_variable_set(:@@base_url, @base_url)
|
||||
@@ -110,14 +111,17 @@ module Precious
|
||||
end
|
||||
|
||||
namespace '/gollum' do
|
||||
|
||||
get '/assets/mathjax/*' do
|
||||
env['PATH_INFO'].sub!("/gollum/assets/mathjax", '')
|
||||
Rack::Static.new(not_found_proc, {:root => @mathjax_path, :urls => ['']}).call(env)
|
||||
end
|
||||
|
||||
get '/assets/*' do
|
||||
env['PATH_INFO'].sub!("/#{Precious::Assets::ASSET_URL}", '')
|
||||
if @use_static_assets
|
||||
env['PATH_INFO'].sub!(Sprockets::Helpers.prefix, '') if @base_url
|
||||
not_found_msg = 'Not found.'
|
||||
not_found = Proc.new {[404, {'Content-Type' => 'text/html', 'Content-Length' => not_found_msg.length.to_s}, [not_found_msg]]}
|
||||
Rack::Static.new(not_found, {:root => @static_assets_path, :urls => ['']}).call(env)
|
||||
Rack::Static.new(not_found_proc, {:root => @static_assets_path, :urls => ['']}).call(env)
|
||||
else
|
||||
settings.sprockets.call(env)
|
||||
end
|
||||
@@ -168,6 +172,7 @@ module Precious
|
||||
if page = wikip.page
|
||||
@page = page
|
||||
@content = page.text_data
|
||||
@mathjax = wiki.mathjax
|
||||
@etag = page.sha
|
||||
mustache :edit
|
||||
else
|
||||
@@ -381,7 +386,6 @@ module Precious
|
||||
end
|
||||
@content = @page.formatted_data
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@h1_title = wiki.h1_title
|
||||
@editable = false
|
||||
@bar_side = wiki.bar_side
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'octicons'
|
||||
|
||||
module Precious
|
||||
module Assets
|
||||
MANIFEST = %w(app.js editor.js app.css criticmarkup.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
|
||||
MANIFEST = %w(app.js editor.js app.css criticmarkup.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf)
|
||||
ASSET_URL = 'gollum/assets'
|
||||
|
||||
def self.sprockets(dir = File.dirname(File.expand_path(__FILE__)))
|
||||
|
||||
@@ -33,7 +33,12 @@ module Precious
|
||||
status 404
|
||||
return mustache :error
|
||||
end
|
||||
|
||||
|
||||
def not_found_proc
|
||||
not_found_msg = 'Not found.'
|
||||
Proc.new {[404, {'Content-Type' => 'text/html', 'Content-Length' => not_found_msg.length.to_s}, [not_found_msg]]}
|
||||
end
|
||||
|
||||
def emoji(name)
|
||||
if emoji = Gemojione.index.find_by_name(name)
|
||||
IO.read(EMOJI_PATHNAME.join("#{emoji['unicode'].downcase}.png"))
|
||||
|
||||
+21
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
+5
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
.criticmarkup mark{background-color:#fffd38;text-decoration:none}.criticmarkup del{background-color:#f6a9a9;text-decoration:line-through}.criticmarkup ins{background-color:#a9f6a9;text-decoration:none}.criticmarkup ins.break{display:block;line-height:2px;padding:0 !important;margin:0 !important}.criticmarkup ins.break span{line-height:1.5em}.criticmarkup .popover{background-color:#fffd38;color:#000}.criticmarkup .critic.comment{display:none}.criticmarkup .popover:hover span.critic.comment{display:block;position:absolute;width:200px;left:30%;font-size:0.8em;color:#ccc;background-color:#333;z-index:10;padding:0.5em 1em;border-radius:0.5em}
|
||||
BIN
Binary file not shown.
+24
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
ul.actions{display:none}#delete-link{display:none}div#footer{display:none}
|
||||
BIN
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 939 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -28,10 +28,14 @@ offline with latex equations without bloating the gollum release tarball.
|
||||
6. Slimify mathjax
|
||||
|
||||
cd MathJax-x.y.z && grunt && cd ..
|
||||
|
||||
7. Remove old mathjax (careful!)
|
||||
|
||||
7. Replace bundled mathjax with newly generated one
|
||||
rm -rf ${GOLLUM_ROOT}/lib/gollum/public/gollum/javascript/MathJax
|
||||
|
||||
cp MathJax-x.y.z ${GOLLUM_ROOT}/lib/gollum/public/gollum/javascript
|
||||
8. Replace bundled mathjax with newly generated one
|
||||
|
||||
8. Update mathjax version in ${GOLLUM_ROOT}/lib/gollum/templates/layout.mustache
|
||||
cp MathJax-x.y.z ${GOLLUM_ROOT}/lib/gollum/public/gollum/javascript/MathJax
|
||||
|
||||
9. Update mathjax version in ${GOLLUM_ROOT}/lib/gollum/templates/layout.mustache
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user