Compare commits

...

5 Commits

Author SHA1 Message Date
977cd0763a Fix #379 2022-01-05 16:46:45 -08:00
fcadd44cb3 Update dependencies 2022-01-05 16:39:56 -08:00
9c325c2cbf Search fixes (#384)
* Default to searching within subreddit

* Redirect to subreddit from search
2022-01-05 14:06:41 -08:00
e9038f4fe2 Add stilic.ml instance. Closes #380 2021-12-31 20:33:53 +00:00
8b8f55e09a Fix sort button scrollbars 2021-12-31 10:42:44 -08:00
8 changed files with 55 additions and 49 deletions

65
Cargo.lock generated
View File

@ -63,9 +63,9 @@ dependencies = [
[[package]] [[package]]
name = "async-recursion" name = "async-recursion"
version = "0.3.2" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" checksum = "2cda8f4bcc10624c4e85bc66b3f452cca98cfa5ca002dc83a16aad2367641bea"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -171,20 +171,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.34.0" version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" checksum = "f6f34b09b9ee8c7c7b400fe2f8df39cafc9538b03d6ba7f4ae13e4cb90bfbb7d"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"indexmap",
"os_str_bytes",
"textwrap", "textwrap",
"unicode-width",
] ]
[[package]] [[package]]
name = "cookie" name = "cookie"
version = "0.16.0-rc.1" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "188a7c2ae2a1026b9831889fd6461db5d33c4f6d54d6f862bd8b81a2fcefbdba" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05"
dependencies = [ dependencies = [
"time", "time",
"version_check", "version_check",
@ -412,13 +413,13 @@ dependencies = [
[[package]] [[package]]
name = "http" name = "http"
version = "0.2.5" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
"itoa 0.4.8", "itoa 1.0.1",
] ]
[[package]] [[package]]
@ -554,7 +555,7 @@ checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]] [[package]]
name = "libreddit" name = "libreddit"
version = "0.21.4" version = "0.21.7"
dependencies = [ dependencies = [
"askama", "askama",
"async-recursion", "async-recursion",
@ -673,6 +674,15 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.0.0" version = "2.0.0"
@ -712,9 +722,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.7" version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -877,18 +887,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.132" version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.132" version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -897,9 +907,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.73" version = "1.0.74"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142"
dependencies = [ dependencies = [
"itoa 1.0.1", "itoa 1.0.1",
"ryu", "ryu",
@ -962,12 +972,9 @@ dependencies = [
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.11.0" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
dependencies = [
"unicode-width",
]
[[package]] [[package]]
name = "time" name = "time"
@ -1103,12 +1110,6 @@ dependencies = [
"tinyvec", "tinyvec",
] ]
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.2" version = "0.2.2"
@ -1135,9 +1136,9 @@ dependencies = [
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.3" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "waker-fn" name = "waker-fn"

View File

@ -3,23 +3,23 @@ name = "libreddit"
description = " Alternative private front-end to Reddit" description = " Alternative private front-end to Reddit"
license = "AGPL-3.0" license = "AGPL-3.0"
repository = "https://github.com/spikecodes/libreddit" repository = "https://github.com/spikecodes/libreddit"
version = "0.21.4" version = "0.21.7"
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"] authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
askama = { version = "0.11.0", default-features = false } askama = { version = "0.11.0", default-features = false }
async-recursion = "0.3.2" async-recursion = "1.0.0"
cached = "0.26.2" cached = "0.26.2"
clap = { version = "2.34.0", default-features = false } clap = { version = "3.0.5", default-features = false, features = ["std"] }
regex = "1.5.4" regex = "1.5.4"
serde = { version = "1.0.132", features = ["derive"] } serde = { version = "1.0.133", features = ["derive"] }
cookie = "0.16.0-rc.1" cookie = "0.16.0"
futures-lite = "1.12.0" futures-lite = "1.12.0"
hyper = { version = "0.14.16", features = ["full"] } hyper = { version = "0.14.16", features = ["full"] }
hyper-rustls = "0.23.0" hyper-rustls = "0.23.0"
route-recognizer = "0.3.1" route-recognizer = "0.3.1"
serde_json = "1.0.73" serde_json = "1.0.74"
tokio = { version = "1.15.0", features = ["full"] } tokio = { version = "1.15.0", features = ["full"] }
time = "0.3.5" time = "0.3.5"
url = "2.2.2" url = "2.2.2"

View File

@ -67,6 +67,7 @@ Feel free to [open an issue](https://github.com/spikecodes/libreddit/issues/new)
| [libreddit.totaldarkness.net](https://libreddit.totaldarkness.net) | 🇨🇦 CA | | | [libreddit.totaldarkness.net](https://libreddit.totaldarkness.net) | 🇨🇦 CA | |
| [libreddit.esmailelbob.xyz](https://libreddit.esmailelbob.xyz) | 🇪🇬 EG | | | [libreddit.esmailelbob.xyz](https://libreddit.esmailelbob.xyz) | 🇪🇬 EG | |
| [libreddit.nl](https://libreddit.nl) | 🇳🇱 NL | | | [libreddit.nl](https://libreddit.nl) | 🇳🇱 NL | |
| [lr.stilic.ml](https://lr.stilic.ml) | 🇫🇷 FR | ✅ |
| [spjmllawtheisznfs7uryhxumin26ssv2draj7oope3ok3wuhy43eoyd.onion](http://spjmllawtheisznfs7uryhxumin26ssv2draj7oope3ok3wuhy43eoyd.onion) | 🇮🇳 IN | | | [spjmllawtheisznfs7uryhxumin26ssv2draj7oope3ok3wuhy43eoyd.onion](http://spjmllawtheisznfs7uryhxumin26ssv2draj7oope3ok3wuhy43eoyd.onion) | 🇮🇳 IN | |
| [fwhhsbrbltmrct5hshrnqlqygqvcgmnek3cnka55zj4y7nuus5muwyyd.onion](http://fwhhsbrbltmrct5hshrnqlqygqvcgmnek3cnka55zj4y7nuus5muwyyd.onion) | 🇩🇪 DE | | | [fwhhsbrbltmrct5hshrnqlqygqvcgmnek3cnka55zj4y7nuus5muwyyd.onion](http://fwhhsbrbltmrct5hshrnqlqygqvcgmnek3cnka55zj4y7nuus5muwyyd.onion) | 🇩🇪 DE | |
| [kphht2jcflojtqte4b4kyx7p2ahagv4debjj32nre67dxz7y57seqwyd.onion](http://kphht2jcflojtqte4b4kyx7p2ahagv4debjj32nre67dxz7y57seqwyd.onion) | 🇳🇱 NL | | | [kphht2jcflojtqte4b4kyx7p2ahagv4debjj32nre67dxz7y57seqwyd.onion](http://kphht2jcflojtqte4b4kyx7p2ahagv4debjj32nre67dxz7y57seqwyd.onion) | 🇳🇱 NL | |

View File

@ -91,15 +91,15 @@ async fn main() {
.version(env!("CARGO_PKG_VERSION")) .version(env!("CARGO_PKG_VERSION"))
.about("Private front-end for Reddit written in Rust ") .about("Private front-end for Reddit written in Rust ")
.arg( .arg(
Arg::with_name("redirect-https") Arg::new("redirect-https")
.short("r") .short('r')
.long("redirect-https") .long("redirect-https")
.help("Redirect all HTTP requests to HTTPS (no longer functional)") .help("Redirect all HTTP requests to HTTPS (no longer functional)")
.takes_value(false), .takes_value(false),
) )
.arg( .arg(
Arg::with_name("address") Arg::new("address")
.short("a") .short('a')
.long("address") .long("address")
.value_name("ADDRESS") .value_name("ADDRESS")
.help("Sets address to listen on") .help("Sets address to listen on")
@ -107,8 +107,8 @@ async fn main() {
.takes_value(true), .takes_value(true),
) )
.arg( .arg(
Arg::with_name("port") Arg::new("port")
.short("p") .short('p')
.long("port") .long("port")
.value_name("PORT") .value_name("PORT")
.help("Port to listen on") .help("Port to listen on")
@ -116,8 +116,8 @@ async fn main() {
.takes_value(true), .takes_value(true),
) )
.arg( .arg(
Arg::with_name("hsts") Arg::new("hsts")
.short("H") .short('H')
.long("hsts") .long("hsts")
.value_name("EXPIRE_TIME") .value_name("EXPIRE_TIME")
.help("HSTS header to tell browsers that this site should only be accessed over HTTPS") .help("HSTS header to tell browsers that this site should only be accessed over HTTPS")

View File

@ -54,6 +54,10 @@ pub async fn find(req: Request<Body>) -> Result<Response<Body>, String> {
return Ok(redirect("/".to_string())); return Ok(redirect("/".to_string()));
} }
if query.starts_with("r/") {
return Ok(redirect(format!("/{}", query)));
}
let sub = req.param("sub").unwrap_or_default(); let sub = req.param("sub").unwrap_or_default();
let quarantined = can_access_quarantine(&req, &sub); let quarantined = can_access_quarantine(&req, &sub);
// Handle random subreddits // Handle random subreddits

View File

@ -211,7 +211,7 @@ pub async fn subscriptions_filters(req: Request<Body>) -> Result<Response<Body>,
.unwrap_or_default(); .unwrap_or_default();
// Find each subreddit name (separated by '+') in sub parameter // Find each subreddit name (separated by '+') in sub parameter
for part in sub.split('+') { for part in sub.split('+').filter(|x| x != &"") {
// Retrieve display name for the subreddit // Retrieve display name for the subreddit
let display; let display;
let part = if part.starts_with("u_") { let part = if part.starts_with("u_") {

View File

@ -597,7 +597,7 @@ button.submit:hover > svg { stroke: var(--accent); }
box-shadow: var(--shadow); box-shadow: var(--shadow);
background: var(--outside); background: var(--outside);
display: flex; display: flex;
overflow: auto; overflow: hidden;
} }
#sort_options > a, footer > a { #sort_options > a, footer > a {

View File

@ -19,7 +19,7 @@
<input id="search" type="text" name="q" placeholder="Search" title="Search libreddit" value="{{ search }}"> <input id="search" type="text" name="q" placeholder="Search" title="Search libreddit" value="{{ search }}">
{% if root != "/r/" && !root.is_empty() %} {% if root != "/r/" && !root.is_empty() %}
<div id="inside"> <div id="inside">
<input type="checkbox" name="restrict_sr" id="restrict_sr"> <input type="checkbox" name="restrict_sr" id="restrict_sr" checked>
<label for="restrict_sr" class="search_label" title="Restrict search to this subreddit">in {{ root }}</label> <label for="restrict_sr" class="search_label" title="Restrict search to this subreddit">in {{ root }}</label>
</div> </div>
{% endif %} {% endif %}