blob: 1a34bc17db77d3f8c252d644288efee68a54e70d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
% SPDX-FileCopyrightText: 2015-2021 Robin Schneider <ypid@riseup.net>
%
% SPDX-License-Identifier: LPPL-1.3c
%
% This work consists of all files listed in manifest.txt.
% For more details about the licensing, refer to the README.md file.
% If you don't have those files, you can find them at: https://ctan.org/pkg/doclicense
\NeedsTeXFormat{LaTeX2e}[1998/12/01]
\ProvidesPackage{doclicense}
[2021/03/13 v2.3.0 Support for putting documents under a license]
\RequirePackage{kvoptions}
\DeclareStringOption{type}
\DeclareStringOption{modifier}
\DeclareStringOption{version}
\DeclareStringOption{lang}
\DeclareStringOption[-88x31]{imagemodifier}% chktex 29
\DeclareStringOption[right]{imageposition}
\DeclareStringOption[10em]{imagewidth}
\DeclareStringOption[2em]{imagedistance}
\DeclareStringOption{hyphenation}
\DeclareBoolOption[true]{hyperxmp}
\ProcessLocalKeyvalOptions*
\RequirePackage{xifthen}
\RequirePackage{xstring}
\RequirePackage{etoolbox} % \ifcsdef
\RequirePackage{xspace}
\RequirePackage{verbatim}
\newenvironment{doclicense@enumerate}{%
\begin{enumerate}
\renewcommand{\labelenumi}{(\alph{enumi})}%
\renewcommand{\labelenumii}{(\arabic{enumii})}%
\renewcommand{\labelenumiii}{(\Alph{enumiii})}%
\renewcommand{\labelenumiv}{(\roman{enumiv})}%
}{\end{enumerate}}
\ifthenelse{
\equal{\doclicense@hyphenation}{}
}{}{%
\RequirePackage{ragged2e}
\ifthenelse{\isnamedefined{\doclicense@hyphenation}}{}{%
\PackageError{doclicense}{Hyphenation macro not defined}
{The macro name given via the hyphenation option is not defined.}%
}
}
\AtEndPreamble{%
\@ifpackageloaded{csquotes}{
% csquotes has already been loaded so we are fine.
}{
\ifcsdef{enquote}{
% \enquote is defined but not by csquotes.
\@ifpackageloaded{biblatex}{
\PackageError{doclicense}{The enquote macro is defined by biblatex}
{This package assumes that the enquote macro is defined by the
csquotes package. Please load csquotes before you load biblatex so
that biblatex does not define enquote instead.}%
}{
\PackageError{doclicense}{The enquote macro is defined by unknown package}
{This package assumes that the enquote macro is defined by the
csquotes package. Please check why enquote is defined without
csquotes being loaded. Maybe try loading csquotes early so that it
can define the enquote macro instead.}%
}
}{
\RequirePackage{csquotes}
}
}
\@ifpackageloaded{ccicons}{}{\RequirePackage{ccicons}}
% For \doclicenseIcon
\@ifpackageloaded{graphicx}{}{\RequirePackage{graphicx}}
% For \doclicenseImage
\@ifpackageloaded{hyperref}{}{\RequirePackage{hyperref}}
\@ifpackageloaded{hyperxmp}{
% The following options are only defined when the hyperxmp package was loaded.
\hypersetup{
pdfcopyright = {\doclicenseLongText},
pdflicenseurl = {\doclicenseURL},
}
}{}
}
\ifdoclicense@hyperxmp
\@ifpackageloaded{pdfx}{%
\PackageWarning{doclicense}{%
The pdfx package was detected. Therefore the mechanism to add license
metadata won't work. Ensure to setup \string\Copyright\space and
corresponding settings to your xmpdata-file.
}
}{
\IfFileExists{hyperxmp.sty}{
\@ifpackageloaded{hyperxmp}{}{\RequirePackage{hyperxmp}}
}{
\PackageWarning{doclicense}{%
The hyperxmp package is missing so no license metadata can be embedded
into the PDF. Consider installing hyperxmp.% chktex 13
}
}
}
\fi
\ifthenelse{
\equal{\doclicense@type}{}
}{
\PackageWarning{doclicense}{%
"type" package option missing. % chktex 18
This option is now required and the fallback to "CC" is deprecated. % chktex 18
In an upcoming major version of doclicense, this will be a package error.
Please explicitly pick a license of your choosing.
}
\renewcommand{\doclicense@type}{CC}
}{}
\ifthenelse{
\equal{\doclicense@modifier}{}
}{
\PackageWarning{doclicense}{%
"modifier" package option missing. % chktex 18
This option is now required and the fallback to "by-sa" is deprecated. % chktex 18
In an upcoming major version of doclicense, this will be a package error.
Please explicitly pick a license of your choosing.
}
\renewcommand{\doclicense@modifier}{by-sa}
}{}
\ifthenelse{
\equal{\doclicense@version}{}
}{
\PackageWarning{doclicense}{%
"version" package option missing. % chktex 18
This option is now required and the fallback is deprecated. % chktex 18
In an upcoming major version of doclicense, this will be a package error.
Please explicitly pick a license of your choosing.
}
}{}
\@namedef{doclicense@lang@lic@CC}{Creative Commons}%
\newcommand{\doclicense@baseUrlCC}{https://creativecommons.org}
\newcommand{\doclicense@versionFallback}{}
\newcommand{\doclicense@versionUsed}{}
\newboolean{doclicense@licenseKnown}
\newlength{\doclicense@hsize}
\newcommand{\doclicense@longName}{%
\@nameuse{doclicense@lang@lic@\doclicense@type @\doclicense@modifier%
@\doclicense@versionUsed}%
}
\newcommand{\doclicense@icon}{%
\PackageError{doclicense}{Icon not defined}
{Please check the manual of doclicense to see what you can do about it.}%
}
\newcommand{\doclicense@modifier@uppercase}{\texorpdfstring{%
\MakeUppercase{\doclicense@modifier}%
}{%
\doclicense@modifier}%
}
\newcommand{\doclicenseType}{\doclicense@type\xspace}
\newcommand{\doclicenseLongType}{}
\newcommand{\doclicenseModifier}{\doclicense@modifier@uppercase\xspace}
\newcommand{\doclicenseVersion}{\doclicense@versionUsed\xspace}
\newcommand{\doclicenseName}{%
\doclicense@type\nobreakspace\doclicense@modifier@uppercase\nobreakspace%
\doclicense@versionUsed\xspace%
}
\newcommand{\doclicenseNameRef}{\href{\doclicenseURL}{\doclicenseName}\xspace}
\newcommand{\doclicenseLongName}{\doclicenseLongType\space%
\doclicense@longName\xspace}
\newcommand{\doclicenseLongNameRef}{\href{\doclicenseURL}{\doclicenseLongName}}
\newcommand{\doclicenseText}{%
\doclicense@lang@thisDoc\space
\href{\doclicenseURL}{\enquote{\doclicenseName{}}}%
\doclicense@lang@word@license.\xspace%
}
\newcommand{\doclicenseLongText}{%
\doclicense@lang@thisDoc\space
\href{\doclicenseURL}{\doclicenseLongType\space\enquote{\doclicense@longName}}%
\doclicense@lang@word@license.\xspace%
}
\newcommand{\doclicenseIcon}{\doclicense@icon\xspace}
\newcommand{\doclicenseTypeIcon}{\doclicenseType}
\newcommand{\doclicenseImageFileName}{%
doclicense-\doclicense@type-\doclicense@modifier\doclicense@imagemodifier}
\newcommand{\doclicenseImage}[1][]{%
\setkeys{doclicense}{#1}
\href{\doclicenseURL}{%
\includegraphics[
width=\doclicense@imagewidth%
]{\doclicenseImageFileName}%
}
}
\newcommand{\doclicensePlainFullTextFileName}{%
doclicense-\doclicense@type-\doclicense@modifier%
-\doclicense@versionUsed-plaintext%
}
\newcommand{\doclicensePlainFullText}{%
\verbatiminput{\doclicensePlainFullTextFileName}
}
\newcommand{\doclicenseFullTextFileName}{%
doclicense-\doclicense@type-\doclicense@modifier-\doclicense@versionUsed-latex}
\newcommand{\doclicenseFullText}{\input{\doclicenseFullTextFileName}}% chktex 27
\newcommand{\doclicenseLicense}{\doclicenseThis} % legacy support
\newcommand{\doclicenseThis}{%
\setlength{\doclicense@hsize}{\linewidth-\doclicense@imagewidth-\doclicense@imagedistance}%
\ifthenelse{\equal{\doclicense@imageposition}{left}}{%
\begin{center}
\begin{minipage}{\doclicense@imagewidth}
\doclicenseImage%
\end{minipage}
\hfill
\begin{minipage}{\doclicense@hsize}
\ifthenelse{\isempty{\doclicense@hyphenation}}{}{%
\@nameuse{\doclicense@hyphenation}%
}%
\doclicenseLongText%
\end{minipage}
\end{center}
}{%
% \ifthenelse{\isnamedefined{iflandscape}}{%
% \iflandscape{%
% \setlength{\doclicense@hsize}{\doclicense@hsize-10em}%
% }{}%
% }{}%
% {%
\begin{center}
\begin{minipage}{\doclicense@hsize}
\ifthenelse{\isempty{\doclicense@hyphenation}}{}{%
\@nameuse{\doclicense@hyphenation}%
}%
\doclicenseLongText%
\end{minipage}
\hfill
\begin{minipage}{\doclicense@imagewidth}
\doclicenseImage%
\end{minipage}
\end{center}
% }
}
}
\ifthenelse{\equal{\doclicense@lang}{}}{%
\renewcommand{\doclicense@lang}{\languagename}}{}
\IfFileExists{doclicense-\doclicense@lang.ldf}{%
\input{doclicense-\doclicense@lang.ldf}% chktex 27
}{%
\PackageWarning{doclicense}{%
No language definition for \doclicense@lang found.
Please add one and submit a patch. Using English as fallback.
}
\renewcommand{\doclicense@lang}{english}
\input{doclicense-\doclicense@lang.ldf}% chktex 27
}
\ifthenelse{\equal{\doclicense@imagemodifier}{-us}}{%
\@namedef{doclicense@imagemodifier}{-88x31}% chktex 29
}{}
\newcommand{\doclicense@setVersion}[1][]{%
\ifthenelse{\equal{#1}{}}{}{%
\renewcommand{\doclicense@versionFallback}{#1}
}
\ifthenelse{\equal{\doclicense@version}{}}{%
\renewcommand{\doclicense@versionUsed}{\doclicense@versionFallback}
}{%
\renewcommand{\doclicense@versionUsed}{\doclicense@version}
}
}
\newcommand{\doclicense@set}{%
% CC (((
\ifthenelse{\equal{\doclicense@type}{CC}}{%
\renewcommand{\doclicenseLongType}{\doclicense@lang@lic@CC\xspace}
\renewcommand{\doclicenseTypeIcon}{\ccLogo\xspace}
\doclicense@setVersion[3.0]
% Allow to predefine the following macros in ldf files.
\ifcsdef{doclicense@UrlLangPart}{}{%
\ifthenelse{\equal{\doclicense@lang@lic@CC@code}{}}{%
\edef\doclicense@UrlLangPart{}
}{%
\edef\doclicense@UrlLangPart{/deed.\doclicense@lang@lic@CC@code}
}
}
\ifcsdef{doclicenseURL}{}{%
\edef\doclicenseURL{%
\doclicense@baseUrlCC/%
licenses/%
\doclicense@modifier/%
\doclicense@versionUsed\doclicense@UrlLangPart%
}
}
\ifthenelse{\equal{\doclicense@modifier}{by}}{%
\renewcommand{\doclicense@icon}{\ccby}
}{}
\ifthenelse{\equal{\doclicense@modifier}{by-sa}}{%
\renewcommand{\doclicense@icon}{\ccbysa}
}{}
\ifthenelse{\equal{\doclicense@modifier}{by-nd}}{%
\renewcommand{\doclicense@icon}{\ccbynd}
}{}
\ifthenelse{\equal{\doclicense@modifier}{by-nc}}{%
\renewcommand{\doclicense@icon}{\ccbync}
\IfBeginWith{\doclicense@imagemodifier}{-eu}{%
\renewcommand{\doclicense@icon}{\ccbynceu}
}{}
\IfBeginWith{\doclicense@imagemodifier}{-jp}{%
\renewcommand{\doclicense@icon}{\ccbyncjp}
\renewcommand{\doclicense@imagemodifier}{-88x31}% chktex 29
}{}
}{}
\ifthenelse{\equal{\doclicense@modifier}{by-nc-sa}}{
\renewcommand{\doclicense@icon}{\ccbyncsa}
\IfBeginWith{\doclicense@imagemodifier}{-eu}{%
\renewcommand{\doclicense@icon}{\ccbyncsaeu}
}{}
\IfBeginWith{\doclicense@imagemodifier}{-jp}{%
\renewcommand{\doclicense@icon}{\ccbyncsajp}
\renewcommand{\doclicense@imagemodifier}{-88x31}% chktex 29
}{}
}{}
\ifthenelse{\equal{\doclicense@modifier}{by-nc-nd}}{
\renewcommand{\doclicense@icon}{\ccbyncnd}
\IfBeginWith{\doclicense@imagemodifier}{-jp}{%
\renewcommand{\doclicense@icon}{\ccbyncndjp}
\renewcommand{\doclicense@imagemodifier}{-88x31}% chktex 29
}{}
}{}
\ifthenelse{\equal{\doclicense@modifier}{zero}}{%
\renewcommand{\doclicense@icon}{\cczero}
\doclicense@setVersion[1.0]
\edef\doclicenseURL{%
\doclicense@baseUrlCC/%
publicdomain/%
\doclicense@modifier/%
\doclicense@versionUsed\doclicense@UrlLangPart}
}{}
\ifthenelse{\equal{\doclicense@modifier}{pd}}{
\PackageError{doclicense}{CC PD license removed as of version 2.0.0}{
Creative Commons PD has been replaced by CC-zero.
Please update your license choice.
}%
}{}
\IfSubStr{\doclicense@modifier}{nc}{}{
% eu (Euro) does only exist for nc (non commercial) so if not nc then reset -eu.
\IfBeginWith{\doclicense@imagemodifier}{-eu}{%
\renewcommand{\doclicense@imagemodifier}{-88x31}% chktex 29
}{}
}
\ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{%
\renewcommand{\doclicense@imagemodifier}{-eu-88x31}% chktex 29
}{}
\ifcsdef{doclicense@lang@lic@\doclicense@type%
@\doclicense@modifier @\doclicense@versionUsed}{}{%
\PackageError{doclicense}{License long name not defined}{%
Please check the manual of doclicense
to see what you can do about it.%
}%
}
\setboolean{doclicense@licenseKnown}{true}
}{}% )))
\ifthenelse{\not\boolean{doclicense@licenseKnown}}{%
\PackageError{doclicense}{License unknown}{%
Please check the manual of doclicense
to see what you can do about it.%
}%
}{}%
}
\doclicense@set%
\endinput
%%
%% End of file `doclicense.sty'.
|