Compare commits
3 commits
4944e47e76
...
3f8d42571b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3f8d42571b |
||
33628331f4 | |||
938d10c3a6 |
4 changed files with 38 additions and 32 deletions
|
@ -33,6 +33,7 @@ The file format is **JSON**:
|
|||
* **observation_internal** (int): Number of seconds to wait between two observations (default 60)
|
||||
* **languages** ([]string): List of supported [languages](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)
|
||||
* **language** (string): Default language (default "text")
|
||||
* **enable_upload_file_button** (bool): Display the upload file button in the UI (default true)
|
||||
|
||||
The configuration file is not required but the service might not be exposed to the public.
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ type Config struct {
|
|||
ObservationInterval int `json:"observation_internal"`
|
||||
Languages []string `json:"languages"`
|
||||
Language string `json:"language"`
|
||||
EnableUploadFileButton bool `json:"enable_upload_file_button"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
@ -70,6 +71,7 @@ func NewConfig() *Config {
|
|||
"YAML",
|
||||
},
|
||||
Language: "text",
|
||||
EnableUploadFileButton: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,10 +189,12 @@ type PageData struct {
|
|||
Title string
|
||||
Version string
|
||||
Expirations []int
|
||||
Expiration int
|
||||
Languages []string
|
||||
Err error
|
||||
URL string
|
||||
Note *Note
|
||||
EnableUploadFileButton bool
|
||||
}
|
||||
|
||||
type HomeHandler struct {
|
||||
|
@ -345,9 +347,6 @@ func (h *GetWebNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
h.PageData.Err = fmt.Errorf("jriou")
|
||||
h.Templates.ExecuteTemplate(w, templateName, h.PageData)
|
||||
|
||||
h.PageData.Note = note
|
||||
|
||||
h.logger.Debug("rendering note web page")
|
||||
|
@ -426,12 +425,14 @@ func (s *Server) Start() error {
|
|||
p := PageData{
|
||||
Title: s.config.Title,
|
||||
Expirations: s.config.Expirations,
|
||||
Expiration: s.config.Expiration,
|
||||
Languages: s.config.Languages,
|
||||
}
|
||||
|
||||
if s.config.ShowVersion {
|
||||
p.Version = s.version
|
||||
}
|
||||
p.EnableUploadFileButton = s.config.EnableUploadFileButton
|
||||
|
||||
templates, err := template.New("templates").Funcs(funcs).ParseFS(templatesFS, "templates/*.html")
|
||||
if err != nil {
|
||||
|
|
|
@ -31,14 +31,16 @@
|
|||
value="delete-after-read" name="delete-after-read">
|
||||
<label class="col-form-label col-form-label-sm" for="delete-after-read">Delete after read</label>
|
||||
</div>
|
||||
{{if .EnableUploadFileButton}}
|
||||
<div class="col">
|
||||
<input type="file" class="form-control" for="file" id="file" name="file" accept="text/plain" />
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="col">
|
||||
<select class="form-select" aria-label="Expiration" id="expiration" name="expiration">
|
||||
<option selected="selected" disabled>Expiration</option>
|
||||
{{range .Expirations}}
|
||||
<option value="{{.}}">{{HumanDuration .}}</option>
|
||||
<option disabled>Expiration</option>
|
||||
{{range $exp := .Expirations}}
|
||||
<option {{ if eq $exp $.Expiration }}selected="selected"{{end}} value="{{$exp}}">{{HumanDuration $exp}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue