Compare commits

..

1 commit

Author SHA1 Message Date
binwiederhier
f3c955b0f8 PoC: Load external images 2023-06-01 22:13:31 -04:00
5 changed files with 19 additions and 20 deletions

View file

@ -1,4 +1,4 @@
FROM r.batts.cloud/debian:testing FROM alpine
LABEL org.opencontainers.image.authors="philipp.heckel@gmail.com" LABEL org.opencontainers.image.authors="philipp.heckel@gmail.com"
LABEL org.opencontainers.image.url="https://ntfy.sh/" LABEL org.opencontainers.image.url="https://ntfy.sh/"

View file

@ -1,4 +1,4 @@
FROM r.batts.cloud/golang:1.19 as builder FROM golang:1.19-bullseye as builder
ARG VERSION=dev ARG VERSION=dev
ARG COMMIT=unknown ARG COMMIT=unknown
@ -8,8 +8,7 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash
RUN apt-get install -y \ RUN apt-get install -y \
build-essential \ build-essential \
nodejs \ nodejs \
python3-pip \ python3-pip
python3-venv
WORKDIR /app WORKDIR /app
ADD Makefile . ADD Makefile .
@ -37,7 +36,7 @@ ADD ./user ./user
ADD ./util ./util ADD ./util ./util
RUN make VERSION=$VERSION COMMIT=$COMMIT cli-linux-server RUN make VERSION=$VERSION COMMIT=$COMMIT cli-linux-server
FROM r.batts.cloud/debian:testing FROM alpine
LABEL org.opencontainers.image.authors="philipp.heckel@gmail.com" LABEL org.opencontainers.image.authors="philipp.heckel@gmail.com"
LABEL org.opencontainers.image.url="https://ntfy.sh/" LABEL org.opencontainers.image.url="https://ntfy.sh/"

View file

@ -110,9 +110,8 @@ build-deps-ubuntu:
docs: docs-deps docs-build docs: docs-deps docs-build
docs-build: venv .PHONY docs-build: .PHONY
@. venv/bin/activate && \ @if ! /bin/echo -e "import sys\nif sys.version_info < (3,8):\n exit(1)" | python3; then \
if ! /bin/echo -e "import sys\nif sys.version_info < (3,8):\n exit(1)" | python3; then \
if which python3.8; then \ if which python3.8; then \
echo "python3.8 $(shell which mkdocs) build"; \ echo "python3.8 $(shell which mkdocs) build"; \
python3.8 $(shell which mkdocs) build; \ python3.8 $(shell which mkdocs) build; \
@ -125,15 +124,10 @@ docs-build: venv .PHONY
mkdocs build; \ mkdocs build; \
fi fi
venv: docs-deps: .PHONY
python3 -m venv ./venv
docs-deps: venv .PHONY
. venv/bin/activate && \
pip3 install -r requirements.txt pip3 install -r requirements.txt
docs-deps-update: venv .PHONY docs-deps-update: .PHONY
. venv/bin/activate && \
pip3 install -r requirements.txt --upgrade pip3 install -r requirements.txt --upgrade

View file

@ -7,7 +7,7 @@
var config = { var config = {
base_url: window.location.origin, // Change to test against a different server base_url: window.location.origin, // Change to test against a different server
app_root: "/app", app_root: "/",
enable_login: true, enable_login: true,
enable_signup: true, enable_signup: true,
enable_payments: false, enable_payments: false,

View file

@ -287,14 +287,15 @@ const NotificationItem = (props) => {
const Attachment = (props) => { const Attachment = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [ imageError, setImageError ] = useState(false);
const { attachment } = props; const { attachment } = props;
const expired = attachment.expires && attachment.expires < Date.now() / 1000; const expired = attachment.expires && attachment.expires < Date.now() / 1000;
const expires = attachment.expires && attachment.expires > Date.now() / 1000; const expires = attachment.expires && attachment.expires > Date.now() / 1000;
const displayableImage = !expired && attachment.type && attachment.type.startsWith("image/"); const displayableImage = !expired && attachment.type && attachment.type.startsWith("image/");
// Unexpired image // Unexpired image
if (displayableImage) { if (!imageError) {
return <Image attachment={attachment} />; return <Image attachment={attachment} onError={() => setImageError(true)} />;
} }
// Anything else: Show box // Anything else: Show box
@ -376,14 +377,19 @@ const Attachment = (props) => {
const Image = (props) => { const Image = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [loaded, setLoaded] = useState(false);
return ( return (
<> <div style={{
display: loaded ? "block" : "none",
}}>
<Box <Box
component="img" component="img"
src={props.attachment.url} src={props.attachment.url}
loading="lazy" loading="lazy"
alt={t("notifications_attachment_image")} alt={t("notifications_attachment_image")}
onClick={() => setOpen(true)} onClick={() => setOpen(true)}
onLoad={() => setLoaded(true)}
onError={props.onError}
sx={{ sx={{
marginTop: 2, marginTop: 2,
borderRadius: "4px", borderRadius: "4px",
@ -413,7 +419,7 @@ const Image = (props) => {
/> />
</Fade> </Fade>
</Modal> </Modal>
</> </div>
); );
}; };