IntegratingAigaion/EmbeddingViews
From AigaionWiki
Contents |
Introduction
There are, as far as we can see, two relatively simple ways to embed Aigaion views in pages of another web site (personal homepage, CMS, Wiki, etc). One is to get the appropriate Aigaion page using PHP from within the PHP script of that other web site, and insert the resulting HTML in to that web site. The other one is needed when you need the embedded Aigaion page to have access to the Aigaion session on the client's computer. In that case, the embedding needs to be done in an Ajax java script on the client computer. For this, add a piece of configured java script to the other web page that opens an Ajax call to the Aigaion server, and inserts the returned display somewhere in a div in the other web page.
The Aigaion content to be displayed
The content that you want to embed in another page can be anything. You might want to embed in your CMS a named link to a single publication, or embed a summary of a publication with a certain ID, or embed in your personal home page a list of all publications by a certain author, etcetera.
Some possibilities are defined in the controller 'readapi', accessed through <aigaionroot>/readapi/link/<type>/<id> and <aigaionroot>/readapi/embed/<type>/<id>.
As you can easily define your own controllers in Aigaion, it is no problem to build custom views to embed in your other web sites or Content Management Systems.
Two methods for embedding content
Method 1: Server Side Embedding of Aigaion Views
A case example: suppose you have a personal home page, and you want to embed a list of your own publications in it, retrieved from your personal Aigaion database. The method described here uses server-side embedding to achieve this. That is, the personal web site is configured with login information, and whever it is displayed, it will will log in to the Aigaion server, retrieve the requested list of publications, and show the list in the homepage.
Method 1 works on the server hosting the enclosing page (CMS, or wiki, or personal home page) in which you want to embed Aigaion content.
The method uses a php httpclient class to make a connection from that server with the Aigaion server, logs in through the httpclient class, retrieves the data, and inserts it into the surrounding page before it is sent to the users' browser.
The http client class needs to be able to understand redirects, sessions, cookies and POST variables.
This is very simple to do. Example code can be found in the Aigaion code base in the directory 'embeddingexamples', in the file 'simple_embedding_example.php'. The example is documented for configuration and use, and allows both retrieval of anonymous content, and content accessed through a login account.
Based on this example, we have written a plugin for MediaWiki that embeds content returned by the Aigaion controller <aigaionroot>/index.php/readapi/link/<type>/<id>. This is shown in the example section on this page.
Method 2: Client Side Embedding of Aigaion Views
Another small case: Suppose that our research group stores all our publications in Aigaion. On the web page of our research group we want to add a list of all publications of last year. Attachments are not accessible for guest users, so they are usually not visible on this embedded page. But if the page is viewed by one of the members of the research group, and he happens to be logged in to Aigaion, too, we want the attachment links to show up for him!
The easiest way to do this is use client-side Ajax scripts to download the embedded view. For this, we add a piece of configured java script to the research group's web page that opens an Ajax call to the Aigaion server, and inserts the returned list of publications somewhere in a div in the web page. This Ajax call will run from the current user session. If the user is a visitor, this will mean a anonymous access, and no attachment links. If the user is a research group member who is also currently logged into Aigaion in a different browser tab, this will mean attachment links.
Example code can be found in the Aigaion code base in the directory 'embeddingexamples', in the files 'clientside_embedding_within_subdomain_example.php' and 'clientside_embedding_cross_subdomain_example.php'. The examples are documented for configuration and use. They are slightly more complicated, especially the one that allows you to embed content cross-subdomain (e.g. from demo2.aigaion.nl into wiki.aigaion.nl, as below).
Examples of embedding Aigaion content in mediawiki
We wrote a mediawiki extension to demonstrate several different embedding approaches. The extension can be found in the Aigaion SVN repository in the directory plugintegration/mediawiki. It's code is based on the examples in the directory embeddingexamples/.
Example of method 1 for embedding of content in MediaWiki
We wrote the mediawiki extension #aigaionlink to embed simple Aigaion links in mediawiki pages. This extension uses method 1 for embedding.
This Aigaion documentation wiki has been configured to retrieve content from the Aigaion database at demo2.aigaion.nl using the 'demo' account login info.
Below you see a list of commands that you can include in the wiki page, and their output.
| Command | Result | Remarks |
|---|---|---|
| {{#aigaionlink: pub | klapuri:06}} | Multiple Fundamental Frequency Estimation by Summing Harmonic Amplitudes | Publication by bibtex-id |
| {{#aigaionlink: pub | 725}} | Multiple Fundamental Frequency Estimation by Summing Harmonic Amplitudes | Publication by publication-id |
| {{#aigaionlink: pub | 999}} | Unknown id or bibtex_id: 999 | Publication '999' does not exist |
| {{#aigaionlink: author | 1054}} | Klapuri, Anssi | Author by number |
| {{#aigaionlink:author|Anssi Klapuri}} | CANNOT INTERPRET FULL AUTHOR NAMES YET. Unknown author id or name: Anssi Klapuri | Author by name: does not work yet. |
| {{#aigaionlink: author | 1054 | simple}} | author#1054 | The 'simple' parameter forces mediawiki to NOT log in into Aigaion, but simply make a link with a number instead of a name. Note that you can enforce all aigaionlinks to be like that by adapting the LocalSettings.php |
| {{#aigaionlink: aaa | 726}} | Unknown entry type for Aigaionlink: "aaa" | 'aaa' is not a valid link type |
| {{#aigaionlink: topic | 37}} | Unknown id or bibtex_id: 37 | Topic linking |
| {{#aigaionlink: topic | 37 | simple}} | pub#37 | Simple topic linking without login |
| {{#aigaionlink:topic|02 - Posters/02 - Tuesday Poster Session}} | 02 - Tuesday Poster Session | Topic linking by name, using tree structure |
Example of method 2 for embedding of content in MediaWiki
Embedding using this #aigaion function retrieves the content using the current login session of the client browser. To see this, look at the embedded publication list of Anssi Klapuri, given below with the command {{#aigaion: author | 1054}}. Normally, you will see one publication, because you will right now not be logged in at the Aigaion demo database. However, if you now go to demo2.aigaion.nl, log in as demo/demo, then refresh this wiki page, you'll see that you get an additional second publication, which has become available to you because you are right now logged in in the Aigaion demo database.
Other examples, for which the Aigaion controller is not yet written:
{{#aigaion: topic | 42}}:
Acknowledgements
The stuff discussed here owes a lot to the contributions on the forums by people such as Øyvind, Braberli, MGorven, boldy, breuera and others.