Add the ability to search for specific comments within posts.
Known issues:
- Just like on reddit, this does not work with comment sorting. The
sorting order is ignored during the search and changing the sorting
order after the search does not change anything. I do not think we
can fix this before reddit does, since in my understanding we rely
on them for the sorting. However we could implement a default
sorting method ourselves by taking the vector of comments returned
from the search and sorting it manually.
- The UI could be improved on mobile. On screens with a max width
inferior to 480 pixels, the comment search bar is displayed below
the comment sorting form. It would be great if we could make the
search bar have the same width as the whole comment sorting form
but I do not have the willpower to write any more css.
To know if the gate should be bypassed, we check if the link contains
the pasameter instead of checking if the link ends with it. This is
impostant, for example if we were to implement searching for comments
within a post. If we wanted to search for comments within a post that we
have bypassed the gate to view: the link will look like
https://libreddit-instance/r/somesub/comments/post-id/post-title&bypass_nsfw_landing/?q=some-query&type=comment
If we can't retrieve subreddit name, just use the user-supplied name.
This fixes banned subreddits being impossible to to unfilter or
unsubscribe from.
A drawback of such approach is that it might be possible to subscribe to
a subreddit twice with different casing, however the chance of this is
extremely low.
* Fix gated communities being unviewable by treating them as quarantined
* Show restriction reason in quarantine template
* Add `gated` checks for other requests
Making a new connection on every request is very slow and wasteful, espectially on slower network.
Fix this by reuse a hyper client which shares a connection pool.
I'm able to lower /r/popular loading time from 5s to 1.5s on my machine.
This simplifies the logic to build the listener by using more clap
features instead of manually accessing the PORT environment variable.
This also removes unnecessary `unwrap_or` calls that set defaults that
are already set by clap.
* Search - add support for raw reddit links
If a search query starts with 'https://www.reddit.com/' or 'https://old.reddit.com/',
this prefix will be truncated and the query will be processed normally.
For example, a search query 'https://www.reddit.com/r/rust' will redirect to
r/rust.
* Search - support a wider variety of reddit links.
Add once cell dependency for static regex support (avoid compiling the
same regex multiple times).
All search queries are now matched against a regex (provided by @Daniel-Valentine)
that determines if it is a reddit link. If it is, the prefix specifying
the reddit instance will be truncated from the query that will then be
processed normally.
For example, the query 'https://www.reddit.com/r/rust' will be treated
the same way as the query 'r/rust'.
* Fix 'all_posts_hidden_nsfw' when there are no posts.
If a search query yielded no results and the user set nsfw posts to be
hidden, libreddit would show 'All posts are hidden because they are NSFW.
Enable "Show NSFW posts" in settings to view'. This is fixed by
verifying tnat posts.len > 0 before setting 'all_posts_hidden_nsfw' to
true.
* Add a message when no posts were found.
* Delete 2
* Redirect /:id to canonical URL for post.
This implements redirection of `/:id` (a short-form URL to a post) to
the post's canonical URL. Libreddit issues a `HEAD /:id` to Reddit to get
the canonical URL, and on success will send an HTTP 302 to a client with
the canonical URL set in as the value of the `Location:` header.
This also implements support for short IDs for non-ASCII posts, c/o
spikecodes.
Co-authored-by: spikecodes <19519553+spikecodes@users.noreply.github.com>
Implements HTTP compression, between both Reddit and Libreddit and Libreddit
and a web browser. Compression between Reddit and Libreddit is mandatory,
whereas compression between Libreddit and a client is opt-in (client must
specify a compressor in the Accept-Encoding header).
Supported compressors are gzip and brotli. gzip support is ubiquitous,
whereas brotli is supported by almost all modern browsers except Safari
(iOS, iPhone, macOS), although Safari may support brotli in the future.
Co-authored-by: Matthew E <matt@matthew.science>
Adds another on/off preference (default: on, keeps same
behaviour) for the fixed navbar.
When off the navbar will not remain at the top of the
page when scrolling.
This is useful for small displays such as phones where
otherwise the navbar takes up a sizeable portion of
the viewport.
* Fix sorting buttons on r/all and r/popular
* Bump version to v0.22.2
* Fix empty sidebar in r/all and r/popular
Co-authored-by: spikecodes <19519553+spikecodes@users.noreply.github.com>