Changes

Jump to: navigation, search

Umlaut partial html API javascript helper

617 bytes added, 20:12, 16 September 2009
no edit summary
== Overview ==
You need to specify your will first include an Umlaut base URL in a global javascript variable called umlaut_base. This is not your link resolver base url which for Umlaut ends in /resolvefile, but and then call the actual Umlaut application base URL, which should be the same, without the /resolveembedUmlaut() js function it supplies. (Link You'll need to pass some arguments to JHU example removed, because i think it was attracting malicious bot/spider traffic)embedUmlaut.
You also need to put a === Umlaut base URL-formatted (KEV) [[OpenURL]] context object in a global js variable called umlaut_openurl_kev_co.===
You then specify mappings from The first argument is your Umlaut html sections to HTML divs on base URL. This is not your page in global js variable called umlaut_section_map containing a hash. link resolver base url which for Umlaut html sections are configured ends in /resolve, but the actual Umlaut in the "partial_html_map" configuration paramapplication base URL, which by default is set to should be the "bg_update_map" config params :divs key. To see same, without the sections in a default Umlaut installation, see: AppConfig::Base.bg_update_map [http://umlautresolve.rubyforge.org/svn/trunk/config/initializers/umlaut/resolve_views.rb in resolve_views in svn]. The :divs key of the hash there is an array of hashes, each individual hash has a :div_id key that corresponds (Link to the html_sections id in this api response. For Umlaut developersJHU example removed, the :partial key tells you what [[Rails]] partial is used to generate this section. because i think it was attracting malicious bot/spider traffic)
You === Context object === The second argument is a URL-formatted (KEV) [[OpenURL]] context object. The third argument is a javascript hash providing mappings from Umlaut html sections to HTML divs on your page. Umlaut html sections are configured in Umlaut in the "partial_html_map" configuration param, which by default is set to the "bg_update_map" config params :divs key. To see the sections in a default Umlaut installation, see: AppConfig::Base.bg_update_map [http://umlaut.rubyforge.org/svn/trunk/config/initializers/umlaut/resolve_views.rb in resolve_views in svn]. The :divs key of the hash there is an array of hashes, each individual hash has a :div_id key that corresponds to the html_sections id in this api response. For Umlaut developers, the :partial key tells you what [[Rails]] partial is used to generate this section.  This mapping hash can also optionally use some javascript callbacks to perform behavior after or during loadingof a particular section. In the following example, we'll demo using a javascript callback to only show a div for search_inside functionality if there are search_inside tools provided.  === General options === The fourth argument is a hash of additional options to embedUmlaut.  === Other Details ===
The umlaut_embed.js script will check if the javascript Prototype library is loaded into the host page, and load it if not. Among other things, this means you can use Prototype in your callbacks.
<script type="text/javascript">
// You have to generate an OpenURL context object somehow, and set it in a js global var.
// Normally this would be generated dynamically, not static HTML like this, of course.
// You may want to include a rfr_id to identify your application as a source, demo below.
umlaut_openurl_kev_co = 'url_ver=Z39.88-2004&rft_val_fmt=info:ofi/fmt:kev:mtx:journal&rft_id=info:doi/10.1002/jez.1401770202&rfr_id=info:sid/university.edu:myapplication&rft.genre=article&rft.jtitle=J.%20Exp.%20Zool&rft.date=1971&rft.atitle=Cytoplasmic%20control%20of%20nuclear%20behavior&rft.aulast=Masui';
// set global js var to tell script where to find umlaut
umlaut_base = 'http://umlaut.university.edu';
}
};
 
//global embedUmlaut options
//demonstrate putting up an alert when Umlaut is done loading all content, which you
//wouldn't want to do, but anyway.
umlaut_options = {
'all-complete-callback': function() { alert('All done!'); }
}
</script>
<!-- now actually load the umlaut js helper, which will do the magic for you -->
<script type="text/javascript" src="http://umlaut.university.edu/javascripts/embed/umlaut-embed.js"> <!-- and call embedUmlaut --> <script type="text/javascript"> embedUmlaut(umlaut_base, umlaut_openurl_kev_co, umlaut_section_map, umlaut_options); </script> </script>

Navigation menu