0.3.1 • Published 6 years ago

ndla-licenses v0.3.1

Weekly downloads
41
License
GPL-3.0
Repository
github
Last release
6 years ago

ndla-licenses

A simple library for retrieving license information by abbreviation (and locale).

Installation

$ npm install ndla-licenses

Usage

Get license by abbreviation

import getLicenseByAbbreviation from 'ndla-licenses';

const license = getLicenseByAbbreviation('CC-BY-NC-4.0', 'en');

console.log(license);
//> { short: 'Free use', title: 'Attribution-NonCommercial', description: 'This license...', rights: ['by', 'sa'] }

// defaults to Norsk Bokmål (nb)
const license = getLicenseByAbbreviation('CC-BY-NC-4.0', 'unknown-locale');
console.log(license);
//> { short: 'Fri bruk', title: 'Navngivelse-IkkeKommersiell', description: 'Denne lisensen...', rights: ['by', 'sa'] }

// returns abbreviation if license is unknown
const license = getLicenseByAbbreviation('unknown-license', 'en');
console.log(license);
//> { short: 'unknown-license', title: 'unknown-license', description: 'unknown-license', rights: [] }

Get license right info by abbreviation/constant

import { getLicenseRightByAbbreviation, BY, CC } from 'ndla-licenses';

const licenseRight = getLicenseRightByAbbreviation(BY, 'en');

console.log(licenseRight);
//> { short: 'cc', title: 'Copyright', userFriendlyTitle: 'Copyright', description: 'Only the creator can derive...' }

// defaults to Norsk Bokmål (nb)
const licenseRight = getLicenseRightByAbbreviation(CC, 'unknown-locale');
console.log(licenseRight);
//> { short: 'cc', title: 'Copyright', userFriendlyTitle: 'Opphavsrett', description: 'Bare opphavspersonen kan bearbeide...' }

// returns abbreviation if licenseRight is unknown
const licenseRight = getLicenseRightByAbbreviation('unknown-lr', 'en');
console.log(licenseRight);
//> { short: 'unknown-lr', title: 'unknown-lr', userFriendlyTitle: 'unknown-lr', description: 'unknown-lr'}

License right constants

import React from 'react';
import { BY, SA } from 'ndla-licenses';
import Icon from './Icons';

const LicenseIcon = ({ licenseRight }) => {
  switch (licenseRight) {
    case BY:
      return <Icon.LicenseBy />;
    case SA:
      return <Icon.LicenseSa />;
    default:
      return undefined;
  }
};

Available constants:

Exported nameValueDescription
BY'by'Attribution
SA'sa'Share-alike
NC'nc'Non-commercial
ND'nd'No derivative work
PD'pd'Public Domain
CC0'cc0'Public Domain Dedication
CC'cc'Copyright
0.3.1

6 years ago

0.3.2

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

7 years ago

0.0.11

7 years ago

0.0.9

7 years ago

0.0.9-2

7 years ago

0.0.9-0

7 years ago

0.0.9-beta.3

7 years ago

0.0.9-beta.2

7 years ago

0.0.8-beta.2

7 years ago

0.0.8

7 years ago

0.0.8-beta.1

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago