mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added imagecaching
This commit is contained in:
parent
88f50e3348
commit
1320f0851f
16 changed files with 43 additions and 35 deletions
|
@ -6,6 +6,7 @@ import { Card } from '../Card';
|
||||||
import { IUser } from '~/redux/auth/types';
|
import { IUser } from '~/redux/auth/types';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import path from 'ramda/es/path';
|
import path from 'ramda/es/path';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
type IProps = HTMLAttributes<HTMLDivElement> & {
|
type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||||
// photo?: string;
|
// photo?: string;
|
||||||
|
@ -33,7 +34,7 @@ const CommentWrapper: FC<IProps> = ({
|
||||||
<div className={styles.thumb}>
|
<div className={styles.thumb}>
|
||||||
<div
|
<div
|
||||||
className={styles.thumb_image}
|
className={styles.thumb_image}
|
||||||
style={{ backgroundImage: `url("${getURL(path(['photo'], user))}")` }}
|
style={{ backgroundImage: `url("${getURL(path(['photo'], user), PRESETS.avatar)}")` }}
|
||||||
/>
|
/>
|
||||||
<div className={styles.thumb_user}>~{path(['username'], user)}</div>
|
<div className={styles.thumb_user}>~{path(['username'], user)}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { selectNode } from '~/redux/node/selectors';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import pick from 'ramda/es/pick';
|
import pick from 'ramda/es/pick';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
const mapStateToProps = state => pick(['current_cover_image'], selectNode(state));
|
const mapStateToProps = state => pick(['current_cover_image'], selectNode(state));
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ const PageCoverUnconnected: FC<IProps> = memo(({ current_cover_image }) =>
|
||||||
? createPortal(
|
? createPortal(
|
||||||
<div
|
<div
|
||||||
className={styles.wrap}
|
className={styles.wrap}
|
||||||
style={{ backgroundImage: `url("${getURL(current_cover_image)}")` }}
|
style={{ backgroundImage: `url("${getURL(current_cover_image, PRESETS.cover)}")` }}
|
||||||
/>,
|
/>,
|
||||||
document.body
|
document.body
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import * as UPLOAD_ACTIONS from '~/redux/uploads/actions';
|
||||||
import { selectUploads } from '~/redux/uploads/selectors';
|
import { selectUploads } from '~/redux/uploads/selectors';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const { statuses, files } = selectUploads(state);
|
const { statuses, files } = selectUploads(state);
|
||||||
|
@ -78,7 +79,7 @@ const EditorUploadCoverButtonUnconnected: FC<IProps> = ({
|
||||||
setData({ ...data, cover: null });
|
setData({ ...data, cover: null });
|
||||||
}, [setData, data]);
|
}, [setData, data]);
|
||||||
|
|
||||||
const background = data.cover ? getURL(data.cover) : null;
|
const background = data.cover ? getURL(data.cover, PRESETS['300']) : null;
|
||||||
const status = cover_temp && path([cover_temp], statuses);
|
const status = cover_temp && path([cover_temp], statuses);
|
||||||
const preview = status && path(['preview'], status);
|
const preview = status && path(['preview'], status);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { SortableImageGridItem } from '~/components/editors/SortableImageGridIte
|
||||||
import { IFile } from '~/redux/types';
|
import { IFile } from '~/redux/types';
|
||||||
import { IUploadStatus } from '~/redux/uploads/reducer';
|
import { IUploadStatus } from '~/redux/uploads/reducer';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
const SortableImageGrid = SortableContainer(
|
const SortableImageGrid = SortableContainer(
|
||||||
({
|
({
|
||||||
|
@ -27,7 +28,7 @@ const SortableImageGrid = SortableContainer(
|
||||||
.filter(file => file && file.id)
|
.filter(file => file && file.id)
|
||||||
.map((file, index) => (
|
.map((file, index) => (
|
||||||
<SortableImageGridItem key={file.id} index={index} collection={0}>
|
<SortableImageGridItem key={file.id} index={index} collection={0}>
|
||||||
<ImageUpload id={file.id} thumb={getURL(file)} onDrop={onDrop} />
|
<ImageUpload id={file.id} thumb={getURL(file, PRESETS.cover)} onDrop={onDrop} />
|
||||||
</SortableImageGridItem>
|
</SortableImageGridItem>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ const Cell: FC<IProps> = ({
|
||||||
}}
|
}}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<img src={getURL({ url: thumbnail })} onLoad={onImageLoad} alt="" />
|
<img src={getURL({ url: thumbnail }, PRESETS.cover)} onLoad={onImageLoad} alt="" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import classNames from 'classnames';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import { withRouter, RouteComponentProps } from 'react-router';
|
import { withRouter, RouteComponentProps } from 'react-router';
|
||||||
import { URLS } from '~/constants/urls';
|
import { URLS, PRESETS } from '~/constants/urls';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
|
|
||||||
type IProps = RouteComponentProps & {
|
type IProps = RouteComponentProps & {
|
||||||
|
@ -103,12 +103,12 @@ const FlowHeroUnconnected: FC<IProps> = ({ heroes, history }) => {
|
||||||
[styles.is_visible]: loaded.includes(hero.id),
|
[styles.is_visible]: loaded.includes(hero.id),
|
||||||
[styles.is_active]: current === hero.id,
|
[styles.is_active]: current === hero.id,
|
||||||
})}
|
})}
|
||||||
style={{ backgroundImage: `url("${getURL({ url: hero.thumbnail })}")` }}
|
style={{ backgroundImage: `url("${getURL({ url: hero.thumbnail }, PRESETS.hero)}")` }}
|
||||||
key={hero.id}
|
key={hero.id}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={getURL({ url: hero.thumbnail })}
|
src={getURL({ url: hero.thumbnail }, PRESETS.hero)}
|
||||||
alt={hero.thumbnail}
|
alt={hero.thumbnail}
|
||||||
onLoad={onLoad(hero.id)}
|
onLoad={onLoad(hero.id)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as styles from './styles.scss';
|
||||||
import { IFlowState } from '~/redux/flow/reducer';
|
import { IFlowState } from '~/redux/flow/reducer';
|
||||||
import { getURL, getPrettyDate } from '~/utils/dom';
|
import { getURL, getPrettyDate } from '~/utils/dom';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { URLS } from '~/constants/urls';
|
import { URLS, PRESETS } from '~/constants/urls';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
@ -18,7 +18,7 @@ const FlowRecent: FC<IProps> = ({ recent, updated }) => (
|
||||||
<Link key={node.id} className={styles.item} to={URLS.NODE_URL(node.id)}>
|
<Link key={node.id} className={styles.item} to={URLS.NODE_URL(node.id)}>
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.thumb, styles.new)}
|
className={classNames(styles.thumb, styles.new)}
|
||||||
style={{ backgroundImage: `url("${getURL({ url: node.thumbnail })}")` }}
|
style={{ backgroundImage: `url("${getURL({ url: node.thumbnail }, PRESETS.avatar)}")` }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className={styles.info}>
|
<div className={styles.info}>
|
||||||
|
@ -33,7 +33,7 @@ const FlowRecent: FC<IProps> = ({ recent, updated }) => (
|
||||||
<Link key={node.id} className={styles.item} to={URLS.NODE_URL(node.id)}>
|
<Link key={node.id} className={styles.item} to={URLS.NODE_URL(node.id)}>
|
||||||
<div
|
<div
|
||||||
className={styles.thumb}
|
className={styles.thumb}
|
||||||
style={{ backgroundImage: `url("${getURL({ url: node.thumbnail })}")` }}
|
style={{ backgroundImage: `url("${getURL({ url: node.thumbnail }, PRESETS.avatar)}")` }}
|
||||||
/>
|
/>
|
||||||
<div className={styles.info}>
|
<div className={styles.info}>
|
||||||
<div className={styles.title}>{node.title}</div>
|
<div className={styles.title}>{node.title}</div>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import styles from './styles.scss';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { IUser } from '~/redux/auth/types';
|
import { IUser } from '~/redux/auth/types';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
user: Partial<IUser>;
|
user: Partial<IUser>;
|
||||||
|
@ -14,7 +15,10 @@ const UserButton: FC<IProps> = ({ user: { username, photo }, onLogout }) => (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<Group horizontal className={styles.user_button}>
|
<Group horizontal className={styles.user_button}>
|
||||||
<div>{username}</div>
|
<div>{username}</div>
|
||||||
<div className={styles.user_avatar} style={{ backgroundImage: `url('${getURL(photo)}')` }}>
|
<div
|
||||||
|
className={styles.user_avatar}
|
||||||
|
style={{ backgroundImage: `url('${getURL(photo, PRESETS.avatar)}')` }}
|
||||||
|
>
|
||||||
{(!photo || !photo.id) && <Icon icon="profile" />}
|
{(!photo || !photo.id) && <Icon icon="profile" />}
|
||||||
</div>
|
</div>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import append from 'ramda/es/append';
|
||||||
import reduce from 'ramda/es/reduce';
|
import reduce from 'ramda/es/reduce';
|
||||||
import { AudioPlayer } from '~/components/media/AudioPlayer';
|
import { AudioPlayer } from '~/components/media/AudioPlayer';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
comment: IComment;
|
comment: IComment;
|
||||||
|
@ -46,7 +47,7 @@ const CommentContent: FC<IProps> = memo(({ comment }) => {
|
||||||
<div className={styles.images}>
|
<div className={styles.images}>
|
||||||
{groupped.image.map(file => (
|
{groupped.image.map(file => (
|
||||||
<div key={file.id}>
|
<div key={file.id}>
|
||||||
<img src={getURL(file)} alt={file.name} />
|
<img src={getURL(file, PRESETS['300'])} alt={file.name} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as styles from './styles.scss';
|
||||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||||
import path from 'ramda/es/path';
|
import path from 'ramda/es/path';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
node: INode;
|
node: INode;
|
||||||
|
@ -19,7 +20,7 @@ const NodeAudioImageBlock: FC<IProps> = ({ node }) => {
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<div
|
<div
|
||||||
className={styles.slide}
|
className={styles.slide}
|
||||||
style={{ backgroundImage: `url("${getURL(path([0], images))}")` }}
|
style={{ backgroundImage: `url("${getURL(path([0], images), PRESETS.hero)}")` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
import React, {
|
import React, { FC, useMemo, useState, useEffect, useRef, useCallback } from 'react';
|
||||||
FC,
|
|
||||||
useMemo,
|
|
||||||
useState,
|
|
||||||
useEffect,
|
|
||||||
RefObject,
|
|
||||||
LegacyRef,
|
|
||||||
useRef,
|
|
||||||
useCallback,
|
|
||||||
} from 'react';
|
|
||||||
import { ImageSwitcher } from '../ImageSwitcher';
|
import { ImageSwitcher } from '../ImageSwitcher';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { getImageSize } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
is_loading: boolean;
|
is_loading: boolean;
|
||||||
|
@ -82,7 +74,7 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout }) => {
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className={styles.image}
|
className={styles.image}
|
||||||
src={getImageSize(file, 'node')}
|
src={getURL(file, PRESETS['1400'])}
|
||||||
alt=""
|
alt=""
|
||||||
key={file.id}
|
key={file.id}
|
||||||
onLoad={onImageLoad(index)}
|
onLoad={onImageLoad(index)}
|
||||||
|
|
|
@ -3,9 +3,10 @@ import { ImageSwitcher } from '../ImageSwitcher';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { getImageSize } from '~/utils/dom';
|
|
||||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||||
import { NODE_SETTINGS } from '~/redux/node/constants';
|
import { NODE_SETTINGS } from '~/redux/node/constants';
|
||||||
|
import { getURL } from '~/utils/dom';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
is_loading: boolean;
|
is_loading: boolean;
|
||||||
|
@ -206,7 +207,7 @@ const NodeImageSlideBlock: FC<IProps> = ({ node, is_loading, updateLayout }) =>
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className={styles.image}
|
className={styles.image}
|
||||||
src={getImageSize(file, 'node')}
|
src={getURL(file, PRESETS['1400'])}
|
||||||
alt=""
|
alt=""
|
||||||
key={file.id}
|
key={file.id}
|
||||||
onLoad={onImageLoad(index)}
|
onLoad={onImageLoad(index)}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React, { FC, memo, useCallback, useState } from 'react';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import { URLS } from '~/constants/urls';
|
import { URLS, PRESETS } from '~/constants/urls';
|
||||||
import { RouteComponentProps, withRouter } from 'react-router';
|
import { RouteComponentProps, withRouter } from 'react-router';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
|
|
||||||
|
@ -22,10 +22,14 @@ const NodeRelatedItemUnconnected: FC<IProps> = memo(({ item, history }) => {
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={styles.thumb}
|
className={styles.thumb}
|
||||||
style={{ backgroundImage: `url("${getURL({ url: item.thumbnail })}")` }}
|
style={{ backgroundImage: `url("${getURL({ url: item.thumbnail }, PRESETS.avatar)}")` }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img src={getURL({ url: item.thumbnail })} alt="loader" onLoad={() => setIsLoaded(true)} />
|
<img
|
||||||
|
src={getURL({ url: item.thumbnail }, PRESETS.avatar)}
|
||||||
|
alt="loader"
|
||||||
|
onLoad={() => setIsLoaded(true)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,4 +19,5 @@ export const PRESETS = {
|
||||||
placeholder: 'placeholder',
|
placeholder: 'placeholder',
|
||||||
cover: 'cover',
|
cover: 'cover',
|
||||||
hero: 'hero',
|
hero: 'hero',
|
||||||
|
avatar: 'avatar',
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,7 +62,6 @@ render(
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- better dialogs: https://codepen.io/muemue/pen/abbEMMy
|
|
||||||
- comment editing
|
- comment editing
|
||||||
- boris with comments
|
- boris with comments
|
||||||
- profile modal
|
- profile modal
|
||||||
|
@ -71,7 +70,6 @@ render(
|
||||||
- relocate files
|
- relocate files
|
||||||
- import videos
|
- import videos
|
||||||
- import graffiti
|
- import graffiti
|
||||||
- imagecaching at backend
|
|
||||||
- password restore
|
- password restore
|
||||||
- signup?
|
- signup?
|
||||||
- text post can also has songs http://vault48.org/post5052
|
- text post can also has songs http://vault48.org/post5052
|
||||||
|
@ -82,6 +80,8 @@ render(
|
||||||
- social integration (assimilate)
|
- social integration (assimilate)
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
- better dialogs: https://codepen.io/muemue/pen/abbEMMy
|
||||||
|
- imagecaching at backend
|
||||||
- social integration (login, signup)
|
- social integration (login, signup)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,7 +72,7 @@ export const getURL = (file: Partial<IFile>, size?: typeof PRESETS[keyof typeof
|
||||||
.replace('REMOTE_OLD://', process.env.REMOTE_OLD);
|
.replace('REMOTE_OLD://', process.env.REMOTE_OLD);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getImageSize = (file: IFile, size?: string): string => getURL(file);
|
// export const getImageSize = (file: IFile, size?: string): string => getURL(file);
|
||||||
// `${process.env.API_HOST}${image}`.replace('{size}', size);
|
// `${process.env.API_HOST}${image}`.replace('{size}', size);
|
||||||
|
|
||||||
export const formatText = (text: string): string =>
|
export const formatText = (text: string): string =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue