Toggle Starred

This commit is contained in:
taskylizard 2023-11-12 13:39:41 +05:30
parent 054e91e6ff
commit d58d95b768
No known key found for this signature in database
GPG Key ID: 5CABA3D642DDC497
10 changed files with 92 additions and 109 deletions

82
.github/replace.py vendored
View File

@ -39,7 +39,8 @@ def change_some_general_formatting(text):
text = re.sub(r'^\* \*\*Note\*\* - (.+)$', r':::tip\n\1\n:::', text, flags=re.MULTILINE)
text = re.sub(r'^Note - (.+)$', r':::tip\n\1\n:::', text, flags=re.MULTILINE)
text = re.sub(r'^\*\*Warning\*\* - (.+)$', r':::warning\n\1\n:::', text, flags=re.MULTILINE)
text = re.sub(r'^\*\s([^*])', "- \\1", text, 0, re.MULTILINE)
return text
def remove_backtowiki_and_toc(text):
@ -112,83 +113,4 @@ def apply_replace_to_all_md_files_in_current_dir():
with open(file, 'w', encoding='utf-8') as f2:
f2.write(content)
def print_info_for_confirmation():
print("This script is about to replace URLs in all .md files in the current directory: " + os.getcwd())
print("The affected files will be the following:")
files = os.listdir('.')
for file in files:
if file.endswith('.md'):
print(file)
# TESTER
testText = """
aaaaaaaa (https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/storage#wiki_telegram_audio_download) aaaaaaa
**[ Back to Wiki Index](https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/index)**
* **[YouTube Music Clients](https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/storage#wiki_youtube_music_players)**
Soundtracks](https://github.com/nbats/FMHYedit/blob/main/base64.md#damons-game-soundtracks)**, [Squ
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/storage#wiki_game_libraries_.2F_launcher)
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/games#wiki_.25BA_tracking_.2F_discovery)
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/linux#wiki_.25BA_linux_adblock_.2F_privacy)
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/video#wiki_.25BA_download_sites)
[sdfasdf](https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/android#wiki_.25B7_android_podcasts_.2F_radio)gwrgewrgew
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/android#wiki_.25B7_android_relaxation)
adfads awerfaw (https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/storage#wiki_music_libraries_.2F_players)
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/edu/#wiki_.25BA_downloading) aaaaaaaaa
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/adblock-vpn-privacy#wiki_.25B7_adblocking_extensions)
* [link](https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/torrent) - ...sdvs
https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/img-tools#wiki_.25B7_painting_.2F_drawing
* **[AI Indexes](https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/ai#wiki_.25BA_ai_indexes)** - Artificial Intelligence Indexes
(https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/adblock-vpn-privacy#wiki_.25BA_vpn)
https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/storage/#wiki_open_directory_search_string_builder
https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/tools-misc#wiki_.25B7_file_tools
~~~~~~
***
***
**[ Back to Wiki Index](https://www.reddit.com/r/FREEMEDIAHECKYEAH/wiki/index)**
***
***
**[Table of Contents](https://i.imgur.com/whYmImm.png)** - For mobile users
***
***
~~~~~~
argaseg ae this is legit test between stuff to remove1
***
# ► with ##
## ▷ with ###
#### with ###
* **Note** - Some aggregators still include TPB, so it's best to avoid using them for software and games.
**Warning** - Misuse of Chat Archivers, Deleters, Mods & 3rd Party Clients is against Discords TOS, so use them at your own risk.
**[movie-web](https://movie-web.app/) / [FMovies](https://fmovies.name/) / [Soap2Day](https://soapgate.org/)** - Fast streaming
**[Zoro](https://zoro.to/) / [9Anime](https://www.9anime.to/)** - Fast anime streaming
"""
def just_test_the_replacer_function():
print("---TEST---")
print("This is how the resulting edited links would look like:")
print( replace_urls_in_links_to_FMHY_wiki(testText) )
print("---END OF TEST---\n\n\n")
just_test_the_replacer_function()
# MAIN EXECUTION
print("---MAIN SCRIPT---")
print_info_for_confirmation()
apply_replace_to_all_md_files_in_current_dir()
print("---END OF MAIN SCRIPT---")

View File

@ -4,10 +4,10 @@ import UnoCSS from "unocss/vite";
import { presetUno, presetAttributify, presetIcons } from "unocss";
import { commitRef, meta } from "./constants";
import { pwa } from "./pwa";
import { generateMeta } from "./hooks/meta";
import { fileURLToPath } from "url";
import { copyableCodePlugin } from "./markdown";
import { generateImages } from "./hooks";
import { generateImages, generateMeta } from "./hooks";
import { toggleStarredPlugin } from "./markdown/toggleStarred";
import { base64DecodePlugin } from "./markdown/base64";
export default defineConfig({
title: "FMHY",
@ -73,7 +73,8 @@ export default defineConfig({
},
markdown: {
config(md) {
md.use(copyableCodePlugin);
md.use(toggleStarredPlugin);
md.use(base64DecodePlugin);
},
},
themeConfig: {
@ -84,7 +85,7 @@ export default defineConfig({
provider: "local",
},
footer: {
message: `Made with ❤️ (${commitRef})`,
message: `Made with ❤️ (rev: ${commitRef})`,
},
outline: "deep",
logo: "/fmhy.ico",

View File

@ -3,14 +3,21 @@ defineProps<{ title: string; description?: string }>();
</script>
<template>
<div tw="w-full h-full bg-black flex flex-col" style="background-image: url(https://files.catbox.moe/1f84dy.png)">
<div
tw="w-full h-full bg-black flex flex-col"
style="background-image: url(https://files.catbox.moe/1f84dy.png)">
<div tw="p-10 w-full min-h-0 grow flex flex-col items-center justify-between">
<div tw="w-full flex justify-between items-center text-5xl font-medium">
<div tw="flex items-center">
<div tw="text-zinc-100 ml-2 mt-1 font-semibold">freemediaheckyeah</div>
</div>
<div tw="flex items-center text-zinc-300">
<svg height="48" width="48" viewBox="0 -960 960 960" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<svg
height="48"
width="48"
viewBox="0 -960 960 960"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg">
<path
d="M831-327.5V-558L516-386.5q-17 9-36 9t-36-9l-329.5-180q-10-5.5-14.5-14.25t-4.5-18.75q0-10 4.5-18.75t14.5-14.25l330-179.5q8.5-5 17.25-7t18.25-2q9.5 0 18.25 2t17.25 7l371 202q9 5 14.25 13.75T906-577v249.5q0 15.5-11 26.5t-26.5 11q-15.5 0-26.5-11t-11-26.5Zm-387 173-197-107q-18.5-10-28.75-27.75T208-328v-149.5L444-349q17 9 36 9t36-9l236-128.5V-328q0 21-10.25 38.75T713-261.5l-197 107q-8.5 5-17.5 7t-18.5 2q-9.5 0-18.5-2t-17.5-7Z" />
</svg>

View File

@ -14,21 +14,21 @@ export function generateMeta(context: TransformContext, hostname: string) {
head.push(["meta", { property: "og:title", content: pageData.frontmatter.title }]);
head.push(["meta", { name: "twitter:title", content: pageData.frontmatter.title }]);
head.push([
"meta",
{
property: "og:description",
content: pageData.frontmatter.description,
},
]);
head.push([
"meta",
{
name: "twitter:description",
content: pageData.frontmatter.description,
},
]);
head.push([
"meta",
{
property: "og:description",
content: pageData.frontmatter.description,
},
]);
head.push([
"meta",
{
name: "twitter:description",
content: pageData.frontmatter.description,
},
]);
if (pageData.frontmatter.image) {
head.push([
"meta",

View File

@ -0,0 +1,25 @@
import { type MarkdownRenderer } from "vitepress";
// FIXME: tasky: possibly write less horror jank?
export function base64DecodePlugin(md: MarkdownRenderer) {
const decode = (str: string): string => Buffer.from(str, "base64").toString("binary");
// Save the original rule for backticks
const defaultRender =
md.renderer.rules.code_inline ||
function (tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};
md.renderer.rules.code_inline = function (tokens, idx, options, env, self) {
// @ts-expect-error shut the fuck up already I HATE THIS
if (!env.frontmatter.title || (env.frontmatter.title && !env.frontmatter.title === "base64")) {
return defaultRender(tokens, idx, options, env, self);
}
const token = tokens[idx];
const content = token.content;
return `<button class='base64' onclick="(function(btn){ const codeEl = btn.querySelector('code'); navigator.clipboard.writeText('${decode(
content,
)}').then(() => { const originalText = codeEl.textContent; codeEl.textContent = 'Copied'; setTimeout(() => codeEl.textContent = originalText, 3000); }).catch(console.error); })(this)"><code>${content}</code></button>`;
};
}

View File

@ -0,0 +1,11 @@
import type { MarkdownRenderer } from "vitepress";
export function toggleStarredPlugin(md: MarkdownRenderer) {
md.renderer.rules.list_item_open = (tokens, index, options, env, self) => {
const contentToken = tokens[index + 2];
if (contentToken && contentToken.content.startsWith("⭐")) {
return `<li class="starred">`;
}
return self.renderToken(tokens, index, options);
};
}

View File

@ -1,6 +1,6 @@
import { corsEventHandler } from "nitro-cors";
export default corsEventHandler((_event) => { }, {
export default corsEventHandler((_event) => {}, {
origin: "*",
methods: "*",
});

View File

@ -2,6 +2,7 @@
import Field from "./CardField.vue";
import Modal from "./Modal.vue";
import InputField from "./InputField.vue";
import ToggleStarred from "./ToggleStarred.vue";
</script>
<template>
@ -20,11 +21,11 @@ import InputField from "./InputField.vue";
<Modal />
</template>
</InputField>
<!-- <InputField id="toggle-starred" label="Toggle Starred"> -->
<!-- <template #display> -->
<!-- <button class="p-[4px 8px] text-xl i-carbon:star"></button> -->
<!-- </template> -->
<!-- </InputField> -->
<InputField id="toggle-starred" label="Toggle Starred">
<template #display>
<ToggleStarred />
</template>
</InputField>
</div>
</template>

View File

@ -0,0 +1,13 @@
<script setup lang="ts">
const toggleStarred = () => document.documentElement.classList.toggle("starred-only");
</script>
<template>
<button class="p-[4px 8px] text-xl i-carbon:star" @click="toggleStarred()" />
</template>
<style>
.starred-only li:not(.starred) {
display: none;
}
</style>

View File

@ -1,3 +1,6 @@
{
"extends": "./.nitro/types/tsconfig.json"
"extends": "./.nitro/types/tsconfig.json",
"compilerOptions": {
"verbatimModuleSyntax": true
}
}