mirror of
https://github.com/docmost/docmost.git
synced 2025-11-25 10:21:10 +10:00
Compare commits
6 Commits
v0.3.0
...
dea9f4c063
| Author | SHA1 | Date | |
|---|---|---|---|
| dea9f4c063 | |||
| 0b6730c06f | |||
| be0d97661a | |||
| 4e2b23c97e | |||
| dc3ce27762 | |||
| 8af2d4e8cf |
@ -17,6 +17,7 @@ To get started with Docmost, please refer to our [documentation](https://docmost
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Real-time collaboration
|
- Real-time collaboration
|
||||||
|
- Diagrams (Draw.io, Excalidraw and Mermaid)
|
||||||
- Spaces
|
- Spaces
|
||||||
- Permissions management
|
- Permissions management
|
||||||
- Groups
|
- Groups
|
||||||
@ -32,4 +33,4 @@ To get started with Docmost, please refer to our [documentation](https://docmost
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
See the [development doc](https://docmost.com/docs/self-hosting/development)
|
See the [development documentation](https://docmost.com/docs/self-hosting/development)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
|
|||||||
@ -64,7 +64,7 @@ export async function exportPage(data: IExportPageParams): Promise<void> {
|
|||||||
.split("filename=")[1]
|
.split("filename=")[1]
|
||||||
.replace(/"/g, "");
|
.replace(/"/g, "");
|
||||||
|
|
||||||
saveAs(req.data, fileName);
|
saveAs(req.data, decodeURIComponent(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function importPage(file: File, spaceId: string) {
|
export async function importPage(file: File, spaceId: string) {
|
||||||
@ -81,14 +81,17 @@ export async function importPage(file: File, spaceId: string) {
|
|||||||
return req.data;
|
return req.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadFile(file: File, pageId: string, attachmentId?: string): Promise<IAttachment> {
|
export async function uploadFile(
|
||||||
|
file: File,
|
||||||
|
pageId: string,
|
||||||
|
attachmentId?: string,
|
||||||
|
): Promise<IAttachment> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if(attachmentId){
|
if (attachmentId) {
|
||||||
formData.append("attachmentId", attachmentId);
|
formData.append("attachmentId", attachmentId);
|
||||||
}
|
}
|
||||||
formData.append("pageId", pageId);
|
formData.append("pageId", pageId);
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
|
|
||||||
const req = await api.post<IAttachment>("/files/upload", formData, {
|
const req = await api.post<IAttachment>("/files/upload", formData, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -7,23 +7,27 @@ declare global {
|
|||||||
export function getAppUrl(): string {
|
export function getAppUrl(): string {
|
||||||
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
|
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
|
||||||
|
|
||||||
// if (import.meta.env.DEV) {
|
// if (import.meta.env.DEV) {
|
||||||
// return appUrl || "http://localhost:3000";
|
// return appUrl || "http://localhost:3000";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return `${window.location.protocol}//${window.location.host}`;
|
return `${window.location.protocol}//${window.location.host}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBackendUrl(): string {
|
export function getBackendUrl(): string {
|
||||||
return getAppUrl() + "/api";
|
return getAppUrl() + '/api';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCollaborationUrl(): string {
|
export function getCollaborationUrl(): string {
|
||||||
const COLLAB_PATH = "/collab";
|
const COLLAB_PATH = '/collab';
|
||||||
const url = process.env.APP_URL || getAppUrl();
|
|
||||||
|
|
||||||
const wsProtocol = url.startsWith("https") ? "wss" : "ws";
|
let url = getAppUrl();
|
||||||
return `${wsProtocol}://${url.split("://")[1]}${COLLAB_PATH}`;
|
if (import.meta.env.DEV) {
|
||||||
|
url = process.env.APP_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wsProtocol = url.startsWith('https') ? 'wss' : 'ws';
|
||||||
|
return `${wsProtocol}://${url.split('://')[1]}${COLLAB_PATH}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAvatarUrl(avatarUrl: string) {
|
export function getAvatarUrl(avatarUrl: string) {
|
||||||
@ -31,17 +35,17 @@ export function getAvatarUrl(avatarUrl: string) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avatarUrl?.startsWith("http")) {
|
if (avatarUrl?.startsWith('http')) {
|
||||||
return avatarUrl;
|
return avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getBackendUrl() + "/attachments/img/avatar/" + avatarUrl;
|
return getBackendUrl() + '/attachments/img/avatar/' + avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSpaceUrl(spaceSlug: string) {
|
export function getSpaceUrl(spaceSlug: string) {
|
||||||
return "/s/" + spaceSlug;
|
return '/s/' + spaceSlug;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFileUrl(src: string) {
|
export function getFileUrl(src: string) {
|
||||||
return src?.startsWith("/files/") ? getBackendUrl() + src : src;
|
return src?.startsWith('/files/') ? getBackendUrl() + src : src;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@ -5,10 +5,10 @@ export enum AttachmentType {
|
|||||||
File = 'file',
|
File = 'file',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validImageExtensions = ['.jpg', '.png', '.jpeg', 'gif'];
|
export const validImageExtensions = ['.jpg', '.png', '.jpeg'];
|
||||||
export const MAX_AVATAR_SIZE = '5MB';
|
export const MAX_AVATAR_SIZE = '5MB';
|
||||||
|
|
||||||
export const InlineFileExtensions = [
|
export const inlineFileExtensions = [
|
||||||
'.jpg',
|
'.jpg',
|
||||||
'.png',
|
'.png',
|
||||||
'.jpeg',
|
'.jpeg',
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import {
|
|||||||
import { getMimeType } from '../../common/helpers';
|
import { getMimeType } from '../../common/helpers';
|
||||||
import {
|
import {
|
||||||
AttachmentType,
|
AttachmentType,
|
||||||
|
inlineFileExtensions,
|
||||||
MAX_AVATAR_SIZE,
|
MAX_AVATAR_SIZE,
|
||||||
MAX_FILE_SIZE,
|
MAX_FILE_SIZE,
|
||||||
} from './attachment.constants';
|
} from './attachment.constants';
|
||||||
@ -177,6 +178,14 @@ export class AttachmentController {
|
|||||||
'Content-Type': attachment.mimeType,
|
'Content-Type': attachment.mimeType,
|
||||||
'Cache-Control': 'public, max-age=3600',
|
'Cache-Control': 'public, max-age=3600',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!inlineFileExtensions.includes(attachment.fileExt)) {
|
||||||
|
res.header(
|
||||||
|
'Content-Disposition',
|
||||||
|
`attachment; filename="${encodeURIComponent(attachment.fileName)}"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return res.send(fileStream);
|
return res.send(fileStream);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(err);
|
this.logger.error(err);
|
||||||
|
|||||||
@ -61,7 +61,8 @@ export class ImportController {
|
|||||||
|
|
||||||
res.headers({
|
res.headers({
|
||||||
'Content-Type': getMimeType(fileExt),
|
'Content-Type': getMimeType(fileExt),
|
||||||
'Content-Disposition': 'attachment; filename="' + fileName + '"',
|
'Content-Disposition':
|
||||||
|
'attachment; filename="' + encodeURIComponent(fileName) + '"',
|
||||||
});
|
});
|
||||||
|
|
||||||
res.send(rawContent);
|
res.send(rawContent);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "docmost",
|
"name": "docmost",
|
||||||
"homepage": "https://docmost.com",
|
"homepage": "https://docmost.com",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nx run-many -t build",
|
"build": "nx run-many -t build",
|
||||||
|
|||||||
Reference in New Issue
Block a user