Difference between revisions of "Partner Interface"

From Creative Commons
Jump to: navigation, search
(Create HTML Output for licensed works manually)
(Create HTML Output for licensed works manually)
Line 206: Line 206:
  
 
We encourage web application writers to add additional, custom RDF based on any available metadata, including license information itself. This will be used in the future for search engines and specialized applications that can crawl the web seeking this RDF out and cataloging the information found. The full set of RDF possibilites follow.
 
We encourage web application writers to add additional, custom RDF based on any available metadata, including license information itself. This will be used in the future for search engines and specialized applications that can crawl the web seeking this RDF out and cataloging the information found. The full set of RDF possibilites follow.
 +
 +
<div class="code">
  
 
'''dc:title''' - A title or name for the resource.
 
'''dc:title''' - A title or name for the resource.
Line 237: Line 239:
 
'''Agents''' (people or things that do stuff) and '''Licenses''', of course, can use the same structure to provide their names, dates, etc.
 
'''Agents''' (people or things that do stuff) and '''Licenses''', of course, can use the same structure to provide their names, dates, etc.
  
Licenses are described by their characteristics, which come in three types:
+
</div>
 +
 
 +
=== Licenses are described by their characteristics, which come in three types: ===
  
 
==== Permissions (rights granted by the license) ====
 
==== Permissions (rights granted by the license) ====

Revision as of 21:09, 12 April 2006

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>
-->

We encourage web application writers to add additional, custom RDF based on any available metadata, including license information itself. This will be used in the future for search engines and specialized applications that can crawl the web seeking this RDF out and cataloging the information found. The full set of RDF possibilites follow.

dc:title - A title or name for the resource.

dc:description - A text description of the resource.

dc:subject - Key words and phrases describing the topic of the resource.

dc:publisher - A cc:Agent responsible for making the resource available.

dc:creator - A cc:Agent who created the resource.

dc:contributor - An cc:Agent who contributed to the creation of the resource.

dc:rights - The cc:Agent who holds the copyright on the resource.

dc:date - A copyright date for the resource.

dc:format - The Media Type of the resource.

Examples: "text/plain," "audio/mpeg".

dc:type - The DCMI Type (schema) of the resource.

Examples: <http://purl.org/dc/dcmitype/Image>, <http://purl.org/dc/dcmitype/Sound>.

dc:source, cc:derivativeWork - A Work that the resource was derived from.

cc:license - A copyright license for the resource, a structured cc:License. If there are two cc:licenses, then the licensee gets to pick which to use.

Agents (people or things that do stuff) and Licenses, of course, can use the same structure to provide their names, dates, etc.

Licenses are described by their characteristics, which come in three types:

Permissions (rights granted by the license)

Reproduction - the work may be reproduced

Distribution - the work (and, if authorized, derivative works) may be distributed, publicly displayed, and publicly performed

DerivativeWorks - derivative works may be created and reproduced

Prohibitions (things prohibited by the license)

CommercialUse - rights may be exercised for commercial purposes

Requirements (restrictions imposed by the license)

Notice - copyright and license notices must be kept intact

Attribution - credit must be given to copyright holder and/or author

ShareAlike - derivative works, if authorized, must be licensed under the same terms as the work

Note: these characteristics are advisory only. They are designed to describe the characteristics of a license; they are not themselves a license. For the specific implementation of each characteristic, as well as other details which may not be encoded in the RDF, you must consult the text of the actual license. A license should always be linked from these metadata terms.

Here's an example of what a full file will look like:

<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="http://example.org/gnomophone.mp3">

  <dc:title>Compilers in the Key of C</dc:title>
  <dc:description>A lovely classical work on compiling code.</dc:description>
  <dc:creator><Agent>
    <dc:title>Yo-Yo Dyne</dc:title>

  </Agent></dc:creator>
  <dc:rights><Agent>
    <dc:title>Gnomophone</dc:title>
  </Agent></dc:rights>

  <dc:date>1842</dc:date>
  <dc:format>audio/mpeg</dc:format>
  <dc:type rdf:resource="http://purl.org/dc/dcmitype/Sound" />
  <dc:source rdf:resource="http://example.net/gnomovision.mov" />

  <license rdf:resource="http://creativecommons.org/licenses/by-nc-nd/2.0/" />
  <license rdf:resource="http://www.eff.org/IP/Open_licenses/eff_oal.html" />
</Work>

<License rdf:about="http://creativecommons.org/licenses/by-nc-nd/2.0/">

  <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
  <permits rdf:resource="http://web.resource.org/cc/Distribution" />
  <requires rdf:resource="http://web.resource.org/cc/Notice" />
  <requires rdf:resource="http://web.resource.org/cc/Attribution" />

  <prohibits rdf:resource="http://web.resource.org/cc/CommercialUse" />
</License>
</rdf:RDF>

For reference, here is a file showing the basic HTML and RDF output for all six licenses and the public domain option.

Storage and Data Considerations

If you have a web application that allows users to select licenses for their contributions, you will probably be keeping track of their license choices in a database. Depending on your application, your data model will need to allow at least the license URL variable to be stored alongside contribution records. You may also want to store the license name, the license code, and the license button image, if you would like to fully automate dynamic output of licenses on your application pages.

Conclusion

Letting users select a license, working with the license data, and outputing information about the licensed works are the three parts necessary to integrate Creative Commons licensing into your application.