Rename project to Ferrit.

This commit is contained in:
Daniel Valentine 2022-10-09 14:31:16 -06:00
parent a19f46ad18
commit be3a4013db
28 changed files with 93 additions and 93 deletions

View File

@ -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
<!--
A clear and concise description of what you want to happen.
-->

View File

@ -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: ''

View File

@ -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"

46
Cargo.lock generated
View File

@ -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"

View File

@ -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 <Daniel-Valentine@users.noreply.github.com>", "spikecodes <19519553+spikecodes@users.noreply.github.com>"]
edition = "2021"

View File

@ -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"]

View File

@ -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"]

View File

@ -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"]

View File

@ -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).

View File

@ -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
}
}

View File

@ -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=

View File

@ -4,7 +4,7 @@ services:
web:
build: .
restart: always
container_name: "libbacon"
container_name: "ferrit"
ports:
- 8080:8080
healthcheck:

View File

@ -73,7 +73,7 @@ fn request(url: String, quarantine: bool) -> Boxed<Result<Response<Body>, 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")

View File

@ -105,7 +105,7 @@ async fn style() -> Result<Response<Body>, 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);

View File

@ -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";

View File

@ -42,7 +42,7 @@ pub async fn profile(req: Request<Body>) -> Result<Response<Body>, 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();

View File

@ -665,7 +665,7 @@ pub fn setting(req: &Request<Body>, 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()

View File

@ -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",

View File

@ -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;
}

View File

@ -2,14 +2,14 @@
<html lang="en">
<head>
{% block head %}
<title>{% block title %}libbacon{% endblock %}</title>
<title>{% block title %}Ferrit{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="View on libbacon, an alternative private front-end to Reddit.">
<meta name="description" content="View on Ferrit, an alternative private front-end to Reddit.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- General PWA -->
<meta name="theme-color" content="#1F1F1F">
<!-- iOS Application -->
<meta name="apple-mobile-web-app-title" content="libbacon">
<meta name="apple-mobile-web-app-title" content="Ferrit">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<!-- Android -->
@ -29,7 +29,7 @@
<!-- NAVIGATION BAR -->
<nav>
<div id="logo">
<a id="libbacon" href="/"><span id="lib">lib</span><span id="bacon">bacon.</span></a>
<a id="ferrit_logo" href="/"><span id="ferrit_logo_p1">ferr</span><span id="ferrit_logo_p2">it.</span></a>
<span id="version">v{{ env!("CARGO_PKG_VERSION") }}</span>
{% block subscriptions %}{% endblock %}
</div>
@ -52,7 +52,7 @@
<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
</svg>
</a>
<a id="code" href="https://github.com/libbacon/libbacon">
<a id="code" href="https://github.com/libbacon/ferrit">
<span>code</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<title>code</title>

View File

@ -16,12 +16,12 @@
<meta property="og:type" content="website">
<meta property="og:url" content="{{ post.permalink }}">
<meta property="og:title" content="{{ post.title }} - r/{{ post.community }}">
<meta property="og:description" content="View on libbacon, an alternative private front-end to Reddit.">
<meta property="og:description" content="View on Ferrit, an alternative private front-end to Reddit.">
<meta property="og:image" content="{{ post.thumbnail.url }}">
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="{{ post.permalink }}">
<meta property="twitter:title" content="{{ post.title }} - r/{{ post.community }}">
<meta property="twitter:description" content="View on libbacon, an alternative private front-end to Reddit.">
<meta property="twitter:description" content="View on Ferrit, an alternative private front-end to Reddit.">
<meta property="twitter:image" content="{{ post.thumbnail.url }}">
{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% import "utils.html" as utils %}
{% block title %}libbacon: search results - {{ params.q }}{% endblock %}
{% block title %}Ferrit: search results - {{ params.q }}{% endblock %}
{% block subscriptions %}
{% call utils::sub_list("") %}
@ -10,7 +10,7 @@
{% block content %}
<div id="column_one">
<form id="search_sort">
<input id="search" type="text" name="q" placeholder="Search" value="{{ params.q }}" title="Search libbacon">
<input id="search" type="text" name="q" placeholder="Search" value="{{ params.q }}" title="Search Ferrit">
{% if sub != "" %}
<div id="inside">
<input type="checkbox" name="restrict_sr" id="restrict_sr" {% if params.restrict_sr != "" %}checked{% endif %}>

View File

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% import "utils.html" as utils %}
{% block title %}libbacon Settings{% endblock %}
{% block title %}Ferrit Settings{% endblock %}
{% block search %}
{% call utils::search("".to_owned(), "", "") %}
@ -68,7 +68,7 @@
<label for="use_hls">Use HLS for videos
<details id="feeds">
<summary>Why?</summary>
<div id="feed_list" class="helper">Reddit videos require JavaScript (via HLS.js) to be enabled to be played with audio. Therefore, this toggle lets you either use libbacon JS-free or utilize this feature.</div>
<div id="feed_list" class="helper">Reddit videos require JavaScript (via HLS.js) to be enabled to be played with audio. Therefore, this toggle lets you either use Ferrit JS-free or utilize this feature.</div>
</details>
</label>
<input type="hidden" value="off" name="use_hls">

View File

@ -4,7 +4,7 @@
{% block title %}
{% if sub.title != "" %}{{ sub.title }}
{% else if sub.name != "" %}{{ sub.name }}
{% else %}libbacon{% endif %}
{% else %}Ferrit{% endif %}
{% endblock %}
{% block search %}

View File

@ -5,7 +5,7 @@
{% call utils::search("".to_owned(), "", "") %}
{% endblock %}
{% block title %}{{ user.name.replace("u/", "") }} (u/{{ user.name }}) - libbacon{% endblock %}
{% block title %}{{ user.name.replace("u/", "") }} (u/{{ user.name }}) - Ferrit{% endblock %}
{% block subscriptions %}
{% call utils::sub_list("") %}

View File

@ -16,7 +16,7 @@
{% macro search(root, search) -%}
<form action="{% if root != "/r/" && !root.is_empty() %}{{ root }}{% endif %}/search" id="searchbox">
<input id="search" type="text" name="q" placeholder="Search" title="Search libbacon" value="{{ search }}">
<input id="search" type="text" name="q" placeholder="Search" title="Search Ferrit" value="{{ search }}">
{% if root != "/r/" && !root.is_empty() %}
<div id="inside">
<input type="checkbox" name="restrict_sr" id="restrict_sr" checked>

View File

@ -3,7 +3,7 @@
{% block title %}
{% if sub != "" %}{{ page }} - {{ sub }}
{% else %}libbacon{% endif %}
{% else %}Ferrit{% endif %}
{% endblock %}
{% block search %}