Commit graph

1793 commits

Author SHA1 Message Date
Kevin Morris
021a1c8fb6 add /accounts/ (get, post) routes
Slight markup changes, same style overall and same
form parameters as the PHP implementation.

In addition, we've disabled the "left" and "right"
navigation buttons when we're at the border of the
table.

CSS Changes:

- Added similar styling to submit `<buttons>` that submit `<input>` had.
- Added .results tr td[align="{left,right}"] styling to align
  the result table's `More -->` button to the right of the table.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-01 11:08:56 -07:00
Kevin Morris
3a74f76ff9 FastAPI: use internal typeahead and remove jquery
Awesome!

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 22:56:48 -07:00
Kevin Morris
2835dd89ea Merge branch 'typeahead' into pu_typeahead 2021-06-29 22:31:18 -07:00
Kevin Morris
4442ba6703 bugfix: return null if config key doesn't exist
This was previously causing a PHP warning due to returning
a missing key.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 10:48:45 -07:00
Leonidas Spyropoulos
2f5d9c63c4 [php] Support DB mysql backend with port instead of socket
Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
2021-06-29 17:59:46 +01:00
Kevin Morris
85ba4a33a8 add /tu/{proposal_id} (get, post) routes
This commit ports the `/tu/?id={proposal_id}` PHP routes to
FastAPI into two individual GET and POST routes.

With this port of the single proposal view and POST logic,
several things have changed.

- The only parameter used is now `decision`, which
  must contain `Yes`, `No`, or `Abstain` as a string.
  When an invalid value is given, a BAD_REQUEST response
  is returned in plaintext: Invalid 'decision' value.
- The `doVote` parameter has been removed.
- The details section has been rearranged into a set
  of divs with specific classes that can be used for
  testing. CSS has been added to persist the layout with
  the element changes.
- Several errors that can be discovered in the POST path
  now trigger their own non-200 HTTPStatus codes.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-26 01:11:52 -07:00
Jelle van der Waa
42bd0027b3
Add archweb typeahead implementation
Use a pure vanilla JavaScript typeahead implementation to finally
deprecate the old jQuery version and typeahead library.
2021-06-25 17:08:54 +02:00
Jelle van der Waa
512f8064c1
Fix JavaScript error on packages overview page 2021-06-25 17:08:47 +02:00
Kevin Morris
763b84d0b9 Merge branch 'master' into pu 2021-06-22 19:39:31 -07:00
Jelle van der Waa
06fa8ab5f3
Convert comment editing to vanilla JavaScript
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-21 15:19:22 -04:00
Jelle van der Waa
d7603fa4d3
Port package details page to pure JavaScript
Use a CSS animation for jQuery.Animate and replace the rest with pure
vanilla JavaScript.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-21 15:19:22 -04:00
Jelle van der Waa
8b6f92f9e9
Use the clipboard API for copy paste
The Document.execCommand API is deprecated and no longer recommended to
be used. It's replacement is the much simpler navigator.clipboard API
which is supported in all browsers except internet explorer.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-21 15:17:42 -04:00
Kevin Morris
be3bab2ce0 Merge branch 'master' into pu 2021-06-12 20:11:48 -07:00
Justin Kromlinger
8d9f20939c Add modified packages RSS feed to frontend 2021-06-12 20:09:56 -07:00
Justin Kromlinger
4330fe4f33 Add RSS feed for modified packages 2021-06-12 20:09:48 -07:00
Justin Kromlinger
e7db894eb7 RSS: Add ability to specify isPermaLink="false" for GUID 2021-06-12 20:09:39 -07:00
Justin Kromlinger
537349e124 Add modified packages RSS feed to frontend 2021-06-12 19:14:43 -07:00
Justin Kromlinger
2bb30f9bf5 Add RSS feed for modified packages 2021-06-12 19:14:43 -07:00
Justin Kromlinger
18ec8e3cc8 RSS: Add ability to specify isPermaLink="false" for GUID 2021-06-12 19:14:43 -07:00
Steven Guikal
a625df07e2
Source valid ssh prefixes from config
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-10 15:32:02 -04:00
Jelle van der Waa
889d358a6d
Add missing ) for addvote.php 2021-06-06 21:49:27 +02:00
Kevin Morris
e5df083d45 use String(max_len) for DECIMAL types with sqlite
This solves an issue where DECIMAL is not native
to sqlite by using a string to store values and
converting them to float in user code.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Jelle van der Waa
1ff822bb14 Use the clipboard API for copy paste
The Document.execCommand API is deprecated and no longer recommended to
be used. It's replacement is the much simpler navigator.clipboard API
which is supported in all browsers except internet explorer.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-05 19:50:51 -07:00
Leonidas Spyropoulos
21140e28a8 Filter out current username from co-maintainers list.
Closes: #8

Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-05 19:49:42 -07:00
Marcus Andersson
4fa220850f
Add error color when package is orphaned
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-05-13 16:50:51 -04:00
Kristian Klausen
bab74dd307
Update wiki links to the new short URL
Done with: find -type f -exec sed -Ee ':wiki.archlinux.org: s:(wiki.archlinux.org)/index.php/:\1/title/:g' -i {} \;

Fixes #16

[1] https://gitlab.archlinux.org/archlinux/infrastructure/-/merge_requests/335

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-05-09 18:06:32 -04:00
Eli Schwartz
8ec170b3e0
dos2unix a file with Windows linebreaks that editors and human reviewers hate
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-05-02 21:46:35 -04:00
Jelle van der Waa
d668ef0bcd Resolve SQL Error when deleting an account
The account deletion code tries to remove user from PackageNotifications
using the wrong column UsersID to identify the user by id. In the
PackagePackageNotifications table the foreign key is called UserID. In
the future ideally this would be unified into UserID for all tables.

Closes: #12
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-03-29 18:39:02 -04:00
Felix Yan
21c457817f Use jsDelivr instead of Google CDN for jquery
jsdelivr is another free CDN service for open source projects.

The main motivation for this change is that it is the only one that works fairly
well across the globe. The Google CDN service is known to be hardly
accessible in mainland China, unfortunately.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:26:32 -05:00
Justin Kromlinger
d5d333005e RSS: Decrease cache time and increase item count
I think after 10-15 years we might want to adjust those values. With a
30min cache and 20 items per creation I would bet some new AUR packages
might be swept under the carpet.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Justin Kromlinger
eb11943fed RSS: Always provide a GUID
https://validator.w3.org/feed/docs/warning/MissingGuid.html
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Justin Kromlinger
1d0c6ffe24 RSS: Make sure image title matches channel title
https://validator.w3.org/feed/docs/warning/ImageTitleDoesntMatch.html
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Justin Kromlinger
78dbbd3dfa RSS: Set proper content type header
https://validator.w3.org/feed/docs/warning/UnexpectedContentType.html
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Justin Kromlinger
568e0d2fa3 RSS: Add atom self link
https://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Jakub Klinkovský
bc972089a1 Fix WHERE clause for keyword search queries with empty keywords
When the keyword parameter is empty, the AND clause has to be omitted,
otherwise we get an SQL syntax error:

... WHERE PackageBases.PackagerUID IS NOT NULL AND () ...

This got broken in commit 9e30013aa4fc6ce3a3c9f6f83a6fe789c1fc2456
Author: Kevin Morris <kevr.gtalk@gmail.com>
Date:   Sun Jul 5 18:19:06 2020 -0700

Support conjunctive keyword search in RPC interface

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Frédéric Mangano-Tarumi
8c28ba6e7f Redirect to referer after SSO login
Introduce a `redirect` query argument to SSO login endpoints so that
users are redirected to the page they were originally on when they
clicked the Login link.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Frédéric Mangano-Tarumi
87815d37c0 Remove the per-user session limit
This feature was originally introduced by
f961ffd9c7 as a fix for FS#12898
<https://bugs.archlinux.org/task/12898>.

As of today, it is broken because of the `q.SessionID IS NULL` condition
in the WHERE clause, which can’t be true because SessionID is not
nullable. As a consequence, the session limit was not applied.

The fact the absence of the session limit hasn’t caused any issue so
far, and hadn’t even been noticed, suggests the feature is unneeded.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:19 -05:00
Frédéric Mangano-Tarumi
9290eee138 Stop redirecting stderr with proc_open
Error outputs were piped to a temporary buffer that wasn’t read by
anyone, making debugging hard because errors were completely silenced.
By not explicitly redirecting stderr on proc_open, the subprocess
inherits its parent stderr.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Kevin Morris
efe99dc16f Support conjunctive keyword search in RPC interface
Newly supported API Version 6 modifies `type=search` for _by_ type
`name-desc`: it now behaves the same as `name-desc` search through the
https://aur.archlinux.org/packages/ search page.

Search for packages containing the literal keyword `blah blah` AND `haha`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="blah blah"%20haha

Search for packages containing the literal keyword `abc 123`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="abc 123"

The following example searches for packages that contain `blah` AND `abc`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg=blah%20abc

The legacy method still searches for packages that contain `blah abc`:
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc

API Version 6 is currently only considered during a `search` of `name-desc`.

Note: This change was written as a solution to
https://bugs.archlinux.org/task/49133.

PS: + Some spacing issues fixed in comments.

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Frédéric Mangano-Tarumi
4d0f2d2279 Implement SSO logout
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Frédéric Mangano-Tarumi
d12ea08fca SSO: Add an SSO option in the login page
We’ll probably change the whole login page in the future, but this makes
development easier.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Eli Schwartz
71740a75a2 rewrite query to support both mysql/sqlite
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:22:11 -05:00
Eli Schwartz
be5197a5fe prevent running mysql-specific query in sqlite
We usually guard such queries and have both mysql and sqlite branches.
But I have not implemented the sqlite branch. Given sqlite is typically
used for local dev setups, the fact that "users with more than the
configured max simultaneous logins" can avoid getting some logins
annulled is probably not a huge risk.

And this always *used* to fail on sqlite, silently. Now, in php 8, it
raises PDOException, which prevents running the test server

Document this as a FIXME for now, until someone reimplements the query
for sqlite.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:22:11 -05:00
Eli Schwartz
d92dd69aa3 fix broken SQL query that always failed
Due to missing whitespace at the end of strings during joining, we ended
up with the query fragment

"DelTS IS NULLAND NOT PinnedTS"

which should be

"DelTS IS NULL AND NOT PinnedTS"

So the check for pinned comments > 5 likely always failed.

In php 7, a completely broken query that raises exceptions in the
database engine was silently ignored... in php 8, it raises

Uncaught PDOException: SQLSTATE[HY000]: General error: 1 near "PinnedTS": syntax error in <file>

and aborts the page building. End result: users with permission to pin
comments cannot see any comments, or indeed page content below the first
comment header

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:22:11 -05:00
Morten Linderud
613364b773 pkg_search_page: Limit number of results on package search
The current package search query is quite poorly optimized and becomes a
resource hog when the offsets gets large enough. This DoSes the service.

A quick fix is to just ensure we have some limit to the number of hits
we return. The current hardcoding of 2500 is based on the following:

    * 250 hits per page max
    * 10 pages

We can maybe consider having it lower, but it seems easier to just have
this a multiple of 250 in the first iteration.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-09-05 10:21:16 -04:00
Lukas Fleischer
169607f153 Fix PHP notices in the account form
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-04-05 15:59:56 -04:00
Lukas Fleischer
1369eb87b3 Fix invalid session ID check
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-04-05 15:59:55 -04:00
Lukas Fleischer
853ed9a950 Release 5.0.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-03-27 08:51:15 -04:00
Lukas Fleischer
4b2102ceb2 Properly escape passwords in the account edit form
Addresses FS#65639.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-27 16:44:36 +01:00
Lukas Fleischer
cbab9870c1 Fix HTML code in the account search results table
Do not add an opening <tbody> tag for every row. Instead, wrap all rows
in <tbody></tbody>.

While at it, also simplify the code used to color the rows.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-26 13:51:18 +01:00