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<String>,
) -> (
Option<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) {