diff --git a/.github/ISSUE_TEMPLATE/feature_parity.md b/.github/ISSUE_TEMPLATE/feature_parity.md index 22b9bd8..a97ac7e 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 Libreddit that is found in Reddit.com +about: Suggest implementing a feature into libbacon 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 Libreddit +## Describe how this could be implemented into libbacon diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index e9e6d31..e4841ce 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 Libreddit that is not found in Reddit +about: Suggest a feature for libbacon that is not found in Reddit title: '💡 Feature request: ' labels: enhancement assignees: '' diff --git a/.github/workflows/docker-arm.yml b/.github/workflows/docker-arm.yml index 6e34e79..f83e7ff 100644 --- a/.github/workflows/docker-arm.yml +++ b/.github/workflows/docker-arm.yml @@ -33,6 +33,6 @@ jobs: file: ./Dockerfile.arm platforms: linux/arm64 push: true - tags: spikecodes/libreddit:arm + tags: libbacon/libbacon:arm cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-armv7.yml b/.github/workflows/docker-armv7.yml index 7c51db2..1364aa3 100644 --- a/.github/workflows/docker-armv7.yml +++ b/.github/workflows/docker-armv7.yml @@ -36,6 +36,6 @@ jobs: file: ./Dockerfile.armv7 platforms: linux/arm/v7 push: true - tags: spikecodes/libreddit:armv7 + tags: libbacon/libbacon:armv7 cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ed1bf73..d9171d0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,6 +33,6 @@ jobs: file: ./Dockerfile platforms: linux/amd64 push: true - tags: spikecodes/libreddit:latest + tags: libbacon/libbacon:latest cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c233140..13ce57f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -30,8 +30,8 @@ jobs: - uses: actions/upload-artifact@v2.2.1 name: Upload a Build Artifact with: - name: libreddit - path: target/release/libreddit + name: libbacon + path: target/release/libbacon - name: Versions id: version @@ -40,7 +40,7 @@ jobs: echo "::set-output name=tag::$(git describe --tags)" - name: Calculate SHA512 checksum - run: sha512sum target/release/libreddit > libreddit.sha512 + run: sha512sum target/release/libbacon > libbacon.sha512 - name: Release uses: softprops/action-gh-release@v1 @@ -50,8 +50,8 @@ jobs: name: ${{ steps.version.outputs.version }} - ${{ github.event.head_commit.message }} draft: true files: | - target/release/libreddit - libreddit.sha512 + target/release/libbacon + libbacon.sha512 body: | - ${{ github.event.head_commit.message }} ${{ github.sha }} generate_release_notes: true diff --git a/.replit b/.replit index d365864..3c96b9d 100644 --- a/.replit +++ b/.replit @@ -1,2 +1,2 @@ -run = "while true; do wget -O libreddit https://github.com/spikecodes/libreddit/releases/latest/download/libreddit;chmod +x libreddit;./libreddit -H 63115200;sleep 1;done" -language = "bash" \ No newline at end of file +run = "while true; do wget -O libbacon https://github.com/libbacon/libbacon/releases/latest/download/libbacon;chmod +x libbacon;./libbacon -H 63115200;sleep 1;done" +language = "bash" diff --git a/Cargo.lock b/Cargo.lock index 2c5da4d..e99e4eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -579,14 +579,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "libreddit" -version = "0.22.9" +name = "libbacon" +version = "0.1.0" dependencies = [ "askama", "async-recursion", @@ -607,6 +601,12 @@ dependencies = [ "url", ] +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + [[package]] name = "lock_api" version = "0.4.7" diff --git a/Cargo.toml b/Cargo.toml index 484962c..c7d46d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "libreddit" +name = "libbacon" description = " Alternative private front-end to Reddit" license = "AGPL-3.0" -repository = "https://github.com/spikecodes/libreddit" -version = "0.22.9" -authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"] +repository = "https://github.com/libbacon/libbacon" +version = "0.1.0" +authors = ["Daniel Valentine "] edition = "2021" [dependencies] diff --git a/Dockerfile b/Dockerfile index 0820de4..ce4e076 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM rust:alpine AS builder RUN apk add --no-cache musl-dev -WORKDIR /libreddit +WORKDIR /libbacon 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 /libreddit/target/x86_64-unknown-linux-musl/release/libreddit /usr/local/bin/libreddit +COPY --from=builder /libbacon/target/x86_64-unknown-linux-musl/release/libbacon /usr/local/bin/libbacon # Use an unprivileged user. -RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit -USER libreddit +RUN adduser --home /nonexistent --no-create-home --disabled-password libbacon +USER libbacon # Tell Docker to expose port 8080 EXPOSE 8080 -# Run a healthcheck every minute to make sure Libreddit is functional +# Run a healthcheck every minute to make sure libbacon is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 -CMD ["libreddit"] \ No newline at end of file +CMD ["libbacon"] diff --git a/Dockerfile.arm b/Dockerfile.arm index 93703d0..5432011 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/libreddit +WORKDIR /usr/src/libbacon 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/libreddit /usr/local/bin/libreddit +COPY --from=builder /usr/local/cargo/bin/libbacon /usr/local/bin/libbacon # Use an unprivileged user. -RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit -USER libreddit +RUN adduser --home /nonexistent --no-create-home --disabled-password libbacon +USER libbacon # Tell Docker to expose port 8080 EXPOSE 8080 -# Run a healthcheck every minute to make sure Libreddit is functional +# Run a healthcheck every minute to make sure libbacon is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 -CMD ["libreddit"] +CMD ["libbacon"] diff --git a/Dockerfile.armv7 b/Dockerfile.armv7 index d28141c..debaf54 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 /libreddit +WORKDIR /libbacon 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 /libreddit/target/armv7-unknown-linux-musleabihf/release/libreddit /usr/local/bin/libreddit +COPY --from=builder /libbacon/target/armv7-unknown-linux-musleabihf/release/libbacon /usr/local/bin/libbacon # Use an unprivileged user. -RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit -USER libreddit +RUN adduser --home /nonexistent --no-create-home --disabled-password libbacon +USER libbacon # Tell Docker to expose port 8080 EXPOSE 8080 -# Run a healthcheck every minute to make sure Libreddit is functional +# Run a healthcheck every minute to make sure libbacon is functional HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 -CMD ["libreddit"] +CMD ["libbacon"] diff --git a/app.json b/app.json index 8573671..3e84f0b 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,5 @@ { - "name": "Libreddit", + "name": "libbacon", "description": "Private front-end for Reddit", "buildpacks": [ { @@ -11,31 +11,31 @@ ], "stack": "container", "env": { - "LIBREDDIT_DEFAULT_THEME": { + "LIBBACON_DEFAULT_THEME": { "required": false }, - "LIBREDDIT_DEFAULT_FRONT_PAGE": { + "LIBBACON_DEFAULT_FRONT_PAGE": { "required": false }, - "LIBREDDIT_DEFAULT_LAYOUT": { + "LIBBACON_DEFAULT_LAYOUT": { "required": false }, - "LIBREDDIT_DEFAULT_WIDE": { + "LIBBACON_DEFAULT_WIDE": { "required": false }, - "LIBREDDIT_DEFAULT_COMMENT_SORT": { + "LIBBACON_DEFAULT_COMMENT_SORT": { "required": false }, - "LIBREDDIT_DEFAULT_POST_SORT": { + "LIBBACON_DEFAULT_POST_SORT": { "required": false }, - "LIBREDDIT_DEFAULT_SHOW_NSFW": { + "LIBBACON_DEFAULT_SHOW_NSFW": { "required": false }, - "LIBREDDIT_USE_HLS": { + "LIBBACON_USE_HLS": { "required": false }, - "LIBREDDIT_HIDE_HLS_NOTIFICATION": { + "LIBBACON_HIDE_HLS_NOTIFICATION": { "required": false } } diff --git a/contrib/libreddit.conf b/contrib/libbacon.conf similarity index 100% rename from contrib/libreddit.conf rename to contrib/libbacon.conf diff --git a/contrib/libreddit.service b/contrib/libbacon.service similarity index 84% rename from contrib/libreddit.service rename to contrib/libbacon.service index 8ed5da7..c118fff 100644 --- a/contrib/libreddit.service +++ b/contrib/libbacon.service @@ -1,5 +1,5 @@ [Unit] -Description=libreddit daemon +Description=libbacon daemon After=network.service [Service] @@ -8,8 +8,8 @@ DynamicUser=yes Environment=ADDRESS=0.0.0.0 Environment=PORT=8080 # Optional Override -EnvironmentFile=-/etc/libreddit.conf -ExecStart=/usr/bin/libreddit -a ${ADDRESS} -p ${PORT} +EnvironmentFile=-/etc/libbacon.conf +ExecStart=/usr/bin/libbacon -a ${ADDRESS} -p ${PORT} # Hardening DeviceAllow= diff --git a/docker-compose.yml b/docker-compose.yml index 2688e9d..5f91d0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: web: build: . restart: always - container_name: "libreddit" + container_name: "libbacon" ports: - 8080:8080 healthcheck: diff --git a/src/client.rs b/src/client.rs index da271dd..2f6f82d 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:libreddit:{}", env!("CARGO_PKG_VERSION"))) + .header("User-Agent", format!("web:libbacon:{}", 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 b6f7889..78d0c62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,7 +104,7 @@ async fn style() -> Result, String> { #[tokio::main] async fn main() { - let matches = Command::new("Libreddit") + let matches = Command::new("libbacon") .version(env!("CARGO_PKG_VERSION")) .about("Private front-end for Reddit written in Rust ") .arg( @@ -149,7 +149,7 @@ async fn main() { let listener = [address, ":", &port].concat(); - println!("Starting Libreddit..."); + println!("Starting libbacon..."); // Begin constructing a server let mut app = server::Server::new(); @@ -188,7 +188,7 @@ async fn main() { .at("/hls.min.js") .get(|_| resource(include_str!("../static/hls.min.js"), "text/javascript", false).boxed()); - // Proxy media through Libreddit + // Proxy media through libbacon 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()); @@ -286,7 +286,7 @@ async fn main() { // Default service in case no routes match app.at("/*").get(|req| error(req, "Nothing here".to_string()).boxed()); - println!("Running Libreddit v{} on {}!", env!("CARGO_PKG_VERSION"), listener); + println!("Running libbacon v{} on {}!", env!("CARGO_PKG_VERSION"), listener); let server = app.listen(listener); diff --git a/src/post.rs b/src/post.rs index 02ca380..5562d47 100644 --- a/src/post.rs +++ b/src/post.rs @@ -226,7 +226,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 libreddit users do not wish to see this kind of comment by default. + // Many libbacon 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 69c4ae9..50a2200 100644 --- a/src/user.rs +++ b/src/user.rs @@ -40,7 +40,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 Libreddit request + // Retrieve other variables from libbacon request let sort = param(&path, "sort").unwrap_or_default(); let username = req.param("name").unwrap_or_default(); let user = user(&username).await.unwrap_or_default(); diff --git a/src/utils.rs b/src/utils.rs index 2691d16..4f46af5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -530,7 +530,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!("LIBREDDIT_DEFAULT_{}", name.to_uppercase())) { + if let Ok(default) = std::env::var(format!("LIBBACON_DEFAULT_{}", name.to_uppercase())) { Cookie::new(name, default) } else { Cookie::named(name) @@ -615,7 +615,7 @@ pub fn format_url(url: &str) -> String { } } -// Rewrite Reddit links to Libreddit in body of text +// Rewrite Reddit links to libbacon 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()) @@ -623,7 +623,7 @@ pub fn rewrite_urls(input_text: &str) -> String { .replace("%5C", "") .replace('\\', ""); - // Rewrite external media previews to Libreddit + // Rewrite external media previews to libbacon 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 cf5d31b..f0a2db6 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -1,6 +1,6 @@ { - "name": "Libreddit", - "short_name": "Libreddit", + "name": "libbacon", + "short_name": "libbacon", "display": "standalone", "background_color": "#1f1f1f", "description": "An alternative private front-end to Reddit", @@ -20,4 +20,4 @@ "sizes": "32x32" } ] -} \ No newline at end of file +} diff --git a/static/style.css b/static/style.css index 3e0d64d..2504218 100644 --- a/static/style.css +++ b/static/style.css @@ -94,7 +94,7 @@ nav { } nav * { color: var(--text); } -nav #reddit, #code > span { color: var(--accent); } +nav #bacon, #code > span { color: var(--accent); } nav #code > svg { stroke: var(--accent); } nav #logo { @@ -119,7 +119,7 @@ nav #version { margin-right: 10px; } -nav #libreddit { +nav #libbacon { vertical-align: -2px; } diff --git a/templates/base.html b/templates/base.html index f30aaaf..f77c420 100644 --- a/templates/base.html +++ b/templates/base.html @@ -2,14 +2,14 @@ {% block head %} - {% block title %}Libreddit{% endblock %} + {% block title %}libbacon{% endblock %} - + - + @@ -29,7 +29,7 @@