[aur-dev] FS#15043: patch for part 3 - package licenses link to Arch Wiki pages
Hi, There is a feature request (FS#15043) for multiple package parsing enhancements on AUR. One of them (part 3) asks for "arch and license arrays can be converted to links [to Arch Wiki]". I checked out the "license" part, as I see the arch is not displayed on AUR at the moment. Linking to common licenses might be an useful idea, so here's a patch that does just that. Good code should speak for itself, but maybe I do elaborate a little: - I took the common licenses distributed in /usr/share/licenses/common and uploaded them to the Wiki as Licenses:NAME. - The code checks for these names in the licenses array, and if there's any match, turns it into a link. If no match, just display it as text. - Can handle multiple licenses in case needed. I can see some problems arise, though. I took the names of these licenses exactly as it is in the directory, and that includes capitalisation. E.g. "APACHE" and "PerlArtistic". Could match the names case-insensitive, but that's a bad idea since the Wiki link is case-sensitive... Thus, if some people use wrong capitalisation in their PKGBUILD (like [1]) and complain that the link "does not work 0rz", then it is the reason... Namcap's check for licenses is case-insensitive, so that's no help to prevent such problems. Anyway, here it is, let me know if there's any issue with the way things are handled, or any other functionality that should be included. Cheers, Greg Ps: I sent this out once before with the patch .gz attached, which seemed to disappear. If later gets sent out, then my apologies.. [1] http://aur.archlinux.org/packages.php?ID=27609
From 7c7c6b13c6cc2dac0ac4b6ea958dfcf1483a2117 Mon Sep 17 00:00:00 2001 From: Gergely Imreh <imrehg@gmail.com> Date: Sun, 16 Aug 2009 15:19:41 +0800 Subject: [PATCH] add wiki link to common licenses in package details
The package licenses turned into wiki links in case of common licenses (the ones that are already in /usr/share/licenses/common). Currently the license name has to be the same as in the directory (same case too). Not common licenses left alone and displayed as text. Can handle multiple licenses in the rare case it is needed. Signed-off-by: Gergely Imreh <imrehg@gmail.com> --- web/template/pkg_details.php | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index e87fc01..4fed861 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -28,9 +28,35 @@ if ($atype == "Developer" or $atype == "Trusted User") { $votes = "<a href=\"voters.php?ID=$pkgid\">$votes</a>"; } +# License # In case of wanting to put a custom message $msg = __('unknown'); -$license = empty($row['License']) ? $msg : $row['License']; +if (empty($row['License'])) { + $license = $msg; +} +else { + $common_licenses = array('APACHE', 'CCPL:by', 'CCPL:by-nc', \\ + 'CCPL:by-nc-nd', 'CCPL:by-nc-sa', 'CCPL:by-nd', 'CCPL:by-sa', \\ + 'CDDL', 'CPL', 'EPL', 'FDL', 'FDL1.2', 'FDL1.3', 'GPL', 'GPL2', \\ + 'GPL3', 'LGPL', 'LGPL2.1', 'LGPL3', 'LPPL', 'MPL', 'PHP', 'PSF', \\ + 'PerlArtistic', 'RALINK', 'RUBY', 'ZPL'); + $license_linkbase = "http://wiki.archlinux.org/index.php/Licenses:"; + + # In case the package is under more than one license + $licenses = explode(" ", $row['License']); + $license = ''; + foreach ($licenses as $pkglicense) { + if (in_array($pkglicense,$common_licenses)) { + # replace ":" in the wiki links as it has meaning for the wiki + $wikilink = str_replace(":", "-", $pkglicense); + $license .= '<a href="' . $license_linkbase . $wikilink \\ + . '" target=_blank>'. $pkglicense . '</a> '; + } + else { + $license .= $pkglicense . ' '; + } + } +} # Print the timestamps for last updates $updated_time = ($row["ModifiedTS"] == 0) ? "(unknown)" : gmdate("r", intval($row["ModifiedTS"])); -- 1.6.4
On Sun 16 Aug 2009 15:41 +0800, Gergely Imreh wrote:
+ $common_licenses = array('APACHE', 'CCPL:by', 'CCPL:by-nc', \\ + 'CCPL:by-nc-nd', 'CCPL:by-nc-sa', 'CCPL:by-nd', 'CCPL:by-sa', \\ + 'CDDL', 'CPL', 'EPL', 'FDL', 'FDL1.2', 'FDL1.3', 'GPL', 'GPL2', \\ + 'GPL3', 'LGPL', 'LGPL2.1', 'LGPL3', 'LPPL', 'MPL', 'PHP', 'PSF', \\
I'm not sure why you have the \\ here, but those cause errors for me. I was thinking that it might make sense to include those licenses in the AUR repo rather than linking to an external site. Any opinion there?
2009/8/24 Loui Chang <louipc.ist@gmail.com>:
On Sun 16 Aug 2009 15:41 +0800, Gergely Imreh wrote:
+ $common_licenses = array('APACHE', 'CCPL:by', 'CCPL:by-nc', \\ + 'CCPL:by-nc-nd', 'CCPL:by-nc-sa', 'CCPL:by-nd', 'CCPL:by-sa', \\ + 'CDDL', 'CPL', 'EPL', 'FDL', 'FDL1.2', 'FDL1.3', 'GPL', 'GPL2', \\ + 'GPL3', 'LGPL', 'LGPL2.1', 'LGPL3', 'LPPL', 'MPL', 'PHP', 'PSF', \\
I'm not sure why you have the \\ here, but those cause errors for me.
What problems do they cause you? I'm using too many languages and lost track that I don't need those to wrap long lines. Though they don't do anything bad for me, that's why I didn't catch it... Attaching an updated patch without those \\ silliness...
I was thinking that it might make sense to include those licenses in the AUR repo rather than linking to an external site. Any opinion there?
Putting right into the source? That's an option... Would make things more self contained. On the other hand, if we use outside links, than I could only imagine linking to the Arch Wiki or to Wikipedia. Other sites link to wikis as well when it's about very static things, that could also benefit from some context. Licenses certainly fall into that category. Cheers, Greg
From f00400cd5adf7c54a185e9c6486eda405cb88306 Mon Sep 17 00:00:00 2001 From: Gergely Imreh <imrehg@gmail.com> Date: Mon, 24 Aug 2009 22:17:58 +0800 Subject: [PATCH] add wiki link to common licenses in package details
The package licenses turned into wiki links in case of common licenses (the ones that are already in /usr/share/licenses/common). Currently the license name has to be the same as in the directory (same case too). Not common licenses left alone and displayed as text. Can handle multiple licenses in the rare case it is needed. Signed-off-by: Gergely Imreh <imrehg@gmail.com> --- web/template/pkg_details.php | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index e87fc01..a36fb2b 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -28,9 +28,35 @@ if ($atype == "Developer" or $atype == "Trusted User") { $votes = "<a href=\"voters.php?ID=$pkgid\">$votes</a>"; } +# License # In case of wanting to put a custom message $msg = __('unknown'); -$license = empty($row['License']) ? $msg : $row['License']; +if (empty($row['License'])) { + $license = $msg; +} +else { + $common_licenses = array('APACHE', 'CCPL:by', 'CCPL:by-nc', + 'CCPL:by-nc-nd', 'CCPL:by-nc-sa', 'CCPL:by-nd', 'CCPL:by-sa', + 'CDDL', 'CPL', 'EPL', 'FDL', 'FDL1.2', 'FDL1.3', 'GPL', 'GPL2', + 'GPL3', 'LGPL', 'LGPL2.1', 'LGPL3', 'LPPL', 'MPL', 'PHP', 'PSF', + 'PerlArtistic', 'RALINK', 'RUBY', 'ZPL'); + $license_linkbase = "http://wiki.archlinux.org/index.php/Licenses:"; + + # In case the package is under more than one license + $licenses = explode(" ", $row['License']); + $license = ''; + foreach ($licenses as $pkglicense) { + if (in_array($pkglicense,$common_licenses)) { + # replace ":" in the wiki links as it has meaning for the wiki + $wikilink = str_replace(":", "-", $pkglicense); + $license .= '<a href="' . $license_linkbase . $wikilink \\ + . '" target=_blank>'. $pkglicense . '</a> '; + } + else { + $license .= $pkglicense . ' '; + } + } +} # Print the timestamps for last updates $updated_time = ($row["ModifiedTS"] == 0) ? "(unknown)" : gmdate("r", intval($row["ModifiedTS"])); -- 1.6.4.1
On Mon 24 Aug 2009 22:33 +0800, Gergely Imreh wrote:
2009/8/24 Loui Chang <louipc.ist@gmail.com>:
On Sun 16 Aug 2009 15:41 +0800, Gergely Imreh wrote:
+ $common_licenses = array('APACHE', 'CCPL:by', 'CCPL:by-nc', \\ + 'CCPL:by-nc-nd', 'CCPL:by-nc-sa', 'CCPL:by-nd', 'CCPL:by-sa', \\ + 'CDDL', 'CPL', 'EPL', 'FDL', 'FDL1.2', 'FDL1.3', 'GPL', 'GPL2', \\ + 'GPL3', 'LGPL', 'LGPL2.1', 'LGPL3', 'LPPL', 'MPL', 'PHP', 'PSF', \\
I'm not sure why you have the \\ here, but those cause errors for me.
What problems do they cause you?
It causes a syntax error: php-cgi: PHP Parse error: syntax error, unexpected T_NS_SEPARATOR, expecting T_STRING in /home/louipc/devel/aur/web/template/pkg_details. php on line 38 It must be a change in php 5.3.0. php 5.2.10 gives a warning, but works otherwise: php-cgi: PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/louipc/devel/aur/web/template/pkg_details.php on line 38
I was thinking that it might make sense to include those licenses in the AUR repo rather than linking to an external site. Any opinion there?
Putting right into the source? That's an option... Would make things more self contained.
Putting them into separate files in a directory somewhere, say web/html/licenses, so it remains in the AUR domain and we know for sure that we are linking to something that exists. I don't really have control over the Wiki, and even if I did I'd prefer not to fragment AUR's data onto other sites.
On the other hand, if we use outside links, than I could only imagine linking to the Arch Wiki or to Wikipedia. Other sites link to wikis as well when it's about very static things, that could also benefit from some context. Licenses certainly fall into that category.
If you want added context, it's mostly sensible to link to Wikipedia. But packages aren't news articles, so I would argue that it's not even necessary, and ultimately the license belongs in the package. Ohloh is maintaining a collection of over 250 different licenses now, and that's supposedly limited to open source licenses. I'm not sure I want to do that. The AUR isn't limited to open source.
+ $license .= '<a href="' . $license_linkbase . $wikilink \\ + . '" target=_blank>'. $pkglicense . '</a> ';
Missed a "\\". I'd also omit the target attribute as that's not available in XHTML strict. No need to resubmit the patch for those two things alone though. So, considering everything, I'm not exactly sure what I think of the idea. It might be kind of convenient, but it would be a pain to maintain, would only be half complete at most, and the licenses that people would need to read are the uncommon ones after all, not the common ones. People already know what the GPL is. I propose just making it a link to Google. Hah Comments?
participants (2)
-
Gergely Imreh
-
Loui Chang