mirror of
https://github.com/fmhy/edit.git
synced 2025-08-01 00:32:30 +10:00
m9ve website code outsidr
This commit is contained in:
parent
15a56af368
commit
df4eecc405
87 changed files with 3108 additions and 59 deletions
160
website/transformer/constants.ts
Normal file
160
website/transformer/constants.ts
Normal file
|
@ -0,0 +1,160 @@
|
|||
/**
|
||||
* Copyright (c) 2025 taskylizard. Apache License 2.0.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
interface Header {
|
||||
[file: string]: { title: string; description: string }
|
||||
}
|
||||
|
||||
export const headers: Header = {
|
||||
'adblockvpnguide.md': {
|
||||
title: 'Adblocking / Privacy',
|
||||
description: 'Adblocking, Privacy, VPNs, Proxies, Antiviruses'
|
||||
},
|
||||
'ai.md': {
|
||||
title: 'Artificial Intelligence',
|
||||
description: 'Chatbots, Text Generators, Image Generators, ChatGPT Tools'
|
||||
},
|
||||
'android-iosguide.md': {
|
||||
title: 'Android / iOS',
|
||||
description: 'Apps, Jailbreaking, Android Emulators'
|
||||
},
|
||||
'audiopiracyguide.md': {
|
||||
title: 'Music / Podcasts / Radio',
|
||||
description: 'Stream Audio, Download Audio, Torrent Audio'
|
||||
},
|
||||
'beginners-guide.md': {
|
||||
title: 'Beginners Guide',
|
||||
description: 'A Guide for Beginners to Piracy'
|
||||
},
|
||||
'downloadpiracyguide.md': {
|
||||
title: 'Downloading',
|
||||
description: 'Download Sites, Software Sites, Open Directories'
|
||||
},
|
||||
'edupiracyguide.md': {
|
||||
title: 'Educational',
|
||||
description: 'Courses, Documentaries, Learning Resources'
|
||||
},
|
||||
'gamingpiracyguide.md': {
|
||||
title: 'Gaming / Emulation',
|
||||
description: 'Download Games, ROMs, Gaming Tools'
|
||||
},
|
||||
'linuxguide.md': {
|
||||
title: 'Linux / macOS',
|
||||
description: 'Apps, Software Sites, Gaming'
|
||||
},
|
||||
'miscguide.md': {
|
||||
title: 'Miscellaneous',
|
||||
description: 'Extensions, Indexes, News, Health, Food, Fun'
|
||||
},
|
||||
'nsfwpiracy.md': {
|
||||
title: 'NSFW',
|
||||
description: 'NSFW Indexes, Streaming, Downloading'
|
||||
},
|
||||
'non-english.md': {
|
||||
title: 'Non-English',
|
||||
description: 'International Piracy Sites'
|
||||
},
|
||||
'readingpiracyguide.md': {
|
||||
title: 'Books / Comics / Manga',
|
||||
description: 'Books, Comics, Magazines, Newspapers'
|
||||
},
|
||||
'gaming-tools.md': {
|
||||
title: 'Gaming Tools',
|
||||
description: 'Gaming Optimization, Game Launchers, Multiplayer'
|
||||
},
|
||||
'devtools.md': {
|
||||
title: 'Developer Tools',
|
||||
description: 'Git, Hosting, App Dev, Software Dev'
|
||||
},
|
||||
'img-tools.md': {
|
||||
title: 'Image Tools',
|
||||
description: 'Image Editors, Generators, Compress'
|
||||
},
|
||||
'audio-tools.md': {
|
||||
title: 'Audio Tools',
|
||||
description: 'Audio Players, Audio Editors, Audio Downloaders'
|
||||
},
|
||||
'system-tools.md': {
|
||||
title: 'System Tools',
|
||||
description: 'System Tools, Hardware Tools, Windows ISOs, Customization'
|
||||
},
|
||||
'file-tools.md': {
|
||||
title: 'File Tools',
|
||||
description: 'Download Managers, File Hosting, File Archivers'
|
||||
},
|
||||
'video-tools.md': {
|
||||
title: 'Video Tools',
|
||||
description: 'Video Players, Video Editors, Live Streaming, Animation'
|
||||
},
|
||||
'text-tools.md': {
|
||||
title: 'Text Tools',
|
||||
description: 'Text Editors, Pastebins, Fonts, Translators'
|
||||
},
|
||||
'internet-tools.md': {
|
||||
title: 'Internet Tools',
|
||||
description: 'Browsers, Extensions, Search Engines'
|
||||
},
|
||||
'social-media-tools.md': {
|
||||
title: 'Social Media Tools',
|
||||
description: 'Discord Tools, Reddit Tools, YouTube Tools'
|
||||
},
|
||||
'storage.md': {
|
||||
title: 'Storage',
|
||||
description: 'Sections too big to fit on main pages'
|
||||
},
|
||||
'torrentpiracyguide.md': {
|
||||
title: 'Torrenting',
|
||||
description: 'Torrent Clients, Torrent Sites, Trackers'
|
||||
},
|
||||
'videopiracyguide.md': {
|
||||
title: 'Movies / TV / Anime',
|
||||
description: 'Stream Videos, Download Videos, Torrent Videos'
|
||||
},
|
||||
'base64.md': {
|
||||
title: 'Base64',
|
||||
description: 'Base64 storage'
|
||||
},
|
||||
'unsafesites.md': {
|
||||
title: 'Unsafe Sites',
|
||||
description: 'Unsafe/harmful sites to avoid.'
|
||||
}
|
||||
} as const
|
||||
|
||||
export const excluded = [
|
||||
'readme.md',
|
||||
'single-page',
|
||||
'feedback.md',
|
||||
'index.md',
|
||||
'sandbox.md',
|
||||
'startpage.md'
|
||||
]
|
||||
|
||||
export function getHeader(meta: { build: { api: boolean } }, id: string) {
|
||||
const title =
|
||||
'<div class="space-y-2 not-prose"><h1 class="text-4xl font-extrabold tracking-tight text-primary underline lg:text-5xl lg:leading-[3.5rem]">'
|
||||
|
||||
const description = '<p class="text-black dark:text-text-2">'
|
||||
|
||||
const feedback = meta.build.api ? '<Feedback />' : ''
|
||||
|
||||
const data = headers[id]
|
||||
let header = '---\n'
|
||||
header += `title: "${data.title}"\n`
|
||||
header += `description: ${data.description}\n`
|
||||
header += '---\n'
|
||||
header += `${title}${data.title}</h1>\n`
|
||||
header += `${description}${data.description}</p></div>\n\n${feedback}\n\n`
|
||||
return header
|
||||
}
|
69
website/transformer/core.ts
Normal file
69
website/transformer/core.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Copyright (c) 2025 taskylizard. Apache License 2.0.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import consola from 'consola'
|
||||
|
||||
type Transform = {
|
||||
name: string
|
||||
find: string | RegExp
|
||||
replace: string | ((match: string) => string)
|
||||
}
|
||||
|
||||
type TransformerFunc = (name: string, transforms: Transform[]) => Replacer
|
||||
|
||||
interface Replacer {
|
||||
transform: TransformerFunc
|
||||
getText(): string
|
||||
}
|
||||
|
||||
export const transformer = (text: string) => {
|
||||
const handler: ProxyHandler<{ text: string }> = {
|
||||
get(target: { text: string }, prop: string | symbol) {
|
||||
if (prop === 'transform') {
|
||||
return (name: string, transforms: Transform[]): Replacer => {
|
||||
consola.debug(`Starting transform ${name} with ${transforms}`)
|
||||
|
||||
transforms.forEach(({ name, find, replace }) => {
|
||||
consola.debug(`Transforming ${name} with ${find}`)
|
||||
target.text = target.text.replace(find, replace as any)
|
||||
})
|
||||
|
||||
// @ts-expect-error - Proxy is not typed
|
||||
return proxy
|
||||
}
|
||||
}
|
||||
if (prop === 'getText') {
|
||||
return () => target.text
|
||||
}
|
||||
return Reflect.get(target, prop)
|
||||
}
|
||||
}
|
||||
|
||||
const target = { text }
|
||||
const proxy = new Proxy(target, handler)
|
||||
return proxy as unknown as Replacer
|
||||
}
|
||||
|
||||
export function replaceUnderscore(text: string): string {
|
||||
const pattern = /\/#[\w\-]+(?:_[\w]+)*/g
|
||||
const matches = text.match(pattern) || []
|
||||
let _text = text
|
||||
for (const match of matches) {
|
||||
const replacement = match.replace(/_/g, '-')
|
||||
_text = _text.replace(match, replacement)
|
||||
}
|
||||
return _text
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue