mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-11-23 10:58:36 +01:00
improved error styling and added index page
This commit is contained in:
parent
fd6184ae10
commit
85cb03cda4
3 changed files with 23 additions and 17 deletions
|
@ -27,10 +27,16 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<script>
|
<script>
|
||||||
|
marked.use(markedKatex());
|
||||||
|
marked.use(markedHighlight.markedHighlight({
|
||||||
|
langPrefix: "hljs language-",
|
||||||
|
highlight: (c, l) => {
|
||||||
|
const language = hljs.getLanguage(l) ? l : "plaintext";
|
||||||
|
return hljs.highlight(c, {language}).value;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
let main = $("#main");
|
let main = $("#main");
|
||||||
|
|
||||||
// TODO display nice message when there is no hash
|
|
||||||
|
|
||||||
$(window).on("hashchange", display);
|
$(window).on("hashchange", display);
|
||||||
display();
|
display();
|
||||||
|
|
||||||
|
@ -40,20 +46,9 @@
|
||||||
hash = hash.substring(1);
|
hash = hash.substring(1);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `share.php?id=${hash}`,
|
url: hash ? `share.php?id=${hash}` : "index.md",
|
||||||
success: t => {
|
success: t => main.html(DOMPurify.sanitize(marked.parse(t))),
|
||||||
marked.use(markedKatex());
|
error: (r, s, e) => main.html(`<div class="error"><p>Error loading shared note with id <code>${hash}</code>: ${e}</p><p><a href="#">Home</a></p></div>`)
|
||||||
marked.use(markedHighlight.markedHighlight({
|
|
||||||
langPrefix: "hljs language-",
|
|
||||||
highlight: (c, l) => {
|
|
||||||
const language = hljs.getLanguage(l) ? l : "plaintext";
|
|
||||||
return hljs.highlight(c, {language}).value;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
main.html(DOMPurify.sanitize(marked.parse(t)));
|
|
||||||
},
|
|
||||||
// TODO display this error more nicely
|
|
||||||
error: (r, s, e) => main.html(e)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
3
server/public/index.md
Normal file
3
server/public/index.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Just Share Please
|
||||||
|
|
||||||
|
Just Share Please is an [Obsidian](https://obsidian.md) plugin that allows quickly and easily sharing individual notes online using an anonymized link. It's pretty cool!
|
|
@ -46,6 +46,14 @@ a:hover {
|
||||||
margin: 40px auto 80px;
|
margin: 40px auto 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
position: absolute;
|
||||||
|
text-align: center;
|
||||||
|
left: 50%;
|
||||||
|
top: 40%;
|
||||||
|
transform: translate(-50%, -60%);
|
||||||
|
}
|
||||||
|
|
||||||
#footer {
|
#footer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
Loading…
Reference in a new issue