Cchost/concepts/Sample Pools

From Creative Commons
Revision as of 06:51, 24 November 2008 by Fourstones (talk | contribs) (Converting Wordpress Blogs into Sample Pool)
Jump to: navigation, search


A sample pool is a site that exposes Creative Commons licensed media and optionally accepts 'trackback' style notifications of reuse. To be a sample pool the site exposes it's media with a RESTful API called the Sample Pool API. Every ccHost is potentially a sample pool with several admin options to control the interfacing with other sample pool enabled sites. The definition of the API can be found at every ccHost installation at <installation_root>/pool_api_doc for example at ccMixter.

Converting Wordpress Blogs into Sample Pool

As it turns out 99% of the functionality needed to be a passive Sample Pool is already built into recent Wordpress installations so the tweaking needed is extremely minimal. Here are the steps:

1) If you have a plugin or some other mechanism that adds a <*.license tag to your feed entries, then skip to step (2). Otherwise, find the 'functions.php' file in your theme. That would be in a place like wp-content/themes/your_theme_name/functions.php

Put the following code into that file:

 //Add CC license to namespace, item, inline img link within description
 function add_license_ns()
  { echo
    'xmlns:cc=""' .
    "\n\t" ; }
 add_action('rss2_ns', 'add_license_ns');
 function add_license_item()
 { if( !empty($_GET['pool']) )
    { echo "\t" .
      '<cc:license></cc:license>' .
      "\n"; } }
 add_action('rss2_item', 'add_license_item');

The code above assumes a BY 3.0 license for your items. If you have a different default license then replace the license URL in the code above. If you have difference licenses for each item then I leave that as an exercise for the reader.

2) This hack assumes you have mod_rewrite enabled on your WP site. In the line directly after:

RewriteBase /

Put the following code:

 RewriteCond %{QUERY_STRING}  ^query=(.+)$
 RewriteRule ^pool/search$ tag/remixable/?feed=rss2&pool=1&s=%1 [L,R]
 RewriteRule ^pool(/info/?)?$   tag/_?feed=rss2&pool=1 [L,R]

(It's possible my mail client breaks the lines apart, there should be three lines that each start with "Rewrite...")

3) Tag all entries that you want in the Sample Pool as 'remixable'. If you use a different tag, replace the word 'remixable' in step (2) above with your tag. If you use a category, replace the word 'tag' with 'category'.

That's it!

These sites should work with either 4.x ccHost sites as well as 5.