Compare commits
No commits in common. "06035326e3177624b349b13b0dea4dc9e278a419" and "660f95b8a55bc99072cb2c97e95ac98e1ec10b8c" have entirely different histories.
06035326e3
...
660f95b8a5
@ -1,34 +1,28 @@
|
|||||||
name: docker
|
name: Build and publish the docker image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: ["custom"]
|
||||||
- "main"
|
|
||||||
paths-ignore:
|
|
||||||
- "README.md"
|
|
||||||
- "LICENSE.txt"
|
|
||||||
- "docker-compose.example.yml"
|
|
||||||
- "ups.json"
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.ngn.tf
|
REGISTRY: git.ngn.tf
|
||||||
IMAGE: ${{gitea.repository}}
|
IMAGE: ${{gitea.repository}}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: "https://github.com/actions/checkout@v4"
|
||||||
|
|
||||||
- name: Login to container repo
|
- name: Login to container repo
|
||||||
uses: docker/login-action@v1
|
uses: "https://github.com/docker/login-action@v1"
|
||||||
with:
|
with:
|
||||||
registry: ${{env.REGISTRY}}
|
registry: ${{env.REGISTRY}}
|
||||||
username: ${{gitea.actor}}
|
username: ${{gitea.actor}}
|
||||||
password: ${{secrets.PACKAGES_TOKEN}}
|
password: ${{secrets.PACKAGES_TOKEN}}
|
||||||
|
|
||||||
- name: Build docker image
|
- name: Build image
|
||||||
run: |
|
run: |
|
||||||
docker build . --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest
|
docker build . --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest
|
||||||
docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest
|
docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest
|
@ -1,25 +0,0 @@
|
|||||||
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
|
|
@ -1,7 +1,5 @@
|
|||||||
# libmedium - proxy for medium.com
|
# [ngn.tf] | libmedium
|
||||||
|
|
||||||

|

|
||||||

|
|
||||||
|
|
||||||
A fork of the [libmedium](https://github.com/realaravinth/libmedium) project,
|
A fork of the [libmedium](https://github.com/realaravinth/libmedium) project, with my personal changes.
|
||||||
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) -> Option<PostUrl> {
|
pub async fn get_post_light(&self, id: &str) -> PostUrl {
|
||||||
match self.posts.get(id) {
|
match self.posts.get(id) {
|
||||||
Ok(Some(v)) => {
|
Ok(Some(v)) => {
|
||||||
let cached: PostResp = bincode::deserialize(&v[..]).unwrap();
|
let cached: PostResp = bincode::deserialize(&v[..]).unwrap();
|
||||||
Some(PostUrl {
|
PostUrl {
|
||||||
slug: cached.unique_slug,
|
slug: cached.unique_slug,
|
||||||
username: cached.creator.username,
|
username: cached.creator.username,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let vars = get_post_light::Variables { id: id.to_owned() };
|
let vars = get_post_light::Variables { id: id.to_owned() };
|
||||||
@ -180,16 +180,10 @@ impl Data {
|
|||||||
let res = post_graphql::<GetPostLight, _>(&self.client, URL, vars)
|
let res = post_graphql::<GetPostLight, _>(&self.client, URL, vars)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if res.data.is_none() {
|
let res = res.data.expect("missing response data").post.unwrap();
|
||||||
None
|
PostUrl {
|
||||||
} else {
|
slug: res.unique_slug,
|
||||||
match res.data.expect("missing response data").post {
|
username: res.creator.username,
|
||||||
None => None,
|
|
||||||
Some(res) => Some(PostUrl {
|
|
||||||
slug: res.unique_slug,
|
|
||||||
username: res.creator.username,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
src/proxy.rs
38
src/proxy.rs
@ -158,33 +158,29 @@ 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")]
|
#[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 {
|
async fn by_post_id(path: web::Path<String>, data: AppData) -> impl Responder {
|
||||||
match data.get_post_light(&path).await {
|
let post_data = data.get_post_light(&path).await;
|
||||||
None => HttpResponse::NotFound().body("Post not found"),
|
HttpResponse::Found()
|
||||||
Some(post_data) => 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()
|
||||||
.append_header((
|
.append_header((
|
||||||
header::LOCATION,
|
header::LOCATION,
|
||||||
crate::V1_API_ROUTES
|
crate::V1_API_ROUTES
|
||||||
.proxy
|
.proxy
|
||||||
.get_page(&post_data.username, &post_data.slug),
|
.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 {
|
} else {
|
||||||
HttpResponse::NotFound().body("Post not found, please file bug report")
|
HttpResponse::NotFound().body("Post not found, please file bug report")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user