88
An Introduction to An Introduction to Juice Juice Matt Machell Machell, Juice Project & Talis , June June 2010 talis.com juice-project.org

An introduction to juice

Embed Size (px)

DESCRIPTION

A broad introduction to the OPAC extension framework Juice.

Citation preview

Page 1: An introduction to juice

An Introduction to JuiceAn Introduction to Juice

Matt MachellMachell, Juice Project & Talis , JuneJune 2010

talis.comjuice-project.org

Page 2: An introduction to juice

In the beginning... In the beginning...

Page 3: An introduction to juice

Next GenerationGeneration OPACs

Page 4: An introduction to juice

Lots of nice functionality, great user Lots of nice functionality, great user experience improvements experience improvements

Page 5: An introduction to juice

butbut...

Page 6: An introduction to juice

• Wouldn’t it be nice to have a preview like Google Books?

• Or a twitter feed?• Or a map to the library?

Page 7: An introduction to juice

Lots of byte-sized bits of extra code to Lots of byte-sized bits of extra code to add extra functionality. add extra functionality.

Page 8: An introduction to juice

Examples

Page 9: An introduction to juice
Page 10: An introduction to juice
Page 11: An introduction to juice

butbut...

Page 12: An introduction to juice

But...

• No re-use• Isolated innovation• You really need to be a web developer to do

this

Page 13: An introduction to juice

What if we could make it easy for What if we could make it easy for everybodyeverybody to do this? to do this?

Photo: National Library of New Zealand, http://www.flickr.com/photos/nationallibrarynz_commons

Page 14: An introduction to juice

• Javascript• User Interface • Componentised • Extensions

What if?What if?

Page 15: An introduction to juice

JuiceJuice

Page 16: An introduction to juice

Juice

• Easy to use• Reuse and share innovation• Extensible• Product-independent• Open Source

Page 17: An introduction to juice

ExamplesExamples

Page 18: An introduction to juice
Page 19: An introduction to juice
Page 20: An introduction to juice

Why?

• Created to make life easier!• Easier for non-techies• Easy to improve• Share OPAC-based knowledge around

– let’s not repeat ourselves!

Page 21: An introduction to juice

Key things

• Based on Javascript• Uses the jQuery framework• Really easy to add to a page

Page 22: An introduction to juice

Aside - The Web Stack

• HTML – For content• CSS – For presentation• Javascript – For behaviour

Page 23: An introduction to juice

How it all fits together

Page 24: An introduction to juice

How it all fits together

Page 25: An introduction to juice

Really easy to add to a page:

<script type="text/javascript" src="assets/-/js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="assets/-/js/juice.js"></script><script type="text/javascript" src="assets/-/js/extend.js"></script>

Page 26: An introduction to juice

Metadefsfunction myopac_metadef(){ juice.findMeta("isbn",".item #details .table .ISBN");

juice.findMeta("author",".item .summary .author .author");

}

Page 27: An introduction to juice

Metadefsfunction myopac_metadef(){ juice.findMeta("isbn",".item #details .table .ISBN");

juice.findMeta("author",".item .summary .author .author");

}

Page 28: An introduction to juice

Metadefsfunction myopac_metadef(){ juice.findMeta("isbn",".item #details .table .ISBN");

juice.findMeta("author",".item .summary .author .author");

}

Page 29: An introduction to juice

Getting Juice

http://juice-project.org/GetJuice

Get the full download

More advanced – checkout SVN at http://juice-project.googlecode.com/svn/trunk/

Page 30: An introduction to juice

Files in the Download

Page 31: An introduction to juice

Juicing a site Juicing a site

Page 32: An introduction to juice

Vufind example

Warning – use a test instance not your live server!

Page 33: An introduction to juice
Page 34: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

Page 35: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

2. Add scripts in the layout.tpl template

Page 36: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

2. Add scripts in the layout.tpl template

<script type="text/javascript" src="{$url}/interface/themes/default/juice/jquery-1.3.2.min.js"></script><script type="text/javascript" src="{$url}/interface/themes/default/juice/juice.js"></script><script type="text/javascript" src=“{$url}/interface/themes/default/juice/extend.js"></script>

Page 37: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

2. Add scripts in the layout.tpl template

<script type="text/javascript" src="{$url}/interface/themes/default/juice/jquery-1.3.2.min.js"></script><script type="text/javascript" src="{$url}/interface/themes/default/juice/juice.js"></script><script type="text/javascript" src=“{$url}/interface/themes/default/juice/extend.js"></script>

Page 38: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

2. Add scripts in the layout.tpl template

<script type="text/javascript" src="{$url}/interface/themes/default/juice/jquery-1.3.2.min.js"></script><script type="text/javascript" src="{$url}/interface/themes/default/juice/juice.js"></script><script type="text/javascript" src=“{$url}/interface/themes/default/juice/extend.js"></script>

Page 39: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

2. Add scripts in the layout.tpl template3. Add .htaccess permissions

Page 40: An introduction to juice

Vufind example

Add .htaccess permissions in juice folder at a file called .htaccess with the content:

<IfModule mod_rewrite.c> RewriteEngine Off</IfModule>

Page 41: An introduction to juice

Vufind example

1. Copy juice folder into vufind/vufind/web/interface/themes/default/

2. Add script in the layout.tpl template3. Add .htaccess permissions4. Write extend.js

Page 42: An introduction to juice

extend.jsextend.js

Page 43: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs(path+"/interface/themes/default/juice/

extensions/extendedbyJuice.js")juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 44: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs(path+"/interface/themes/default/juice/

extensions/extendedbyJuice.js")juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 45: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs(path+"/interface/themes/default/juice/

extensions/extendedbyJuice.js")juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 46: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs(path+"/interface/themes/default/juice/

extensions/extendedbyJuice.js")juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 47: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs(path+"/interface/themes/default/juice/

extensions/extendedbyJuice.js")juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 48: An introduction to juice
Page 49: An introduction to juice

Prism 3 Example

Page 50: An introduction to juice

Prism 3 Example

Warning! Use your sandbox and backup your themes!

Page 51: An introduction to juice
Page 52: An introduction to juice

Prism 3 Example

1. Download your theme via admin.talis.com

Page 53: An introduction to juice
Page 54: An introduction to juice

Prism 3 Example

1. Download your theme via admin.talis.com2. Add juice to downloaded copy

Page 55: An introduction to juice

Adding the files

1. Extract the zip file2. Add juice files in the a /js subfolder3. Open footer.html4. Add the snippet below

<script type="text/javascript" src="assets/-/js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="assets/-/js/juice.js"></script><script type="text/javascript" src="assets/-/js/extend.js"></script>

Page 56: An introduction to juice

Adding the files

1. Extract the zip file2. Add juice files in the a /js subfolder3. Open footer.html4. Add the snippet below

<script type="text/javascript" src="assets/-/js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="assets/-/js/juice.js"></script><script type="text/javascript" src="assets/-/js/extend.js"></script>

Page 57: An introduction to juice

Adding the files

1. Extract the zip file2. Add juice files in the a /js subfolder3. Open footer.html4. Add the snippet below

<script type="text/javascript" src="assets/-/js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="assets/-/js/juice.js"></script><script type="text/javascript" src="assets/-/js/extend.js"></script>

Page 58: An introduction to juice

Adding the files

1. Extract the zip file2. Add juice files in the a /js subfolder3. Open footer.html4. Add the snippet below

<script type="text/javascript" src="assets/-/js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="assets/-/js/juice.js"></script><script type="text/javascript" src="assets/-/js/extend.js"></script>

Page 59: An introduction to juice

Create extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 60: An introduction to juice

Create extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 61: An introduction to juice

Create extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 62: An introduction to juice

Create extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 63: An introduction to juice

Create extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 64: An introduction to juice

Prism 3 Example

1. Download your theme via admin.talis.com2. Add juice to downloaded copy3. Zip and upload new copy

Page 65: An introduction to juice

Prism 3 Example

1. Download your theme via admin.talis.com2. Add juice to downloaded copy3. Zip and upload new copy 4. Check at all works!

Page 66: An introduction to juice
Page 67: An introduction to juice

A Note on Demo Tenancies

function prismTenancy(){ var prism = ""; var urlParts = window.location.href.split('/'); if(urlParts[2] == "prism.talis.com"){ prism = urlParts[3]; if (prism == 'demo') { prism += '/' + urlParts[4]; } } return prism;}

jQuery(function () {juice.setDebug(true);var tenant=prismTenancy()juice.loadJs("/assets/-/js/extensions/extendedbyJuice.js",

tenant);juice.onAllLoaded(runExtensions);

}); function runExtensions(){

new extendedbyJuice(juice);}

Page 68: An introduction to juice

A Sample RecipeA Sample Recipe

Page 69: An introduction to juice

Google Books Preview

• Easy addition• Useful feature• Shows external sources

Page 70: An introduction to juice

Google Books Preview

1. Have Juice working

Page 71: An introduction to juice

Google Books Preview

1. Have Juice working2. Download extension and add to extensions

folder:

http://juice-project.org/node/28

Page 72: An introduction to juice

Google Books Preview

1. Have Juice working2. Download extension and add to extensions

folder3. Update extend.js

Page 73: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.loadJs("/assets/-/js/extensions/GBSEmbed.js");juice.onAllLoaded(runExtensions);

});

Page 74: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/

extendedbyJuice.js");juice.loadJs("/assets/-/js/extensions/GBSEmbed.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){ switch(jQuery("body").attr("id")){ case "renderitem": // add code for item page here break; }}

Page 75: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/extendedbyJuice.js");juice.loadJs("/assets/-/js/extensions/GBSEmbed.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){ switch(jQuery("body").attr("id")){ case "renderitem": var div = '<div id="GBSPanel" style="display: block; width: 100%">' + '<h2 class="title">Look Inside</h2>' + '<div id="GBSViewer" style="width: 100%; height: 800px"></div>' + '</div>'; var insert = new JuiceInsert(div,"#details .table","after"); new GBSEmbedJuice(juice,insert,"GBSViewer"); break; }}

Page 76: An introduction to juice

extend.js

case "renderitem": var div = '<div id="GBSPanel" style="display: block; width: 100%">' + '<h2 class="title">Look Inside</h2>' + '<div id="GBSViewer" style="width: 100%; height: 800px"></div>' + '</div>'; var insert = new JuiceInsert(div,"#details .table","after"); new GBSEmbedJuice(juice,insert,"GBSViewer"); break;

Page 77: An introduction to juice

extend.js

case "renderitem": var div = '<div id="GBSPanel" style="display: block; width: 100%">' + '<h2 class="title">Look Inside</h2>' + '<div id="GBSViewer" style="width: 100%; height: 800px"></div>' + '</div>'; var insert = new JuiceInsert(div,"#details .table","after"); new GBSEmbedJuice(juice,insert,"GBSViewer"); break;

Page 78: An introduction to juice

extend.js

case "renderitem": var div = '<div id="GBSPanel" style="display: block; width: 100%">' + '<h2 class="title">Look Inside</h2>' + '<div id="GBSViewer" style="width: 100%; height: 800px"></div>' + '</div>'; var insert = new JuiceInsert(div,"#details .table","after"); new GBSEmbedJuice(juice,insert,"GBSViewer"); break;

Page 79: An introduction to juice

extend.js

case "renderitem": var div = '<div id="GBSPanel" style="display: block; width: 100%">' + '<h2 class="title">Look Inside</h2>' + '<div id="GBSViewer" style="width: 100%; height: 800px"></div>' + '</div>'; var insert = new JuiceInsert(div,"#details .table","after"); new GBSEmbedJuice(juice,insert,"GBSViewer"); break;

Page 80: An introduction to juice

extend.js

jQuery(function () {juice.setDebug(true);juice.loadJs("/assets/-/js/extensions/extendedbyJuice.js");juice.loadJs("/assets/-/js/extensions/GBSEmbed.js");juice.onAllLoaded(runExtensions);

}); function runExtensions(){ switch(jQuery("body").attr("id")){ case "renderitem": var div = '<div id="GBSPanel" style="display: block; width: 100%">' + '<h2 class="title">Look Inside</h2>' + '<div id="GBSViewer" style="width: 100%; height: 800px"></div>' + '</div>'; var insert = new JuiceInsert(div,"#details .table","after"); new GBSEmbedJuice(juice,insert,"GBSViewer"); break; }}

Page 81: An introduction to juice

Google Books Preview

1. Have Juice working2. Download extension and add to extensions

folder3. Update extend.js4. Upload extend.js

Page 82: An introduction to juice

Google Books Preview

1. Have Juice working2. Download extension and add to extensions

folder3. Update extend.js4. Upload extend.js5. Check it all still works

Page 83: An introduction to juice
Page 84: An introduction to juice

As Easy as That!As Easy as That!

Page 85: An introduction to juice

juice-project.org

• Documentation – inc. Screencasts• Downloads• Mailing List• Extension Bazaar

Page 86: An introduction to juice

http://juice-project.org

Page 87: An introduction to juice

Common Issues

• Conflicts with jQuery• Mixed content / Security alerts• Plugins running on pages they shouldn’t

Page 88: An introduction to juice

Questions?