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