Rename codimd to hedgedoc (#434)

Rename codimd to hedgedoc
This commit is contained in:
mrdrogdrog 2020-09-02 21:17:26 +02:00 committed by GitHub
parent 3a0e35a9f3
commit 0e912d64dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 87 additions and 84 deletions

View file

@ -8,7 +8,8 @@ export const defaultFetchConfig: Partial<RequestInit> = {
'Content-Type': 'application/json'
},
redirect: 'follow',
referrerPolicy: 'no-referrer'
referrerPolicy: 'no-referrer',
method: 'GET'
}
export const getApiUrl = (): string => {

View file

@ -10,7 +10,7 @@ export const DocumentTitle: React.FC<DocumentTitleProps> = ({ title }) => {
const brandingName = useSelector((state: ApplicationState) => state.config.branding.name)
useEffect(() => {
document.title = `${title ? title + ' - ' : ''}CodiMD ${brandingName ? ` @ ${brandingName}` : ''}`
document.title = `${title ? title + ' - ' : ''}HedgeDoc ${brandingName ? ` @ ${brandingName}` : ''}`
}, [brandingName, title])
return null

View file

@ -24,7 +24,7 @@ export const Links: React.FC = () => {
<TranslatedExternalLink
i18nKey='editor.help.contacts.meetUsOn'
i18nOption={{ service: 'Matrix' }}
href='https://riot.im/app/#/room/#codimd:matrix.org'
href='https://riot.im/app/#/room/#hedgedoc:matrix.org'
icon='hashtag'
className='text-primary'
/>

View file

@ -9,7 +9,7 @@ export const NavbarBranding: React.FC = () => {
<Navbar.Brand>
<Link to="/intro" className="text-secondary text-decoration-none d-flex align-items-center">
<ForkAwesomeIcon icon="file-text" className={'mr-2'}/>
<span>CodiMD</span>
<span>HedgeDoc</span>
<Branding inline={true}/>
</Link>
</Navbar.Brand>

View file

@ -2,7 +2,7 @@ export const editorTestContent = `---
title: Features
description: Many features, such wow!
robots: noindex
tags: codimd, demo, react
tags: hedgedoc, demo, react
opengraph:
title: Features
---

View file

@ -13,7 +13,7 @@ const IntroPage: React.FC = () => {
<Fragment>
<h1 dir='auto' className={'align-items-center d-flex justify-content-center'}>
<ForkAwesomeIcon icon="file-text" className={'mr-2'}/>
<span>CodiMD</span>
<span>HedgeDoc</span>
<Branding/>
</h1>
<p className="lead mb-5">

View file

@ -15,7 +15,7 @@ export const PoweredByLinks: React.FC = () => {
return (
<p>
<Trans i18nKey="landing.footer.poweredBy">
<ExternalLink href="https://codimd.org" text="CodiMD"/>
<ExternalLink href="https://codimd.org" text="HedgeDoc"/>
</Trans>
&nbsp;|&nbsp;
<TranslatedInternalLink href='/n/release-notes' i18nKey='landing.footer.releases'/>

View file

@ -9,7 +9,7 @@ const SocialLink: React.FC = () => {
<Trans i18nKey="landing.footer.followUs" components={[
<ExternalLink href="https://github.com/codimd/server" icon='github' text="GitHub"/>,
<ExternalLink href="https://community.codimd.org" icon='users' text="Discourse"/>,
<ExternalLink href="https://riot.im/app/#/room/#codimd:matrix.org" icon="comment" text="Riot"/>,
<ExternalLink href="https://riot.im/app/#/room/#hedgedoc:matrix.org" icon="comment" text="Riot"/>,
<ExternalLink href="https://social.codimd.org/mastodon" icon='mastodon' text="Mastodon"/>,
<ExternalLink href="https://translate.codimd.org" icon="globe" text="POEditor"/>
]}/>

View file

@ -16,7 +16,7 @@ export interface LineNumberMarkerOptions {
*/
export const lineNumberMarker: () => MarkdownIt.PluginWithOptions<LineNumberMarkerOptions> = () => {
return (md: MarkdownIt, options) => {
// add codimd_linemarker token before each opening or self-closing level-0 tag
// add app_linemarker token before each opening or self-closing level-0 tag
md.core.ruler.push('line_number_marker', (state) => {
const lineMarkers: LineMarkers[] = []
tagTokens(state.tokens, lineMarkers)
@ -26,7 +26,7 @@ export const lineNumberMarker: () => MarkdownIt.PluginWithOptions<LineNumberMark
return true
})
md.renderer.rules.codimd_linemarker = (tokens: Token[], index: number): string => {
md.renderer.rules.app_linemarker = (tokens: Token[], index: number): string => {
const startLineNumber = tokens[index].attrGet('data-start-line')
const endLineNumber = tokens[index].attrGet('data-end-line')
@ -35,11 +35,11 @@ export const lineNumberMarker: () => MarkdownIt.PluginWithOptions<LineNumberMark
return ''
}
// noinspection CheckTagEmptyBody
return `<codimd-linemarker data-start-line='${startLineNumber}' data-end-line='${endLineNumber}'></codimd-linemarker>`
return `<app-linemarker data-start-line='${startLineNumber}' data-end-line='${endLineNumber}'></app-linemarker>`
}
const insertNewLineMarker = (startLineNumber: number, endLineNumber: number, tokenPosition: number, level: number, tokens: Token[]) => {
const startToken = new Token('codimd_linemarker', 'codimd-linemarker', 0)
const startToken = new Token('app_linemarker', 'app-linemarker', 0)
startToken.level = level
startToken.attrPush(['data-start-line', `${startLineNumber}`])
startToken.attrPush(['data-end-line', `${endLineNumber}`])

View file

@ -54,7 +54,7 @@ import { replaceVimeoLink } from './regex-plugins/replace-vimeo-link'
import { replaceYouTubeLink } from './regex-plugins/replace-youtube-link'
import { buildTransformer, calculateNewLineNumberMapping, LineKeys } from './renderer-utils'
import { AsciinemaReplacer } from './replace-components/asciinema/asciinema-replacer'
import { CodimdLinemarkerReplacer } from './replace-components/codimd-linemarker/codimd-linemarker-replacer'
import { LinemarkerReplacer } from './replace-components/linemarker/linemarker-replacer'
import { ComponentReplacer } from './replace-components/ComponentReplacer'
import { CsvReplacer } from './replace-components/csv/csv-replacer'
import { FlowchartReplacer } from './replace-components/flow/flowchart-replacer'
@ -281,12 +281,12 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({
permalinkSymbol: '<i class="fa fa-link"></i>'
})
md.use(mathJax({
beforeMath: '<codimd-katex>',
afterMath: '</codimd-katex>',
beforeInlineMath: '<codimd-katex inline>',
afterInlineMath: '</codimd-katex>',
beforeDisplayMath: '<codimd-katex>',
afterDisplayMath: '</codimd-katex>'
beforeMath: '<app-katex>',
afterMath: '</app-katex>',
beforeInlineMath: '<app-katex inline>',
afterInlineMath: '</app-katex>',
beforeDisplayMath: '<app-katex>',
afterDisplayMath: '</app-katex>'
}))
md.use(markdownItRegex, replaceLegacyYoutubeShortCode)
md.use(markdownItRegex, replaceLegacyVimeoShortCode)
@ -339,7 +339,7 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({
const markdownReactDom: ReactElement[] = useMemo(() => {
const allReplacers: ComponentReplacer[] = [
new CodimdLinemarkerReplacer(),
new LinemarkerReplacer(),
new PossibleWiderReplacer(),
new GistReplacer(),
new YoutubeReplacer(),

View file

@ -13,6 +13,6 @@ export const replaceAsciinemaLink: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-asciinema id="${match}"></codimd-asciinema>`
return `<app-asciinema id="${match}"></app-asciinema>`
}
}

View file

@ -13,6 +13,6 @@ export const replaceGistLink: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-gist id="${match}"></codimd-gist>`
return `<app-gist id="${match}"></app-gist>`
}
}

View file

@ -8,6 +8,6 @@ export const replaceLegacyGistShortCode: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-gist id="${match}"></codimd-gist>`
return `<app-gist id="${match}"></app-gist>`
}
}

View file

@ -6,6 +6,6 @@ export const replaceLegacyVimeoShortCode: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-vimeo id="${match}"></codimd-vimeo>`
return `<app-vimeo id="${match}"></app-vimeo>`
}
}

View file

@ -6,6 +6,6 @@ export const replaceLegacyYoutubeShortCode: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-youtube id="${match}"></codimd-youtube>`
return `<app-youtube id="${match}"></app-youtube>`
}
}

View file

@ -6,6 +6,6 @@ export const replacePdfShortCode: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-pdf url="${match}"></codimd-pdf>`
return `<app-pdf url="${match}"></app-pdf>`
}
}

View file

@ -13,6 +13,6 @@ export const replaceVimeoLink: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-vimeo id="${match}"></codimd-vimeo>`
return `<app-vimeo id="${match}"></app-vimeo>`
}
}

View file

@ -14,6 +14,6 @@ export const replaceYouTubeLink: RegexOptions = {
replace: (match) => {
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
// noinspection CheckTagEmptyBody
return `<codimd-youtube id="${match}"></codimd-youtube>`
return `<app-youtube id="${match}"></app-youtube>`
}
}

View file

@ -1,6 +1,6 @@
import { DomElement } from 'domhandler'
import React from 'react'
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
import { getAttributesFromHedgeDocTag } from '../utils'
import { ComponentReplacer } from '../ComponentReplacer'
import { AsciinemaFrame } from './asciinema-frame'
@ -8,7 +8,7 @@ export class AsciinemaReplacer extends ComponentReplacer {
private counterMap: Map<string, number> = new Map<string, number>()
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
const attributes = getAttributesFromCodiMdTag(node, 'asciinema')
const attributes = getAttributesFromHedgeDocTag(node, 'asciinema')
if (attributes && attributes.id) {
const asciinemaId = attributes.id
const count = (this.counterMap.get(asciinemaId) || 0) + 1

View file

@ -1,8 +0,0 @@
import { DomElement } from 'domhandler'
export const getAttributesFromCodiMdTag = (node: DomElement, tagName: string): ({ [s: string]: string; }|undefined) => {
if (node.name !== `codimd-${tagName}` || !node.attribs) {
return
}
return node.attribs
}

View file

@ -1,6 +1,6 @@
import { DomElement } from 'domhandler'
import React from 'react'
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
import { getAttributesFromHedgeDocTag } from '../utils'
import { ComponentReplacer } from '../ComponentReplacer'
import { OneClickEmbedding } from '../one-click-frame/one-click-embedding'
import { GistFrame } from './gist-frame'
@ -10,7 +10,7 @@ export class GistReplacer extends ComponentReplacer {
private counterMap: Map<string, number> = new Map<string, number>()
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
const attributes = getAttributesFromCodiMdTag(node, 'gist')
const attributes = getAttributesFromHedgeDocTag(node, 'gist')
if (attributes && attributes.id) {
const gistId = attributes.id
const count = (this.counterMap.get(gistId) || 0) + 1

View file

@ -9,12 +9,12 @@ const getNodeIfKatexBlock = (node: DomElement): (DomElement|undefined) => {
return
}
return node.children.find((subnode) => {
return (subnode.name === 'codimd-katex' && subnode.attribs?.inline === undefined)
return (subnode.name === 'app-katex' && subnode.attribs?.inline === undefined)
})
}
const getNodeIfInlineKatex = (node: DomElement): (DomElement|undefined) => {
return (node.name === 'codimd-katex' && node.attribs?.inline !== undefined) ? node : undefined
return (node.name === 'app-katex' && node.attribs?.inline !== undefined) ? node : undefined
}
export class KatexReplacer extends ComponentReplacer {

View file

@ -1,7 +1,7 @@
import { DomElement } from 'domhandler'
import { ComponentReplacer } from '../ComponentReplacer'
export class CodimdLinemarkerReplacer extends ComponentReplacer {
export class LinemarkerReplacer extends ComponentReplacer {
public getReplacement (codeNode: DomElement, index: number): null | undefined {
return codeNode.name === 'codimd-linemarker' ? null : undefined
}

View file

@ -1,6 +1,6 @@
import { DomElement } from 'domhandler'
import React from 'react'
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
import { getAttributesFromHedgeDocTag } from '../utils'
import { ComponentReplacer } from '../ComponentReplacer'
import { PdfFrame } from './pdf-frame'
@ -8,7 +8,7 @@ export class PdfReplacer extends ComponentReplacer {
private counterMap: Map<string, number> = new Map<string, number>()
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
const attributes = getAttributesFromCodiMdTag(node, 'pdf')
const attributes = getAttributesFromHedgeDocTag(node, 'pdf')
if (attributes && attributes.url) {
const pdfUrl = attributes.url
const count = (this.counterMap.get(pdfUrl) || 0) + 1

View file

@ -2,7 +2,7 @@ import { DomElement } from 'domhandler'
import { ComponentReplacer, NativeRenderer, SubNodeTransform } from '../ComponentReplacer'
import './possible-wider-replacer.scss'
const enabledTags = ['img', 'codimd-youtube', 'codimd-vimeo', 'codimd-asciinema', 'codimd-pdf']
const enabledTags = ['img', 'app-youtube', 'app-vimeo', 'app-asciinema', 'app-pdf']
/**
* This replacer doesn't actually replace something.

View file

@ -0,0 +1,8 @@
import { DomElement } from 'domhandler'
export const getAttributesFromHedgeDocTag = (node: DomElement, tagName: string): ({ [s: string]: string; }|undefined) => {
if (node.name !== `app-${tagName}` || !node.attribs) {
return
}
return node.attribs
}

View file

@ -1,6 +1,6 @@
import { DomElement } from 'domhandler'
import React from 'react'
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
import { getAttributesFromHedgeDocTag } from '../utils'
import { ComponentReplacer } from '../ComponentReplacer'
import { VimeoFrame } from './vimeo-frame'
@ -8,7 +8,7 @@ export class VimeoReplacer extends ComponentReplacer {
private counterMap: Map<string, number> = new Map<string, number>()
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
const attributes = getAttributesFromCodiMdTag(node, 'vimeo')
const attributes = getAttributesFromHedgeDocTag(node, 'vimeo')
if (attributes && attributes.id) {
const videoId = attributes.id
const count = (this.counterMap.get(videoId) || 0) + 1

View file

@ -1,6 +1,6 @@
import { DomElement } from 'domhandler'
import React from 'react'
import { getAttributesFromCodiMdTag } from '../codi-md-tag-utils'
import { getAttributesFromHedgeDocTag } from '../utils'
import { ComponentReplacer } from '../ComponentReplacer'
import { YouTubeFrame } from './youtube-frame'
@ -8,7 +8,7 @@ export class YoutubeReplacer extends ComponentReplacer {
private counterMap: Map<string, number> = new Map<string, number>()
public getReplacement (node: DomElement, index: number): React.ReactElement | undefined {
const attributes = getAttributesFromCodiMdTag(node, 'youtube')
const attributes = getAttributesFromHedgeDocTag(node, 'youtube')
if (attributes && attributes.id) {
const videoId = attributes.id
const count = (this.counterMap.get(videoId) || 0) + 1