Difference between revisions of "Umlaut partial html API javascript helper"

From Code4Lib
Jump to: navigation, search
(yUAaIuGeGhHiRcER)
 
(40 intermediate revisions by 13 users not shown)
Line 1: Line 1:
http://www.bebo.com/TrevaR8 free porn movies
+
=WARNING: This is Outdated Documentation!!!!=
http://www.bebo.com/CorinneA34 free porn sites
+
 
http://www.bebo.com/SibylC6 free porn video
+
'''THIS IS OUTDATED DOCUMENTATION''' See new Umlaut documentation at http://github.com/team-umlaut/umlaut/wiki
http://www.bebo.com/LolaF575 free amateur porn
+
---------
http://www.bebo.com/PatsyA49 free porn vids
+
 
http://www.bebo.com/TaylorL9449 free porn galleries
+
THE CODE DOCUMENTED HERE IS DEPRECATED. PLEASE SEE INSTEAD: [[JQuery HTML Updater]]
http://www.bebo.com/MaryanneG35 free porn pics
+
 
http://www.bebo.com/CelesteB42 free streaming porn
+
If you want to include [[Umlaut]]-generated HTML directly on a third party page via javascript, there is a javascript helper script to make that very easy. This helper uses the [[Umlaut partial html API]], but does everything for you.  The helper will update your divs, and keep polling Umlaut for new results, continuing to re-update your divs until Umlaut is finished.  How often it polls is configured by application config 'poll_wait_seconds', which defaults to 4 seconds.  
http://www.bebo.com/ReynaC414 free black porn
+
 
http://www.bebo.com/StephanieB9235 free online porn
+
== Overview ==
http://www.bebo.com/ChristineW623 free porn tube
+
 
http://www.bebo.com/ClarissaW35 free full length porn
+
Your page needs to include the JS Prototype library. Currently, automatic inclusion of the Prototype library isn't working, so you'll need to include a <script> line to do so. You can link to the prototype library in Umlaut, see example below.  
http://www.bebo.com/EugeniaM95 free porn downloads
+
 
http://www.bebo.com/ClaudiaG927 free incest porn
+
You will then include an Umlaut javascript file, and then call the embedUmlaut() js function it supplies.  You'll need to pass some arguments to embedUmlaut:  
http://www.bebo.com/ChristalA2 free amature porn
+
 
http://www.bebo.com/KimberleeN9 free homemade porn
+
=== Umlaut base URL ===
http://www.bebo.com/AlfredaJ08 free amatuer porn
+
 
http://www.bebo.com/BridgetM702 free porn site
+
The first argument is your Umlaut base URL. This is not your link resolver base url which for Umlaut ends in /resolve, but the actual Umlaut application base URL, which should be the same, without the /resolve. (Link to JHU example removed, because i think it was attracting malicious bot/spider traffic)
http://www.bebo.com/JordynM393 free xxx porn
+
 
http://www.bebo.com/SuzannaD51 free ebony porn
+
=== Context object ===
http://www.bebo.com/CherylS176 free porn online
+
 
http://www.bebo.com/NatalieJ575 free lesbian porn videos
+
The second argument is a URL-formatted (KEV) [[OpenURL]] context object.
http://www.bebo.com/AnnetteJ081 free young porn
+
 
http://www.bebo.com/ElenoraL5 watch free porn
+
=== Display section mappings ===
http://www.bebo.com/MollyA433 free online porn videos
+
 
http://www.bebo.com/FlorenceW25 best free porn
+
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.  
http://www.bebo.com/ClarissaF18 free teen porn videos
+
 
http://www.bebo.com/NatalieW8899 free porn tubes
+
This mapping hash can also optionally use some javascript callbacks to perform behavior after or during loading of 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.  
http://www.bebo.com/AlthaC free teen porn movies
+
 
http://www.bebo.com/EarleneT65 free porn passwords
+
=== General options ===
http://www.bebo.com/JackieR042 free amateur porn videos
+
 
http://www.bebo.com/GayleP03 free porn for women
+
The fourth argument is a hash of additional options to embedUmlaut.  
http://www.bebo.com/JeannieC075 free beastiality porn
+
 
http://www.bebo.com/ArleneC41 free home made porn
+
=== Other Details ===
http://www.bebo.com/NatalieW4623 free full length porn movie
+
 
http://www.bebo.com/FloL63 free porn flash videos
+
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.  
http://www.bebo.com/KarlaP775 free tranny porn
+
 
 +
The html loaded will sometimes include a "spinner" with a message "loading more", if the content is not yet loaded.
 +
 
 +
An example is best:
 +
 
 +
== Example ==
 +
 
 +
<pre>
 +
 
 +
  <H1>Here is an article page. </h1>
 +
 
 +
  <p>We're looking up Cytoplasmic Control of nuclear behavior by Masui. Of course normally this
 +
    would be dynamically generated, not in static html like this.<p>
 +
 
 +
  <!-- umlaut full text will be loaded here. You might want to include some initial content
 +
      here for browsers without javascript. For browsers with javascript, this will be overwritten.-->
 +
  <div id="my_fulltext">
 +
    <a href="http://umlaut.university.edu/resolve?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">
 +
        Link to umlaut
 +
      </a>
 +
  </div>
 +
 
 +
  <!-- we hide this div to start out with, our js callback later
 +
      will show it there is full text. But we avoid a "spinner" showing up
 +
      here before everything is fully loaded. -->
 +
  <div id="my_search_inside" style="display:none;"></div>
 +
 
 +
  <div id="my_cover"></div>
 +
 
 +
  <div id="my_see_also"</div>
 +
 
 +
  <div id="my_excerpts"></div>
 +
 
 +
 
 +
  <!-- now the javascript to actually load content in those divs -->
 +
 
 +
  <script type="text/javascript">
 +
    // You have to generate an OpenURL context object somehow.  
 +
    // 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';
 +
 
 +
    // where to find umlaut
 +
    umlaut_base = 'http://umlaut.university.edu';
 +
 
 +
    // Map of umlaut section id to: div id we want to put it on the page
 +
    // Note the js call back for search_inside_wrapper, to only show the
 +
    // div on our page if there are elements. Js callback function gets one
 +
    // argument, which will be number of Umlaut responses in the section.  
 +
    // Note also that we can use Prototype in the callback.  
 +
 
 +
    umlaut_section_map = {
 +
      'fulltext': 'my_fulltext',
 +
      'highlighted_links': 'my_see_also',
 +
      'excerpts': 'my_excerpts',
 +
      'cover_image': 'my_cover',
 +
      'search_inside': {'host_div_id': 'my_search_inside',
 +
                                'after_update':
 +
                                  function(count) {
 +
                                    if ( count > 0) {
 +
                                        $('my_search_inside').show();
 +
                                    }
 +
                                  }
 +
                              }
 +
      };
 +
 
 +
      //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>
 +
 
 +
    <!-- include the prototype library -->
 +
    <script type="text/javascript" src="http://umlaut.university.edu/javascripts/prototype.js"></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-func.js"></script>
 +
 
 +
    <!-- and call embedUmlaut -->
 +
    <script type="text/javascript">
 +
      embedUmlaut(umlaut_base, umlaut_openurl_kev_co, umlaut_section_map, umlaut_options);
 +
    </script>
 +
 
 +
 
 +
 
 +
</pre>
 +
 
 +
 
 +
 
 +
 
 +
[[Category:Umlaut]]

Latest revision as of 16:22, 19 June 2012

WARNING: This is Outdated Documentation!!!!

THIS IS OUTDATED DOCUMENTATION See new Umlaut documentation at http://github.com/team-umlaut/umlaut/wiki


THE CODE DOCUMENTED HERE IS DEPRECATED. PLEASE SEE INSTEAD: JQuery HTML Updater

If you want to include Umlaut-generated HTML directly on a third party page via javascript, there is a javascript helper script to make that very easy. This helper uses the Umlaut partial html API, but does everything for you. The helper will update your divs, and keep polling Umlaut for new results, continuing to re-update your divs until Umlaut is finished. How often it polls is configured by application config 'poll_wait_seconds', which defaults to 4 seconds.

Overview

Your page needs to include the JS Prototype library. Currently, automatic inclusion of the Prototype library isn't working, so you'll need to include a <script> line to do so. You can link to the prototype library in Umlaut, see example below.

You will then include an Umlaut javascript file, and then call the embedUmlaut() js function it supplies. You'll need to pass some arguments to embedUmlaut:

Umlaut base URL

The first argument is your Umlaut base URL. This is not your link resolver base url which for Umlaut ends in /resolve, but the actual Umlaut application base URL, which should be the same, without the /resolve. (Link to JHU example removed, because i think it was attracting malicious bot/spider traffic)

Context object

The second argument is a URL-formatted (KEV) OpenURL context object.

Display section mappings

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 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 loading of 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.

The html loaded will sometimes include a "spinner" with a message "loading more", if the content is not yet loaded.

An example is best:

Example


  <H1>Here is an article page. </h1>

  <p>We're looking up Cytoplasmic Control of nuclear behavior by Masui. Of course normally this
     would be dynamically generated, not in static html like this.<p>

  <!-- umlaut full text will be loaded here. You might want to include some initial content
       here for browsers without javascript. For browsers with javascript, this will be overwritten.-->
  <div id="my_fulltext">
     <a href="http://umlaut.university.edu/resolve?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">
        Link to umlaut
      </a>
  </div>

  <!-- we hide this div to start out with, our js callback later 
       will show it there is full text. But we avoid a "spinner" showing up
       here before everything is fully loaded.  -->
  <div id="my_search_inside" style="display:none;"></div>

  <div id="my_cover"></div>

  <div id="my_see_also"</div>

  <div id="my_excerpts"></div>

  
  <!-- now the javascript to actually load content in those divs -->

  <script type="text/javascript">
    // You have to generate an OpenURL context object somehow. 
    // 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';

    // where to find umlaut
    umlaut_base = 'http://umlaut.university.edu';

    // Map of umlaut section id to: div id we want to put it on the page
    // Note the js call back for search_inside_wrapper, to only show the
    // div on our page if there are elements. Js callback function gets one
    // argument, which will be number of Umlaut responses in the section. 
    // Note also that we can use Prototype in the callback. 

    umlaut_section_map = {
      'fulltext': 'my_fulltext',
      'highlighted_links': 'my_see_also',
      'excerpts': 'my_excerpts',
      'cover_image': 'my_cover',
      'search_inside': {'host_div_id': 'my_search_inside', 
                                'after_update':
                                  function(count) {
                                    if ( count > 0) {
                                        $('my_search_inside').show();
                                    }
                                  }
                              }
      };

      //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>

    <!-- include the prototype library -->
    <script type="text/javascript" src="http://umlaut.university.edu/javascripts/prototype.js"></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-func.js"></script>

    <!-- and call embedUmlaut -->
    <script type="text/javascript">
       embedUmlaut(umlaut_base, umlaut_openurl_kev_co, umlaut_section_map, umlaut_options);
    </script>