From: Dessalines Date: Fri, 12 Jun 2020 21:51:37 +0000 (-0400) Subject: Merge branch 'master' into use-pictrs-1 X-Git-Url: http://these/git/readmes/%7Bthis.props.banner%7D?a=commitdiff_plain;h=5594bed6a8832b3fcba48966752cf0d5859cf1d4;p=lemmy.git Merge branch 'master' into use-pictrs-1 --- 5594bed6a8832b3fcba48966752cf0d5859cf1d4 diff --cc server/src/lib.rs index 9b73caa8,23d6a87a..49971cfa --- a/server/src/lib.rs +++ b/server/src/lib.rs @@@ -203,19 -197,15 +203,19 @@@ pub fn fetch_pictrs(image_url: &str) - is_image_content_type(image_url)?; let fetch_url = format!( - "http://pictshare/api/geturl.php?url={}", - utf8_percent_encode(image_url, NON_ALPHANUMERIC) + "http://pictrs:8080/image/download?url={}", + utf8_percent_encode(image_url, NON_ALPHANUMERIC) // TODO this might not be needed ); - let text = isahc::get(&fetch_url)?.text()?; + let text = attohttpc::get(&fetch_url).send()?.text()?; - let res: PictshareResponse = serde_json::from_str(&text)?; - Ok(res) + let res: PictrsResponse = serde_json::from_str(&text)?; + if res.msg == "ok" { + Ok(res) + } else { + Err(format_err!("{}", &res.msg)) + } } -fn fetch_iframely_and_pictshare_data( +fn fetch_iframely_and_pictrs_data( url: Option, ) -> ( Option, diff --cc ui/src/utils.ts index 570ea48c,93b9cab0..500992d7 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@@ -413,10 -413,19 +413,23 @@@ export function setTheme(theme: string } } - // Load the theme dynamically - let cssLoc = `/static/assets/css/themes/${theme}.min.css`; - loadCss(theme, cssLoc); - document.getElementById(theme).removeAttribute('disabled'); + // if the user is not logged in, we load the default themes and let the browser decide - if(!loggedIn) { - document.getElementById("default-light").removeAttribute('disabled') - document.getElementById("default-dark").removeAttribute('disabled') ++ if (!loggedIn) { ++ document.getElementById('default-light').removeAttribute('disabled'); ++ document.getElementById('default-dark').removeAttribute('disabled'); + } else { - document.getElementById("default-light").setAttribute('disabled', 'disabled'); - document.getElementById("default-dark").setAttribute('disabled', 'disabled'); ++ document ++ .getElementById('default-light') ++ .setAttribute('disabled', 'disabled'); ++ document ++ .getElementById('default-dark') ++ .setAttribute('disabled', 'disabled'); + + // Load the theme dynamically + let cssLoc = `/static/assets/css/themes/${theme}.min.css`; + loadCss(theme, cssLoc); + document.getElementById(theme).removeAttribute('disabled'); + } } export function loadCss(id: string, loc: string) {