Compare commits

...

10 Commits

Author SHA1 Message Date
Aravinth Manivannan d2dcd6b048 Merge pull request 'Added libmedium.ducks.party instance' (#13) from nyuuzyou/libmedium:master into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: #13
Reviewed-by: Aravinth Manivannan <realaravinth@batsense.net>
2024-04-25 16:01:19 +05:30
nyuuzyou a5afd55fee Added libmedium.ducks.party instance
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful Details
2024-04-24 22:47:18 +05:30
Aravinth Manivannan f106f0a9cc Merge pull request 'fix: assign unique IDs to gist permanent links' (#11) from gh-32 into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: #11
2024-04-13 22:24:20 +05:30
Aravinth Manivannan f231175d97
fix: update tests to reflect new permanent linking scheme
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful Details
2024-04-13 16:31:56 +05:30
Aravinth Manivannan 612001e570
fix: update default source code config param
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2024-04-13 06:59:15 +05:30
Aravinth Manivannan dcdc2051cc
fix: assign unique IDs to gist permanent links 2024-04-13 06:50:07 +05:30
Aravinth Manivannan defe361077 Merge pull request 'fix: guard steps with events and rm secret in PR workflow' (#12) from fix-woodpecker-pr-config into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: #12
2024-04-13 06:49:32 +05:30
Aravinth Manivannan 032d67cd27
fix: guard steps with events and rm secret in PR workflow
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful Details
2024-04-13 06:21:50 +05:30
Aravinth Manivannan 9f14325233
fix: publish img
ci/woodpecker/manual/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
2024-01-26 19:52:28 +05:30
Aravinth Manivannan 1874596751 Merge pull request 'feat: publish multi-arch docker images' (#10) from multi-arch into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: #10
2024-01-26 18:10:27 +05:30
10 changed files with 38 additions and 15 deletions

View File

@ -1,6 +1,8 @@
steps:
backend:
image: rust
when:
event: [push, pull_request, tag, deployment, cron, manual, release]
environment:
- GIT_HASH=8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
- COMPILED_DATE=2021-07-21
@ -16,13 +18,10 @@ steps:
image: woodpeckerci/plugin-docker-buildx
when:
event: [pull_request]
secrets: [docker_token]
settings:
dry_run: true
repo: realaravinth/libmedium
username: realaravinth
password:
from_secret: DOCKER_TOKEN
platforms: linux/amd64,linux/arm64/v8
tag: latest
@ -34,7 +33,6 @@ steps:
branch: master
secrets: [docker_token]
settings:
dry_run: true
repo: realaravinth/libmedium
username: realaravinth
password:

20
Cargo.lock generated
View File

@ -924,6 +924,12 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.5"
@ -1170,6 +1176,7 @@ dependencies = [
"sailfish",
"serde",
"serde_json",
"sha256",
"sled",
"syntect",
"url",
@ -1963,6 +1970,19 @@ dependencies = [
"digest",
]
[[package]]
name = "sha256"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0"
dependencies = [
"async-trait",
"bytes",
"hex",
"sha2",
"tokio",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.1"

View File

@ -30,6 +30,7 @@ sled = "0.34.7"
syntect = "5.0.0"
url = "2.2"
actix-web-codegen-const-routes = "0.2.0"
sha256 = "1.5.0"
[dependencies.graphql_client]
features = ["reqwest"]

View File

@ -58,7 +58,7 @@ business.
| http://vernaqj2qr2pijpgvf3od6ssc3ulz3nv52gwr3hba5l6humuzmgq.b32.i2p/ | N/A | Hetzner | [~vern](https://vern.cc) |
| https://medium.hostux.net | France | Gandi | [hostux](https://hostux.net) |
| https://read.sudovanilla.com | US | Cloudflare | [SudoVanilla](https://sudovanilla.com) |
| https://libmedium.ducks.party | DE | Datalix | [ducks.party](https://ducks.party) |
## Deploy
1. Grab [`./config/default.toml`](./config/default.toml) and make

View File

@ -1,5 +1,5 @@
debug = true
source_code = "https://github.com/realaravinth/libmedium"
source_code = "https://git.batsense.net/realaravinth/libmedium"
#cache = "/var/lib/libmedium"
[server]

View File

@ -21,6 +21,7 @@ use graphql_client::{reqwest::post_graphql, GraphQLQuery};
use reqwest::header::USER_AGENT;
use reqwest::Client;
use serde::{Deserialize, Serialize};
use sha256::digest;
use sled::{Db, Tree};
use crate::proxy::StringUtils;
@ -287,19 +288,21 @@ impl Data {
filepath: &file.file_name,
code: &file.content,
};
file.content = highlight.syntax_highlight();
file.content = highlight.syntax_highlight(&digest(&file.raw_url));
files.push(file);
GistContent {
files,
html_url: gist_url,
}
} else {
let mut index = 1;
gist.files.iter_mut().for_each(|f| {
let highlight = render_html::SourcegraphQuery {
filepath: &f.file_name,
code: &f.content,
};
f.content = highlight.syntax_highlight();
f.content = highlight.syntax_highlight(&digest(&f.raw_url));
index += 1;
});
gist
};

View File

@ -133,7 +133,7 @@ const INDEX: &str = include_str!("../templates/index.html");
async fn index() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(INDEX)
.body(INDEX.replace("SOURCE_CODE_REPLACE", &crate::SETTINGS.source_code))
}
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.asset")]

View File

@ -38,7 +38,7 @@ pub struct SourcegraphQuery<'a> {
}
impl<'a> SourcegraphQuery<'a> {
pub fn syntax_highlight(&self) -> String {
pub fn syntax_highlight(&self, gist_name: &str) -> String {
// let ss = SYNTAX_SET;
let ts = ThemeSet::load_defaults();
@ -66,7 +66,8 @@ impl<'a> SourcegraphQuery<'a> {
if line_num == 0 || line_num == total_lines - 1 {
output.push_str(line);
} else {
output.push_str(&format!("<div title='click for more options' id=\"line-{num}\"class=\"line\"><details class='line_links'><summary class='line_top-link'><a href=\"#line-{num}\"<span class=\"line-number\">{num}</span></a>{line}</summary><a href=\"#line-{num}\"<span class=\"line-link\">Permanant link</span></a><a href=\"#line-{num}\"<span class=\"line-link\">Highlight</span></a></details></div>"
let line_id = format!("{gist_name}-{num}");
output.push_str(&format!("<div title='click for more options' id=\"line-{line_id}\"class=\"line\"><details class='line_links'><summary class='line_top-link'><a href=\"#line-{line_id}\"<span class=\"line-number\">{num}</span></a>{line}</summary><a href=\"#line-{line_id}\"<span class=\"line-link\">Permanant link</span></a><a href=\"#line-{line_id}\"<span class=\"line-link\">Highlight</span></a></details></div>"
));
num += 1;
}
@ -153,7 +154,7 @@ mod tests {
};
let result = query.determine_language(&syntax_set);
assert_eq!(result.name, "TeX");
let _result = query.syntax_highlight();
let _result = query.syntax_highlight("foo");
}
//#[test]

View File

@ -15,7 +15,7 @@
href="/@tylerneely/fear-and-loathing-in-lock-free-programming-7158b1cdd50c"
>Demo Article</a
>
| <a href="https://github.com/realaravinth/libmedium">Source Code</a>
| <a href="SOURCE_CODE_REPLACE">Source Code</a>
</p>
</div>
</main>

File diff suppressed because one or more lines are too long