Commit Graph

527 Commits

Author SHA1 Message Date
Jonne Ransijn 2b4c2f9972 Fix generation of Blame url
The Blame URLs returned by `url_for` currently return e.g. `b'master'`
for the ref component, breaking the "Blame" tab. Example:

https://git.sr.ht/~yyny/test/blame/b%27master%27/README.md

This patch fixes that.
2024-04-19 12:25:22 +02:00
Drew DeVault 7144962487 Cap editorconfig line length to 256
Thanks to Naglis Jonaitis for pointing out the opportunity for a DoS
through this.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-04-12 10:10:00 +02:00
Naglis Jonaitis b3c993e21b Do not use bare `except:`
According to PEP8[1]:

> A bare `except:` clause will catch SystemExit and KeyboardInterrupt
> exceptions, making it harder to interrupt a program with Control-C,
> and can disguise other problems.

Use more specific exceptions or `contextlib.suppress()` in case of
`try: ... except: pass`.

[1]: https://peps.python.org/pep-0008/#programming-recommendations
2024-02-21 09:25:03 +01:00
Naglis Jonaitis e3198ebd3b Use f-strings in `linecounter`
This is a bit simpler and has a marginal performance gain.
2024-02-06 11:09:22 +01:00
Naglis Jonaitis 2a40a3f233 Fix undefined `ResponseError`
`ResponseError` is currently undefined. It manifests when an exception
is raised in the `try` block.

`ResponseError` was renamed[1] to `S3Error` in minio 7.0.0.

[1]: b81883a98e
2024-02-06 11:07:57 +01:00
Naglis Jonaitis 237aa3712e Replace inline CSS with Bootstrap classes
This replaces occurrences of inline CSS that can be replaced directly
(equivalent style) with Bootstrap classes.

Inline styles are generally longer, are not cached, make implementing
CSP policies harder, etc.
2024-01-31 10:21:08 +01:00
Simon Ser 2da016a3d3 Add support for [objects]s3-insecure 2024-01-24 12:51:32 +01:00
Ersei Saggi 4278f329f8 Improve performance on rendering files by ~30% 2023-12-04 11:06:12 +01:00
Conrad Hoffmann 9cd8be0740 Remove unused PoC using sr.ht as pygit2 backend
Not sure if it ever worked, but it depends on the legacy API.
2023-12-04 11:06:12 +01:00
Gabriel Augendre 32c466e8a7 show ref in title
Signed-off-by: Gabriel Augendre <gabriel@augendre.info>
2023-12-04 11:06:12 +01:00
Gregory Anders 8249531f38 Use next commit in log continuation
Fix a bug where the first commit in the log after clicking "Next" is the
same as the last commit on the previous page.
2023-12-04 11:06:12 +01:00
наб 7922c6d097 Consistently accept both spellings of LICENCES in presence detexion and tree traversal 2023-10-24 13:27:36 +02:00
наб 631e5dbc17 Match LICENSES entries by full name before dot-stripping
This meant that for a repository with
  LICENSES/
    0BSD
    GPL-2.0
only 0BSD was detected.

So keep allowing LICENSES/0BSD.jpeg,
but also don't break LICENSES/GPL-2.0.
2023-10-24 13:27:31 +02:00
наб e7fb739535 Consistently render and link to discovered-signed format of archive
We linked to and served .tar.asc but the archive link both said
.tar.gz and /linked/ to .tar.gz. We never linked to .tar, or even
exposed the possibility.
2023-10-24 13:27:24 +02:00
Adnan Maolood e520aa8a73 gitsrht/templates: Drop /item/ from forge meta tags
Links with /item/ result in 404s for the root directory. Remove /item/
so that links to the root directory work properly.

For example, this link on godocs.io is broken:
https://godocs.io/git.sr.ht/~sircmpwn/getopt#pkg-files
2023-08-16 11:18:24 +02:00
Thorben Günther 31832f94c4 blueprints/manage.py: Fix description in repository creation
Right now the description gets set to an empty string if no input is
specified instead of "null". In comparison updating a repository handles
it correctly [1].

[1]: f3df3ac3f1/item/gitsrht/blueprints/manage.py (L120)
2023-06-22 10:41:02 +02:00
Jonne Ransijn f3df3ac3f1 prevent XSS attacks from raw blobs 2023-06-01 12:42:40 +02:00
Jonne Ransijn b52b348696 Allow rendering of images from blob
Adds a `Content-Type` header to image files.
This allows images to be rendered by the browser.
In particular, it allows SVGs to be used in READMEs.

I have restricted this feature to only work on image files for now,
but it might make sense to send this header for other file types as
well if we can reasonably assume that the browser is able to render
it, such as PDFs and XML documents.
2023-06-01 12:42:37 +02:00
Axel Karjalainen 7fb5c45da8 Add name to enum to prevent crash
The SQLAlchemy documentation doesn't state that the `name`
keyword-argument is required but on my setup without this patch
git.sr.ht crashes immediately on start.
2023-06-01 12:41:42 +02:00
Umar Getagazov 012e5ec38b repo.patch: fix empty output
Fixes f2c8bab45d
2023-04-12 10:30:52 +02:00
Drew DeVault cba1e4ca92 log.html: fix exception on zero commits 2023-04-11 12:07:09 +02:00
Drew DeVault f2c8bab45d repo.patch: fix command injection 2023-04-03 16:54:09 +02:00
Drew DeVault 3dcb94204f archive: fix command injection 2023-04-01 15:07:15 +02:00
Drew DeVault a0e9ae716e blueprints/manage.py: fix incorrect route name 2023-02-22 09:51:08 +01:00
Arsen Arsenović 58f956ab09 utils.html: Add a permalink breadcrumb 2023-02-22 09:25:53 +01:00
David Florness 1f83634d68 Replace meta.sr.ht's /oauth endpoint with /oauth2 in comment
While there is a link to /oauth2 on the /oauth page, landing on /oauth2 right
away makes it obvious to server admins that /oauth2 is where they should be.

Discussion: <https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3C877cwnhpni.fsf%40florness.com%3E>
Signed-off-by: David Florness <david@florness.com>
2023-02-20 10:55:20 +01:00
Paul Wise e74ae7acf1 Add repo description to summary page title
Makes it easier to find repos in the history of browsers that save titles.

Potentially makes web search engine results more useful.
2023-02-13 10:31:05 +01:00
Arsen Arsenović 59b98e2e44 commit.html: Add button to download .tar.gz 2023-01-26 10:18:01 +01:00
Vlad-Stefan Harbuz 0100a8a30b add license nav item to repo subpages
Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/374
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
2023-01-26 10:16:39 +01:00
Conrad Hoffmann 09128ad3ad Revert "Change markup for diff insert/delete lines"
This reverts commit b75d2f0e03.

This commit has some issues:

- It uses <ins>/<del> not for the content that was actually
  added/removed (i.e. the diff), but for the line stats. I don't think
  that helps accessibility, it might actually make it worse.
- It adds some CSS to apply text decoration to <ins>/<del>, but only
  inside the `diff` class. However, the elements never occur inside the
  `diff` class (see first item). The CSS is never used.
- Instead, the place where it was used (line stats) got unintended text
  decoration applied, causing a follow-up commit which fixed this the
  wrong way, causing yet more issues (fixed in next commit).

I think the one place where it would make sense to apply <ins>/<del> is
the diff itself, but that might be a more serious operation.
2022-12-19 13:14:08 +01:00
Drew DeVault cd790c9bed Revert "Resolve name and email from mailmap"
This patch has an oversight, sent backtrace to Seb for review.

This reverts commit 2369d4aa22.
2022-11-07 13:16:54 +01:00
Sebastian 2369d4aa22 Resolve name and email from mailmap
The mailmap file is consulted to obtain the canonical name/email of an
author or committer of a commit, or a tagger of a tag.

Signed-off-by: Sebastian <sebastian@sebsite.pw>
2022-11-07 12:18:17 +01:00
Vlad-Stefan Harbuz 9d26151dfe licenses: check that LICENSES/ is directory
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
2022-10-28 10:45:17 +02:00
Adnan Maolood 1272ef2588 gitsrht: Use canonical user IDs
Update user IDs across git.sr.ht to match those of meta.sr.ht.
2022-10-26 10:42:56 +02:00
Vlad-Stefan Harbuz a00fc083e4 add REUSE-based licenses to repo page
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
2022-10-10 11:23:24 +02:00
Thorben Günther 0797e15451 Fix flask send_file arguments
The deprecated attachment_filename was removed in a recent flask release
and is superseded by download_name [1].

[1]: https://github.com/pallets/flask/pull/4667
2022-09-29 10:52:48 +02:00
Vlad-Stefan Harbuz 2d3175c5e4 add whitespace back to pre, body on blob page
This is a partial revert of fd8cca2e. It fixes a bug where, for example, viewing
a README file on a blob page results in no bottom margin for <pre>s at all, and
no bottom padding on the body. Adding bottom padding to the body also improves
the experience on mobile.

Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
2022-08-15 12:17:14 +02:00
Adnan Maolood 9f9c12995d gitsrht: Rename RepoVisibility to Visibility
Rename RepoVisibility to Visibility so that gitsrht-initdb will name the
type 'visibility' instead of 'repovisibility'.
2022-08-15 12:17:04 +02:00
Adnan Maolood 30f949522f gitsrht/templates: Surface validation errors
Surface validation errors which are not attached to a given field.
2022-08-15 12:16:52 +02:00
Chris DeLuca b75d2f0e03 Change markup for diff insert/delete lines
HTML provides semantic markup for the concept of inserting and deleting
content from a document. Leveraging these tags can increase the
correctness and accessibility of the document without effecting its
presentation.

See:

- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del
2022-04-28 11:25:13 +02:00
Adnan Maolood 76af91d084 gitsrht/templates/user: Remove extraneous paragraph 2022-04-20 11:04:09 +02:00
delthas 2a5f5783d6 Fix stripping trailing slashes of URLs
Most URLs ending with a trailing slash currently 404, because the strict
mode is not properly disabled in the app.

The strict_slashes value must be set before adding the routes.

After this patch, requesting URLs with a trailing slash will work as
expected (eg git.sr.ht/~sircmpwn/git.sr.ht/)
2022-04-14 10:33:04 +02:00
delthas 530f4839a1 Fix obsolete Jinja2 imports
jinja2.Markup was moved to markupsafe.Markup.

See: https://github.com/pallets/jinja/issues/1438
2022-04-14 10:32:57 +02:00
Adnan Maolood 1838cce8c7 gitsrht/blueprints/api: Fix canonical_name
Fix canonical_name, which was wrongly named canonicalName, in user
resources returned by the legacy API.

Also take the opportunity to refactor the GraphQL queries such that each
query retrieves only the data it needs.
2022-04-08 14:09:10 +02:00
Ignas Kiela 41c01b9e4d Get all author users with a single query for log
Right now repos log page is the slowest page on git.sr.ht, and a big
reason for that is that it currently averages on 19 queries per view,
most of them coming from the template looking up users to show links to
their user pages. We can get all the users we have before that, and pass
that on to the template. With these changes, a page view always takes 5
queries consistently.
2022-03-21 10:28:50 +01:00
xdavidwu 02ed08c389 email: use start_smtp from core.sr.ht
This make it support smtp-encryption config
2022-03-14 12:23:08 +01:00
Conrad Hoffmann 8c445ecb04 Supply missing ENUM type name 2022-03-14 12:23:02 +01:00
Adnan Maolood ad42bf4448 gitsrht: Store visibility as enum instead of varchar
Add a 'visibility' enum type to the database and use it for the
repository.visibility column.

This required changes to scm.sr.ht code. Instead of updating scm.sr.ht,
most of the scm.sr.ht code that git.sr.ht uses was moved to git.sr.ht.
2022-03-14 09:59:12 +01:00
Adnan Maolood cd8225a534 gitsrht: Add missing templates 2022-03-14 09:56:09 +01:00
Hoolean 985b1e58af Fix text wrapping for multi-line cover letters and commentary
Fixes: https://todo.sr.ht/~sircmpwn/git.sr.ht/360
2022-02-21 11:32:14 +01:00