www/src/app/resources/views/snippet.pug

42 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-03-31 15:22:41 +00:00
extends template_raj
block append style
link(rel='stylesheet' data-name='vs/editor/editor.main' href=asset('monaco/package/min/vs/editor/editor.main.css'))
block content
.container#home
if needsAccessKey
.inner
h2 Snippet: #{snippet.slug}
p This snippet is protected by an access key. Please enter it to view:
form(method='get')
.form-group
input.form-control(name='accessKey' placeholder='abc123' style="margin-right: 10px")
button View
else if needsConfirm
.inner
h2 Snippet: #{snippet.slug}
p This snippet is single-access only. Once you view it, it will be permanently deleted. Continue?
form(method='get')
if accessKey
input(name='accessKey' type='hidden' value=accessKey)
input(name='confirmSingleAccess' type='hidden' value='yes')
button Continue
else
.inner(style='width: 100%')
h2 Snippet: #{snippet.slug}
#monaco-container(style="width: 100%; height: 100%")
block append script
script.
var require = { paths: { vs: "#{asset('monaco/package/min/vs')}" }}
script(src=asset('monaco/package/min/vs/loader.js'))
script(src=asset('monaco/package/min/vs/editor/editor.main.nls.js'))
script(src=asset('monaco/package/min/vs/editor/editor.main.js'))
script.
var editor = monaco.editor.create(document.querySelector('#monaco-container'), {
theme: 'vs-dark',
value: !{JSON.stringify(snippet.body)},
language: !{JSON.stringify(snippet.syntax)},
})