restart: always
pictrs:
- image: asonix/pictrs:v0.1.0-r13
+ image: asonix/pictrs:v0.1.3-r1
ports:
- "127.0.0.1:8537:8080"
user: 991:991
return Err(APIError::err("site_ban").into());
}
- // Fetch Iframely and Pictshare cached image
- let (iframely_title, iframely_description, iframely_html, pictshare_thumbnail) =
+ // Fetch Iframely and pictrs cached image
+ let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) =
fetch_iframely_and_pictrs_data(data.url.to_owned());
let post_form = PostForm {
embed_title: iframely_title,
embed_description: iframely_description,
embed_html: iframely_html,
- thumbnail_url: pictshare_thumbnail,
+ thumbnail_url: pictrs_thumbnail,
};
let inserted_post = match Post::create(&conn, &post_form) {
return Err(APIError::err("site_ban").into());
}
- // Fetch Iframely and Pictshare cached image
- let (iframely_title, iframely_description, iframely_html, pictshare_thumbnail) =
+ // Fetch Iframely and Pictrs cached image
+ let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) =
fetch_iframely_and_pictrs_data(data.url.to_owned());
let post_form = PostForm {
embed_title: iframely_title,
embed_description: iframely_description,
embed_html: iframely_html,
- thumbnail_url: pictshare_thumbnail,
+ thumbnail_url: pictrs_thumbnail,
};
let _updated_post = match Post::update(&conn, data.edit_id, &post_form) {
setupTribute,
wsJsonToRes,
emojiPicker,
+ pictrsDeleteToast,
} from '../utils';
import { WebSocketService, UserService } from '../services';
import autosize from 'autosize';
</button>
{this.state.commentForm.content && (
<button
- className={`btn btn-sm mr-2 btn-secondary ${this.state
- .previewMode && 'active'}`}
+ className={`btn btn-sm mr-2 btn-secondary ${
+ this.state.previewMode && 'active'
+ }`}
onClick={linkEvent(this, this.handlePreviewToggle)}
>
{i18n.t('preview')}
const imageUploadUrl = `/pictrs/image`;
const formData = new FormData();
- formData.append('file', file);
+ formData.append('images[]', file);
i.state.imageLoading = true;
i.setState(i.state);
})
.then(res => res.json())
.then(res => {
- let url = `${window.location.origin}/pictrs/${res.url}`;
- let imageMarkdown =
- res.filetype == 'mp4' ? `[vid](${url}/raw)` : `![](${url})`;
- let content = i.state.commentForm.content;
- content = content ? `${content}\n${imageMarkdown}` : imageMarkdown;
- i.state.commentForm.content = content;
- i.state.imageLoading = false;
- i.setState(i.state);
- let textarea: any = document.getElementById(i.id);
- autosize.update(textarea);
+ console.log('pictrs upload:');
+ console.log(res);
+ if (res.msg == 'ok') {
+ let hash = res.files[0].file;
+ let url = `${window.location.origin}/pictrs/image/${hash}`;
+ let deleteToken = res.files[0].delete_token;
+ let deleteUrl = `${window.location.origin}/pictrs/image/delete/${deleteToken}/${hash}`;
+ let imageMarkdown = `![](${url})`;
+ let content = i.state.commentForm.content;
+ content = content ? `${content}\n${imageMarkdown}` : imageMarkdown;
+ i.state.commentForm.content = content;
+ i.state.imageLoading = false;
+ i.setState(i.state);
+ let textarea: any = document.getElementById(i.id);
+ autosize.update(textarea);
+ pictrsDeleteToast(
+ i18n.t('click_to_delete_picture'),
+ i18n.t('picture_deleted'),
+ deleteUrl
+ );
+ } else {
+ i.state.imageLoading = false;
+ i.setState(i.state);
+ toast(JSON.stringify(res), 'danger');
+ }
})
.catch(error => {
i.state.imageLoading = false;
setupTribute,
setupTippy,
emojiPicker,
+ pictrsDeleteToast,
} from '../utils';
import autosize from 'autosize';
import Tribute from 'tributejs/src/Tribute.js';
if (res.msg == 'ok') {
let hash = res.files[0].file;
let url = `${window.location.origin}/pictrs/image/${hash}`;
+ let deleteToken = res.files[0].delete_token;
+ let deleteUrl = `${window.location.origin}/pictrs/image/delete/${deleteToken}/${hash}`;
i.state.postForm.url = url;
i.state.imageLoading = false;
i.setState(i.state);
+ pictrsDeleteToast(
+ i18n.t('click_to_delete_picture'),
+ i18n.t('picture_deleted'),
+ deleteUrl
+ );
} else {
i.state.imageLoading = false;
i.setState(i.state);
}).showToast();
}
+export function pictrsDeleteToast(
+ clickToDeleteText: string,
+ deletePictureText: string,
+ deleteUrl: string
+) {
+ let backgroundColor = `var(--light)`;
+ let toast = Toastify({
+ text: clickToDeleteText,
+ backgroundColor: backgroundColor,
+ gravity: 'top',
+ position: 'right',
+ duration: 0,
+ onClick: () => {
+ if (toast) {
+ window.location.replace(deleteUrl);
+ alert(deletePictureText);
+ toast.hideToast();
+ }
+ },
+ close: true,
+ }).showToast();
+}
+
export function messageToastify(
creator: string,
avatar: string,
"delete_account": "Delete Account",
"delete_account_confirm":
"Warning: this will permanently delete all your data. Enter your password to confirm.",
+ "click_to_delete_picture": "Click to delete picture.",
+ "picture_deleted": "Picture deleted.",
"restore": "restore",
"ban": "ban",
"ban_from_site": "ban from site",