Merge branch 'master' into pu

This commit is contained in:
Kevin Morris 2021-06-22 19:39:31 -07:00
commit 763b84d0b9
5 changed files with 129 additions and 66 deletions

View file

@ -23,7 +23,7 @@ git_clone_uri_anon = https://aur.archlinux.org/%s.git
git_clone_uri_priv = ssh://aur@aur.archlinux.org/%s.git git_clone_uri_priv = ssh://aur@aur.archlinux.org/%s.git
max_rpc_results = 5000 max_rpc_results = 5000
max_depends = 1000 max_depends = 1000
aur_request_ml = aur-requests@archlinux.org aur_request_ml = aur-requests@lists.archlinux.org
request_idle_time = 1209600 request_idle_time = 1209600
request_archive_time = 15552000 request_archive_time = 15552000
auto_orphan_age = 15552000 auto_orphan_age = 15552000

View file

@ -31,7 +31,7 @@ name = aur.db
[options] [options]
aur_location = https://aur.archlinux.org aur_location = https://aur.archlinux.org
aur_request_ml = aur-requests@archlinux.org aur_request_ml = aur-requests@lists.archlinux.org
enable-maintenance = 0 enable-maintenance = 0
maintenance-exceptions = 127.0.0.1 maintenance-exceptions = 127.0.0.1
commit_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s&id=%s commit_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s&id=%s

View file

@ -199,3 +199,8 @@ label.confirmation,
.error { .error {
color: red; color: red;
} }
.article-content > div {
overflow: hidden;
transition: height 1s;
}

View file

@ -46,70 +46,94 @@ if (isset($pkgname)) {
html_header($title, $details); html_header($title, $details);
?> ?>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery@1.9.1/jquery.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function collapseDependsList(list) { function collapseDependsList(list) {
list = $(list); list = document.getElementById(list);
// Hide everything past a given limit. Don't do anything if we don't have // Hide everything past a given limit. Don't do anything if we don't have
// enough items, or the link already exists. // enough items, or the link already exists.
var limit = 20, const limit = 20;
linkid = list.attr('id') + 'link', const linkid = list.getAttribute('id') + 'link';
items = list.find('li').slice(limit); const items = Array.from(list.querySelectorAll('li')).slice(limit);
if (items.length <= 1 || $('#' + linkid).length > 0) { if (items.length <= 1 || document.getElementById(linkid)) {
return; return;
} }
items.hide();
list.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>'); items.forEach(function(item) {
item.style.display = 'none';
});
const link = document.createElement('a');
link.id = linkid;
link.href = '#';
link.textContent = 'Show More…';
const showMore = document.createElement('p');
showMore.appendChild(link);
list.insertAdjacentElement('afterend', showMore);
// add link and wire it up to show the hidden items // add link and wire it up to show the hidden items
$('#' + linkid).click(function(event) { link.addEventListener('click', function(event) {
event.preventDefault(); event.preventDefault();
list.find('li').show();
items.forEach(function(item) {
item.style.display = '';
});
// remove the full <p/> node from the DOM // remove the full <p/> node from the DOM
$(this).parent().remove(); event.target.parentNode.removeChild(event.target);
}); });
} }
function collapseComment(div) { function collapseComment(div) {
var linkid = div.attr('id') + 'link', const linkid = div.getAttribute('id') + 'link';
inner = div.find('div'), const inner = div.querySelector('div');
height = inner.height(), // max height of a collapsed comment.
maxheight = 200; const maxheight = 200;
const height = inner.offsetHeight;
if (height <= maxheight) if (height <= maxheight)
return; return;
inner.css({ 'overflow': 'hidden', 'height': maxheight + 'px' }); inner.style.height = maxheight + 'px';
inner.addClass('collapsed'); inner.classList.add('collapsed');
inner.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>');
$('#' + linkid).click(function(event) { const link = document.createElement('a');
var inner = $(this).parent().parent().find('div'); link.id = linkid;
link.href = '#';
link.textContent = 'Show More…';
const showMore = document.createElement('p');
showMore.appendChild(link);
inner.insertAdjacentElement('afterend', showMore);
link.addEventListener('click', function(event) {
const showMoreLink = event.target;
const inner = showMoreLink.parentNode.parentNode.querySelector('div');
var newheight; var newheight;
if (inner.hasClass('collapsed')) { if (inner.classList.contains('collapsed')) {
inner.css({ 'height': 'auto' }); inner.style.height = height + 'px';
newheight = inner.height(); showMoreLink.textContent = 'Collapse';
inner.css({ 'height': maxheight });
$(this).text('Collapse');
} else { } else {
newheight = maxheight; newheight = maxheight + 'px';
$(this).text('Show More…'); inner.style.height = newheight;
showMoreLink.textContent = 'Show More…';
} }
inner.animate({ 'height': newheight }); inner.classList.toggle('collapsed');
inner.toggleClass('collapsed');
event.preventDefault(); event.preventDefault();
}); });
} }
$(document).ready(function() { document.addEventListener('DOMContentLoaded', function() {
collapseDependsList("#pkgdepslist"); collapseDependsList("pkgdepslist");
collapseDependsList("#pkgreqslist"); collapseDependsList("pkgreqslist");
collapseDependsList("#pkgsrcslist"); collapseDependsList("pkgsrcslist");
$(".article-content").each(function() {
collapseComment($(this)); Array.from(document.querySelectorAll('.article-content')).forEach(collapseComment);
});
}); });
</script> </script>

View file

@ -169,37 +169,71 @@ if ($comment_section == "package") {
</div> </div>
<script> <script>
$(document).ready(function() { function add_busy_indicator(sibling) {
$('.edit-comment').click(function () { const img = document.createElement('img');
var parent_element = this.parentElement, img.src = "/images/ajax-loader.gif";
parent_id = parent_element.id, img.classList.add('ajax-loader');
comment_id = parent_id.substr(parent_id.indexOf('-') + 1), img.style.height = 11;
edit_form = $(parent_element).next(), img.style.width = 16;
_this = $(this); img.alt = "Busy…";
add_busy_indicator(_this);
$.getJSON('<?= get_uri('/rpc') ?>', { sibling.insertAdjacentElement('afterend', img);
type: 'get-comment-form', }
function remove_busy_indicator(sibling) {
const elem = sibling.nextElementSibling;
elem.parentNode.removeChild(elem);
}
function getParentsUntil(elem, className) {
// Limit to 10 depth
for ( ; elem && elem !== document; elem = elem.parentNode) {
if (elem.matches(className)) {
break;
}
}
return elem;
}
function handleEditCommentClick(event) {
event.preventDefault();
const parent_element = getParentsUntil(event.target, '.comment-header');
const parent_id = parent_element.id;
const comment_id = parent_id.substr(parent_id.indexOf('-') + 1);
// The div class="article-content" which contains the comment
const edit_form = parent_element.nextElementSibling;
const params = new URLSearchParams({
type: "get-comment-form",
arg: comment_id, arg: comment_id,
base_id: <?= intval($row["PackageBaseID"]) ?>, base_id: <?= intval($row["PackageBaseID"]) ?>,
pkgbase_name: <?= json_encode($pkgbase_name) ?> pkgbase_name: <?= json_encode($pkgbase_name) ?>
}, function (data) { });
remove_busy_indicator(_this);
const url = '<?= get_uri('/rpc') ?>' + '?' + params.toString();
add_busy_indicator(event.target);
fetch(url, {
method: 'GET'
})
.then(function(response) { return response.json(); })
.then(function(data) {
remove_busy_indicator(event.target);
if (data.success) { if (data.success) {
edit_form.html(data.form); edit_form.innerHTML = data.form;
edit_form.find('textarea').focus(); edit_form.querySelector('textarea').focus();
} else { } else {
alert(data.error); alert(data.error);
} }
}); });
return false;
});
function add_busy_indicator(sibling) {
sibling.after('<img src="/images/ajax-loader.gif" class="ajax-loader" width="16" height="11" alt="Busy…" />');
} }
function remove_busy_indicator(sibling) { document.addEventListener('DOMContentLoaded', function() {
sibling.next().remove(); const divs = document.querySelectorAll('.edit-comment');;
for (let div of divs) {
div.addEventListener('click', handleEditCommentClick);
} }
}); });
</script> </script>