[aur-dev] FS#15043: patch for part 3 - package licenses link to Arch Wiki pages

Gergely Imreh imrehg at gmail.com
Mon Aug 24 10:33:32 EDT 2009


2009/8/24 Loui Chang <louipc.ist at 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 at 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 at 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


More information about the aur-dev mailing list