mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-28 14:04:43 -04:00
Refactor handling of environment variables (#2303)
* Refactor environment variables Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
e412115a78
commit
39a4125cb0
85 changed files with 624 additions and 461 deletions
76
src/pages/api/private/config.ts
Normal file
76
src/pages/api/private/config.ts
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import type { Config } from '../../../api/config/types'
|
||||
import { AuthProviderType } from '../../../api/config/types'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../handler-utils/respond-to-matching-request'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<Config>(HttpMethod.GET, req, res, {
|
||||
allowAnonymous: true,
|
||||
allowRegister: true,
|
||||
authProviders: [
|
||||
{
|
||||
type: AuthProviderType.LOCAL
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.LDAP,
|
||||
identifier: 'test-ldap',
|
||||
providerName: 'Test LDAP'
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.DROPBOX
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.FACEBOOK
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.GITHUB
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.GITLAB,
|
||||
identifier: 'test-gitlab',
|
||||
providerName: 'Test GitLab'
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.GOOGLE
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.OAUTH2,
|
||||
identifier: 'test-oauth2',
|
||||
providerName: 'Test OAuth2'
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.SAML,
|
||||
identifier: 'test-saml',
|
||||
providerName: 'Test SAML'
|
||||
},
|
||||
{
|
||||
type: AuthProviderType.TWITTER
|
||||
}
|
||||
],
|
||||
branding: {
|
||||
name: 'DEMO Corp',
|
||||
logo: 'public/img/demo.png'
|
||||
},
|
||||
useImageProxy: false,
|
||||
specialUrls: {
|
||||
privacy: 'https://example.com/privacy',
|
||||
termsOfUse: 'https://example.com/termsOfUse',
|
||||
imprint: 'https://example.com/imprint'
|
||||
},
|
||||
version: {
|
||||
major: 2,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
commit: 'mock'
|
||||
},
|
||||
plantumlServer: 'https://www.plantuml.com/plantuml',
|
||||
maxDocumentLength: 1000000
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
18
src/pages/api/private/groups/_EVERYONE.ts
Normal file
18
src/pages/api/private/groups/_EVERYONE.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { GroupInfo } from '../../../../api/group/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<GroupInfo>(HttpMethod.GET, req, res, {
|
||||
name: '_EVERYONE',
|
||||
displayName: 'Everyone',
|
||||
special: true
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
18
src/pages/api/private/groups/_LOGGED_IN.ts
Normal file
18
src/pages/api/private/groups/_LOGGED_IN.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { GroupInfo } from '../../../../api/group/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<GroupInfo>(HttpMethod.GET, req, res, {
|
||||
name: '_LOGGED_IN',
|
||||
displayName: 'All registered users',
|
||||
special: true
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
18
src/pages/api/private/groups/hedgedoc-devs.ts
Normal file
18
src/pages/api/private/groups/hedgedoc-devs.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { GroupInfo } from '../../../../api/group/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<GroupInfo>(HttpMethod.GET, req, res, {
|
||||
name: 'hedgedoc-devs',
|
||||
displayName: 'HedgeDoc devs',
|
||||
special: true
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
44
src/pages/api/private/me/history.ts
Normal file
44
src/pages/api/private/me/history.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { HistoryEntry } from '../../../../api/history/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<HistoryEntry[]>(HttpMethod.GET, req, res, [
|
||||
{
|
||||
identifier: 'slide-example',
|
||||
title: 'Slide example',
|
||||
lastVisitedAt: '2020-05-30T15:20:36.088Z',
|
||||
pinStatus: true,
|
||||
tags: ['features', 'cool', 'updated']
|
||||
},
|
||||
{
|
||||
identifier: 'features',
|
||||
title: 'Features',
|
||||
lastVisitedAt: '2020-05-31T15:20:36.088Z',
|
||||
pinStatus: true,
|
||||
tags: ['features', 'cool', 'updated']
|
||||
},
|
||||
{
|
||||
identifier: 'ODakLc2MQkyyFc_Xmb53sg',
|
||||
title: 'Non existent',
|
||||
lastVisitedAt: '2020-05-25T19:48:14.025Z',
|
||||
pinStatus: false,
|
||||
tags: []
|
||||
},
|
||||
{
|
||||
identifier: 'l8JuWxApTR6Fqa0LCrpnLg',
|
||||
title: 'Non existent',
|
||||
lastVisitedAt: '2020-05-24T16:04:36.433Z',
|
||||
pinStatus: false,
|
||||
tags: ['agenda', 'HedgeDoc community', 'community call']
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
export default handler
|
21
src/pages/api/private/me/index.ts
Normal file
21
src/pages/api/private/me/index.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { LoginUserInfo } from '../../../../api/me/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<LoginUserInfo>(HttpMethod.GET, req, res, {
|
||||
username: 'mock',
|
||||
photo: 'public/img/avatar.png',
|
||||
displayName: 'Mock User',
|
||||
authProvider: 'local',
|
||||
email: 'mock@hedgedoc.test'
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
33
src/pages/api/private/me/media.ts
Normal file
33
src/pages/api/private/me/media.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { MediaUpload } from '../../../../api/media/types'
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<MediaUpload[]>(HttpMethod.GET, req, res, [
|
||||
{
|
||||
username: 'tilman',
|
||||
createdAt: '2022-03-20T20:36:32Z',
|
||||
url: 'https://dummyimage.com/256/f00',
|
||||
noteId: 'features'
|
||||
},
|
||||
{
|
||||
username: 'tilman',
|
||||
createdAt: '2022-03-20T20:36:57+0000',
|
||||
url: 'https://dummyimage.com/256/00f',
|
||||
noteId: null
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
export default handler
|
33
src/pages/api/private/media.ts
Normal file
33
src/pages/api/private/media.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import type { MediaUpload } from '../../../api/media/types'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../handler-utils/respond-to-matching-request'
|
||||
import { isMockMode, isTestMode } from '../../../utils/test-modes'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse): Promise<void> => {
|
||||
if (isMockMode && !isTestMode) {
|
||||
await new Promise((resolve) => {
|
||||
setTimeout(resolve, 3000)
|
||||
})
|
||||
}
|
||||
|
||||
respondToMatchingRequest<MediaUpload>(
|
||||
HttpMethod.POST,
|
||||
req,
|
||||
res,
|
||||
{
|
||||
url: 'public/img/avatar.png',
|
||||
noteId: null,
|
||||
username: 'test',
|
||||
createdAt: '2022-02-27T21:54:23.856Z'
|
||||
},
|
||||
201
|
||||
)
|
||||
}
|
||||
|
||||
export default handler
|
54
src/pages/api/private/notes/features/index.ts
Normal file
54
src/pages/api/private/notes/features/index.ts
Normal file
File diff suppressed because one or more lines are too long
213
src/pages/api/private/notes/features/revisions/0.ts
Normal file
213
src/pages/api/private/notes/features/revisions/0.ts
Normal file
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../../../handler-utils/respond-to-matching-request'
|
||||
import type { RevisionDetails } from '../../../../../../api/revisions/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<RevisionDetails>(HttpMethod.GET, req, res, {
|
||||
id: 0,
|
||||
createdAt: '2021-12-21T16:59:42.000Z',
|
||||
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 <back:cadetblue><size:18>displayed</size></back>
|
||||
+ __left of__ Alice.
|
||||
+end note
|
||||
+note left of Bob
|
||||
+ <u:red>This</u> is <color #118888>displayed</color>
|
||||
+ **<color purple>left of</color> <s:red>Alice</strike> Bob**.
|
||||
+end note
|
||||
+note over Alice, Bob
|
||||
+ <w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
|
||||
+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 <back:cadetblue><size:18>displayed</size></back>
|
||||
__left of__ Alice.
|
||||
end note
|
||||
note left of Bob
|
||||
<u:red>This</u> is <color #118888>displayed</color>
|
||||
**<color purple>left of</color> <s:red>Alice</strike> Bob**.
|
||||
end note
|
||||
note over Alice, Bob
|
||||
<w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
|
||||
end note
|
||||
@enduml
|
||||
\`\`\`
|
||||
|
||||
`
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
160
src/pages/api/private/notes/features/revisions/1.ts
Normal file
160
src/pages/api/private/notes/features/revisions/1.ts
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../../../handler-utils/respond-to-matching-request'
|
||||
import type { RevisionDetails } from '../../../../../../api/revisions/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<RevisionDetails>(HttpMethod.GET, req, res, {
|
||||
id: 1,
|
||||
createdAt: '2021-12-29T17:54:11.000Z',
|
||||
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 <back:cadetblue><size:18>displayed</size></back>
|
||||
__left of__ Alice.
|
||||
end note
|
||||
note left of Bob
|
||||
<u:red>This</u> is <color #118888>displayed</color>
|
||||
**<color purple>left of</color> <s:red>Alice</strike> Bob**.
|
||||
end note
|
||||
note over Alice, Bob
|
||||
<w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
|
||||
end note
|
||||
@enduml
|
||||
\`\`\`
|
||||
|
||||
`
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
30
src/pages/api/private/notes/features/revisions/index.ts
Normal file
30
src/pages/api/private/notes/features/revisions/index.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../../../handler-utils/respond-to-matching-request'
|
||||
import type { RevisionMetadata } from '../../../../../../api/revisions/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<RevisionMetadata[]>(HttpMethod.GET, req, res, [
|
||||
{
|
||||
id: 1,
|
||||
createdAt: '2021-12-29T17:54:11.000Z',
|
||||
length: 2788,
|
||||
authorUsernames: [],
|
||||
anonymousAuthorCount: 4
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
createdAt: '2021-12-21T16:59:42.000Z',
|
||||
length: 2782,
|
||||
authorUsernames: [],
|
||||
anonymousAuthorCount: 2
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
export default handler
|
59
src/pages/api/private/notes/index.ts
Normal file
59
src/pages/api/private/notes/index.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { Note } from '../../../../api/notes/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<Note>(
|
||||
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
|
66
src/pages/api/private/notes/slide-example/index.ts
Normal file
66
src/pages/api/private/notes/slide-example/index.ts
Normal file
File diff suppressed because one or more lines are too long
29
src/pages/api/private/tokens.ts
Normal file
29
src/pages/api/private/tokens.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import type { AccessToken } from '../../../api/tokens/types'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../handler-utils/respond-to-matching-request'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse) => {
|
||||
respondToMatchingRequest<AccessToken[]>(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
|
18
src/pages/api/private/users/erik.ts
Normal file
18
src/pages/api/private/users/erik.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { UserInfo } from '../../../../api/users/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<UserInfo>(HttpMethod.GET, req, res, {
|
||||
username: 'erik',
|
||||
displayName: 'Erik',
|
||||
photo: 'public/img/avatar.png'
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
19
src/pages/api/private/users/molly.ts
Normal file
19
src/pages/api/private/users/molly.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { UserInfo } from '../../../../api/users/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<UserInfo>(HttpMethod.GET, req, res, {
|
||||
username: 'molly',
|
||||
displayName: 'Molly',
|
||||
photo: 'public/img/avatar.png'
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
18
src/pages/api/private/users/tilman.ts
Normal file
18
src/pages/api/private/users/tilman.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { HttpMethod, respondToMatchingRequest } from '../../../../handler-utils/respond-to-matching-request'
|
||||
import type { UserInfo } from '../../../../api/users/types'
|
||||
|
||||
const handler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
respondToMatchingRequest<UserInfo>(HttpMethod.GET, req, res, {
|
||||
username: 'tilman',
|
||||
displayName: 'Tilman',
|
||||
photo: 'public/img/avatar.png'
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
Loading…
Add table
Add a link
Reference in a new issue