Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Licenses

Summary: Markup to display licensing info on pages
Version: 2007-02-15
Prerequisites: PmWiki 2.0
Status: New
Maintainer: Pm
Categories: Markup
Discussion: Licenses-Talk

Questions answered by this recipe

How can I allow authors to display a Creative Commons license in pages?

Description

This recipe enables a (:license:) markup, which allows authors to embed common licensing links (such as Creative Commons licenses) into pages.

To install the recipe, simply download licenses.phpΔ into the cookbook/ directory, and then add the line below to a local customization file:

    include_once('cookbook/licenses.php');

Once installed, the recipe enables the (:license:) markup, which can be used to display a variety of licenses based on its parameter:

(:license by-nc-nd:)   CC Attribution Non-commercial No Derivatives
(:license by-nc-sa:)   CC Attribution Non-commercial Share Alike
(:license by-nc:)      CC Attribution Non-commercial
(:license by-nd:)      CC Attribution No Derivatives
(:license by-sa:)      CC Attribution Share Alike
(:license by:)         CC Attribution
(:license pd:)         Public Domain
(:license:)            site default license, configured by $LicenseDefault
Example 1
(:license by-nc-sa:)
Creative Commons License

WikiStyles can be used to alter the appearance and behavior of the directive, thus

Example 2
%rframe newwin% (:license pd:)
Public Domain Dedication

Notes

Easy 3.0 update + icons for the individual license conditions

in response to Lighans' suggestion below, a new recipe is not required in order update PM's current recipe - rather, one need only add their own up-to-date $LicenseTypeFmt array to their config before loading the licenses.php recipe. In fact, here's a version of $LicenseTypeFmt that includes the possibility of quickly changing the location, version, and size, and also includes the display of icons for the individual license conditions:

$LicenseDefault = 'by-sa-nc';
$LicenseLoc = "/us";  # location is not necessary - the following works without it
$LicenseSize = "88x31";	# regular size
#$LicenseSize = "80x15";  # smaller
$LicenseVersion = "3.0";  # change or update the version

$LicenseTypeFmt = array(
   # main licenses
   'by' => "[[http://creativecommons.org/licenses/by/$LicenseVersion/ | 
      http://i.creativecommons.org/l/by/$LicenseVersion$LicenseLoc/$LicenseSize.png\"Creative Commons License\"]]",
   'by-nd' => "[[http://creativecommons.org/licenses/by-nd/$LicenseVersion/ | 
      http://i.creativecommons.org/l/by-nd/$LicenseVersion$LicenseLoc/$LicenseSize.png\"Creative Commons License\"]]",
   'by-nc-nd' => "[[http://creativecommons.org/licenses/by-nc-nd/$LicenseVersion/ | 
      http://i.creativecommons.org/l/by-nc-nd/$LicenseVersion$LicenseLoc/$LicenseSize.png\"Creative Commons License\"]]",
   'by-nc' => "[[http://creativecommons.org/licenses/by-nc/$LicenseVersion/ | 
      http://i.creativecommons.org/l/by-nc/$LicenseVersion$LicenseLoc/$LicenseSize.png\"Creative Commons License\"]]",
   'by-nc-sa' => "[[http://creativecommons.org/licenses/by-nc-sa/$LicenseVersion/ | 
      http://i.creativecommons.org/l/by-nc-sa/$LicenseVersion$LicenseLoc/$LicenseSize.png\"Creative Commons License\"]]",
   'by-sa' => "[[http://creativecommons.org/licenses/by-sa/$LicenseVersion/ | 
      http://i.creativecommons.org/l/by-sa/$LicenseVersion$LicenseLoc/$LicenseSize.png\"Creative Commons License\"]]",
   'pd' => "[[http://creativecommons.org/licenses/publicdomain/ | 
      http://i.creativecommons.org/l/publicdomain/$LicenseSize.png\"Public Domain Dedication\"]]",

   # individual license condition icons
   'by-icon' => "[[http://creativecommons.org/about/licenses | 
      http://creativecommons.org/images/icons/attrib.gif\"Creative Commons - Attribution\"]]",
   'sa-icon' => "[[http://creativecommons.org/about/licenses | 
      http://creativecommons.org/images/icons/sharealike.gif\"Creative Commons - Share Alike\"]]",
   'nd-icon' => "[[http://creativecommons.org/about/licenses | 
      http://creativecommons.org/images/icons/nomod.gif\"Creative Commons - No Derivative Works\"]]",
   'nc-icon' => "[[http://creativecommons.org/about/licenses | 
      http://creativecommons.org/images/icons/noncomm.gif\"Creative Commons - Noncommercial\"]]",
   'pd-icon' => "[[http://creativecommons.org/about/licenses | 
      http://creativecommons.org/images/icons/pd.gif\"Creative Commons - Public Domain\"]]"
);
include_once("$FarmD/cookbook/licenses.php"); 

As a result, one can call (:license nc-icon:) and get the non-commercial icon to appear... overtones99 August 04, 2009, at 10:42 PM


An updated license recipe, incorporating all of the above!

licenses-2009-08-04.phpΔ - So, this may be a little too complex for such a simple recipe, but I went ahead and created another recipe that takes the modifications mentioned above - the ability to declare a location, to display a license-condition icon, to change the size - and makes them possible at the markup level. This only makes sense for a site where individual users may want to declare different creative commons licenses for different groups or pages; for sites that only need one site-wide license, I recommend just using the original licenses.php by PM.

To start, simply include the file:

include_once("$FarmD/cookbook/licenses-2009-08-04.php");

... and then use any of the following markup to indicate license-type, size, and location (optional):

(:license type=by-nc-nd size=large loc=us:)
or
(:license by-nc-nd size=small:)

This version of the license recipe also incorporates the individual license-condition icons for each aspect of a CC license, i.e. Share Alike, No Derivatives, etc. These are accessed the same as above, but without any size or location arguments, using one of the following arguments - by-icon, sa-icon, nc-icon, nd-icon, pd-icon - as in:

(:license by-icon:)
or
(:license type=by-icon:)

The recipe also permits the following default variables in config.php:

  • $LicenseDefault - i.e. 'by-nc-nd', 'by-icon', ... - used if no type is supplied
  • $LicenseLoc - not required - otherwise enter one of the following two-letter country codes: at, cz, de, ec, es, gr, gt, hk, hr, lu, nl, no, nz, ph, pl, pr, ro, rs, sg, th, us
  • $LicenseSizeDefault - 'large' or 'small' - determines which size license to post if no 'size' argument is provided
  • $LicenseSizeArray - defaults sizes for the two kinds of icons on the creativecommons site - 'large'=>'88x31', or 'small'=>'80x15' - this only applies to the main licenses, not the individual license-condition icons
  • $LicenseVersion - easily update the version your using - default is '3.0'
  • $LicenseBaseLinkURL - base link for most (not all) of the CC-deed link urls - default is http://creativecommons.org/licenses
  • $LicenseBaseImgURL - base link for most (not all) of the CC-image urls - default is http://i.creativecommons.org/l

overtones99 August 04, 2009, at 10:42 PM

History

  • 2009-08-04: added a new receipe, based on the original, that permits markup of the type: (:license type=by-nc-sa size=small loc=es:), along with markup to show individual license-condition icons.
  • 2009-08-04: added an example of a $LicenseTypeFmt array containing v.3.0 icons, PLUS the ability to display the various individual license-condition icons
  • 2007-03-07: This version is for the new creative license 3.0. It also ads nice 80X15px buttons when entering the code. Not sure if I could remove the other one. licenses30.phpΔ Lighans
  • 2007-02-15: Corrected bug with 'pd' license. Allow either uppercase or lowercase specifications.

Comments

  • It would also be nice if the recipe included links to other licenses, e.g. different GPL and BSD. chr

See Also

Contributors

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:42 AM