20 Commits

Author SHA1 Message Date
2d859ce0a8 fix(deps): update rust crate bincode to v2
Some checks failed
renovate/artifacts Artifact file update failure
2025-05-13 02:01:43 +00:00
ngn
d7b258c8e7 ups: update to c715480 2025-05-12 23:00:56 +03:00
ngn
06035326e3 add the ups configuration
Signed-off-by: ngn <ngn@ngn.tf>
2025-05-12 22:42:29 +03:00
Gavin Mogan
33c29ea1af update get_post_light to return none when no data is found, so not found error can happen 2025-05-12 22:37:58 +03:00
ngn
beda276909 add the ups workflow
Signed-off-by: ngn <ngn@ngn.tf>
2025-05-12 22:07:12 +03:00
ngn
660f95b8a5 Merge pull request 'fix(deps): update rust crate actix-rt to v2.10.0' (#9) from renovate/actix-rt-2.x-lockfile into custom
All checks were successful
Build and publish the docker image / build (push) Successful in 4m35s
Reviewed-on: #9
2025-02-12 19:50:28 +03:00
ngn
22068e46d5 Merge branch 'custom' into renovate/actix-rt-2.x-lockfile 2025-02-12 19:50:18 +03:00
ngn
4f9a4a3f47 Merge pull request 'fix(deps): update rust crate actix-http to v3.9.0' (#8) from renovate/actix-http-3.x-lockfile into custom
All checks were successful
Build and publish the docker image / build (push) Successful in 3m32s
Reviewed-on: #8
2025-01-21 09:09:39 +03:00
ngn
a77526cfb3 Merge branch 'custom' into renovate/actix-http-3.x-lockfile 2025-01-21 09:09:29 +03:00
ngn
552abfe6d8 Merge pull request 'fix(deps): update rust crate serde_json to v1.0.137' (#6) from renovate/serde_json-1.x-lockfile into custom
All checks were successful
Build and publish the docker image / build (push) Successful in 4m3s
Reviewed-on: #6
2025-01-21 05:52:03 +03:00
ngn
79a76f850a Merge branch 'custom' into renovate/serde_json-1.x-lockfile 2025-01-21 05:51:56 +03:00
ngn
4fd5b9ca6a Merge pull request 'fix(deps): update rust crate log to v0.4.25' (#16) from renovate/log-0.x-lockfile into custom
All checks were successful
Build and publish the docker image / build (push) Successful in 3m27s
Reviewed-on: #16
2025-01-21 01:41:37 +03:00
ngn
729223f262 Merge branch 'custom' into renovate/log-0.x-lockfile 2025-01-21 01:41:27 +03:00
ngn
f76e30020a Merge pull request 'fix(deps): update rust crate url to v2.5.4' (#7) from renovate/url-2.x-lockfile into custom
All checks were successful
Build and publish the docker image / build (push) Successful in 3m25s
Reviewed-on: #7
2025-01-21 01:36:42 +03:00
ngn
4fd1493c02 Merge branch 'custom' into renovate/url-2.x-lockfile 2025-01-21 01:36:33 +03:00
ngn
85cef58653 revert sailfish update
All checks were successful
Build and publish the docker image / build (push) Successful in 3m29s
Signed-off-by: ngn <ngn@ngn.tf>
2025-01-21 01:32:06 +03:00
bf64021798 fix(deps): update rust crate log to v0.4.25 2025-01-20 20:01:11 +00:00
98f1461706 fix(deps): update rust crate actix-rt to v2.10.0 2025-01-20 03:02:07 +00:00
1f36575f1f fix(deps): update rust crate actix-http to v3.9.0 2025-01-20 03:02:01 +00:00
9301d2bccd fix(deps): update rust crate serde_json to v1.0.137 2025-01-20 03:01:49 +00:00
8 changed files with 92 additions and 43 deletions

View File

@@ -1,28 +1,34 @@
name: Build and publish the docker image
name: docker
on:
push:
branches: ["custom"]
branches:
- "main"
paths-ignore:
- "README.md"
- "LICENSE.txt"
- "docker-compose.example.yml"
- "ups.json"
env:
REGISTRY: git.ngn.tf
IMAGE: ${{gitea.repository}}
jobs:
build:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: "https://github.com/actions/checkout@v4"
uses: actions/checkout@v4
- name: Login to container repo
uses: "https://github.com/docker/login-action@v1"
uses: docker/login-action@v1
with:
registry: ${{env.REGISTRY}}
username: ${{gitea.actor}}
password: ${{secrets.PACKAGES_TOKEN}}
- name: Build image
- name: Build docker image
run: |
docker build . --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest
docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest

25
.gitea/workflows/ups.yml Normal file
View File

@@ -0,0 +1,25 @@
name: ups
on:
schedule:
- cron: "@weekly"
jobs:
ups:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update -y
sudo apt install -y python3 python3-build python3-requests make
- name: Install ups
run: |
git clone https://git.ngn.tf/ngn/ups && cd ups
make && make install
- name: Run ups
run: PATH=~/.local/bin:$PATH ups-check

17
Cargo.lock generated
View File

@@ -44,9 +44,9 @@ dependencies = [
[[package]]
name = "actix-http"
version = "3.7.0"
version = "3.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb9843d84c775696c37d9a418bbb01b932629d01870722c0f13eb3f95e2536d"
checksum = "d48f96fc3003717aeb9856ca3d02a8c7de502667ad76eeacd830b48d2e91fac4"
dependencies = [
"actix-codec",
"actix-rt",
@@ -108,9 +108,9 @@ dependencies = [
[[package]]
name = "actix-rt"
version = "2.9.0"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d"
checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208"
dependencies = [
"actix-macros",
"futures-core",
@@ -1399,9 +1399,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.21"
version = "0.4.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
[[package]]
name = "memchr"
@@ -2096,11 +2096,12 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.117"
version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]

View File

@@ -15,7 +15,7 @@ actix-http = "3.0.4"
actix-rt = "2"
actix-web = "4.0.1"
actix-files = "0.6.6"
bincode = "1.3.3"
bincode = "2.0.0"
chrono = "0.4.23"
config = "0.13"
derive_more = "0.99"
@@ -24,7 +24,7 @@ lazy_static = "1.4"
log = "0.4"
num_cpus = "1.13"
pretty_env_logger = "0.5"
sailfish = "0.9.0"
sailfish = "0.8.1"
serde = "1"
serde_json = "1"
sled = "0.34.7"

View File

@@ -1,5 +1,7 @@
# [ngn.tf] | libmedium
# libmedium - proxy for medium.com
![](https://git.ngn.tf/ngn/libmedium/actions/workflows/build.yml/badge.svg)
![](https://git.ngn.tf/ngn/libmedium/actions/workflows/docker.yml/badge.svg)
![](https://git.ngn.tf/ngn/libmedium/actions/workflows/ups.yml/badge.svg)
A fork of the [libmedium](https://github.com/realaravinth/libmedium) project, with my personal changes.
A fork of the [libmedium](https://github.com/realaravinth/libmedium) project,
with my personal changes.

View File

@@ -164,14 +164,14 @@ impl Data {
}
}
pub async fn get_post_light(&self, id: &str) -> PostUrl {
pub async fn get_post_light(&self, id: &str) -> Option<PostUrl> {
match self.posts.get(id) {
Ok(Some(v)) => {
let cached: PostResp = bincode::deserialize(&v[..]).unwrap();
PostUrl {
Some(PostUrl {
slug: cached.unique_slug,
username: cached.creator.username,
}
})
}
_ => {
let vars = get_post_light::Variables { id: id.to_owned() };
@@ -180,10 +180,16 @@ impl Data {
let res = post_graphql::<GetPostLight, _>(&self.client, URL, vars)
.await
.unwrap();
let res = res.data.expect("missing response data").post.unwrap();
PostUrl {
slug: res.unique_slug,
username: res.creator.username,
if res.data.is_none() {
None
} else {
match res.data.expect("missing response data").post {
None => None,
Some(res) => Some(PostUrl {
slug: res.unique_slug,
username: res.creator.username,
}),
}
}
}
}

View File

@@ -158,29 +158,33 @@ async fn assets(path: web::Path<String>, data: AppData) -> impl Responder {
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.by_post_id")]
async fn by_post_id(path: web::Path<String>, data: AppData) -> impl Responder {
let post_data = data.get_post_light(&path).await;
HttpResponse::Found()
.append_header((
header::LOCATION,
crate::V1_API_ROUTES
.proxy
.get_page(&post_data.username, &post_data.slug),
))
.finish()
}
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.top_level_post")]
async fn by_top_level_post(path: web::Path<String>, data: AppData) -> impl Responder {
if let Some(post_id) = path.split('-').last() {
let post_data = data.get_post_light(post_id).await;
HttpResponse::Found()
match data.get_post_light(&path).await {
None => HttpResponse::NotFound().body("Post not found"),
Some(post_data) => HttpResponse::Found()
.append_header((
header::LOCATION,
crate::V1_API_ROUTES
.proxy
.get_page(&post_data.username, &post_data.slug),
))
.finish()
.finish(),
}
}
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.top_level_post")]
async fn by_top_level_post(path: web::Path<String>, data: AppData) -> impl Responder {
if let Some(post_id) = path.split('-').last() {
match data.get_post_light(post_id).await {
None => HttpResponse::NotFound().body("Post not found"),
Some(post_data) => HttpResponse::Found()
.append_header((
header::LOCATION,
crate::V1_API_ROUTES
.proxy
.get_page(&post_data.username, &post_data.slug),
))
.finish(),
}
} else {
HttpResponse::NotFound().body("Post not found, please file bug report")
}

5
ups.json Normal file
View File

@@ -0,0 +1,5 @@
{
"upstream": "https://git.batsense.net/realaravinth/libmedium",
"provider": "gitea",
"commit": "c7154807884e1bb8228a7682c5a3dee9becf5ac4"
}