Compare commits
No commits in common. "e1b7961f456269a32e1f7356aab642a26cfb8bdf" and "7a0b49364fe0d831461653842d30c3eb8df55d18" have entirely different histories.
e1b7961f45
...
7a0b49364f
|
@ -13,10 +13,6 @@ npm/codemirror@5.65.16/lib/codemirror.min.css,
|
|||
npm/codemirror@5.65.16/theme/nord.min.css"
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta property="og:title" content="Paste - No-database paste service" />
|
||||
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/bokub/nopaste@images/logo.png" />
|
||||
<meta property="og:url" content="https://paste.scambier.xyz" />
|
||||
<meta property="og:type" content="website" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import { shareUrl, selectedLang } from '../store'
|
||||
import ComboBox from './ComboBox.svelte'
|
||||
import Icon from '@iconify/svelte'
|
||||
import { goto } from '$app/navigation'
|
||||
|
||||
type Language = {
|
||||
text: string
|
||||
|
@ -81,11 +80,6 @@
|
|||
function closeUrlInput() {
|
||||
isUrlInputVisible = false
|
||||
}
|
||||
|
||||
async function goToPreview() {
|
||||
await updateShareUrl()
|
||||
goto($shareUrl)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class={cssClass}>
|
||||
|
@ -122,9 +116,9 @@
|
|||
</button>
|
||||
|
||||
<!-- Switch to readonly view -->
|
||||
<button class="button" on:click={goToPreview}>
|
||||
<a class="button" href={$shareUrl}>
|
||||
<Icon class="text-xl" icon="fluent:eye-12-regular" />
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<h1 class="text-xl">Paste</h1>
|
||||
<span class="ml-8 text-xs">
|
||||
<a
|
||||
href="/?l=md#G44EgKwOeI4yftHdG1GcYD0C2OgpAyPf6/ETlHECvFqN4PKltfWVNNq/dxrd9ewVthcNrRISpdBi1XT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9qGBL6BhLpjlpqxjmf9fwkKHFYClXmn7yaZrc/HrW6YH5F6Ei9MGKMvY5be++/noh6TJ5MeGgDzeJgNr0rjvcltZrDRS8wumbWpseMjTY1bz/rp/fJVQxwy/Rd+kXjlGrMJLZsVVwED5b0Jr26wUAm85shUyLX50kklq6ZIRfnzNX4LWrnl72vWR1YaTr/3n+Cp+6IBEliYA"
|
||||
target="_blank"
|
||||
>
|
||||
About
|
||||
|
|
|
@ -33,6 +33,3 @@ export function getLangFromUrl() {
|
|||
}
|
||||
|
||||
export const byId = (id: string) => document.getElementById(id)
|
||||
|
||||
export const staticMetaDescription =
|
||||
'Paste is a client-side paste service with no database, and no back-end code. The data is stored entirely in the shared link'
|
||||
|
|
|
@ -10,26 +10,15 @@
|
|||
import 'highlight.js/styles/nord.min.css'
|
||||
import TopBar from '../components/TopBar.svelte'
|
||||
import Icon from '@iconify/svelte'
|
||||
import { getLangFromUrl, staticMetaDescription } from '$lib/utils'
|
||||
import { getLangFromUrl } from '$lib/utils'
|
||||
|
||||
let decompressed: string
|
||||
let htmlContent: string
|
||||
let isMarkdown = false
|
||||
let isPlainText = false
|
||||
|
||||
// Meta description
|
||||
$: metaDescription = (() => {
|
||||
if (decompressed) {
|
||||
const text = decompressed.slice(0, 100)
|
||||
return text + (text.length === 100 ? '...' : '')
|
||||
}
|
||||
return staticMetaDescription
|
||||
})()
|
||||
|
||||
onMount(async () => {
|
||||
let lang = getLangFromUrl()
|
||||
// Remove github flavored markdown, redundant with markdown
|
||||
lang = lang === 'gflm' ? 'md' : lang
|
||||
lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links
|
||||
|
||||
// extract the part in the url after the hash
|
||||
const hash = window.location.hash.slice(1)
|
||||
|
@ -48,7 +37,7 @@
|
|||
.use(rehypeStringify)
|
||||
.process(decompressed)
|
||||
isMarkdown = true
|
||||
htmlContent = html.toString()
|
||||
decompressed = html.toString()
|
||||
}
|
||||
// Plain text
|
||||
else if (lang === 'plt' || !lang) {
|
||||
|
@ -56,7 +45,7 @@
|
|||
}
|
||||
// Code
|
||||
else {
|
||||
htmlContent = hljs.highlight(lang, decompressed).value
|
||||
decompressed = hljs.highlight(lang, decompressed).value
|
||||
}
|
||||
} else {
|
||||
// Redirect to editor page
|
||||
|
@ -70,7 +59,7 @@
|
|||
</script>
|
||||
|
||||
<div class="overflow-hidden h-screen flex flex-col">
|
||||
{#if htmlContent || decompressed}
|
||||
{#if decompressed}
|
||||
<TopBar>
|
||||
<a
|
||||
href={'/editor' + getUrlDataPart()}
|
||||
|
@ -83,23 +72,19 @@
|
|||
<div class="overflow-y-auto grow">
|
||||
<div class="prose dark:prose-invert lg:py-12 p-[0.5em] md:max-w-3xl md:mx-auto lg:max-w-4xl">
|
||||
{#if isMarkdown}
|
||||
{@html htmlContent}
|
||||
{@html decompressed}
|
||||
{:else if isPlainText}
|
||||
<div class="whitespace-pre-line">
|
||||
{decompressed}
|
||||
</div>
|
||||
{:else}
|
||||
<pre><code>{@html htmlContent}</code></pre>
|
||||
<pre><code>{@html decompressed}</code></pre>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<svelte:head>
|
||||
<meta name="description" property="og:description" content={metaDescription} />
|
||||
</svelte:head>
|
||||
|
||||
<style lang="scss">
|
||||
:global(pre code.hljs) {
|
||||
background-color: transparent;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import type { Editor } from 'codemirror'
|
||||
import { debounce } from 'lodash-es'
|
||||
import * as brotli from '$lib/brotli'
|
||||
import { byId, staticMetaDescription } from '$lib/utils'
|
||||
import { byId } from '$lib/utils'
|
||||
import TopBar from '../../components/TopBar.svelte'
|
||||
import { selectedLang, shareUrl } from '../../store'
|
||||
import EditForm from '../../components/EditForm.svelte'
|
||||
|
@ -18,8 +18,7 @@
|
|||
if (editor) {
|
||||
const url = new URL(window.location.origin)
|
||||
compressed = await brotli.compress(editor.getValue())
|
||||
// Set the language (ignore for plain text, since it's the default)
|
||||
if ($selectedLang && $selectedLang !== 'plt') {
|
||||
if ($selectedLang) {
|
||||
url.searchParams.set('l', $selectedLang)
|
||||
}
|
||||
url.hash = compressed
|
||||
|
@ -33,8 +32,6 @@
|
|||
}, 1000)
|
||||
|
||||
async function initCodeEditor() {
|
||||
$selectedLang = new URLSearchParams(window.location.search).get('l') ?? ' plt'
|
||||
|
||||
CodeMirror.modeURL = 'https://cdn.jsdelivr.net/npm/codemirror@5.65.16/mode/%N/%N.js'
|
||||
editor = new CodeMirror(byId('editor'), {
|
||||
lineNumbers: true,
|
||||
|
@ -67,11 +64,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
$selectedLang = new URLSearchParams(window.location.search).get('l') ?? ' plt'
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta name="description" property="og:description" content={staticMetaDescription} />
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/combine/
|
||||
npm/codemirror@5.65.16,
|
||||
|
|
Loading…
Reference in New Issue
Block a user