Initial import of LogDarioSeq baseline
Establishes version control for the personal Logseq DB fork before starting the server-client architecture migration and domain features described in docs/agent-guide and the approved implementation plan. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
168
resources/marketplace.html
Normal file
168
resources/marketplace.html
Normal file
@@ -0,0 +1,168 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Logseq Marketplace</title>
|
||||
<link rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css"
|
||||
integrity="sha512-Oy18vBnbSJkXTndr2n6lDMO5NN31UljR8e/ICzVPrGpSud4Gkckb8yUpqhKuUNoE+o9gAb4O/rAxxw1ojyUVzg=="
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer"/>
|
||||
<style>
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: sans-serif;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar-thumb:active {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar-corner {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#app {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
width: 900px;
|
||||
min-height: 100%;
|
||||
padding: 30px;
|
||||
margin: 0 auto;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#app > strong {
|
||||
padding-top: 30vh;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
pre {
|
||||
max-width: 800px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./js/marked.umd.js"></script>
|
||||
<script src="./js/purify.js"></script>
|
||||
<script>
|
||||
;(async function () {
|
||||
const app = document.getElementById('app')
|
||||
const url = new URL(location.href)
|
||||
const setMsg = (msg) => app.innerHTML = `<strong>${msg}</strong>`
|
||||
const repo = url.searchParams.get('repo')
|
||||
if (!repo) {
|
||||
return setMsg('Repo parameter not found!')
|
||||
}
|
||||
|
||||
const setContent = (content) => app.innerHTML = `<main class="markdown-body">${content}</main>`
|
||||
const endpoint = (repo, branch, file) => `https://raw.githubusercontent.com/${repo}/${branch}/${file}`
|
||||
|
||||
let defaultPoints = [
|
||||
endpoint(repo, 'master', 'README.md'), endpoint(repo, 'main', 'README.md'),
|
||||
endpoint(repo, 'master', 'readme.md'), endpoint(repo, 'main', 'readme.md')]
|
||||
|
||||
let content = ''
|
||||
let readme
|
||||
|
||||
const fixLink = (link) => readme.replace(/[^\/]+\.md$/i, link)
|
||||
const isRelative = (href) => href && !href.startsWith('http') && !!href.match(/^([.\/]+|[^\/]+)/) &&
|
||||
href.replace(/^[.\/]+/, '')
|
||||
|
||||
marked.use({
|
||||
renderer: {
|
||||
link({ href, title, text }) {
|
||||
return `<a href="${href}" target="_blank" title="${title}">${text}</a>`
|
||||
},
|
||||
|
||||
image({ href, title, text }) {
|
||||
let link = isRelative(href)
|
||||
|
||||
if (link) {
|
||||
link = fixLink(link)
|
||||
return `<img style="max-width: 100%;" src="${link}" alt="${title}" />`
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// force fix Markdown content
|
||||
function fixAllImageTagHref (content) {
|
||||
const isRelativeImageSrc = (src) => src && !src.match(/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i) && isRelative(src)
|
||||
|
||||
return content.replace(/<img\b[^>]*>/gi, (img) => {
|
||||
return img.replace(/\bsrc\s*=\s*(['"]?)([^'"\s>]+)\1/i, (attr, quote, src) => {
|
||||
const link = isRelativeImageSrc(src)
|
||||
return link ? attr.replace(src, fixLink(link)) : attr
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// load exist points content
|
||||
async function loadPage(points) {
|
||||
setMsg('Loading ...')
|
||||
|
||||
for (let url of points) {
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
if (res.status !== 200) {
|
||||
throw new Error(res.statusText)
|
||||
}
|
||||
content = await res.text()
|
||||
readme = url
|
||||
break
|
||||
} catch (e) {
|
||||
console.debug('Error:', url, e.message)
|
||||
}
|
||||
}
|
||||
|
||||
content = marked.parse(fixAllImageTagHref(content))
|
||||
setContent(DOMPurify.sanitize(content))
|
||||
}
|
||||
|
||||
// load default
|
||||
await loadPage(defaultPoints)
|
||||
|
||||
// handle link
|
||||
document.querySelector('#app').addEventListener('click', (e) => {
|
||||
const target = e.target
|
||||
const href = target.getAttribute('href')
|
||||
if (!!href && href.endsWith('.md') && !href.startsWith('http')) {
|
||||
loadPage([
|
||||
endpoint(repo, 'master', href),
|
||||
endpoint(repo, 'main', href)
|
||||
])
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
}())
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user