From efec25e4fb6a3d55bb02814e0e903e2bfe66478f Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Tue, 11 Mar 2025 06:57:55 +0100 Subject: [PATCH] wip --- frontend/build.sh | 21 -- frontend/next-env.d.ts | 1 - frontend/next.config.js | 10 +- frontend/package.json | 2 - .../hooks/yjs/use-realtime-connection.ts | 44 ++-- .../hooks/yjs/use-websocket-url.ts | 9 +- .../respond-to-matching-request.ts | 74 ------ .../src/pages/api/private/auth/local/login.ts | 13 -- frontend/src/pages/api/private/auth/logout.ts | 15 -- frontend/src/pages/api/private/config.ts | 79 ------- .../src/pages/api/private/groups/_EVERYONE.ts | 18 -- .../pages/api/private/groups/_LOGGED_IN.ts | 18 -- .../pages/api/private/groups/hedgedoc-devs.ts | 18 -- frontend/src/pages/api/private/me/history.ts | 47 ---- frontend/src/pages/api/private/me/index.ts | 25 -- frontend/src/pages/api/private/me/media.ts | 29 --- frontend/src/pages/api/private/media.ts | 33 --- .../pages/api/private/notes/features/index.ts | 57 ----- .../api/private/notes/features/revisions/0.ts | 215 ------------------ .../api/private/notes/features/revisions/1.ts | 163 ------------- .../private/notes/features/revisions/index.ts | 35 --- frontend/src/pages/api/private/notes/index.ts | 58 ----- .../api/private/notes/slide-example/index.ts | 65 ------ frontend/src/pages/api/private/tokens.ts | 29 --- .../pages/api/private/users/profile/erik.ts | 18 -- .../pages/api/private/users/profile/mock.ts | 18 -- .../pages/api/private/users/profile/molly.ts | 18 -- .../pages/api/private/users/profile/tilman.ts | 18 -- frontend/src/utils/test-modes.js | 9 +- 29 files changed, 25 insertions(+), 1134 deletions(-) delete mode 100644 frontend/src/handler-utils/respond-to-matching-request.ts delete mode 100644 frontend/src/pages/api/private/auth/local/login.ts delete mode 100644 frontend/src/pages/api/private/auth/logout.ts delete mode 100644 frontend/src/pages/api/private/config.ts delete mode 100644 frontend/src/pages/api/private/groups/_EVERYONE.ts delete mode 100644 frontend/src/pages/api/private/groups/_LOGGED_IN.ts delete mode 100644 frontend/src/pages/api/private/groups/hedgedoc-devs.ts delete mode 100644 frontend/src/pages/api/private/me/history.ts delete mode 100644 frontend/src/pages/api/private/me/index.ts delete mode 100644 frontend/src/pages/api/private/me/media.ts delete mode 100644 frontend/src/pages/api/private/media.ts delete mode 100644 frontend/src/pages/api/private/notes/features/index.ts delete mode 100644 frontend/src/pages/api/private/notes/features/revisions/0.ts delete mode 100644 frontend/src/pages/api/private/notes/features/revisions/1.ts delete mode 100644 frontend/src/pages/api/private/notes/features/revisions/index.ts delete mode 100644 frontend/src/pages/api/private/notes/index.ts delete mode 100644 frontend/src/pages/api/private/notes/slide-example/index.ts delete mode 100644 frontend/src/pages/api/private/tokens.ts delete mode 100644 frontend/src/pages/api/private/users/profile/erik.ts delete mode 100644 frontend/src/pages/api/private/users/profile/mock.ts delete mode 100644 frontend/src/pages/api/private/users/profile/molly.ts delete mode 100644 frontend/src/pages/api/private/users/profile/tilman.ts diff --git a/frontend/build.sh b/frontend/build.sh index 27575a9b7..e848dbd62 100755 --- a/frontend/build.sh +++ b/frontend/build.sh @@ -7,31 +7,10 @@ set -e -cleanup () { - if [ -d ../tmp/src/pages/api ]; then - echo "πŸ¦” > Moving Mock API files back" - mv ../tmp/src/pages/api src/pages - fi -} - -trap cleanup EXIT - echo "πŸ¦” Frontend Production Build" echo "πŸ¦” > Clearing existing builds" rm -rf dist/ -echo "πŸ¦” > Preparing files" -if [ ! -z "${NEXT_PUBLIC_USE_MOCK_API}" ]; then - echo "πŸ¦” > Keeping Mock API because NEXT_PUBLIC_USE_MOCK_API is set" - if [ ! -d src/pages/api ]; then - echo "πŸ¦” > ⚠️ src/pages/api doesn't exist" - fi -else - echo "πŸ¦” > Moving Mock API because NEXT_PUBLIC_USE_MOCK_API is unset" - mkdir -p ../tmp/src/pages - mv src/pages/api ../tmp/src/pages/ -fi - echo "πŸ¦” > Building" BUILD_TIME=true next build diff --git a/frontend/next-env.d.ts b/frontend/next-env.d.ts index 725dd6f24..40c3d6809 100644 --- a/frontend/next-env.d.ts +++ b/frontend/next-env.d.ts @@ -1,6 +1,5 @@ /// /// -/// // NOTE: This file should not be edited // see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. diff --git a/frontend/next.config.js b/frontend/next.config.js index bea576648..3efd85471 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -const { isMockMode, isTestMode, isProfilingMode, isBuildTime } = require('./src/utils/test-modes') +const { isTestMode, isProfilingMode, isBuildTime } = require('./src/utils/test-modes') const path = require('path') const CopyWebpackPlugin = require('copy-webpack-plugin') const withBundleAnalyzer = require('@next/bundle-analyzer')({ @@ -21,14 +21,6 @@ if (isTestMode) { `) } -if (isMockMode) { - console.warn(`This build runs in mock mode. This means: - - No real data. All API responses are mocked - - No persistent data - - No realtime editing -`) -} - if (isBuildTime) { console.warn(`This process runs in build mode. During build time this means: - Editor and Renderer base urls are '' (empty string) diff --git a/frontend/package.json b/frontend/package.json index c7ede9520..1d3f4602d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,7 +5,6 @@ "license": "AGPL-3.0", "scripts": { "build": "dotenv -v NODE_ENV=production -c production -- ./build.sh", - "build:mock": "dotenv -v NEXT_PUBLIC_USE_MOCK_API=true -- ./build.sh", "build:test": "dotenv -v NODE_ENV=test -v NEXT_PUBLIC_TEST_MODE=true -c test -- ./build.sh", "analyze": "cross-env ANALYZE=true yarn build --profile", "format": "prettier -c \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"", @@ -14,7 +13,6 @@ "lint:fix": "eslint --fix --ext .ts,.tsx src", "start": "cross-env PORT=${HD_FRONTEND_PORT:-3001} node dist/frontend/server.js", "start:dev": "cross-env PORT=${HD_FRONTEND_PORT:-3001} next dev", - "start:dev:mock": "cross-env PORT=${HD_FRONTEND_PORT:-3001} NEXT_PUBLIC_USE_MOCK_API=true HD_BASE_URL=\"http://localhost:3001/\" HD_RENDERER_BASE_URL=\"http://127.0.0.1:3001/\" next dev", "start:dev:test": "cross-env PORT=${HD_FRONTEND_PORT:-3001} NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true next dev", "test:e2e:open": "cypress open", "test:e2e": "cypress run --browser chrome", diff --git a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-realtime-connection.ts b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-realtime-connection.ts index a461b5ac0..7b2b1920b 100644 --- a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-realtime-connection.ts +++ b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-realtime-connection.ts @@ -4,13 +4,11 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { useApplicationState } from '../../../../../hooks/common/use-application-state' -import { getGlobalState } from '../../../../../redux' import { setRealtimeConnectionState } from '../../../../../redux/realtime/methods' import { Logger } from '../../../../../utils/logger' -import { isMockMode } from '../../../../../utils/test-modes' import { FrontendWebsocketAdapter } from './frontend-websocket-adapter' import { useWebsocketUrl } from './use-websocket-url' -import { DisconnectReason, MessageTransporter, MockedBackendTransportAdapter } from '@hedgedoc/commons' +import { DisconnectReason, MessageTransporter } from '@hedgedoc/commons' import type { Listener } from 'eventemitter2' import { useCallback, useEffect, useMemo, useRef } from 'react' @@ -30,29 +28,25 @@ export const useRealtimeConnection = (): MessageTransporter => { const reconnectCount = useRef(0) const disconnectReason = useRef(undefined) const establishWebsocketConnection = useCallback(() => { - if (isMockMode) { - logger.debug('Creating Loopback connection...') - messageTransporter.setAdapter( - new MockedBackendTransportAdapter(getGlobalState().noteDetails?.markdownContent.plain ?? '') - ) - } else if (websocketUrl) { - logger.debug(`Connecting to ${websocketUrl.toString()}`) - - const socket = new WebSocket(websocketUrl.toString()) - socket.addEventListener('error', () => { - const timeout = WEBSOCKET_RECONNECT_INTERVAL + reconnectCount.current * 1000 + Math.random() * 1000 - setTimeout( - () => { - reconnectCount.current += 1 - establishWebsocketConnection() - }, - Math.max(timeout, WEBSOCKET_RECONNECT_MAX_DURATION) - ) - }) - socket.addEventListener('open', () => { - messageTransporter.setAdapter(new FrontendWebsocketAdapter(socket)) - }) + if (!websocketUrl) { + return } + + logger.debug(`Connecting to ${websocketUrl.toString()}`) + const socket = new WebSocket(websocketUrl.toString()) + socket.addEventListener('error', () => { + const timeout = WEBSOCKET_RECONNECT_INTERVAL + reconnectCount.current * 1000 + Math.random() * 1000 + setTimeout( + () => { + reconnectCount.current += 1 + establishWebsocketConnection() + }, + Math.max(timeout, WEBSOCKET_RECONNECT_MAX_DURATION) + ) + }) + socket.addEventListener('open', () => { + messageTransporter.setAdapter(new FrontendWebsocketAdapter(socket)) + }) }, [messageTransporter, websocketUrl]) const isConnected = useApplicationState((state) => state.realtimeStatus.isConnected) diff --git a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-websocket-url.ts b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-websocket-url.ts index 0f514e8f8..5c3b4dece 100644 --- a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-websocket-url.ts +++ b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-websocket-url.ts @@ -5,11 +5,13 @@ */ import { useApplicationState } from '../../../../../hooks/common/use-application-state' import { useBaseUrl } from '../../../../../hooks/common/use-base-url' -import { isMockMode } from '../../../../../utils/test-modes' import { useMemo } from 'react' +import { Logger } from '../../../../../utils/logger' const LOCAL_FALLBACK_URL = 'ws://localhost:8080/realtime/' +const logger = new Logger('WebsocketUrl') + /** * Provides the URL for the realtime endpoint. */ @@ -18,16 +20,13 @@ export const useWebsocketUrl = (): URL | null => { const baseUrl = useBaseUrl() const websocketUrl = useMemo(() => { - if (isMockMode) { - return LOCAL_FALLBACK_URL - } try { const backendBaseUrlParsed = new URL(baseUrl) backendBaseUrlParsed.protocol = backendBaseUrlParsed.protocol === 'https:' ? 'wss:' : 'ws:' backendBaseUrlParsed.pathname += 'realtime' return backendBaseUrlParsed.toString() } catch (e) { - console.error(e) + logger.error(e) return LOCAL_FALLBACK_URL } }, [baseUrl]) diff --git a/frontend/src/handler-utils/respond-to-matching-request.ts b/frontend/src/handler-utils/respond-to-matching-request.ts deleted file mode 100644 index 6e3eb344b..000000000 --- a/frontend/src/handler-utils/respond-to-matching-request.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import { isMockMode, isTestMode } from '../utils/test-modes' -import type { NextApiRequest, NextApiResponse } from 'next' - -export enum HttpMethod { - GET = 'GET', - POST = 'POST', - PUT = 'PUT', - DELETE = 'DELETE' -} - -/** - * Intercepts a mock HTTP request, checks the used request method and responds with given response content or an error - * that the request method is not allowed. - * - * @param method The expected HTTP method. - * @param req The request object. - * @param res The response object. - * @param response The response data that will be returned when the HTTP method was the expected one. - * @param statusCode The status code with which the response will be sent. - * @param respondMethodNotAllowedOnMismatch If set and the method can't process the request then a 405 will be returned. Used for chaining multiple calls together. - * @return {@link true} if the HTTP method of the request is the expected one, {@link false} otherwise. - */ -export const respondToMatchingRequest = ( - method: HttpMethod, - req: NextApiRequest, - res: NextApiResponse, - response: T, - statusCode = 200, - respondMethodNotAllowedOnMismatch = true -): boolean => { - if (!isMockMode) { - res.status(404).send('Mock API is disabled') - return false - } else if (method === req.method) { - res.status(statusCode).json(response) - return true - } else if (respondMethodNotAllowedOnMismatch) { - res.status(405).send('Method not allowed') - return true - } else { - return false - } -} - -/** - * Intercepts a mock HTTP request that is only allowed in test mode. - * Such requests can only be issued from localhost and only if mock API is activated. - * - * @param req The request object. - * @param res The response object. - * @param response The response data that will be returned when the HTTP method was the expected one. - */ -export const respondToTestRequest = (req: NextApiRequest, res: NextApiResponse, response: () => T): boolean => { - if (!isMockMode) { - res.status(404).send('Mock API is disabled') - } else if (req.method !== HttpMethod.POST) { - res.status(405).send('Method not allowed') - } else if (!isTestMode) { - res.status(404).send('Route only available in test mode') - } else if ( - req.socket.remoteAddress === undefined || - !['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(req.socket.remoteAddress) - ) { - res.status(403).send(`Request must come from localhost but was ${req.socket.remoteAddress}`) - } else { - res.status(200).json(response()) - } - return true -} diff --git a/frontend/src/pages/api/private/auth/local/login.ts b/frontend/src/pages/api/private/auth/local/login.ts deleted file mode 100644 index 40dc07a53..000000000 --- a/frontend/src/pages/api/private/auth/local/login.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - res.status(200).setHeader('Set-Cookie', ['mock-session=1; Path=/']).json({}) -} - -export default handler diff --git a/frontend/src/pages/api/private/auth/logout.ts b/frontend/src/pages/api/private/auth/logout.ts deleted file mode 100644 index a56102c4b..000000000 --- a/frontend/src/pages/api/private/auth/logout.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - res.setHeader('Set-Cookie', 'mock-session=0; Path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT').status(200).json({ - redirect: '/' - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/config.ts b/frontend/src/pages/api/private/config.ts deleted file mode 100644 index 74973cb08..000000000 --- a/frontend/src/pages/api/private/config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { FrontendConfig } from '../../../api/config/types' -import { AuthProviderType, GuestAccessLevel } from '../../../api/config/types' -import { - HttpMethod, - respondToMatchingRequest, - respondToTestRequest -} from '../../../handler-utils/respond-to-matching-request' -import { isTestMode } from '../../../utils/test-modes' -import type { NextApiRequest, NextApiResponse } from 'next' - -const initialConfig: FrontendConfig = { - allowRegister: true, - allowProfileEdits: true, - allowChooseUsername: true, - branding: { - name: 'DEMO Corp', - logo: '/public/img/demo.png' - }, - guestAccess: GuestAccessLevel.WRITE, - useImageProxy: false, - specialUrls: { - privacy: 'https://example.com/privacy', - termsOfUse: 'https://example.com/termsOfUse', - imprint: 'https://example.com/imprint' - }, - version: { - major: isTestMode ? 0 : 2, - minor: 0, - patch: 0, - preRelease: isTestMode ? undefined : '', - commit: 'mock' - }, - plantumlServer: isTestMode ? 'http://mock-plantuml.local' : 'https://www.plantuml.com/plantuml', - maxDocumentLength: isTestMode ? 200 : 1000000, - authProviders: [ - { - type: AuthProviderType.LOCAL - }, - { - type: AuthProviderType.LDAP, - identifier: 'test-ldap', - providerName: 'Test LDAP' - }, - { - type: AuthProviderType.OIDC, - identifier: 'test-oidc', - providerName: 'Test OIDC' - } - ] -} - -let currentConfig: FrontendConfig = initialConfig - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - const responseSuccessful = respondToMatchingRequest( - HttpMethod.GET, - req, - res, - currentConfig, - 200, - false - ) - if (!responseSuccessful) { - respondToTestRequest(req, res, () => { - currentConfig = { - ...initialConfig, - ...(req.body as FrontendConfig) - } - return currentConfig - }) - } -} - -export default handler diff --git a/frontend/src/pages/api/private/groups/_EVERYONE.ts b/frontend/src/pages/api/private/groups/_EVERYONE.ts deleted file mode 100644 index c921171fe..000000000 --- a/frontend/src/pages/api/private/groups/_EVERYONE.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { GroupInfo } from '../../../../api/group/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - name: '_EVERYONE', - displayName: 'Everyone', - special: true - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/groups/_LOGGED_IN.ts b/frontend/src/pages/api/private/groups/_LOGGED_IN.ts deleted file mode 100644 index ef273f9b7..000000000 --- a/frontend/src/pages/api/private/groups/_LOGGED_IN.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { GroupInfo } from '../../../../api/group/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - name: '_LOGGED_IN', - displayName: 'All registered users', - special: true - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/groups/hedgedoc-devs.ts b/frontend/src/pages/api/private/groups/hedgedoc-devs.ts deleted file mode 100644 index 4b19a666a..000000000 --- a/frontend/src/pages/api/private/groups/hedgedoc-devs.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { GroupInfo } from '../../../../api/group/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - name: 'hedgedoc-devs', - displayName: 'HedgeDoc devs', - special: true - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/me/history.ts b/frontend/src/pages/api/private/me/history.ts deleted file mode 100644 index f9b83b76c..000000000 --- a/frontend/src/pages/api/private/me/history.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { HistoryEntry } from '../../../../api/history/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - respondToMatchingRequest(HttpMethod.GET, req, res, [ - { - identifier: 'slide-example', - title: 'Slide example', - lastVisitedAt: '2020-05-30T15:20:36.088Z', - pinStatus: true, - tags: ['features', 'cool', 'updated'], - owner: null - }, - { - identifier: 'features', - title: 'Features', - lastVisitedAt: '2020-05-31T15:20:36.088Z', - pinStatus: true, - tags: ['features', 'cool', 'updated'], - owner: null - }, - { - identifier: 'ODakLc2MQkyyFc_Xmb53sg', - title: 'Non existent', - lastVisitedAt: '2020-05-25T19:48:14.025Z', - pinStatus: false, - tags: [], - owner: null - }, - { - identifier: 'l8JuWxApTR6Fqa0LCrpnLg', - title: 'Non existent', - lastVisitedAt: '2020-05-24T16:04:36.433Z', - pinStatus: false, - tags: ['agenda', 'HedgeDoc community', 'community call'], - owner: 'test' - } - ]) -} - -export default handler diff --git a/frontend/src/pages/api/private/me/index.ts b/frontend/src/pages/api/private/me/index.ts deleted file mode 100644 index 4432f3014..000000000 --- a/frontend/src/pages/api/private/me/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { LoginUserInfo } from '../../../../api/me/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - const cookieSet = req.headers?.['cookie']?.split(';').find((value) => value.trim() === 'mock-session=1') !== undefined - if (!cookieSet) { - res.status(403).json({}) - return - } - respondToMatchingRequest(HttpMethod.GET, req, res, { - username: 'mock', - photoUrl: '/public/img/avatar.png', - displayName: 'Mock User', - authProvider: 'local', - email: 'mock@hedgedoc.test' - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/me/media.ts b/frontend/src/pages/api/private/me/media.ts deleted file mode 100644 index fbdfc7074..000000000 --- a/frontend/src/pages/api/private/me/media.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { MediaUpload } from '../../../../api/media/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - respondToMatchingRequest(HttpMethod.GET, req, res, [ - { - username: 'tilman', - createdAt: '2022-03-20T20:36:32Z', - uuid: '5355ed83-7e12-4db0-95ed-837e124db08c', - fileName: 'dummy.png', - noteId: 'features' - }, - { - username: 'tilman', - createdAt: '2022-03-20T20:36:57+0000', - uuid: '656745ab-fbf9-47f1-a745-abfbf9a7f10c', - fileName: 'dummy2.png', - noteId: null - } - ]) -} - -export default handler diff --git a/frontend/src/pages/api/private/media.ts b/frontend/src/pages/api/private/media.ts deleted file mode 100644 index e48473500..000000000 --- a/frontend/src/pages/api/private/media.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { MediaUpload } from '../../../api/media/types' -import { HttpMethod, respondToMatchingRequest } from '../../../handler-utils/respond-to-matching-request' -import { isMockMode, isTestMode } from '../../../utils/test-modes' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = async (req: NextApiRequest, res: NextApiResponse): Promise => { - if (isMockMode && !isTestMode) { - await new Promise((resolve) => { - setTimeout(resolve, 3000) - }) - } - - respondToMatchingRequest( - HttpMethod.POST, - req, - res, - { - uuid: 'e81f57cd-5866-4253-9f57-cd5866a253ca', - fileName: 'avatar.png', - noteId: null, - username: 'test', - createdAt: '2022-02-27T21:54:23.856Z' - }, - 201 - ) -} - -export default handler diff --git a/frontend/src/pages/api/private/notes/features/index.ts b/frontend/src/pages/api/private/notes/features/index.ts deleted file mode 100644 index ef76d20ed..000000000 --- a/frontend/src/pages/api/private/notes/features/index.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { Note } from '../../../../../api/notes/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - content: - '---\ntitle: Features\ndescription: Many features, such wow!\nrobots: noindex\ntags:\n - hedgedoc\n - demo\n - react\nopengraph:\n title: Features\n---\n# Embedding demo\n[TOC]\n\n## Vega-Lite\n\n```vega-lite\n\n{\n "$schema": "https://vega.github.io/schema/vega-lite/v5.json",\n "description": "Reproducing http://robslink.com/SAS/democd91/pyramid_pie.htm",\n "data": {\n "values": [\n {"category": "Sky", "value": 75, "order": 3},\n {"category": "Shady side of a pyramid", "value": 10, "order": 1},\n {"category": "Sunny side of a pyramid", "value": 15, "order": 2}\n ]\n },\n "mark": {"type": "arc", "outerRadius": 80},\n "encoding": {\n "theta": {\n "field": "value", "type": "quantitative",\n "scale": {"range": [2.35619449, 8.639379797]},\n "stack": true\n },\n "color": {\n "field": "category", "type": "nominal",\n "scale": {\n "domain": ["Sky", "Shady side of a pyramid", "Sunny side of a pyramid"],\n "range": ["#416D9D", "#674028", "#DEAC58"]\n },\n "legend": {\n "orient": "none",\n "title": null,\n "columns": 1,\n "legendX": 200,\n "legendY": 80\n }\n },\n "order": {\n "field": "order"\n }\n },\n "view": {"stroke": null}\n}\n\n\n```\n\n## GraphViz\n\n```graphviz\ngraph {\n a -- b\n a -- b\n b -- a [color=blue]\n}\n```\n\n```graphviz\ndigraph structs {\n node [shape=record];\n struct1 [label=" left| mid\ dle| right"];\n struct2 [label=" one| two"];\n struct3 [label="hello\nworld |{ b |{c| d|e}| f}| g | h"];\n struct1:f1 -> struct2:f0;\n struct1:f2 -> struct3:here;\n}\n```\n\n```graphviz\ndigraph G {\n main -> parse -> execute;\n main -> init;\n main -> cleanup;\n execute -> make_string;\n execute -> printf\n init -> make_string;\n main -> printf;\n execute -> compare;\n}\n```\n\n```graphviz\ndigraph D {\n node [fontname="Arial"];\n node_A [shape=record label="shape=record|{above|middle|below}|right"];\n node_B [shape=plaintext label="shape=plaintext|{curly|braces and|bars without}|effect"];\n}\n```\n\n```graphviz\ndigraph D {\n A -> {B, C, D} -> {F}\n}\n```\n\n## High Res Image\n\n![Wheat Field with Cypresses](/public/img/highres.jpg)\n\n## Sequence Diagram (deprecated)\n\n```sequence\nTitle: Here is a title\nnote over A: asdd\nA->B: Normal line\nB-->C: Dashed line\nC->>D: Open arrow\nD-->>A: Dashed open arrow\nparticipant IOOO\n```\n\n## Mermaid\n\n```mermaid\ngantt\n title A Gantt Diagram\n\n section Section\n A task: a1, 2014-01-01, 30d\n Another task: after a1, 20d\n\n section Another\n Task in sec: 2014-01-12, 12d\n Another task: 24d\n```\n\n## Flowchart\n\n```flow\nst=>start: Start\ne=>end: End\nop=>operation: My Operation\nop2=>operation: lalala\ncond=>condition: Yes or No?\n\nst->op->op2->cond\ncond(yes)->e\ncond(no)->op2\n```\n\n## ABC\n\n```abc\nX:1\nT:Speed the Plough\nM:4/4\nC:Trad.\nK:G\n|:GABc dedB|dedB dedB|c2ec B2dB|c2A2 A2BA|\nGABc dedB|dedB dedB|c2ec B2dB|A2F2 G4:|\n|:g2gf gdBd|g2f2 e2d2|c2ec B2dB|c2A2 A2df|\ng2gf g2Bd|g2f2 e2d2|c2ec B2dB|A2F2 G4:|\n```\n\n## CSV\n\n```csv delimiter=; header\nUsername; Identifier;First name;Last name\n"booker12; rbooker";9012;Rachel;Booker\ngrey07;2070;Laura;Grey\njohnson81;4081;Craig;Johnson\njenkins46;9346;Mary;Jenkins\nsmith79;5079;Jamie;Smith\n```\n\n## some plain text\n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n## KaTeX\nYou can render *LaTeX* mathematical expressions using **KaTeX**, as on [math.stackexchange.com](https://math.stackexchange.com/):\n\nThe *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral\n\n$$\nx = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.\n$$\n\n$$\n\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,.\n$$\n\n> More information about **LaTeX** mathematical expressions [here](https://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference).\n\n## Blockquote\n> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n> [color=red] [name=John Doe] [time=2020-06-21 22:50]\n\n## Slideshare\n{%slideshare mazlan1/internet-of-things-the-tip-of-an-iceberg %}\n\n## Gist\nhttps://gist.github.com/schacon/1\n\n## YouTube\nhttps://www.youtube.com/watch?v=YE7VzlLtp-4\n\n## Vimeo\nhttps://vimeo.com/23237102\n\n## Asciinema\nhttps://asciinema.org/a/117928\n\n## PDF\n{%pdf https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf %}\n\n## Code highlighting\n```js=\nvar s = "JavaScript syntax highlighting";\nalert(s);\nfunction $initHighlight(block, cls) {\n try {\n if (cls.search(/\\bno\\-highlight\\b/) != -1)\n return process(block, true, 0x0F) +\n \' class=""\';\n } catch (e) {\n /* handle exception */\n }\n for (var i = 0 / 2; i < classes.length; i++) {\n if (checkCondition(classes[i]) === undefined)\n return /\\d+[\\s/]/g;\n }\n}\n```\n\n## PlantUML\n```plantuml\n@startuml\nparticipant Alice\nparticipant "The **Famous** Bob" as Bob\n\nAlice -> Bob : hello --there--\n... Some ~~long delay~~ ...\nBob -> Alice : ok\nnote left\n This is **bold**\n This is //italics//\n This is ""monospaced""\n This is --stroked--\n This is __underlined__\n This is ~~waved~~\nend note\n\nAlice -> Bob : A //well formatted// message\nnote right of Alice\n This is displayed\n __left of__ Alice.\nend note\nnote left of Bob\n This is displayed\n **left of Alice Bob**.\nend note\nnote over Alice, Bob\n This is hosted by \nend note\n@enduml\n```\n\n## ToDo List\n\n- [ ] ToDos\n - [X] Buy some salad\n - [ ] Brush teeth\n - [x] Drink some water\n - [ ] **Click my box** and see the source code, if you\'re allowed to edit!\n\n', - metadata: { - id: 'exampleId', - version: 2, - viewCount: 0, - updatedAt: '2021-04-24T09:27:51.000Z', - createdAt: '2021-04-24T09:27:51.000Z', - updateUsername: null, - primaryAddress: 'features', - editedBy: [], - title: 'Features', - tags: ['hedgedoc', 'demo', 'react'], - description: 'Many features, such wow!', - aliases: [ - { - name: 'features', - primaryAlias: true, - noteId: 'exampleId' - } - ], - permissions: { - owner: 'tilman', - sharedToUsers: [ - { - username: 'molly', - canEdit: true - } - ], - sharedToGroups: [ - { - groupName: '_LOGGED_IN', - canEdit: true - }, - { - groupName: '_EVERYONE', - canEdit: false - } - ] - } - }, - editedByAtPosition: [] - } as Note) -} - -export default handler diff --git a/frontend/src/pages/api/private/notes/features/revisions/0.ts b/frontend/src/pages/api/private/notes/features/revisions/0.ts deleted file mode 100644 index dc39264e6..000000000 --- a/frontend/src/pages/api/private/notes/features/revisions/0.ts +++ /dev/null @@ -1,215 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { RevisionDetails } from '../../../../../../api/revisions/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - id: 0, - createdAt: '2021-12-21T16:59:42.000Z', - title: 'Features', - description: 'Many features, such wow!', - tags: ['hedgedoc', 'demo', 'react'], - patch: `Index: -=================================================================== ---- -+++ -@@ -0,0 +1,92 @@ -+--- -+title: Features -+description: Many features, such wow! -+robots: noindex -+tags: hedgedoc, demo, react -+opengraph: -+ title: Features -+--- -+# Embedding demo -+[TOC] -+ -+## some plain text -+ -+Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. -+ -+## MathJax -+You can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com](https://math.stackexchange.com/): -+ -+The *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral -+ -+$$ -+x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}. -+$$ -+ -+$$ -+\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,. -+$$ -+ -+> More information about **LaTeX** mathematical expressions [here](https://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference). -+ -+## Blockquote -+> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. -+> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. -+> [color=red] [name=John Doe] [time=2020-06-21 22:50] -+ -+## Slideshare -+{%slideshare mazlan1/internet-of-things-the-tip-of-an-iceberg %} -+ -+## Gist -+https://gist.github.com/schacon/1 -+ -+## YouTube -+https://www.youtube.com/watch?v=KgMpKsp23yY -+ -+## Vimeo -+https://vimeo.com/23237102 -+ -+## Asciinema -+https://asciinema.org/a/117928 -+ -+## PDF -+{%pdf https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf %} -+ -+## Code highlighting -+\`\`\`javascript= -+ -+let a = 1 -+\`\`\` -+ -+## PlantUML -+\`\`\`plantuml -+@startuml -+participant Alice -+participant "The **Famous** Bob" as Bob -+ -+Alice -> Bob : hello --there-- -+... Some ~~long delay~~ ... -+Bob -> Alice : ok -+note left -+ This is **bold** -+ This is //italics// -+ This is ""monospaced"" -+ This is --stroked-- -+ This is __underlined__ -+ This is ~~waved~~ -+end note -+ -+Alice -> Bob : A //well formatted// message -+note right of Alice -+ This is displayed -+ __left of__ Alice. -+end note -+note left of Bob -+ This is displayed -+ **left of Alice Bob**. -+end note -+note over Alice, Bob -+ This is hosted by -+end note -+@enduml -+\`\`\` -+ -`, - edits: [], - length: 2782, - authorUsernames: [], - anonymousAuthorCount: 2, - content: `--- -title: Features -description: Many features, such wow! -robots: noindex -tags: hedgedoc, demo, react -opengraph: - title: Features ---- -# Embedding demo -[TOC] - -## some plain text - -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. - -## MathJax -You can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com](https://math.stackexchange.com/): - -The *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral - -$$ -x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}. -$$ - -$$ -\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,. -$$ - -> More information about **LaTeX** mathematical expressions [here](https://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference). - -## Blockquote -> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. -> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. -> [color=red] [name=John Doe] [time=2020-06-21 22:50] - -## Slideshare -{%slideshare mazlan1/internet-of-things-the-tip-of-an-iceberg %} - -## Gist -https://gist.github.com/schacon/1 - -## YouTube -https://www.youtube.com/watch?v=KgMpKsp23yY - -## Vimeo -https://vimeo.com/23237102 - -## Asciinema -https://asciinema.org/a/117928 - -## PDF -{%pdf https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf %} - -## Code highlighting -\`\`\`javascript= - -let a = 1 -\`\`\` - -## PlantUML -\`\`\`plantuml -@startuml -participant Alice -participant "The **Famous** Bob" as Bob - -Alice -> Bob : hello --there-- -... Some ~~long delay~~ ... -Bob -> Alice : ok -note left - This is **bold** - This is //italics// - This is ""monospaced"" - This is --stroked-- - This is __underlined__ - This is ~~waved~~ -end note - -Alice -> Bob : A //well formatted// message -note right of Alice - This is displayed - __left of__ Alice. -end note -note left of Bob - This is displayed - **left of Alice Bob**. -end note -note over Alice, Bob - This is hosted by -end note -@enduml -\`\`\` - -` - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/notes/features/revisions/1.ts b/frontend/src/pages/api/private/notes/features/revisions/1.ts deleted file mode 100644 index b5a955260..000000000 --- a/frontend/src/pages/api/private/notes/features/revisions/1.ts +++ /dev/null @@ -1,163 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { RevisionDetails } from '../../../../../../api/revisions/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - id: 1, - createdAt: '2021-12-29T17:54:11.000Z', - title: 'Features', - description: 'Many more features, such wow!', - tags: ['hedgedoc', 'demo', 'react'], - patch: `Index: -=================================================================== ---- -+++ -@@ -1,7 +1,7 @@ - --- - title: Features --description: Many features, such wow! -+description: Many more features, such wow! - robots: noindex - tags: hedgedoc, demo, react - opengraph: - title: Features -@@ -10,9 +10,9 @@ - [TOC] - - ## some plain text - --Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. -+Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magnus aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetezur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam _et_ justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. - - ## MathJax - You can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com](https://math.stackexchange.com/): - -@@ -39,9 +39,9 @@ - ## Gist - https://gist.github.com/schacon/1 - - ## YouTube --https://www.youtube.com/watch?v=KgMpKsp23yY -+https://www.youtube.com/watch?v=zHAIuE5BQWk - - ## Vimeo - https://vimeo.com/23237102 - -@@ -62,9 +62,9 @@ - @startuml - participant Alice - participant "The **Famous** Bob" as Bob - --Alice -> Bob : hello --there-- -+Alice -> Bob : bye --there-- - ... Some ~~long delay~~ ... - Bob -> Alice : ok - note left - This is **bold**`, - edits: [], - length: 2788, - authorUsernames: [], - anonymousAuthorCount: 4, - content: `--- -title: Features -description: Many more features, such wow! -robots: noindex -tags: hedgedoc, demo, react -opengraph: - title: Features ---- -# Embedding demo -[TOC] - -## some plain text - -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magnus aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetezur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam _et_ justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. - -## MathJax -You can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com](https://math.stackexchange.com/): - -The *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral - -$$ -x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}. -$$ - -$$ -\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,. -$$ - -> More information about **LaTeX** mathematical expressions [here](https://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference). - -## Blockquote -> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. -> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. -> [color=red] [name=John Doe] [time=2020-06-21 22:50] - -## Slideshare -{%slideshare mazlan1/internet-of-things-the-tip-of-an-iceberg %} - -## Gist -https://gist.github.com/schacon/1 - -## YouTube -https://www.youtube.com/watch?v=zHAIuE5BQWk - -## Vimeo -https://vimeo.com/23237102 - -## Asciinema -https://asciinema.org/a/117928 - -## PDF -{%pdf https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf %} - -## Code highlighting -\`\`\`javascript= - -let a = 1 -\`\`\` - -## PlantUML -\`\`\`plantuml -@startuml -participant Alice -participant "The **Famous** Bob" as Bob - -Alice -> Bob : bye --there-- -... Some ~~long delay~~ ... -Bob -> Alice : ok -note left - This is **bold** - This is //italics// - This is ""monospaced"" - This is --stroked-- - This is __underlined__ - This is ~~waved~~ -end note - -Alice -> Bob : A //well formatted// message -note right of Alice - This is displayed - __left of__ Alice. -end note -note left of Bob - This is displayed - **left of Alice Bob**. -end note -note over Alice, Bob - This is hosted by -end note -@enduml -\`\`\` - -` - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/notes/features/revisions/index.ts b/frontend/src/pages/api/private/notes/features/revisions/index.ts deleted file mode 100644 index 5cef755b7..000000000 --- a/frontend/src/pages/api/private/notes/features/revisions/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { RevisionMetadata } from '../../../../../../api/revisions/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, [ - { - id: 1, - createdAt: '2021-12-29T17:54:11.000Z', - length: 2788, - authorUsernames: [], - anonymousAuthorCount: 4, - title: 'Features', - description: 'Many features, such wow!', - tags: ['hedgedoc', 'demo', 'react'] - }, - { - id: 0, - createdAt: '2021-12-21T16:59:42.000Z', - length: 2782, - authorUsernames: [], - anonymousAuthorCount: 2, - title: 'Features', - description: 'Many more features, such wow!', - tags: ['hedgedoc', 'demo', 'react'] - } - ]) -} - -export default handler diff --git a/frontend/src/pages/api/private/notes/index.ts b/frontend/src/pages/api/private/notes/index.ts deleted file mode 100644 index 0b2098995..000000000 --- a/frontend/src/pages/api/private/notes/index.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { Note } from '../../../../api/notes/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest( - HttpMethod.POST, - req, - res, - { - content: 'new note content', - metadata: { - id: 'featuresId', - version: 2, - viewCount: 0, - updatedAt: '2021-04-24T09:27:51.000Z', - createdAt: '2021-04-24T09:27:51.000Z', - updateUsername: null, - primaryAddress: 'features', - editedBy: [], - title: 'New note', - tags: ['hedgedoc', 'demo', 'react'], - description: 'Many features, such wow!', - aliases: [ - { - name: 'features', - primaryAlias: true, - noteId: 'featuresId' - } - ], - permissions: { - owner: 'tilman', - sharedToUsers: [ - { - username: 'molly', - canEdit: true - } - ], - sharedToGroups: [ - { - groupName: '_LOGGED_IN', - canEdit: false - } - ] - } - }, - editedByAtPosition: [] - }, - 201 - ) -} - -export default handler diff --git a/frontend/src/pages/api/private/notes/slide-example/index.ts b/frontend/src/pages/api/private/notes/slide-example/index.ts deleted file mode 100644 index 1dfef64cf..000000000 --- a/frontend/src/pages/api/private/notes/slide-example/index.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { Note } from '../../../../../api/notes/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - content: - '---\ntype: slide\nslideOptions:\n transition: slide\n---\n\n# Slide example\n\nThis feature still in beta, may have some issues.\n\nFor details please visit:\n\n\nYou can use `URL query` or `slideOptions` of the YAML metadata to customize your slides.\n\n---\n\n## First slide\n\n`---`\n\nIs the divider of slides\n\n----\n\n### First branch of first the slide\n\n`----`\n\nIs the divider of branches\n\nUse the *Space* key to navigate through all slides.\n\n----\n\n### Second branch of first the slide\n\nNested slides are useful for adding additional detail underneath a high-level horizontal slide.\n\n---\n\n## Point of View\n\nPress **ESC** to enter the slide overview.\n\n---\n\n## Touch Optimized\n\nPresentations look great on touch devices, like mobile phones and tablets. Simply swipe through your slides.\n\n---\n\n## Fragments\n\n``\n\nIs the fragment syntax\n\nHit the next arrow...\n\n... to step through ...\n\n... a fragmented slide.\n\nNote:\n This slide has fragments which are also stepped through in the notes window.\n\n---\n\n## Fragment Styles\n\nThere are different types of fragments, like:\n\ngrow\n\nshrink\n\nfade-out\n\nfade-up (also down, left and right!)\n\ncurrent-visible\n\nHighlight red blue green\n\n---\n\n\n\n## Transition Styles\nDifferent background transitions are available via the transition option. This one\'s called "zoom".\n\n``\n\nIs the transition syntax\n\nYou can use:\n\nnone/fade/slide/convex/concave/zoom\n\n---\n\n\n\n``\n\nAlso, you can set different in/out transition\n\nYou can use:\n\nnone/fade/slide/convex/concave/zoom\n\npostfix with `-in` or `-out`\n\n---\n\n\n\n``\n\nCustom the transition speed!\n\nYou can use:\n\ndefault/fast/slow\n\n---\n\n## Themes\n\nreveal.js comes with a few themes built in:\n\nBlack (default) - White - League - Sky - Beige - Simple\n\nSerif - Blood - Night - Moon - Solarized\n\nIt can be set in YAML slideOptions\n\n---\n\n\n\n``\n\nIs the background syntax\n\n---\n\n\n\n
\n\n## Image Backgrounds\n\n``\n\n
\n\n----\n\n\n\n
\n\n## Tiled Backgrounds\n\n``\n\n
\n\n----\n\n\n\n
\n\n## Video Backgrounds\n\n``\n\n
\n\n----\n\n\n\n## ... and GIFs!\n\n---\n\n## Pretty Code\n\n``` javascript\nfunction linkify( selector ) {\n if( supports3DTransforms ) {\n\n const nodes = document.querySelectorAll( selector );\n\n for( const i = 0, len = nodes.length; i < len; i++ ) {\n var node = nodes[i];\n\n if( !node.className ) {\n node.className += \' roll\';\n }\n }\n }\n}\n```\nCode syntax highlighting courtesy of [highlight.js](http://softwaremaniacs.org/soft/highlight/en/description/).\n\n---\n\n## Marvelous List\n\n- No order here\n- Or here\n- Or here\n- Or here\n\n---\n\n## Fantastic Ordered List\n\n1. One is smaller than...\n2. Two is smaller than...\n3. Three!\n\n---\n\n## Tabular Tables\n\n| Item | Value | Quantity |\n| ---- | ----- | -------- |\n| Apples | $1 | 7 |\n| Lemonade | $2 | 18 |\n| Bread | $3 | 2 |\n\n---\n\n## Clever Quotes\n\n> β€œFor years there has been a theory that millions of monkeys typing at random on millions of typewriters would reproduce the entire works of Shakespeare. The Internet has proven this theory to be untrue.”\n\n---\n\n## Intergalactic Interconnections\n\nYou can link between slides internally, [like this](#/1/3).\n\n---\n\n## Speaker\n\nThere\'s a [speaker view](https://github.com/hakimel/reveal.js#speaker-notes). It includes a timer, preview of the upcoming slide as well as your speaker notes.\n\nPress the *S* key to try it out.\n\nNote:\n Oh hey, these are some notes. They\'ll be hidden in your presentation, but you can see them if you open the speaker notes window (hit `s` on your keyboard).\n\n---\n\n## Take a Moment\n\nPress `B` or `.` on your keyboard to pause the presentation. This is helpful when you\'re on stage and want to take distracting slides off the screen.\n\n---\n\n## Print your Slides\n\nDown below you can find a print icon.\n\nAfter you click on it, use the print function of your browser (either CTRL+P or cmd+P) to print the slides as PDF. [See official reveal.js instructions for details](https://github.com/hakimel/reveal.js#instructions-1)\n\n---\n\n# The End\n\n', - metadata: { - id: 'slideId', - primaryAddress: 'slide-example', - version: 2, - viewCount: 8, - updatedAt: '2021-04-30T18:38:23.000Z', - updateUsername: null, - createdAt: '2021-04-30T18:38:14.000Z', - editedBy: [], - title: 'Slide example', - tags: [], - description: '', - aliases: [ - { - noteId: 'slideId', - primaryAlias: true, - name: 'slide-example' - } - ], - permissions: { - owner: 'erik', - sharedToUsers: [ - { - username: 'tilman', - canEdit: true - }, - { - username: 'molly', - canEdit: true - } - ], - sharedToGroups: [ - { - groupName: '_LOGGED_IN', - canEdit: true - }, - { - groupName: '_EVERYONE', - canEdit: false - }, - { - groupName: 'hedgedoc-devs', - canEdit: true - } - ] - } - }, - editedByAtPosition: [] - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/tokens.ts b/frontend/src/pages/api/private/tokens.ts deleted file mode 100644 index b203d259e..000000000 --- a/frontend/src/pages/api/private/tokens.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { AccessToken } from '../../../api/tokens/types' -import { HttpMethod, respondToMatchingRequest } from '../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - respondToMatchingRequest(HttpMethod.GET, req, res, [ - { - label: 'Demo-App', - keyId: 'demo', - createdAt: '2021-11-20T23:54:13+01:00', - lastUsedAt: '2021-11-20T23:54:13+01:00', - validUntil: '2022-11-20' - }, - { - label: 'CLI @ Test-PC', - keyId: 'cli', - createdAt: '2021-11-20T23:54:13+01:00', - lastUsedAt: '2021-11-20T23:54:13+01:00', - validUntil: '2021-11-20' - } - ]) -} - -export default handler diff --git a/frontend/src/pages/api/private/users/profile/erik.ts b/frontend/src/pages/api/private/users/profile/erik.ts deleted file mode 100644 index 280633992..000000000 --- a/frontend/src/pages/api/private/users/profile/erik.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { UserInfo } from '../../../../../api/users/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - username: 'erik', - displayName: 'Erik', - photoUrl: '/public/img/avatar.png' - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/users/profile/mock.ts b/frontend/src/pages/api/private/users/profile/mock.ts deleted file mode 100644 index fb9fe14c0..000000000 --- a/frontend/src/pages/api/private/users/profile/mock.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { UserInfo } from '../../../../../api/users/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - username: 'mock', - displayName: 'Mock User', - photoUrl: '' - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/users/profile/molly.ts b/frontend/src/pages/api/private/users/profile/molly.ts deleted file mode 100644 index f52f427aa..000000000 --- a/frontend/src/pages/api/private/users/profile/molly.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { UserInfo } from '../../../../../api/users/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - username: 'molly', - displayName: 'Molly', - photoUrl: '/public/img/avatar.png' - }) -} - -export default handler diff --git a/frontend/src/pages/api/private/users/profile/tilman.ts b/frontend/src/pages/api/private/users/profile/tilman.ts deleted file mode 100644 index d71bff512..000000000 --- a/frontend/src/pages/api/private/users/profile/tilman.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import type { UserInfo } from '../../../../../api/users/types' -import { HttpMethod, respondToMatchingRequest } from '../../../../../handler-utils/respond-to-matching-request' -import type { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse): void => { - respondToMatchingRequest(HttpMethod.GET, req, res, { - username: 'tilman', - displayName: 'Tilman', - photoUrl: '/public/img/avatar.png' - }) -} - -export default handler diff --git a/frontend/src/utils/test-modes.js b/frontend/src/utils/test-modes.js index 56ad561a6..9fa729f2b 100644 --- a/frontend/src/utils/test-modes.js +++ b/frontend/src/utils/test-modes.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -/** +/* * This file is intentionally a js and not a ts file because it is used in `next.config.js` */ @@ -25,12 +25,6 @@ const isPositiveAnswer = (value) => { */ const isTestMode = !!process.env.NEXT_PUBLIC_TEST_MODE && isPositiveAnswer(process.env.NEXT_PUBLIC_TEST_MODE) -/** - * Defines if the current runtime should use the mocked backend. - * @type boolean - */ -const isMockMode = !!process.env.NEXT_PUBLIC_USE_MOCK_API && isPositiveAnswer(process.env.NEXT_PUBLIC_USE_MOCK_API) - /** * Defines if the current runtime was built in development mode. * @type boolean @@ -52,7 +46,6 @@ const isBuildTime = !!process.env.BUILD_TIME && isPositiveAnswer(process.env.BUI module.exports = { isTestMode, - isMockMode, isDevMode, isProfilingMode, isBuildTime