Commit graph

777 commits

Author SHA1 Message Date
Kevin Morris
9bfe2b07ba
fix(fastapi): render Logged-in as page on authenticated /login
This was missed during the initial porting of the /login route.

Modifications:
-------------
- A form is now used for the [Logout] link and some css was
  needed to deal with positioning.

Closes #186

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-29 19:40:55 -08:00
Kevin Morris
fd8d23a379
fix(fastapi): fix new Logout nav item css
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-29 19:04:55 -08:00
Kevin Morris
69eb17cb0d
change(fastapi): remove the GET /logout route; replaced with POST
Had to add some additional CSS in to style a form button the same
as <a> links are styled.

Closes #188

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-29 16:52:10 -08:00
Kevin Morris
7739b2178e
fix(fastapi): fix comment edit image sources
These were using the old comment image sources. Slipped in
due to cache and not checking without cache.

Fixed them to use src="/static/images/...".

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-18 16:43:10 -08:00
Kevin Morris
f3f662c696
fix(mkpkglists): improve package meta archive
The SQL logic in this file for package metadata now exactly
reflects RPC's search logic, without searching for specific
packages.

Two command line arguments are available:

    --extended | Include License, Keywords, Groups, relations
                 and dependencies.

When --extended is passed, the script will create a
packages-meta-ext-v1.json.gz, configured via packagesmetaextfile.

Archive JSON is in the following format: line-separated package objects
enclosed in a list:

    [
    {...},
    {...},
    {...}
    ]

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:06:50 -08:00
Kristian Klausen
f606140050
feat(PHP): Add packages dump file with more metadata 2021-11-09 02:04:58 -08:00
Kevin Morris
691b7b9091
feat(fastapi): add comment actions to /account/{username}/comments
With this change, we've decoupled some partials shared between
`/pkgbase/{name}` and `/account/{username}/comments`. The comment
actions template now resolves its package base via the `comment`
instance instead of requiring `pkgbase`.

We've also modified the existing package comment routes to
support execution from any location using the `next` parameter.
This allows us to reuse code from package comments for
account comments actions.

Moved the majority of comment editing javascript to its own
.js file.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-29 17:18:49 -07:00
Kevin Morris
2b9840149e
feat(fastapi): add /pkgbase/{name}/merge (get)
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-20 20:31:44 -07:00
Kevin Morris
990f4d182b
feat(rpc): add 'suggest-pkgbase' type
This feature of RPC is required to take advantage of
javascript typeahead.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-20 20:31:42 -07:00
Steven Guikal
a54a09f61d fix(FastAPI): fix padding on email inputs
Signed-off-by: Steven Guikal <void@fluix.one>
2021-10-05 17:50:22 -04:00
Kevin Morris
ad8369395e
feat(FastAPI): add /pkgbase/{name}/request (get)
This change brings in the package base request form
for new submissions.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 22:46:48 -07:00
Kevin Morris
5cf7062092
feat(FastAPI): add /packages (get) search
In terms of performance, most queries on this page win over
PHP in query times, with the exception of sorting by Voted or
Notify (https://gitlab.archlinux.org/archlinux/aurweb/-/issues/102).
Otherwise, there are a few modifications: described below.

* Pagination
    * The `paginate` Python module has been used in the FastAPI
      project
      here to implement paging on the packages search page. This
      changes how pagination is displayed, however it serves the
      same purpose. We'll take advantage of this module in other
      places as well.
* Form action
    * The form action for actions now use `POST /packages` to
      perform. This is currently implemented and will be
      addressed in a follow-up commit.
* Input names and values
    * Input names and values have been modified to satisfy the
      snake_case naming convention we'd like to use as much as
      possible.
    * Some input names and values were modified to comply with
      FastAPI Forms: (IDs[<id>]) -> (IDs, <id>).

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-19 12:44:19 -07:00
Kevin Morris
ae3d302c47 implement /packages/{name} as its own route
A few things added with this commit:

- aurweb.packages.util
    - A module providing package and pkgbase helpers.
- aurweb.template.register_filter
    - A decorator that can be used to register a filter:
      @register_filter("some_filter") def f(): pass

Additionally, template partials have been split off a bit
differently. Changes:

- /packages/{name} is defined in packages/show.html.
- partials/packages/package_actions.html is now
  partials/packages/actions.html.
- partials/packages/details.html has been added.
- partials/packages/comments.html has been added.
- partials/packages/comment.html has been added.
- models.dependency_type additions: name and id constants.
- models.relation_type additions: name and id constants.
- models.official_provider additions: base official url constant.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-27 20:48:40 -07:00
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
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
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
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
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
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
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
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
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
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
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
ee2aa9755f Add support for backup email addresses
Support secondary email addresses that can be used to recover an account
in case access to the primary email address is lost. Reset keys for an
account are always sent to both the primary and the backup email
address.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-02 12:12:42 +01:00
Lukas Fleischer
e5a839bf0b Add option to send reset key for a given user name
In addition to supporting email addresses in the reset key form, also
support user names. The reset key is then sent to the email address in
the user's profile.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-02 12:12:42 +01:00
Lukas Fleischer
def2787b45 Require password when changing account information
Since commits daee20c (Require current password when setting a new one,
2020-01-30) and 8fc8898 (Require password when deleting an account,
2020-01-30), changing a password and deleting an account require the
current password. Extend this to all other profile changes.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 14:05:24 +01:00
Lukas Fleischer
8fc8898fef Require password when deleting an account
Further reduce the attack surface in case of a stolen session ID.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 13:25:15 +01:00
Lukas Fleischer
daee20c694 Require current password when setting a new one
Prevent from easily taking over an account by changing the password with
a stolen session ID.

Fixes FS#65325.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 10:31:26 +01:00
Lukas Fleischer
dd0e090301 Sync CSS with archweb
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-19 00:19:16 -04:00
Lukas Fleischer
d6ae970785 Add a simple CAPTCHA to the sign up form
Add a CAPTCHA to protect against automated account creation. The CAPTCHA
changes whenever three new accounts are registered.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-05 13:44:00 -04:00
Eli Schwartz
3ac958ac01
Move permission for LIST_COMMENTS to dev/tu block
In commit 3578e77ad4 we implemented
listing of comments from the account details page , but this was
intended to only be available to TUs and Devs. As the comment says:
"display the comment list if they're a TU/dev"

The credential checking code, however, set this credential for all
users, contrary to the intention of the commit.

In order to preserve the ability to list a person's own comments, also
declare the allowed uids based on the profile being viewed.
2019-08-18 13:01:37 -04:00
Lukas Fleischer
fc9c519852 Display warning when flagging VCS packages
VCS packages should not be flagged out-of-date when the package version
does not match the most recent commit.

Implements FS#62733.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-05-25 19:01:33 -04:00
Lukas Fleischer
5a66a381fb Sync CSS with archweb
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-05-25 12:40:18 -04:00
Vladimir Panteleev
e3ca3c96e5 Add "Enable notifications" checkbox in "Add Comment" form
Currently, it is a little to easy to forget to enable notifications
for a package after leaving a comment, thus never being notified of a
reply. Even though the "Enable notifications" link is on the same
page, it is not part of the flow for posting a new comment, and so,
easy to miss.

Most web forums and comment systems include a checkbox to enable
notifications when posting for the first time in a thread. This patch
implements this in aurweb, as well.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-04-28 08:58:29 -04:00
Johannes Löthberg
3578e77ad4 Allow listing all comments from a user
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:58 +02:00
Lukas Fleischer
41a4189d20 Sync CSS with archweb
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-07-07 15:57:47 +02:00