Compare commits
20 Commits
6e4ac477dc
...
renovate/b
Author | SHA1 | Date | |
---|---|---|---|
2d859ce0a8 | |||
d7b258c8e7
|
|||
06035326e3
|
|||
![]() |
33c29ea1af
|
||
beda276909
|
|||
660f95b8a5 | |||
22068e46d5 | |||
4f9a4a3f47 | |||
a77526cfb3 | |||
552abfe6d8 | |||
79a76f850a | |||
4fd5b9ca6a | |||
729223f262 | |||
f76e30020a | |||
4fd1493c02 | |||
85cef58653
|
|||
bf64021798 | |||
98f1461706 | |||
1f36575f1f | |||
9301d2bccd |
@@ -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
25
.gitea/workflows/ups.yml
Normal 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
17
Cargo.lock
generated
@@ -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",
|
||||
]
|
||||
|
@@ -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"
|
||||
|
@@ -1,5 +1,7 @@
|
||||
# [ngn.tf] | libmedium
|
||||
# libmedium - proxy for medium.com
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
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.
|
||||
|
20
src/data.rs
20
src/data.rs
@@ -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,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
src/proxy.rs
38
src/proxy.rs
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user