[aur-dev] [PATCH 1/3] Allow dependency names of up to 255 characters
This field needs to be a bit larger now that optdepends (including descriptions) are stored there as well. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- UPGRADING | 6 ++++++ schema/aur-schema.sql | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/UPGRADING b/UPGRADING index 48737f2..0a801cc 100644 --- a/UPGRADING +++ b/UPGRADING @@ -165,6 +165,12 @@ ALTER TABLE PackageDepends ADD FOREIGN KEY (DepTypeID) REFERENCES DependencyTypes(ID) ON DELETE NO ACTION; ---- +14. Resize the package dependency name field: + +---- +ALTER TABLE PackageDepends MODIFY DepName VARCHAR(255) NOT NULL; +---- + From 2.2.0 to 2.3.0 ------------------- diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 327a792..af03b69 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -151,7 +151,7 @@ INSERT INTO DependencyTypes VALUES (4, 'optdepends'); CREATE TABLE PackageDepends ( PackageID INTEGER UNSIGNED NOT NULL, DepTypeID TINYINT UNSIGNED NOT NULL, - DepName VARCHAR(64) NOT NULL, + DepName VARCHAR(255) NOT NULL, DepCondition VARCHAR(20), INDEX (PackageID), INDEX (DepName), -- 1.9.2
Collapse package dependency lists with more than 20 entries and add a link to show the full list. The JavaScript code for this originates from the archweb project. Note that the full list is shown when JavaScript is disabled or unavailable. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/packages.php | 30 ++++++++++++++++++++++++++++++ web/template/pkg_details.php | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index bf325cf..466042a 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -50,6 +50,36 @@ if (isset($pkgname)) { html_header($title, $details); ?> +<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> +<script type="text/javascript"> +function collapseDependsList(list) { + list = $(list); + // Hide everything past a given limit. Don't do anything if we don't have + // enough items, or the link already exists. + var limit = 20, + linkid = list.attr('id') + 'link', + items = list.find('li').slice(limit); + if (items.length <= 1 || $('#' + linkid).length > 0) { + return; + } + items.hide(); + list.after('<p><a id="' + linkid + '" href="#">Show Moreā¦</a></p>'); + + // add link and wire it up to show the hidden items + $('#' + linkid).click(function(event) { + event.preventDefault(); + list.find('li').show(); + // remove the full <p/> node from the DOM + $(this).parent().remove(); + }); +} + +$(document).ready(function() { + collapseDependsList("#pkgdepslist"); + collapseDependsList("#pkgreqslist"); +}); +</script> + <?php if (isset($pkgid)) { include('pkg_search_form.php'); diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index ef40f1f..f0bfa0b 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -218,7 +218,7 @@ if ($row["MaintainerUID"]): <div id="pkgdeps" class="listing"> <h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3> <?php if (count($deps) > 0): ?> - <ul> + <ul id="pkgdepslist"> <?php while (list($k, $darr) = each($deps)): ?> <li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3]); ?></li> <?php endwhile; ?> @@ -228,7 +228,7 @@ if ($row["MaintainerUID"]): <div id="pkgreqs" class="listing"> <h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3> <?php if (count($requiredby) > 0): ?> - <ul> + <ul id="pkgreqslist"> <?php # darr: (PackageName, PackageID) while (list($k, $darr) = each($requiredby)): -- 1.9.2
Instead of overwriting arrays, such as depends, from the pkgbase section, new entries should be appended. Replace array_merge() with a mixture of array_merge_recursive() and array_replace_recursive() that merges array fields and replaces non-array fields. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/pkgsubmit.php | 4 ++-- web/lib/aur.inc.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 045b8f9..11206e1 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -147,7 +147,7 @@ if ($uid): if (isset($section_info['pkgbase'])) { $pkgbase_info = $section_info; } elseif (isset($section_info['pkgname'])) { - $pkginfo[] = array_merge($pkgbase_info, $section_info); + $pkginfo[] = array_pkgbuild_merge($pkgbase_info, $section_info); } } $section_info = array( @@ -180,7 +180,7 @@ if ($uid): if (isset($section_info['pkgbase'])) { $pkgbase_info = $section_info; } elseif (isset($section_info['pkgname'])) { - $pkginfo[] = array_merge($pkgbase_info, $section_info); + $pkginfo[] = array_pkgbuild_merge($pkgbase_info, $section_info); } } else { /* Use data from the PKGBUILD parser (deprecated!) */ diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index 16aa261..b41b720 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -572,3 +572,28 @@ function latest_pkgs($numpkgs) { return $packages; } + +/** + * Merge pkgbase and package options + * + * Merges entries of the first and the second array. If any key appears in both + * arrays and the corresponding value is an array itself, the arrays are + * merged. If a key appears in both arrays and the corresponding value is not + * an array, the second value replaces the first one. + * + * @param array $pkgbase_info Options from the pkgbase section + * @param array $section_info Options from the package section + * + * @return array Merged information from both sections + */ +function array_pkgbuild_merge($pkgbase_info, $section_info) { + $pi = $pkgbase_info; + foreach ($section_info as $opt_key => $opt_val) { + if (is_array($opt_val)) { + $pi[$opt_key] += $opt_val; + } else { + $pi[$opt_key] = $opt_val; + } + } + return $pi; +} -- 1.9.2
participants (1)
-
Lukas Fleischer