mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4c7a99a36 | |||
| 2ec2c2b299 | |||
| b806ceaa56 | |||
| 19af5ef09e | |||
| 34faf434d4 | |||
| da5e5c0ca0 |
@@ -59,6 +59,9 @@ function SharePopover({ collection, visible, onRequestClose }: Props) {
|
||||
useKeyDown(
|
||||
"Escape",
|
||||
(ev) => {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ function SharePopover({
|
||||
useKeyDown(
|
||||
"Escape",
|
||||
(ev) => {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ const Sticky = styled.div`
|
||||
background: ${s("background")};
|
||||
transition: ${s("backgroundTransition")};
|
||||
|
||||
margin-top: 80px;
|
||||
margin-top: calc(50px + 6vh);
|
||||
margin-right: 52px;
|
||||
min-width: 204px;
|
||||
width: 228px;
|
||||
|
||||
+1
-1
@@ -367,5 +367,5 @@
|
||||
"qs": "6.9.7",
|
||||
"rollup": "^4.5.1"
|
||||
},
|
||||
"version": "0.77.1"
|
||||
"version": "0.77.2"
|
||||
}
|
||||
|
||||
@@ -72,34 +72,32 @@ router.get(
|
||||
async (ctx: APIContext<T.FilesGetReq>) => {
|
||||
const actor = ctx.state.auth.user;
|
||||
const key = getKeyFromContext(ctx);
|
||||
const forceDownload = !!ctx.input.query.download;
|
||||
const isSignedRequest = !!ctx.input.query.sig;
|
||||
const { isPublicBucket, fileName } = AttachmentHelper.parseKey(key);
|
||||
const skipAuthorize = isPublicBucket || isSignedRequest;
|
||||
const cacheHeader = "max-age=604800, immutable";
|
||||
let contentType =
|
||||
(fileName ? mime.lookup(fileName) : undefined) ||
|
||||
"application/octet-stream";
|
||||
|
||||
if (skipAuthorize) {
|
||||
ctx.set("Cache-Control", cacheHeader);
|
||||
ctx.set(
|
||||
"Content-Type",
|
||||
(fileName ? mime.lookup(fileName) : undefined) ||
|
||||
"application/octet-stream"
|
||||
);
|
||||
ctx.attachment(fileName);
|
||||
} else {
|
||||
if (!skipAuthorize) {
|
||||
const attachment = await Attachment.findOne({
|
||||
where: { key },
|
||||
rejectOnEmpty: true,
|
||||
});
|
||||
|
||||
authorize(actor, "read", attachment);
|
||||
|
||||
ctx.set("Cache-Control", cacheHeader);
|
||||
ctx.set("Content-Type", attachment.contentType);
|
||||
ctx.attachment(attachment.name, {
|
||||
type: FileStorage.getContentDisposition(attachment.contentType),
|
||||
});
|
||||
contentType = attachment.contentType;
|
||||
}
|
||||
|
||||
ctx.set("Cache-Control", cacheHeader);
|
||||
ctx.set("Content-Type", contentType);
|
||||
ctx.attachment(fileName, {
|
||||
type: forceDownload
|
||||
? "attachment"
|
||||
: FileStorage.getContentDisposition(contentType),
|
||||
});
|
||||
|
||||
// Handle byte range requests
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
|
||||
const stats = await (FileStorage as LocalStorage).stat(key);
|
||||
|
||||
@@ -24,6 +24,7 @@ export const FilesGetSchema = z.object({
|
||||
.optional()
|
||||
.transform((val) => (val ? ValidateKey.sanitize(val) : undefined)),
|
||||
sig: z.string().optional(),
|
||||
download: z.string().optional(),
|
||||
})
|
||||
.refine((obj) => !(isEmpty(obj.key) && isEmpty(obj.sig)), {
|
||||
message: "One of key or sig is required",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Transaction } from "sequelize";
|
||||
import { Optional } from "utility-types";
|
||||
import { Document, Event, User } from "@server/models";
|
||||
import { ProsemirrorHelper } from "@server/models/helpers/ProsemirrorHelper";
|
||||
import { TextHelper } from "@server/models/helpers/TextHelper";
|
||||
|
||||
type Props = Optional<
|
||||
@@ -58,6 +59,12 @@ export default async function documentCreator({
|
||||
}: Props): Promise<Document> {
|
||||
const templateId = templateDocument ? templateDocument.id : undefined;
|
||||
|
||||
if (state && templateDocument) {
|
||||
throw new Error(
|
||||
"State cannot be set when creating a document from a template"
|
||||
);
|
||||
}
|
||||
|
||||
if (urlId) {
|
||||
const existing = await Document.unscoped().findOne({
|
||||
attributes: ["id"],
|
||||
@@ -103,6 +110,12 @@ export default async function documentCreator({
|
||||
ip,
|
||||
transaction
|
||||
),
|
||||
content: templateDocument
|
||||
? ProsemirrorHelper.replaceTemplateVariables(
|
||||
templateDocument.content,
|
||||
user
|
||||
)
|
||||
: undefined,
|
||||
state,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,7 +19,9 @@ import { schema, parser } from "@server/editor";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import { trace } from "@server/logging/tracing";
|
||||
import Attachment from "@server/models/Attachment";
|
||||
import User from "@server/models/User";
|
||||
import FileStorage from "@server/storage/files";
|
||||
import { TextHelper } from "./TextHelper";
|
||||
|
||||
export type HTMLOptions = {
|
||||
/** A title, if it should be included */
|
||||
@@ -172,6 +174,29 @@ export class ProsemirrorHelper {
|
||||
return removeMarksInner(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all template variables in the node.
|
||||
*
|
||||
* @param data The ProsemirrorData object to replace variables in
|
||||
* @param user The user to use for replacing variables
|
||||
* @returns The content with variables replaced
|
||||
*/
|
||||
static replaceTemplateVariables(data: ProsemirrorData, user: User) {
|
||||
function replace(node: ProsemirrorData) {
|
||||
if (node.type === "text" && node.text) {
|
||||
node.text = TextHelper.replaceTemplateVariables(node.text, user);
|
||||
}
|
||||
|
||||
if (node.content) {
|
||||
node.content.forEach(replace);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
return replace(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the document as a plain JSON object with attachment URLs signed.
|
||||
*
|
||||
|
||||
@@ -32,7 +32,8 @@ export class TextHelper {
|
||||
return text
|
||||
.replace(/{date}/g, startCase(getCurrentDateAsString(locales)))
|
||||
.replace(/{time}/g, startCase(getCurrentTimeAsString(locales)))
|
||||
.replace(/{datetime}/g, startCase(getCurrentDateTimeAsString(locales)));
|
||||
.replace(/{datetime}/g, startCase(getCurrentDateTimeAsString(locales)))
|
||||
.replace(/{author}/g, user.name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,10 +28,6 @@ export default class S3Storage extends BaseStorage {
|
||||
this.client = new S3Client({
|
||||
bucketEndpoint: env.AWS_S3_ACCELERATE_URL ? true : false,
|
||||
forcePathStyle: env.AWS_S3_FORCE_PATH_STYLE,
|
||||
credentials: {
|
||||
accessKeyId: env.AWS_ACCESS_KEY_ID || "",
|
||||
secretAccessKey: env.AWS_SECRET_ACCESS_KEY || "",
|
||||
},
|
||||
region: env.AWS_REGION,
|
||||
endpoint: this.getEndpoint(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user