Difference between revisions of "Cchost/concepts/Sample Pools"
Fourstones (talk | contribs) (→Converting Wordpress Blogs into Sample Pool) |
Fourstones (talk | contribs) (→Converting Wordpress Blogs into Sample Pool) |
||
Line 17: | Line 17: | ||
'xmlns:cc="<nowiki>http://backend.userland.com/creativeCommonsRssModule</nowiki>"' . | 'xmlns:cc="<nowiki>http://backend.userland.com/creativeCommonsRssModule</nowiki>"' . | ||
"\n\t" ; } | "\n\t" ; } | ||
− | + | ||
add_action('rss2_ns', 'add_license_ns'); | add_action('rss2_ns', 'add_license_ns'); | ||
− | + | ||
function add_license_item() | function add_license_item() | ||
{ if( !empty($_GET['pool']) ) | { if( !empty($_GET['pool']) ) | ||
Line 25: | Line 25: | ||
'<nowiki><cc:license>http://creativecommons.org/licenses/by/3.0/</cc:license></nowiki>' . | '<nowiki><cc:license>http://creativecommons.org/licenses/by/3.0/</cc:license></nowiki>' . | ||
"\n"; } } | "\n"; } } | ||
− | + | ||
add_action('rss2_item', 'add_license_item'); | add_action('rss2_item', 'add_license_item'); | ||
Revision as of 05:52, 24 November 2008
Overview
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="http://backend.userland.com/creativeCommonsRssModule"' . "\n\t" ; } add_action('rss2_ns', 'add_license_ns'); function add_license_item() { if( !empty($_GET['pool']) ) { echo "\t" . '<cc:license>http://creativecommons.org/licenses/by/3.0/</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.