Partner Interface

From Creative Commons
Revision as of 20:50, 12 April 2006 by Jon Phillips (talk | contribs)
Jump to: navigation, search

Web Integration Developer's Guide

Integrating Creative Commons licenses into your web application

While Creative Commons offers a range of license choices and public domain options direct from its license page, if you have created an application or built a website that allow people to contribute works you may prefer to integrate the license engine directly into your site or application. This guide serves to explain all the steps necessary and options available for integrating Creative Commons into your software.

This guide is generally split into three parts:

Part 1: Letting users select a license

Whether your software is a website or a downloadable application, the first step to integrating Creative Commons licenses is letting users select a license directly from your software. The process involves loading a simplified Creative Commons license interface from within a popup window, embedded into your website, or launched from an HTML window control in your application. URL variables are read into the page and are appended when complete, allowing data to be extracted from the process and passed through it.

The remote license engine application

The heart of the process is running the remote license interface which is available at this URL:

http://creativecommons.org/license/?partner={partner}&exit_url={exit_url}&stylesheet={stylesheet}&partner_icon_url={partner_icon_url}

The full set of URL variables available are as follows:

partner (required): The name of your application or site, used for tracking usage at Creative Commons. Any descriptive name can be added here.

exit_url (required): The return URL on your application that will load after a user selects a license and will contain appended variables in the URL that your software will need to read.

additional requirement:

Your exit_url must include "license_url=[license_url]" and may optionally include the license_name=[license_name], license_button=[license_button], and deed_url=[deed_url] variables. Explanation of each:

license_url: URL for the selected license. Link to this URL in the licensed page. Example: http://creativecommons.org/licenses/by/2.0/

license_name: Pretty name for the selected license. Example: Attribution

license_button: URL for the image corresponding to the selected license, useful for displaying on a licensed page. Example: http://creativecommons.org/images/public/somerights20.gif

deed_url: URL for the deed corresponding to the selected license. Usually this will be identical to the value of license_url, unless a "branded" license is selected. Note that even if deed_url is different than license_url, is is still valid to use the URL specified by license_url, as both will point to the same legal code. If you want to support this feature, link to the deed_url in the licensed page. Example: http://creativecommons.org/licenses/by-nc-nd/2.0/deed-music

A sample exit URL would be:

http://example.com/return_from_cc?license_url=[license_url]%26license_name=[license_name]

The license engine will replace the license_url, license_name, license_button, and deed_url variables with proper variables once a user has chosen a license (more on this in Part 2).

Note that your exit URL can carry your application's URL variables into and out of the license application by URL escaping within your exit URL, for example:

http://example.com/return_from_cc?license_url=[license_url]%26license_name=[license_name]%26userID=42%26user-work=foo.jpg

The above example will let your application know that a userID of 42 that submitted a user-work titled foo.jpg selected a specific license on exit of the license engine.

If you want to maintain state but do not wish to pass data through the URL (e.g., for reasons of privacy or data size), consider saving the data in a user cookie (which will only be sent to your site, not creativecommons.org), save the data in a file or database and save a lookup key in a cookie or pass the lookup key via the URL, or use the popup or iframe methods (see below), which do not require the user to "leave" your form.

stylesheet (optional):

URL of a Cascading Style Sheet (CSS) file to customize the layout, look, and feel of the license questions. View source on the license engine to see the ID and classes available to be styled.

partner_icon_url (optional): if you'd like a custom image displayed at the top of the license application, add the image's URL in this variable.

The following enable choosing licenses ported to the copyright law of specific legal jurisdictions. See the [iCommons project] for more information.

jurisdiction (optional): Choose licenses of specified jurisdiction. With jurisdiction_choose on, sets pre-selected jurisdiction. Currently supported jurisdictions: at, au, be, br, ca, de, es, fi, fr, hr, it, jp, kr, nl, tw.

jurisdiction_choose (optional): If set to '1', user will be given a list of jurisdictions to choose from.

Invoking the remote license engine from your application

Once you have figured out the appropriate variables that will be fed into and out of the remote license engine, you need to invoke it from your website or application.

There are a few basic ways to accomplish this task:

  • Popup window launched from your website
  • Redirect from your website to license engine
  • IFRAME embedded within your website
  • Launched via HTML control within your desktop application

Popup window launched from your website

The most popular method of invoking the remote license engine is via a popup window. A user clicks something on a page that launches a small window containing the questions. After answering them, users proceed, the window closes, and the original page is updated to reflect their choice. Sites using this method will usually change a hidden form variable dynamically (using javascript) when the user finishes the license selection process.

Redirect from your website to license page

This option does not use popup windows of any kind and instead you leave the site you originated from, pick your license, then return to the site with your selection info for the site to decifer. Sites using this method would need to parse the URL variables within the return URL.

IFRAME embedded within your website

For those that do not want to use popup windows, have an audience using version 5.0 web browsers and up, and would like to keep the license selection within their application, an IFRAME can be used much like the popup. Sites using this method would embed the question form into their page, and upon completion, pass variables between the IFRAME and surrounding page.

Launched via HTML control within your desktop application

For desktop applications this method would essentially mimic the popup window code, but instead use a native HTML control within your application. On Windows, visual basic and visual C++ applications have access to an Internet Explorer HTML control that can be launched from within your application. For Mac programmers, OS X offers webcore controls that use Safari as a native browser environment from within your application.

Part 2: Processing and Storage of license information

Once users of your website and application have the ability to select a license, the next step is processing the results of their selection. As mentioned in the previous section, the exit_url is the place on your server that users will return to. Once loaded, the data in the URL will need to be parsed. A exit URL result is shown below:

http://example.com/return.cgi?license_url=http://creativecommons.org/licenses/by-nc/2.0/&license_name=Attribution-NonCommercial&license_button=http://creativecommons.org/images/public/somerights20.gif&deed_url=http://creativecommons.org/licenses/by-nc/2.0/

Depending on your web application's server technology, you'll have to parse data from the URL as needed. From the above url, the following data points can be found:

If you had any additional embedded URL variables specific to your application, you will want to parse those out as well. The exact method and code used to read URL variables will depend on your website/application's language of choice and the syntax of that language.

This data can be used in several places within an application. A well-written application will display a user's choice by using the license_name variable as confirmation, such as "You selected the Attribution-Noncommercial license for your uploaded work." You will likely want to store the license_url and license_code variables within your application, most likely in database filed associated with contributions. Again, the exact method and code used to store license information will depend on your configuration, setup, and storage options.

Part 3: Display of license information

The final step to incorporating Creative Commons licensing into your website or application will be the display and expression of license information to other users. For a typical site, we'll need to output some HTML and some RDF (Resource Description Framework) within the HTML. You can use a service at creativecommons.org to generate HTML with RDF for you, or you may create the HTML with RDF yourself.

Request HTML Output for licensed works

Invoke http://creativecomons.org/license/get-html? with information about the license chosen and licensed work. A chunk of HTML that you can include in a web page will be returned. The following data may be passed in:

license_url: Example: http://creativecommons.org/license/by/2.0/

title: Example: A Happy Book

creator: Example: John Smith

copyright_holder: Example: J. Smith Publishing

copyright_year: Example: 2004

description: Example: A short book this is happy, but won't necessarily make you so.

format: Can be one of text, audio, video, image, or interactive.

work_url: If not set, RDF will refer to the page it is included in. Usually this is desired, and work_url should not be specified.

source_work_url: URL for work derived from, if any. Example: http://example.com/jsmith/a_sad_book.html

The following is a complete get-html request using the above values:

http://creativecommons.org/license/get-html?license_url=http://creativecommons.org/licenses/by/2.0/&title=A%20short%20book%20this%20is%20happy,%20but%20won't%20necessarily%20make%20you%20so.&creator=John%20Smith&copyright_holder=J.%20Smith%20Publishing&copyright_year=2004&description=A%20short%20book%20this%20is%20happy,%20but%20won't%20necessarily%20make%20you%20so.&format=text&source_work_url=http://example.com/jsmith/a_sad_book.html

Try it!

If you only want RDF metadata, invoke get-rdf instead of get-html, using the same data.

Try it!

Create HTML Output for licensed works manually

The most transparent way to display a Creative Commons license on a work is to display the "Some Rights Reserved" or "No Rights Reserved" button next to the work. The generic HTML is below:

<!-- Creative Commons License -->
<a href="{license_url}">
<img alt="Creative Commons License" border="0"
src="{license_button}" /></a>
<br />
This work is licensed under a
<a href="{license_url}"

>Creative Commons License</a>.
<!-- /Creative Commons License -->

If you stored the license_url variable into your application's database, you can query for it and fill it into the {license URL} area above. The code will output a button and message like the one at the footer of this very page, but like our guide to marking up HTML says, customizing the phrase "This work is licensed..." into something more specific is strongly encouraged.

The next bit of HTML to be output is the RDF metadata, embedded within an HTML comment. The following is the bare minimum RDF needed for output, and should immediately follow the HTML for the button:

<!--
<rdf:RDF xmlns="http://web.resource.org/cc/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<Work rdf:about="">
<license rdf:resource="{license_url}" />
</Work>
</rdf:RDF>
-->