Init repo

This commit is contained in:
clerie 2024-11-29 20:51:17 +01:00
commit 3f0b99c5df
6 changed files with 1728 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
result*

1615
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "rainbowrss"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.93"
reqwest = { version = "0.12.9", features = ["blocking"] }
rss = "2.0.11"

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1732521221,
"narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

37
flake.nix Normal file
View File

@ -0,0 +1,37 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }: {
packages.x86_64-linux = let
pkgs = import nixpkgs {
system = "x86_64-linux";
};
in {
rainbowrss = pkgs.rustPlatform.buildRustPackage rec {
pname = "rainbowrss";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [
pkgs.pkg-config
];
buildInputs = [
pkgs.openssl
];
cargoLock.lockFile = ./Cargo.lock;
};
default = self.packages.x86_64-linux.rainbowrss;
};
hydraJobs = {
inherit (self)
packages;
};
};
}

38
src/main.rs Normal file
View File

@ -0,0 +1,38 @@
use anyhow::{
Context,
Result,
};
use rss::Channel;
fn fetch_feed() -> Result<Channel> {
let content = reqwest::blocking::get("https://feed.zugfunk-podcast.de/")?.bytes()?;
let channel = Channel::read_from(&content[..])?;
Ok(channel)
}
fn main() -> Result<()> {
let feed = fetch_feed()?;
let mut out = String::new();
out.push_str("<!DOCTYPE html>\n");
out.push_str("<html>\n");
out.push_str("<head>\n");
out.push_str("</head>\n");
out.push_str("<body>\n");
out.push_str("<ul>\n");
for item in feed.items {
out.push_str(&format!("<li><a href=\"{}\">{}</a></li>\n", item.link.context("No link found")?, item.title.context("No title found")?));
}
out.push_str("</ul>\n");
out.push_str("</body>\n");
out.push_str("</html>\n");
std::fs::write("index.html", out)?;
Ok(())
}