Class: Wirispluginengine::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Wiris, WirisPlugin
Defined in:
app/controllers/wirispluginengine/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#integrationObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/controllers/wirispluginengine/application_controller.rb', line 17

def integration
  #Loading resources for WirisPlugin (gem/resources dir).
  spec = Gem::Specification.find_by_name("wirispluginengine")
  gem_root = spec.gem_dir
  Storage.resourcesDir = gem_root.to_s + '/resources'

  wirishash = Hash.new()
  params.each do |key, value|
    wirishash[key] = value
  end
  propertiesparams = PropertiesTools.toProperties(wirishash)
  rcu = RubyConfigurationUpdater.new()
  rcu.request = request
  pb = PluginBuilderImpl.getInstance()
  pb.addConfigurationUpdater(rcu)
  provider = GenericParamsProviderImpl.new(propertiesparams)
  pb.setStorageAndCacheCacheObject(CacheImpl.new(pb.getConfiguration().getFullConfiguration()));
  pb.setStorageAndCacheCacheFormulaObject(CacheFormulaImpl.new(pb.getConfiguration().getFullConfiguration()));

  pb.addCorsHeaders(HttpResponse.new(self), request.headers['Origin'])

  case self.params[:script].inspect.gsub('"', '')
  when 'configurationjs'
    configurationjs = Configurationjs.new
    render :js =>  configurationjs.dispatch(request, response, pb)
  when 'createimage'
    createimage = CreateImage.new
    render :plain => createimage.dispatch(request, response, provider, pb)
  when 'showimage'
    showimage = ShowImage.new
    image = showimage.dispatch(request, response, provider, pb)
    if (pb.getConfiguration().getProperty('wirispluginperformance', 'false') == 'true')
      expires_in 60.minutes
      render :json => image
    else
      send_data image.pack("C*"), :type => response.content_type, :disposition => 'inline'
    end
  when 'service'
    service = Service.new()
    render :plain => service.dispatch(request, response, provider, pb)
  when 'getmathml'
    getmathml = GetMathMLDispatcher.new()
    render :text => getmathml.dispatch(request, response, provider, pb)
  when 'test'
    #test variable changed to wiristest
    #in order to avoid conflict with rails production consoles
    wiristest = WirisTest.new()
    render :html => wiristest.dispatch(request, pb).html_safe
  when 'cleancache'
    wiriscleancache = CleanCache.new()
    render :text => wiriscleancache.dispatch(request, response, provider, pb)
  when 'resource'
    wirisresource = Resource.new()
    render :text => wirisresource.dispatch(response, provider, pb)
  when 'configurationjson'
    wirisconfiguration = ConfigurationJson.new()
    render :json => wirisconfiguration.dispatch(request, response, provider, pb)
  when 'testfilter'
    filteredText = TestFilter.new()
    render :plain => filteredText.dispatch(request, response, provider, pb)

  else
    render plain:"Method no exists"
  end
  Storage.resourcesDir = nil
end