From 29bea277a1bd84954373fb00d32609d5dba15cff Mon Sep 17 00:00:00 2001 From: Alex Hoyau Date: Thu, 14 Sep 2023 14:57:29 +0300 Subject: [PATCH] duplicate website api --- public/assets/favicon.ico | Bin 0 -> 15406 bytes src/ts/client/publication-transformers.ts | 14 ++++----- src/ts/constants.ts | 1 + src/ts/plugins/server/FtpConnector.ts | 15 ++++++++-- src/ts/server/api/websiteApi.ts | 33 ++++++++++++++++++++-- src/ts/server/connectors/FsStorage.ts | 22 +++++++++++++++ src/ts/server/connectors/connectors.ts | 2 +- src/ts/types.ts | 1 + 8 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 public/assets/favicon.ico diff --git a/public/assets/favicon.ico b/public/assets/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..f6c95f42697ab56729df71cfeb4825de4c929716 GIT binary patch literal 15406 zcmeHNYfuzd79ML;`}nh!t=d=Z)^6A;W2G$1_y9&;0xBJk3kqf9T?uAf`Fjn zD~k^>t5IAL@sSu2qKKMBHxeZ#LDU$sNt9^9s_Qd`DAH%o8SJ5ZrhBFbTK31C@kLZ=ZYb>2t3_F-Gwd#mg@%uyjzQzNAn%D-;R`hr!>k{Ys(Oj@KqldiMWu3dNb< zC={>ZJ!pa!gV(VTJffna-ma^wgQB9Mfe8~P{7&#D&PBS1?j;+t&Ckzo0z8f!IRd4* zURTz}gm$e74mU$YSHz4JU7_A+Y)RT|U#FGujRxSW2w-wn@@yYvz5(Uok4*OLbG%%l zH?h@X?U}Avo-OG(k#x$!mYyMK|8YFeejuw7Rz=*mu+NVHaQ7DA|0IrQe|6E{Eo=)S z0iw47xXc!?zZ}i8Z%aODVXs{aFz25m*{@f|R$icR)A zV!!0s$8D5gUzcUF-xl+=$)4J5-aZNTXA({Jb#b4Y?9&ZHwp{&Fr%qK)_i#MaQXc^Q zSMkO6U>!;aeeiH%hsi#*XwW`vUqASlwSbeS-!ZZ^7z|Cly}i)T&;ad+1EKqLFmzWZ z!RILja4>c|=vCcD#AbJ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)3j;ZU5wQ+ifqa z|4<)3rv;{Hxo97_mGLH2L|E?OHg9{1(}ZFL^R|~;zj6P{YVkbWos4RXJ@44`|6DD9 z508*;_L^+|gY9qhp#$ln?SId(2{uOC-h*UVWEp3&dd*8&^-~=#$B5<<9~!D)n}qm5 zpKX24<<`N9{xP`L@dtz>=5t*!$5^ipnZ{f^sRBaJxlmv*ZZPFQNjv)vb_jou{g|~5 zr0oAoD-@5{=Iv)7cxw*?ZMX=52#<(t+MjS7*YvzdE9TDsh`G-(sQLGJ{XNuu1MwZ= zd!^D5{AM{Dp_;9PD{Uc``l$|Qu^$V}Wt8J@O*#!r)dS*v0L@cq-V%tFsohnZuYhu< z3YAgsSTN^~FAM=8y? z@ArwQ{zBAm+>axo->siUe zmkW18MfmrqpZ4!sqEN#?@^S{-Ul@MHha|5b+0w6zcZ2f9-onW8f%3UwP#&n}p=fpt zXl5*f5ZqfWgkbM-@Cz#kuld4o3)RV{AARjQ`rXCR1aV4Tzq8f;*x&WERzI2`PO187 zE${T{)9~QI10Fg$I>6W0_kXtjPTZuyTo-9&*B`N-ub^Laxx2eR#{C97&@~*R9^gFz z+;yhWI44fx7SlzVN&EQm<9~|hz6d?SVvhj&VKmnD7o(w>%R!vPEu`t0R$tQ2wRv&= Kq6PlnTHwFFtnZ%y literal 0 HcmV?d00001 diff --git a/src/ts/client/publication-transformers.ts b/src/ts/client/publication-transformers.ts index c7102bdfb..90ebdc134 100644 --- a/src/ts/client/publication-transformers.ts +++ b/src/ts/client/publication-transformers.ts @@ -68,13 +68,13 @@ export const publicationTransformerDefault: PublicationTransformer = { // Define files URLs transformPermalink(link: string, type: ClientSideFileType, initiator: Initiator): string { switch(initiator) { - case Initiator.HTML: - return link - case Initiator.CSS: - // In case of a link from a CSS file, we need to go up one level - return `../${link.replace(/^\//, '')}` - default: - throw new Error(`Unknown initiator ${initiator}`) + case Initiator.HTML: + return link + case Initiator.CSS: + // In case of a link from a CSS file, we need to go up one level + return `../${link.replace(/^\//, '')}` + default: + throw new Error(`Unknown initiator ${initiator}`) } }, // Define how files are named diff --git a/src/ts/constants.ts b/src/ts/constants.ts index 7632bd27f..b0fb8d261 100644 --- a/src/ts/constants.ts +++ b/src/ts/constants.ts @@ -45,6 +45,7 @@ export const API_WEBSITE_READ = '/' export const API_WEBSITE_WRITE = '/' export const API_WEBSITE_CREATE = '/' export const API_WEBSITE_DELETE = '/' +export const API_WEBSITE_DUPLICATE = '/duplicate' export const API_WEBSITE_LIST = '/' export const API_WEBSITE_ASSET_READ = '/assets' export const API_WEBSITE_ASSETS_WRITE = '/assets' diff --git a/src/ts/plugins/server/FtpConnector.ts b/src/ts/plugins/server/FtpConnector.ts index 2694a0cce..29eb3d232 100644 --- a/src/ts/plugins/server/FtpConnector.ts +++ b/src/ts/plugins/server/FtpConnector.ts @@ -23,9 +23,10 @@ import { WEBSITE_DATA_FILE, WEBSITE_META_DATA_FILE } from '../../constants' import { ConnectorType, ConnectorUser, WebsiteMeta, FileMeta, JobData, JobStatus, WebsiteId, PublicationJobData, WebsiteMetaFileContent, defaultWebsiteData, WebsiteData, ConnectorOptions } from '../../types' import { ServerConfig } from '../../server/config' import { join } from 'path' -import { type } from 'os' +import { tmpdir } from 'os' import { v4 as uuid } from 'uuid' import { JobManager } from '../../server/jobs' +import { mkdtemp } from 'fs/promises' /** * @fileoverview FTP connector for Silex @@ -338,7 +339,6 @@ export default class FtpConnector implements StorageConnector { async getLoginForm(session: FtpSession, redirectTo: string): Promise { const { host, user, pass, port, secure, publicationPath, storageRootPath, websiteUrl } = this.sessionData(session) - requiredParam(type, 'connector type') return `