diff --git a/.github/ISSUE_TEMPLATE/feature_parity.md b/.github/ISSUE_TEMPLATE/feature_parity.md index a97ac7e..6d7a76f 100644 --- a/.github/ISSUE_TEMPLATE/feature_parity.md +++ b/.github/ISSUE_TEMPLATE/feature_parity.md @@ -1,6 +1,6 @@ --- name: ✨ Feature parity -about: Suggest implementing a feature into libbacon that is found in Reddit.com +about: Suggest implementing a feature into Ferrit that is found in Reddit.com title: '✨ Feature parity: ' labels: feature parity assignees: '' @@ -12,7 +12,7 @@ assignees: '' A clear and concise description of what the feature is. --> -## Describe how this could be implemented into libbacon +## Describe how this could be implemented into Ferrit diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index e4841ce..c408bd2 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,6 +1,6 @@ --- name: 💡 Feature request -about: Suggest a feature for libbacon that is not found in Reddit +about: Suggest a feature for Ferrit that is not found in Reddit title: '💡 Feature request: ' labels: enhancement assignees: '' diff --git a/.replit b/.replit index 98dee1f..179f999 100644 --- a/.replit +++ b/.replit @@ -1,2 +1,2 @@ -run = "while :; do set -ex; curl -o./libbacon -fsSL -- https://github.com/libbacon/libbacon/releases/latest/download/libbacon; chmod +x libbacon; set +e; ./libbacon -H 63115200; sleep 1; done" +run = "while :; do set -ex; curl -o./ferrit -fsSL -- https://github.com/libbacon/ferrit/releases/latest/download/ferrit; chmod +x ferrit; set +e; ./ferrit -H 63115200; sleep 1; done" language = "bash" diff --git a/Cargo.lock b/Cargo.lock index 17ce3fb..4e5d7ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,6 +289,29 @@ dependencies = [ "instant", ] +[[package]] +name = "ferrit" +version = "0.1.0" +dependencies = [ + "askama", + "async-recursion", + "cached", + "clap", + "cookie", + "futures-lite", + "hyper", + "hyper-rustls", + "percent-encoding", + "regex", + "route-recognizer", + "rust-embed", + "serde", + "serde_json", + "time", + "tokio", + "url", +] + [[package]] name = "fnv" version = "1.0.7" @@ -581,29 +604,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "libbacon" -version = "0.1.0" -dependencies = [ - "askama", - "async-recursion", - "cached", - "clap", - "cookie", - "futures-lite", - "hyper", - "hyper-rustls", - "percent-encoding", - "regex", - "route-recognizer", - "rust-embed", - "serde", - "serde_json", - "time", - "tokio", - "url", -] - [[package]] name = "libc" version = "0.2.133" diff --git a/Cargo.toml b/Cargo.toml index 78d0f36..b3522c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "libbacon" +name = "ferrit" description = " Alternative private front-end to Reddit" license = "AGPL-3.0" -repository = "https://github.com/libbacon/libbacon" +repository = "https://github.com/libbacon/ferrit" version = "0.1.0" authors = ["Daniel Valentine ", "spikecodes <19519553+spikecodes@users.noreply.github.com>"] edition = "2021" diff --git a/Dockerfile b/Dockerfile index ce4e076..2b2e2ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM rust:alpine AS builder RUN apk add --no-cache musl-dev -WORKDIR /libbacon +WORKDIR /ferrit COPY . . @@ -21,16 +21,16 @@ COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates COPY --from=builder /etc/ssl/certs /etc/ssl/certs # Copy our build -COPY --from=builder /libbacon/target/x86_64-unknown-linux-musl/release/libbacon /usr/local/bin/libbacon +COPY --from=builder /ferrit/target/x86_64-unknown-linux-musl/release/ferrit /usr/local/bin/ferrit # Use an unprivileged user. -RUN adduser --home /nonexistent --no-create-home --disabled-password libbacon -USER libbacon +RUN adduser --home /nonexistent --no-create-home --disabled-password ferrit +USER ferrit # Tell Docker to expose port 8080 EXPOSE 8080 -# Run a healthcheck every minute to make sure libbacon is functional +# Run a healthcheck every minute to make sure ferrit is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 -CMD ["libbacon"] +CMD ["ferrit"] diff --git a/Dockerfile.arm b/Dockerfile.arm index 5432011..9ef1e6c 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -5,7 +5,7 @@ FROM rust:alpine AS builder RUN apk add --no-cache g++ -WORKDIR /usr/src/libbacon +WORKDIR /usr/src/ferrit COPY . . @@ -21,16 +21,16 @@ COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates COPY --from=builder /etc/ssl/certs /etc/ssl/certs # Copy our build -COPY --from=builder /usr/local/cargo/bin/libbacon /usr/local/bin/libbacon +COPY --from=builder /usr/local/cargo/bin/ferrit /usr/local/bin/ferrit # Use an unprivileged user. -RUN adduser --home /nonexistent --no-create-home --disabled-password libbacon -USER libbacon +RUN adduser --home /nonexistent --no-create-home --disabled-password ferrit +USER ferrit # Tell Docker to expose port 8080 EXPOSE 8080 -# Run a healthcheck every minute to make sure libbacon is functional +# Run a healthcheck every minute to make sure ferrit is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 -CMD ["libbacon"] +CMD ["ferrit"] diff --git a/Dockerfile.armv7 b/Dockerfile.armv7 index debaf54..1cfb123 100644 --- a/Dockerfile.armv7 +++ b/Dockerfile.armv7 @@ -12,7 +12,7 @@ RUN apt-get update && apt-get -y install gcc-arm-linux-gnueabihf \ RUN rustup target add armv7-unknown-linux-musleabihf -WORKDIR /libbacon +WORKDIR /ferrit COPY . . @@ -28,16 +28,16 @@ COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates COPY --from=builder /etc/ssl/certs /etc/ssl/certs # Copy our build -COPY --from=builder /libbacon/target/armv7-unknown-linux-musleabihf/release/libbacon /usr/local/bin/libbacon +COPY --from=builder /ferrit/target/armv7-unknown-linux-musleabihf/release/ferrit /usr/local/bin/ferrit # Use an unprivileged user. -RUN adduser --home /nonexistent --no-create-home --disabled-password libbacon -USER libbacon +RUN adduser --home /nonexistent --no-create-home --disabled-password ferrit +USER ferrit # Tell Docker to expose port 8080 EXPOSE 8080 -# Run a healthcheck every minute to make sure libbacon is functional +# Run a healthcheck every minute to make sure ferrit is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 -CMD ["libbacon"] +CMD ["ferrit"] diff --git a/README.md b/README.md index 3c288a0..64326ab 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# libbacon +# Ferrit -**libbacon** is a front-end for Reddit, written in [Rust](https://www.rust-lang.org/). It is a fork of the [Libreddit project](https://github.com/spikecodes/libreddit) started by [spikecodes](https://spike.codes). +**Ferrit** is a front-end for Reddit, written in [Rust](https://www.rust-lang.org/). It is a fork of the [Libreddit project](https://github.com/spikecodes/libreddit) started by [spikecodes](https://spike.codes). diff --git a/app.json b/app.json index de16e00..2384bfd 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,5 @@ { - "name": "libbacon", + "name": "Ferrit", "description": "Private front-end for Reddit", "buildpacks": [ { @@ -11,34 +11,34 @@ ], "stack": "container", "env": { - "LIBBACON_DEFAULT_THEME": { + "FERRIT_DEFAULT_THEME": { "required": false }, - "LIBBACON_DEFAULT_FRONT_PAGE": { + "FERRIT_DEFAULT_FRONT_PAGE": { "required": false }, - "LIBBACON_DEFAULT_LAYOUT": { + "FERRIT_DEFAULT_LAYOUT": { "required": false }, - "LIBBACON_DEFAULT_WIDE": { + "FERRIT_DEFAULT_WIDE": { "required": false }, - "LIBBACON_DEFAULT_COMMENT_SORT": { + "FERRIT_DEFAULT_COMMENT_SORT": { "required": false }, - "LIBBACON_DEFAULT_POST_SORT": { + "FERRIT_DEFAULT_POST_SORT": { "required": false }, - "LIBBACON_DEFAULT_SHOW_NSFW": { + "FERRIT_DEFAULT_SHOW_NSFW": { "required": false }, - "LIBBACON_DEFAULT_BLUR_NSFW": { + "FERRIT_DEFAULT_BLUR_NSFW": { "required": false }, - "LIBBACON_USE_HLS": { + "FERRIT_USE_HLS": { "required": false }, - "LIBBACON_HIDE_HLS_NOTIFICATION": { + "FERRIT_HIDE_HLS_NOTIFICATION": { "required": false } } diff --git a/contrib/libbacon.conf b/contrib/ferrit.conf similarity index 100% rename from contrib/libbacon.conf rename to contrib/ferrit.conf diff --git a/contrib/libbacon.service b/contrib/ferrit.service similarity index 85% rename from contrib/libbacon.service rename to contrib/ferrit.service index c118fff..d47ee80 100644 --- a/contrib/libbacon.service +++ b/contrib/ferrit.service @@ -1,5 +1,5 @@ [Unit] -Description=libbacon daemon +Description=Ferrit daemon After=network.service [Service] @@ -8,8 +8,8 @@ DynamicUser=yes Environment=ADDRESS=0.0.0.0 Environment=PORT=8080 # Optional Override -EnvironmentFile=-/etc/libbacon.conf -ExecStart=/usr/bin/libbacon -a ${ADDRESS} -p ${PORT} +EnvironmentFile=-/etc/ferrit.conf +ExecStart=/usr/bin/ferrit -a ${ADDRESS} -p ${PORT} # Hardening DeviceAllow= diff --git a/docker-compose.yml b/docker-compose.yml index 5f91d0a..0f4367c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: web: build: . restart: always - container_name: "libbacon" + container_name: "ferrit" ports: - 8080:8080 healthcheck: diff --git a/src/client.rs b/src/client.rs index 7f009f0..8d7e9e9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -73,7 +73,7 @@ fn request(url: String, quarantine: bool) -> Boxed, String let builder = Request::builder() .method("GET") .uri(&url) - .header("User-Agent", format!("web:libbacon:{}", env!("CARGO_PKG_VERSION"))) + .header("User-Agent", format!("web:ferrit:{}", env!("CARGO_PKG_VERSION"))) .header("Host", "www.reddit.com") .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") .header("Accept-Language", "en-US,en;q=0.5") diff --git a/src/main.rs b/src/main.rs index b925606..229d88f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,7 +105,7 @@ async fn style() -> Result, String> { #[tokio::main] async fn main() { - let matches = Command::new("libbacon") + let matches = Command::new("Ferrit") .version(env!("CARGO_PKG_VERSION")) .about("Private front-end for Reddit written in Rust ") .arg( @@ -150,7 +150,7 @@ async fn main() { let listener = [address, ":", &port].concat(); - println!("Starting libbacon..."); + println!("Starting Ferrit..."); // Begin constructing a server let mut app = server::Server::new(); @@ -189,7 +189,7 @@ async fn main() { .at("/hls.min.js") .get(|_| resource(include_str!("../static/hls.min.js"), "text/javascript", false).boxed()); - // Proxy media through libbacon + // Proxy media through Ferrit app.at("/vid/:id/:size").get(|r| proxy(r, "https://v.redd.it/{id}/DASH_{size}").boxed()); app.at("/hls/:id/*path").get(|r| proxy(r, "https://v.redd.it/{id}/{path}").boxed()); app.at("/img/*path").get(|r| proxy(r, "https://i.redd.it/{path}").boxed()); @@ -297,7 +297,7 @@ async fn main() { // Default service in case no routes match app.at("/*").get(|req| error(req, "Nothing here".to_string()).boxed()); - println!("Running libbacon v{} on {}!", env!("CARGO_PKG_VERSION"), listener); + println!("Running Ferrit v{} on {}!", env!("CARGO_PKG_VERSION"), listener); let server = app.listen(listener); diff --git a/src/post.rs b/src/post.rs index a0da095..5e68734 100644 --- a/src/post.rs +++ b/src/post.rs @@ -147,7 +147,7 @@ fn parse_comments(json: &serde_json::Value, post_link: &str, post_author: &str, let is_filtered = filters.contains(&["u_", author.name.as_str()].concat()); // Many subreddits have a default comment posted about the sub's rules etc. - // Many libbacon users do not wish to see this kind of comment by default. + // Many Ferrit users do not wish to see this kind of comment by default. // Reddit does not tell us which users are "bots", so a good heuristic is to // collapse stickied moderator comments. let is_moderator_comment = data["distinguished"].as_str().unwrap_or_default() == "moderator"; diff --git a/src/user.rs b/src/user.rs index 181c36a..2872984 100644 --- a/src/user.rs +++ b/src/user.rs @@ -42,7 +42,7 @@ pub async fn profile(req: Request) -> Result, String> { let url = String::from(req.uri().path_and_query().map_or("", |val| val.as_str())); let redirect_url = url[1..].replace('?', "%3F").replace('&', "%26"); - // Retrieve other variables from libbacon request + // Retrieve other variables from Ferrit request let sort = param(&path, "sort").unwrap_or_default(); let username = req.param("name").unwrap_or_default(); diff --git a/src/utils.rs b/src/utils.rs index 2c7e010..642cd74 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -665,7 +665,7 @@ pub fn setting(req: &Request, name: &str) -> String { .cookie(name) .unwrap_or_else(|| { // If there is no cookie for this setting, try receiving a default from an environment variable - if let Ok(default) = std::env::var(format!("LIBBACON_DEFAULT_{}", name.to_uppercase())) { + if let Ok(default) = std::env::var(format!("FERRIT_DEFAULT_{}", name.to_uppercase())) { Cookie::new(name, default) } else { Cookie::named(name) @@ -750,7 +750,7 @@ pub fn format_url(url: &str) -> String { } } -// Rewrite Reddit links to libbacon in body of text +// Rewrite Reddit links to Ferrit in body of text pub fn rewrite_urls(input_text: &str) -> String { let text1 = Regex::new(r#"href="(https|http|)://(www\.|old\.|np\.|amp\.|)(reddit\.com|redd\.it)/"#) .map_or(String::new(), |re| re.replace_all(input_text, r#"href="/"#).to_string()) @@ -758,7 +758,7 @@ pub fn rewrite_urls(input_text: &str) -> String { .replace("%5C", "") .replace('\\', ""); - // Rewrite external media previews to libbacon + // Rewrite external media previews to Ferrit Regex::new(r"https://external-preview\.redd\.it(.*)[^?]").map_or(String::new(), |re| { if re.is_match(&text1) { re.replace_all(&text1, format_url(re.find(&text1).map(|x| x.as_str()).unwrap_or_default())).to_string() diff --git a/static/manifest.json b/static/manifest.json index f0a2db6..b185b41 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -1,6 +1,6 @@ { - "name": "libbacon", - "short_name": "libbacon", + "name": "Ferrit", + "short_name": "Ferrit", "display": "standalone", "background_color": "#1f1f1f", "description": "An alternative private front-end to Reddit", diff --git a/static/style.css b/static/style.css index 0d26302..356dec4 100644 --- a/static/style.css +++ b/static/style.css @@ -94,7 +94,7 @@ nav { } nav * { color: var(--text); } -nav #bacon, #code > span { color: var(--accent); } +nav #ferrit_logo_p2, #code > span { color: var(--accent); } nav #code > svg { stroke: var(--accent); } nav #logo { @@ -119,7 +119,7 @@ nav #version { margin-right: 10px; } -nav #libbacon { +nav #ferrit_logo { vertical-align: -2px; } diff --git a/templates/base.html b/templates/base.html index 3b59f8b..40acb35 100644 --- a/templates/base.html +++ b/templates/base.html @@ -2,14 +2,14 @@ {% block head %} - {% block title %}libbacon{% endblock %} + {% block title %}Ferrit{% endblock %} - + - + @@ -29,7 +29,7 @@