Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
53e8143520
commit
577d19b9d8
6 changed files with 20 additions and 2 deletions
|
@ -38,6 +38,7 @@ The file format is **JSON**:
|
|||
* **tls_key_file** (string): Path to TLS key file to enable HTTPS
|
||||
* **ace_directory** (string): Serve [Ace](hhttps://ace.c9.io/) assets from this local directory (ex: "./node_modules/ace-builds"). See **Dependencies** for details.
|
||||
* **bootstrap_directory** (string): Serve [Bootstrap](https://getbootstrap.com/) assets from this local directory (ex: "./node_modules/bootstrap/dist"). See **Dependencies** for details.
|
||||
* **disable_editor** (bool): Disable Ace editor.
|
||||
|
||||
The configuration file is not required but the service might not be exposed to the public.
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ type Config struct {
|
|||
TLSKeyFile string `json:"tls_key_file"`
|
||||
AceDirectory string `json:"ace_directory"`
|
||||
BootstrapDirectory string `json:"bootstrap_directory"`
|
||||
DisableEditor bool `json:"disable_editor"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
|
|
@ -29,6 +29,7 @@ type PageData struct {
|
|||
EnableUploadFileButton bool
|
||||
AceDirectory string
|
||||
BootstrapDirectory string
|
||||
DisableEditor bool
|
||||
}
|
||||
|
||||
type HomeHandler struct {
|
||||
|
|
|
@ -118,6 +118,7 @@ func (s *Server) Start() error {
|
|||
Languages: s.config.Languages,
|
||||
AceDirectory: s.config.AceDirectory,
|
||||
BootstrapDirectory: s.config.BootstrapDirectory,
|
||||
DisableEditor: s.config.DisableEditor,
|
||||
}
|
||||
|
||||
if s.config.ShowVersion {
|
||||
|
|
|
@ -58,11 +58,15 @@
|
|||
</div>
|
||||
|
||||
<div class="container mb-4">
|
||||
{{if .DisableEditor}}
|
||||
<textarea class="form-control" id="content" name="content" cols="40" rows="12"></textarea>
|
||||
{{else}}
|
||||
<div class="row">
|
||||
<div id="editor" name="editor" class="form-control"
|
||||
style="height: 300px; resize: vertical; overflow: auto;"></div>
|
||||
<input type="hidden" id="content" />
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="container mb-4">
|
||||
<div class="row text-center justify-content-center">
|
||||
|
@ -71,6 +75,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{if eq false .DisableEditor}}
|
||||
<script
|
||||
src="{{if .AceDirectory}}/static/ace-builds{{else}}https://cdn.jsdelivr.net/npm/ace-builds@1.43.3{{end}}/src-noconflict/ace.js"
|
||||
type="text/javascript" charset="utf-8"></script>
|
||||
|
@ -103,6 +108,7 @@
|
|||
e.formData.append('content', editor.getValue());
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
</form>
|
||||
|
||||
{{block "footer" .}}{{end}}
|
||||
|
|
|
@ -33,9 +33,16 @@
|
|||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
{{if .DisableEditor}}
|
||||
<div class="row">
|
||||
<pre class="border px-3 pt-3" style="min-height: 300px; resize: vertical; overflow: auto;">
|
||||
{{string .Note.Content}}
|
||||
</pre>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="row">
|
||||
<div id="editor" name="editor" class="form-control"
|
||||
style="height: 300px; resize: vertical; overflow: auto;"></div>
|
||||
style="min-height: 300px; resize: vertical; overflow: auto;"></div>
|
||||
</div>
|
||||
<script
|
||||
src="{{if .AceDirectory}}/static/ace-builds{{else}}https://cdn.jsdelivr.net/npm/ace-builds@1.43.3{{end}}/src-noconflict/ace.js"
|
||||
|
@ -46,6 +53,7 @@
|
|||
editor.setReadOnly(true);
|
||||
editor.getSession().setMode("ace/mode/{{.Note.Language}}");
|
||||
editor.getSession().selection.clearSelection();
|
||||
editor.setOptions({maxLines: Infinity});
|
||||
|
||||
if (document.documentElement.getAttribute('data-bs-theme') == 'light') {
|
||||
editor.setTheme("ace/theme/github_light_default");
|
||||
|
@ -61,8 +69,8 @@
|
|||
editor.setTheme("ace/theme/github_dark")
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue