1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00
Commit graph

871 commits

Author SHA1 Message Date
gudvinr
83254a1f26 refactor(model): replace Sprintf("%d") in tests
This is just Itoa but weird.
2025-08-20 19:45:24 -07:00
Julien Voisin
3acb888309
refactor(response): simplify switch-case and remove unnecessary defer
- b.body can never be of type error, so let's remove it from the switch-case
  construct.
- there is no need to use defer when the only return statement is two lines
  after.
2025-08-20 19:31:28 -07:00
Julien Voisin
7c29166ef9
refactor(ui): move inline SVG to sprite.svg
There is no need to have an inline svg when we can have it in the sprite.svg
file.
2025-08-20 19:26:47 -07:00
Julien Voisin
71105bec56
refactor(template): improve consistency in layout.html (meta tags, whitespace, comments)
- Group the `<meta>` tags together
- Trim some superfluous whitespace
- Remove an obvious and thus useless comment
2025-08-20 19:24:13 -07:00
Julien Voisin
2a372674a2
refactor(icon): avoid calling AbsoluteURL twice for the feed icon URL
The url of a feed's icon is always absolute.
2025-08-20 19:01:59 -07:00
Julien Voisin
9d32b23ab0
perf(sanitizer): make sanitizer ~10% faster by using slices.Contains instead of nested maps
```console
$ go test -bench=. -count=25 > old.txt
$ go test -bench=. -count=25 > new.txt
$ benchstat old.txt new.txt
goos: linux
goarch: arm64
pkg: miniflux.app/v2/internal/reader/sanitizer
           │   old.txt   │            new.txt            │
           │   sec/op    │   sec/op     vs base          │
Sanitize-8   21.55m ± 5%   19.64m ± 9%  ~ (p=0.059 n=25)
```

Almost a 10% improvement, yay.
2025-08-20 18:54:49 -07:00
jvoisin
da8bf3890c refactor(templates): be explicit about dependencies
Instead of blindly compiling all the common/ templates for every view/ ones,
let's be explicit about the dependencies. This should significantly decrease
the resident memory consumption, as ParseTemplate is responsible for ~10M of
the current 11M of heap memory on my instance, so any win there is interesting.
This will also allow better factorization of templates, now that everything is
explicit. Another side-effect is that it'll make testing easier, as we now have
a comprehensive list of views/ templates affected by a change in a file in
common/
2025-08-20 18:51:51 -07:00
Frédéric Guillot
459b1bf1ee test(icon): add tests for finding icon URLs in HTML documents 2025-08-19 20:14:34 -07:00
Frédéric Guillot
fdc12bf18c fix(icon): improve logging messages in resizeIcon function 2025-08-19 20:14:34 -07:00
Frédéric Guillot
1b1ceaf8b4 test(icon): add test case to verify SVG minification with error 2025-08-19 20:14:34 -07:00
jvoisin
cad40cc158 feat(icon): minify svg favicons 2025-08-19 20:14:34 -07:00
Frédéric Guillot
c105b14f58 test(api): add integration test for fetching categories with counters 2025-08-18 20:08:31 -07:00
Frédéric Guillot
49575c8902 test(version): add a test to enforce the version format 2025-08-18 19:51:09 -07:00
Frédéric Guillot
b25f9651fe test(fetcher): add unit tests for RequestBuilder 2025-08-18 19:38:14 -07:00
Frédéric Guillot
953ea885e0 fix(mediaproxy): always forward the browser Accept header
Tumblr CDN is blocking the Accept header used to fetch feeds
2025-08-18 18:08:21 -07:00
Frédéric Guillot
9536ce7dbc fix(version): change development version naming to avoid breaking some clients
Some Miniflux clients expect a specific version format.
For example, Flux News converts the string version to an integer.

Using `Development Version` will break some clients.
2025-08-18 17:41:17 -07:00
Frédéric Guillot
84ae1d5dc0 fix(storage): index only the first 500K characters of the article contents to avoid tsvector limits
The length of a tsvector (lexemes + positions) must be less than 1 megabyte.

We don't need to index the entire content, and we need to keep a buffer for the positions.
2025-08-17 19:32:56 -07:00
Frédéric Guillot
5403ca09f6 feat(storage): add limit parameter to ClearRemovedEntriesContent
Without the limit, this query is going to hangs forever on large
databases with millions of entries.
2025-08-17 17:39:04 -07:00
gudvinr
905d652511 refactor(ui): use request builder in media proxy handler
builder is used seemingly everywhere but media proxy uses manual
transport construction
2025-08-17 13:09:32 -07:00
Frédéric Guillot
a16ac51326 refactor(storage): split DeleteContentRemovedEntries into 2 functions and fix condition
- Add `content IS NOT NULL` to avoid clearing the same entries over and over
- Create `DeleteRemovedEntriesEnclosures` and `ClearRemovedEntriesContent` that report individual counts
2025-08-16 21:19:28 -07:00
jvoisin
5c26e06780 feat(entry): keep only metadata for removed entries
This should significantly shrink the space taken by miniflux' database:

```sql
miniflux=#
SELECT
  relname, pg_size_pretty(pg_total_relation_size(relname::regclass))
FROM
  pg_catalog.pg_statio_user_tables
ORDER BY
  pg_total_relation_size(relname::regclass)
DESC;

       relname        | pg_size_pretty
----------------------+----------------
 entries              | 158 MB
 icons                | 3312 kB
 enclosures           | 1568 kB
 sessions             | 1048 kB
 feeds                | 288 kB
 feed_icons           | 72 kB
 users                | 64 kB
 user_sessions        | 64 kB
 categories           | 48 kB
 integrations         | 32 kB
 api_keys             | 32 kB
 webauthn_credentials | 24 kB
 schema_version       | 16 kB
 acme_cache           | 16 kB
(14 rows)

miniflux=#
```

This should close #3524
2025-08-16 20:57:59 -07:00
Frédéric Guillot
9e4248c7c1 fix(templates): remove non-breaking space in about page 2025-08-16 16:51:39 -07:00
Frédéric Guillot
a654a5f710 feat(template): show GitHub links in about page only when tag and commit are available 2025-08-16 13:08:38 -07:00
Frédéric Guillot
6bf3b3c464 fix(version): allow build info to be set with LDFLAGS and fallback to VCS metadata when available 2025-08-16 12:41:45 -07:00
Frédéric Guillot
a010544200 fix(version): be explicit when VCS info is unavailable 2025-08-16 12:21:40 -07:00
Frédéric Guillot
c1af510ead feat(version): use Golang's builtin vcs feature to get commit and build date 2025-08-16 12:05:53 -07:00
gudvinr
ce6cadc176 refactor(mediaproxy): use *url.URL for MEDIA_PROXY_CUSTOM_URL
Same behaviour as for HTTP_CLIENT_PROXY.
2025-08-15 18:12:44 -07:00
Julien Voisin
40fa77851c
refactor(locale): avoid code duplication in Printer.Printf() function 2025-08-15 18:02:25 -07:00
jvoisin
dd8011a4aa refactor(template): remove some useless attributes
When `target="_blank"` is used, it has the same effect than rel="noopener",
so we can remove the latter. Moreover, since we're already setting `<meta
name="referrer" content="no-referrer" />` in the `<head>`, there is no need to
set it on every single link in the HTML, as we're rendering everything in the
same origin.

Note that we need to keep adding those in the sanitizer, the entry content HTML
can be consumed by third-party clients via the Miniflux/GoogleReader/Fever API.

See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel/noopener
and https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Referrer-Policy#integration_with_html
2025-08-15 17:55:49 -07:00
Julien Voisin
3955df43f5
perf(js): don't load webauthn,js when disabled
This saves around 1kB of data, yay.
2025-08-15 17:11:12 -07:00
Julien Voisin
6f2ec8b3e9
refactor(ui): rename the small favicons to icons
There is no need to distinguish between "Android icons" and favicons.
2025-08-15 16:37:39 -07:00
jvoisin
2fa813fe01 refactor(fetcher): use errors.New when possible instead of fmt.Errorf 2025-08-15 16:25:58 -07:00
gudvinr
7c1602c2c0 refactor(internal): fix doc comments 2025-08-15 16:24:48 -07:00
gudvinr
5e3bba9ae1 refactor(request): fix typo in big corp name 2025-08-15 16:24:48 -07:00
gudvinr
ab26a4e20f refactor(config): fix typos in test 2025-08-15 16:24:48 -07:00
Julien Voisin
2c4f4e2ae6
perf(templates): removes superfluous whitespaces in two templates 2025-08-14 19:40:30 -07:00
Julien Voisin
261b72f149
feat(icon): add resizing support for webp images 2025-08-14 19:36:11 -07:00
Julien Voisin
6c60d61f36
fix(icon): use rel=apple-touch-icon instead of rel=apple-touch-icon-precomposed.png
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
2025-08-14 19:32:50 -07:00
Julien Voisin
fa85a0eff4
feat(ui): disable OAuth routes if OAuth is disabled 2025-08-13 21:15:26 -07:00
jvoisin
eb6f7f30bb feat(storage): make removed entries' status immutable
This is a first step towards "keeping only metadata for removed entries" #3524.
2025-08-12 20:17:34 -07:00
jvoisin
93fc206f42 refactor(opml): reduce indirections
Don't use a slice of pointers to opml items, when we can simply use a slice of
items instead. This should reduce the amount of memory allocations and the
number of indirections the GC has to process, speedup up the import process.

Note that this doesn't introduce any additional copies, as the only time a
slice of subscription is created, the items are created and inserted inline.
2025-08-12 19:47:47 -07:00
Julien Voisin
8bca777a6d
refactor(model): remove some indirection
For small fixed-size structures, it's better to use a slice of values, instead
of a slice of pointers to values: they're stored contiguously and thus can be
iterated on quickly by the CPU, and it does remove an indirection per object
every time the GC kicks in.
2025-08-12 19:46:14 -07:00
Frédéric Guillot
37d539eb42 fix(template): webauthn error alert was broken on the settings page 2025-08-11 20:01:53 -07:00
jvoisin
f5188b1edc refactor(ui): don't expose webauthn routes if webauthn is disabled 2025-08-11 19:53:23 -07:00
Julien Voisin
5d9d0b2652
refactor(ui): standardize user variable naming and avoid a SQL query when only userID is used
- Use `user` everywhere, instead of sometimes `loggedUser`
- Delay the instantiation of some variables: no need to perform SQL queries for
  nothing.
- Remove a SQL query getting the whole user struct when only user.ID is used.
2025-08-11 19:48:36 -07:00
jvoisin
50c5996280 refactor: remove some fmt.Sprintf calls
fmt.Sprintf is slow, so let's get rid of it in trivial cases that are in (at
least) moderately hot paths.
2025-08-11 19:27:34 -07:00
jvoisin
884521a7dd refactor(template): use modern svg directive
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/use
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/xlink:href

> Warning: Since SVG 2, the xlink:href attribute is deprecated in favor of
href. See xlink:href page for more information.
2025-08-11 18:31:16 -07:00
jvoisin
3a01f8a691 perf(misc): use arrays instead of slices where possible
Arrays have a fixed size in go, while slices don't, making the former way
faster than the latter: https://go-benchmarks.com/array-vs-slice
2025-08-11 18:26:58 -07:00
jvoisin
68984da332 perf(static): minimize the SVG
Since tdewolff/minify supports SVG minimization, let's make use of it. As we
need to keep the license in the SVG because we're nice netizens, we can at
least use SPDX identifiers instead of using it verbatim.

This does save a couple of kB.
2025-08-09 15:38:43 -07:00
jvoisin
485baf9654 refactor(misc): fix a handful of TODO 2025-08-09 15:22:02 -07:00