From bb51b61cfc3fcb367f52d31948039a1468fbcf80 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Wed, 17 Mar 2021 03:01:06 +0000
Subject: CTAN sync 202103170301

---
 .../biblatex-license/biblatex-license.sty          | 125 +++++++++++++++++++++
 1 file changed, 125 insertions(+)
 create mode 100644 macros/latex/contrib/biblatex-contrib/biblatex-license/biblatex-license.sty

(limited to 'macros/latex/contrib/biblatex-contrib/biblatex-license/biblatex-license.sty')

diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-license/biblatex-license.sty b/macros/latex/contrib/biblatex-contrib/biblatex-license/biblatex-license.sty
new file mode 100644
index 0000000000..f4b27e0943
--- /dev/null
+++ b/macros/latex/contrib/biblatex-contrib/biblatex-license/biblatex-license.sty
@@ -0,0 +1,125 @@
+% This package serves the purpose of providing a way
+% for relating entries in the bibliography to the license
+% under which those entries where licensed. For this end
+% it uses the build in biblatex 'related' mechanism to
+% link works to their license. It therefor defines a new
+% 'relatedtype', which is 'license'.
+% 
+% Anselm Wagner (a.wagner1@uni-wuppertal.de)
+%
+% This material is subject to the LaTeX Project Public License 1.3c.
+% https://ctan.org/license/lppl1.3
+% 
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\ProvidesPackage{biblatex-license}
+  [2020/01/30 v1.0 biblatex-license]
+\RequirePackage{biblatex}
+\RequirePackage{kvoptions}
+\SetupKeyvalOptions{
+  family=biblicense,
+  prefix=biblicense@}
+\DeclareStringOption[short]{license} % how should the licenses be printed in
+                                     % bib? Options: short, full, off
+\DeclareBoolOption[false]{url} % should the url of the license be printed
+                               % as well?
+\DeclareBoolOption[true]{link} % should the lincense be a weblink?
+\DeclareStringOption[default]{introtext} % alternative introtext for licenses
+                                         % in the bibliography. Arbitrary text.
+\ProcessKeyvalOptions*
+
+\ifbiblicense@link % link=true
+  \RequirePackage{hyperref}
+\fi
+
+% set related=true otherwise this package has no functionality
+\ExecuteBibliographyOptions{related=true}
+
+% Common definitions:
+\NewBibliographyString{licensedunder}
+\DefineBibliographyStrings{english}{%
+  licensedunder = {licensed under},
+}
+\DefineBibliographyStrings{german}{%
+  licensedunder = {Lizenziert unter},
+}
+
+\newbibmacro*{shortIfShorttitleExists}{%
+    \iffieldundef{shorttitle}
+    {\printfield{title}}
+    {\printfield{shorttitle}}
+}
+
+\newbibmacro*{licenseAsLink}{\printfield[licenseAsLink]{url}}
+
+\DeclareFieldFormat{licenseAsLink}{\href{#1}{\usebibmacro{shortIfShorttitleExists}\unspace}}
+
+% test if alternative introtext was entered and change accordingly
+\ifnum\pdf@strcmp{\biblicense@introtext}{default}=0%
+    \newcommand{\biblicenseintrotext}{\biblstring{licensedunder}}
+\else
+    \newcommand{\biblicenseintrotext}{\biblicense@introtext}
+\fi
+
+
+\ifnum\pdf@strcmp{\biblicense@license}{off}=0% Package has no functionality.
+  \newbibmacro*{related:license}[1]{}
+\else % license is to be printed
+  \ifnum\pdf@strcmp{\biblicense@license}{short}=0% short license to be printed
+    \ifbiblicense@url % url=true
+      \newbibmacro*{related:license}[1]{%
+        \entrydata{#1}{%
+          \printtext{\biblicenseintrotext}%
+          \setunit{\addspace}%
+          \usebibmacro{shortIfShorttitleExists}%
+          \iffieldundef{url}
+          {}
+          {\setunit{\addspace}\usebibmacro{url}}}%
+      }
+    \else % url=false
+      \ifbiblicense@link % link=true
+        \newbibmacro*{related:license}[1]{%
+          \entrydata{#1}{%
+            \printtext{\biblicenseintrotext}%
+            \setunit{\addspace}%
+            \iffieldundef{url}
+            {\usebibmacro{shortIfShorttitleExists}}
+            {\usebibmacro{licenseAsLink}}%
+          }
+        }
+      \else % link=false
+        \newbibmacro*{related:license}[1]{%
+          \entrydata{#1}{%
+            \printtext{\biblicenseintrotext}%
+            \setunit{\addspace}%
+            {\usebibmacro{shortIfShorttitleExists}}%
+          }
+        }
+      \fi % link = ?
+    \fi % url = ?
+  \else % license=full -- full license to be printed
+      \newbibmacro*{related:license}[1]{%
+          \entrydata{#1}{%
+              \printtext{\biblicenseintrotext}%
+              \setunit{\addspace}%
+              \usedriver
+              {\ifnameundef{savedauthor}
+                  {\ifnameundef{savededitor}
+                      {}
+                      {\ifnamesequal{editor}{savededitor}
+                      {\clearname{editor}}
+                      {}}}
+                  {\ifnamesequal{author}{savedauthor}
+                      {\clearname{author}}
+                      {}}%
+              \renewbibmacro*{related:init}{}%
+              \DeclareNameAlias{sortname}{default}%
+              \ifbibmacroundef{date+extradate}
+                  {}
+                  {\renewbibmacro*{date+extradate}{}%
+                  \renewbibmacro*{date}{\printdate}}%
+              \renewbibmacro*{pageref}{}}
+              {\thefield{entrytype}}
+          }
+      }
+  \fi
+\fi
-- 
cgit v1.2.3

