Class: ResolveController
- Inherits:
-
UmlautController
- Object
- ApplicationController
- UmlautController
- ResolveController
- Defined in:
- app/controllers/resolve_controller.rb
Overview
Requests to the Resolve controller are OpenURLs. There is one exception: Instead of an OpenURL, you can include the parameter umlaut.request_id=[some id] to hook up to a pre-existing umlaut request (that presumably was an OpenURL).
Constant Summary collapse
- @@no_create_request_actions =
Init processing will look at this list, and for actions mentioned, will not create a @user_request if an existing one can’t be found. Used for actions meant only to deal with existing requests.
['background_update']
Instance Method Summary collapse
- #api ⇒ Object
-
#background_status ⇒ Object
Display a non-javascript background service status page–or redirect back to index if we’re done.
-
#bg_thread ⇒ Object
Not an action method.
-
#display_coins ⇒ Object
Useful for developers, generate a coins.
-
#get_permalink ⇒ Object
Return permalink for request, creating one if it doesn’t already exist.
- #index ⇒ Object
-
#partial_html_sections ⇒ Object
This action is for external callers.
Methods included from Umlaut::ControllerBehavior
#default_url_options, #set_locale
Methods included from UmlautConfigurable
Instance Method Details
#api ⇒ Object
108 109 110 111 112 113 |
# File 'app/controllers/resolve_controller.rb', line 108 def api # Run the request if neccesary. self.service_dispatch() @user_request.save! api_render() end |
#background_status ⇒ Object
Display a non-javascript background service status page–or redirect back to index if we’re done.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/resolve_controller.rb', line 65 def background_status unless ( @user_request.any_services_in_progress? ) # Just redirect to ordinary index, no need to show progress status. # Include request.id, but also context object kev. params_hash = {:controller=>"resolve", :action=>'index', 'umlaut.skip_resolve_menu'.to_sym => params['umlaut.skip_resolve_menu'], 'umlaut.request_id'.to_sym => @user_request.id } url = url_for_with_co( params_hash, @user_request.to_context_object ) redirect_to( url ) else # If we fall through, we'll show the background_status view, a non-js # meta-refresh update on progress of background services. # Your layout should respect this instance var--it will if it uses # the resolve_head_content partial, which it should. @meta_refresh_self = umlaut_config.lookup!("poll_wait_seconds", 4) end end |
#bg_thread ⇒ Object
Not an action method. Used only in test environment, get the Thread object executing background services, so you can #join on it to wait for bg services to complete.
118 119 120 |
# File 'app/controllers/resolve_controller.rb', line 118 def bg_thread @bg_thread end |
#display_coins ⇒ Object
Useful for developers, generate a coins. Start from search/journals?umlaut.display_coins=true or search/books?umlaut.display_coins=true
60 61 |
# File 'app/controllers/resolve_controller.rb', line 60 def display_coins end |
#get_permalink ⇒ Object
Return permalink for request, creating one if it doesn’t already exist. Usually called by AJAX, to create on-demand permalink.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/resolve_controller.rb', line 42 def get_permalink unless current_permalink_url permalink = Permalink.new_with_values!(@user_request.referent, @user_request.referrer_id) @user_request.referent.permalinks << permalink end respond_to do |format| format.html format.json do render :json => {:permalink => current_permalink_url} end end end |
#index ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/resolve_controller.rb', line 24 def index # saving the bg Thread object mostly so testing environment # can wait on it. @bg_thread = self.service_dispatch() # check for menu skipping configuration. link is a ServiceResponse link = if ( ! link.nil? ) redirect_to url_for(:controller => "link_router", :action => "index", :id => link.id ) else # Render configed view, if configed, or default view if not. render umlaut_config.resolve_view end end |
#partial_html_sections ⇒ Object
This action is for external callers. An external caller could get data as xml or json or whatever. But Umlaut already knows how to render it. What if the external caller wants the rendered content, but in discrete letter packets, a packet of HTML for each ServiceTypeValue? This does that, and also let’s the caller know if background services are still running and should be refreshed, and gives the caller a URL to refresh from if neccesary.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/controllers/resolve_controller.rb', line 93 def partial_html_sections # Tell our application_helper#url_for to generate urls with hostname @generate_urls_with_host = true # Force background status to be the spinner--default js way of putting # spinner in does not generally work through ajax techniques. @force_bg_progress_spinner = true # Mark that we're doing a partial generation, because it might # matter later. @generating_embed_partials = true # Run the request if neccesary. self.service_dispatch() @user_request.save! self.api_render() end |