Module: JSC::Plugin
- Included in:
- JSCRef, JSCite, MathJaxBlock, MathJaxInline
- Defined in:
- lib/plugin.rb
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #config ⇒ Object
- #math_jax ⇒ Object
- #mj_config ⇒ Object
- #mj_local ⇒ Object
- #mj_local? ⇒ Boolean
- #mj_url ⇒ Object
- #set_ctx(ctx) ⇒ Object
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
3 4 5 |
# File 'lib/plugin.rb', line 3 def ctx @ctx end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
3 4 5 |
# File 'lib/plugin.rb', line 3 def site @site end |
Instance Method Details
#config ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/plugin.rb', line 5 def config @config ||= Hash.new @config['match_jax'] ||= Hash.new @config['match_jax']['config'] ||= 'default.js' @config['match_jax']['local_config'] ||= '' @config['match_jax']['url'] ||= '' @config end |
#math_jax ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/plugin.rb', line 36 def math_jax r = !ctx['jsc']['mj_injected'] ? "<script type=\"text/javascript\" src=\"#{mj_url}?config=#{mj_config}#{mj_local}\"></script>" : '' ctx['jsc']['mj_injected'] ||= true r #todo need to modify loadComplete http://docs.mathjax.org/en/latest/configuration.html#local-config-files end |
#mj_config ⇒ Object
20 21 22 |
# File 'lib/plugin.rb', line 20 def mj_config config['match_jax']['config'] end |
#mj_local ⇒ Object
28 29 30 |
# File 'lib/plugin.rb', line 28 def mj_local mj_local? ? ',' + config['match_jax']['config'] : '' end |
#mj_local? ⇒ Boolean
24 25 26 |
# File 'lib/plugin.rb', line 24 def mj_local? !config['match_jax']['local_config'].empty? end |
#mj_url ⇒ Object
32 33 34 |
# File 'lib/plugin.rb', line 32 def mj_url config['match_jax']['url'].empty? ? 'http://cdn.mathjax.org/mathjax/latest/MathJax.js' : config['match_jax']['url'] end |
#set_ctx(ctx) ⇒ Object
14 15 16 17 18 |
# File 'lib/plugin.rb', line 14 def set_ctx(ctx) @ctx, @site, = ctx, ctx.registers[:site] @config = @site.config['jsc'] || {} ctx['jsc'] ||= {} end |