mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-11-23 02:48:34 +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 id="main">
|
||||
<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");
|
||||
|
||||
// TODO display nice message when there is no hash
|
||||
|
||||
$(window).on("hashchange", display);
|
||||
display();
|
||||
|
||||
|
@ -40,20 +46,9 @@
|
|||
hash = hash.substring(1);
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: `share.php?id=${hash}`,
|
||||
success: t => {
|
||||
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;
|
||||
}
|
||||
}));
|
||||
main.html(DOMPurify.sanitize(marked.parse(t)));
|
||||
},
|
||||
// TODO display this error more nicely
|
||||
error: (r, s, e) => main.html(e)
|
||||
url: hash ? `share.php?id=${hash}` : "index.md",
|
||||
success: t => main.html(DOMPurify.sanitize(marked.parse(t))),
|
||||
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>`)
|
||||
});
|
||||
}
|
||||
</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;
|
||||
}
|
||||
|
||||
.error {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
left: 50%;
|
||||
top: 40%;
|
||||
transform: translate(-50%, -60%);
|
||||
}
|
||||
|
||||
#footer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
|
Loading…
Reference in a new issue