Compare commits
No commits in common. "master" and "chore-rm-gh-actions" have entirely different histories.
master
...
chore-rm-g
9 changed files with 415 additions and 477 deletions
|
@ -31,6 +31,7 @@ steps:
|
||||||
when:
|
when:
|
||||||
event: [push, tag, deployment]
|
event: [push, tag, deployment]
|
||||||
branch: master
|
branch: master
|
||||||
|
secrets: [docker_token]
|
||||||
settings:
|
settings:
|
||||||
repo: realaravinth/libmedium
|
repo: realaravinth/libmedium
|
||||||
username: realaravinth
|
username: realaravinth
|
||||||
|
|
793
Cargo.lock
generated
793
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@ actix-rt = "2"
|
||||||
actix-web = "4.0.1"
|
actix-web = "4.0.1"
|
||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
chrono = "0.4.23"
|
chrono = "0.4.23"
|
||||||
config = "0.14"
|
config = "0.13"
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
futures = "0.3.17"
|
futures = "0.3.17"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
|
|
@ -57,7 +57,7 @@ business.
|
||||||
| http://md.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/ | N/A | Hetzner | [~vern](https://vern.cc) |
|
| http://md.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/ | N/A | Hetzner | [~vern](https://vern.cc) |
|
||||||
| http://vernaqj2qr2pijpgvf3od6ssc3ulz3nv52gwr3hba5l6humuzmgq.b32.i2p/ | N/A | Hetzner | [~vern](https://vern.cc) |
|
| http://vernaqj2qr2pijpgvf3od6ssc3ulz3nv52gwr3hba5l6humuzmgq.b32.i2p/ | N/A | Hetzner | [~vern](https://vern.cc) |
|
||||||
| https://medium.hostux.net | France | Gandi | [hostux](https://hostux.net) |
|
| https://medium.hostux.net | France | Gandi | [hostux](https://hostux.net) |
|
||||||
| https://r.sudovanilla.org | US | Selfhosted | [SudoVanilla](https://sudovanilla.org) |
|
| https://read.sudovanilla.com | US | Cloudflare | [SudoVanilla](https://sudovanilla.com) |
|
||||||
| https://libmedium.ducks.party | DE | Datalix | [ducks.party](https://ducks.party) |
|
| https://libmedium.ducks.party | DE | Datalix | [ducks.party](https://ducks.party) |
|
||||||
## Deploy
|
## Deploy
|
||||||
|
|
||||||
|
|
16
src/data.rs
16
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 {
|
|
||||||
match res.data.expect("missing response data").post {
|
|
||||||
None => None,
|
|
||||||
Some(res) => Some(PostUrl {
|
|
||||||
slug: res.unique_slug,
|
slug: res.unique_slug,
|
||||||
username: res.creator.username,
|
username: res.creator.username,
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
34
src/post.rs
34
src/post.rs
|
@ -345,7 +345,6 @@ pub fn apply_markup(
|
||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
let mut paragraphs: Vec<String> = Vec::with_capacity(data.content.body_model.paragraphs.len());
|
let mut paragraphs: Vec<String> = Vec::with_capacity(data.content.body_model.paragraphs.len());
|
||||||
let mut state = ListState::default();
|
let mut state = ListState::default();
|
||||||
let mut no_render_html = false;
|
|
||||||
for (pindex, p) in data.content.body_model.paragraphs.iter().enumerate() {
|
for (pindex, p) in data.content.body_model.paragraphs.iter().enumerate() {
|
||||||
let mut pos = PositionMap::default();
|
let mut pos = PositionMap::default();
|
||||||
if p.type_ == "H3" && pindex == 0 {
|
if p.type_ == "H3" && pindex == 0 {
|
||||||
|
@ -384,42 +383,33 @@ pub fn apply_markup(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut content = String::with_capacity(p.text.len());
|
let mut content = String::with_capacity(p.text.len());
|
||||||
let start = &Markup::start(p, gists, pindex, &mut state);
|
content += &Markup::start(p, gists, pindex, &mut state);
|
||||||
content += start;
|
|
||||||
if start == "<pre>" {
|
|
||||||
no_render_html = true;
|
|
||||||
}
|
|
||||||
pos.arr.sort();
|
pos.arr.sort();
|
||||||
let mut page = String::default();
|
|
||||||
if let Some(first) = pos.arr.first() {
|
if let Some(first) = pos.arr.first() {
|
||||||
page += p.text.slice(cur..*first as usize);
|
//content += p.text.substring(cur, *first as usize);
|
||||||
|
content += p.text.slice(cur..*first as usize);
|
||||||
cur = incr_cur(cur, *first);
|
cur = incr_cur(cur, *first);
|
||||||
for point in pos.arr.iter() {
|
for point in pos.arr.iter() {
|
||||||
|
//content.push(p.text.substring(start, start + point);
|
||||||
|
// if *point != 0 {
|
||||||
|
|
||||||
if cur != *point as usize {
|
if cur != *point as usize {
|
||||||
page += p.text.slice(cur..*point as usize);
|
// content += p.text.substring(cur, *point as usize);
|
||||||
|
content += p.text.slice(cur..*point as usize);
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
let pos_markups = pos.map.get(point).unwrap();
|
let pos_markups = pos.map.get(point).unwrap();
|
||||||
for m in pos_markups.iter() {
|
for m in pos_markups.iter() {
|
||||||
page += &m.apply_markup(pindex);
|
content += &m.apply_markup(pindex);
|
||||||
}
|
}
|
||||||
cur = incr_cur(cur, *point);
|
cur = incr_cur(cur, *point);
|
||||||
}
|
}
|
||||||
log::debug!("LAST");
|
log::debug!("LAST");
|
||||||
page += p.text.slice(cur..);
|
content += p.text.slice(cur..);
|
||||||
let end = &Markup::end(p, pindex, &mut state);
|
content += &Markup::end(p, pindex, &mut state);
|
||||||
if end == "</pre>" {
|
|
||||||
no_render_html = false;
|
|
||||||
}
|
|
||||||
content += &page;
|
|
||||||
content += end;
|
|
||||||
} else {
|
} else {
|
||||||
log::debug!("LAST WITH NO MARKUP");
|
log::debug!("LAST WITH NO MARKUP");
|
||||||
page += p.text.slice(cur..);
|
content += p.text.slice(cur..);
|
||||||
if no_render_html {
|
|
||||||
page = page.replace("<", "<").replace(">", ">");
|
|
||||||
}
|
|
||||||
content += &page;
|
|
||||||
content += &Markup::end(p, pindex, &mut state);
|
content += &Markup::end(p, pindex, &mut state);
|
||||||
}
|
}
|
||||||
paragraphs.push(content);
|
paragraphs.push(content);
|
||||||
|
|
16
src/proxy.rs
16
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((
|
.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")]
|
#[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 {
|
async fn by_top_level_post(path: web::Path<String>, data: AppData) -> impl Responder {
|
||||||
if let Some(post_id) = path.split('-').last() {
|
if let Some(post_id) = path.split('-').last() {
|
||||||
match data.get_post_light(post_id).await {
|
let post_data = data.get_post_light(post_id).await;
|
||||||
None => HttpResponse::NotFound().body("Post not found"),
|
HttpResponse::Found()
|
||||||
Some(post_data) => 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()
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
HttpResponse::NotFound().body("Post not found, please file bug report")
|
HttpResponse::NotFound().body("Post not found, please file bug report")
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
body {
|
body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
|
@ -317,6 +317,7 @@ padding: 0;
|
||||||
body {
|
body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
main {
|
main {
|
||||||
width: 35em;
|
width: 35em;
|
||||||
|
|
Loading…
Reference in a new issue