Skip to content

Commit

Permalink
avoid doclicense but borrow images
Browse files Browse the repository at this point in the history
circumvents and thus fixes #58
  • Loading branch information
krono committed Feb 9, 2024
1 parent 93f5116 commit 4949eaa
Showing 1 changed file with 63 additions and 60 deletions.
123 changes: 63 additions & 60 deletions programming.cls
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,15 @@


\providecommand*\P@license{by}

\newcommand*\P@set@license[1]{%
\renewcommand*\P@license{#1}
\if@atdocument
\P@error{License set too late, move \string\paperdetails\space up in the document.}%
{The license cannot be set to ``#1'' at this point in the process. Please
move the \string\paperdetails\space command before the \string\begin\{document\}
command.}
\else
\@ifpackageloaded{doclicense}%
{\undef\doclicenseURL%
\setkeys{doclicense}{modifier=#1}%
% hack: propagate settings
\doclicense@set}
{\PassOptionsToPackage{modifier=#1}{doclicense}}
\fi}
{The license cannot be set to ``#1'' at this point in the process. Please
move the \string\paperdetails\space command before the \string\begin{document}
command.}
\fi
\renewcommand*\P@license{#1}%
\P@lic@setURL}%

\P@Key{license}{
\P@setnum{license}{@tempa}{%
Expand Down Expand Up @@ -468,52 +461,62 @@
%
% We're emulating doclicense and having none of its shenanigans
%
\newlength{\P@doclicenseimagewidth}
\setlength{\P@doclicenseimagewidth}{2.7cm}
\RequirePackage{ccicons}
\def\P@doclicenseversionUsed{4.0}
\def\P@doclicenseimagemodifier{-88x31}

\def\P@doclicenseImageFileName{doclicense-CC-\P@license\P@doclicenseimagemodifier}

\def\P@doclicensetext#1{This work is licensed under a #1 license}
\def\P@doclicenseText{\href{\P@doclicenseURL}{``\P@doclicensetext{CC~\MakeUppercase{\P@license}~\P@doclicenseversionUsed}''}}
\def\P@doclicenseLongTextForHyperref{\P@doclicensetext{Creative Commons "\csuse{P@doclicense@l@\P@license @\P@doclicenseversionUsed}"}}
\def\P@doclicenseIcon{\csuse{P@doclicense@i@\P@license @\P@doclicenseversionUsed}}
\csdef{P@doclicense@l@[email protected]}{Attribution 4.0 International}%
% \csdef{P@doclicense@l@[email protected]}{Attribution-ShareAlike 4.0 International}%
% \csdef{P@doclicense@l@[email protected]}{Attribution-NoDerivatives 4.0 International}%
\csdef{P@doclicense@l@[email protected]}{Attribution-NonCommercial 4.0 International}%
% \csdef{P@doclicense@l@[email protected]}{Attribution-NonCommercial-ShareAlike 4.0 International}%
% \csdef{P@doclicense@l@[email protected]}{Attribution-NonCommercial-NoDerivatives 4.0 International}%
\csdef{P@doclicense@i@[email protected]}{\ccby}%
% \csdef{P@doclicense@i@[email protected]}{\ccbysa}%
% \csdef{P@doclicense@i@[email protected]}{\ccbynd}%
\csdef{P@doclicense@i@[email protected]}{\ccbync}%
% \csdef{P@doclicense@i@[email protected]}{\ccbyncsa}%
% \csdef{P@doclicense@i@[email protected]}{\ccbyncnd}%

\def\P@doclicenseImage@{%
\href%
{\P@doclicenseURL}%
{\includegraphics[width=\P@doclicenseimagewidth]{\P@doclicenseImageFileName}}}
\def\P@doclicenseImage@@{%
\makebox[\P@doclicenseimagewidth]%
% Data.
\newlength{\P@lic@imagewidth}
\setlength{\P@lic@imagewidth}{2.7cm}
\newcommand*\P@lic@version{4.0}
\newcommand*\P@lic@imagemodifier{-88x31}
%
\csdef{P@lic@l@[email protected]}{Attribution 4.0 International}%
% \csdef{P@lic@l@[email protected]}{Attribution-ShareAlike 4.0 International}%
% \csdef{P@lic@l@[email protected]}{Attribution-NoDerivatives 4.0 International}%
\csdef{P@lic@l@[email protected]}{Attribution-NonCommercial 4.0 International}%
% \csdef{P@lic@l@[email protected]}{Attribution-NonCommercial-ShareAlike 4.0 International}%
% \csdef{P@lic@l@[email protected]}{Attribution-NonCommercial-NoDerivatives 4.0 International}%
%
% These require ccicons, and we take care of that when necessary.
% If someone uses these regardless, they can sure keep the errors
\csdef{P@lic@i@[email protected]}{\ccby}%
% \csdef{P@lic@i@[email protected]}{\ccbysa}%
% \csdef{P@lic@i@[email protected]}{\ccbynd}%
\csdef{P@lic@i@[email protected]}{\ccbync}%
% \csdef{P@lic@i@[email protected]}{\ccbyncsa}%
% \csdef{P@lic@i@[email protected]}{\ccbyncnd}%

\newcommand*\P@lic@ImageFileName{doclicense-CC-\P@license\P@lic@imagemodifier}
\newcommand*\P@lic@OldImageFileName{doclicense-CC-\P@license}
\newcommand*\P@lic@text[1]{This work is licensed under a #1 license}
\newcommand*\P@lic@Text{\P@lic@text{\href{\P@lic@URL}{``CC~\MakeUppercase{\P@license}~\P@lic@version}''}}
\newcommand*\P@lic@LongTextForHyperref{\P@lic@text{Creative Commons "\csuse{P@lic@l@\P@license @\P@lic@version}"}}
\newcommand*\P@lic@Icon{\csuse{P@lic@i@\P@license @\P@lic@version}}

\newcommand*\P@lic@Image@%
{\href%
{\P@lic@URL}%
{\includegraphics[width=\P@lic@imagewidth]{\P@lic@ImageFileName}}}
\newcommand*\P@lic@Image@@%
{\makebox[\P@lic@imagewidth]%
{\setlength{\fboxsep}{5pt}%
\raisebox{.5\baselineskip}{\colorbox{P@GrayBG}{\Huge\selectfont\P@doclicenseIcon}}}}
\IfFileExists{\P@doclicenseImageFileName.pdf}% new image present
{\let\P@doclicenseImage\P@doclicenseImage@}%
{\def\P@doclicenseImageFileName{doclicense-CC-\P@license}
\IfFileExists{\P@doclicenseImageFileName.pdf}% old image present
{\let\P@doclicenseImage\P@doclicenseImage@}%
{\let\P@doclicenseImage\P@doclicenseImage@@}}% no image present, us icon


\BeforeBeginEnvironment{document}{%
\edef\P@doclicenseURL{https://creativecommons.org/licenses/\P@license/\P@doclicenseversionUsed/deed.en}
\raisebox{.5\baselineskip}{\colorbox{P@GrayBG}{\Huge\selectfont\P@lic@Icon}}}}
\providecommand*\P@lic@Image{}
\IfFileExists{doclicense.sty}% borrow images
{\let\P@lic@Image\P@lic@Image@%
\IfFileExists{\P@lic@ImageFileName.pdf}
% image not present, but if doclicense is, assume old
{}{\let\P@lic@ImageFileName\P@lic@OldImageFileName}}
{\RequirePackage{ccicons}% no image present, us icon
\let\P@lic@Image\P@lic@Image@@}
%
% hook into hyperxmp at document begin
%
\providecommand*\P@lic@URL{https://creativecommons.org/licenses/by/4.0/deed.en}
\newcommand*\P@lic@setURL{\xdef\P@lic@URL{https://creativecommons.org/licenses/\P@license/\P@lic@version/deed.en}}

\BeforeBeginEnvironment{document}%
{\P@lic@setURL
\hypersetup{%
pdfcopyright = {\P@doclicenseLongTextForHyperref},
pdflicenseurl = {\P@doclicenseURL}}}
pdfcopyright = {\P@lic@LongTextForHyperref},
pdflicenseurl = {\P@lic@URL}}}

\RequirePackage{pict2e}
\RequirePackage[tbtags,fleqn]{amsmath}
Expand Down Expand Up @@ -1002,14 +1005,14 @@
\begin{minipage}[b][0pt][b]{\textwidth}
\null\noindent%
\normalfont%
\hspace{-1mm}\P@doclicenseImage%
\hspace{-1mm}\P@lic@Image%
\hfill%
\begin{minipage}[b]%
{\dimexpr\linewidth - \P@doclicenseimagewidth - 1\columnsep\relax}%
{\dimexpr\linewidth - \P@lic@imagewidth - 1\columnsep\relax}%
\ignorespaces
\scriptsize%
\textcopyright\ {\@authorrunning}\\
\P@doclicenseText\\
\P@lic@Text\\
\ifboolexpr{bool{P@submission}}%
{Submitted to \textit{\P@banner}.}%
{In \textit{\P@banner}\ignorespaces%
Expand Down

0 comments on commit 4949eaa

Please sign in to comment.