feat: add possibility to hide upload button #25

Merged
jriou merged 1 commit from tapiron/coller:feat/make_file_upload_button_optional into main 2025-09-15 09:20:51 +02:00
4 changed files with 34 additions and 27 deletions
Showing only changes of commit 3f8d42571b - Show all commits

feat: add possibility to hide upload button

Thibault Piron 2025-09-12 18:20:19 +02:00
Signed by untrusted user who does not match committer: tapiron
GPG key ID: 37EE240037F90B38

View file

@ -33,6 +33,7 @@ The file format is **JSON**:
* **observation_internal** (int): Number of seconds to wait between two observations (default 60) * **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) * **languages** ([]string): List of supported [languages](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)
* **language** (string): Default language (default "text") * **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. The configuration file is not required but the service might not be exposed to the public.

View file

@ -25,6 +25,7 @@ type Config struct {
ObservationInterval int `json:"observation_internal"` ObservationInterval int `json:"observation_internal"`
Languages []string `json:"languages"` Languages []string `json:"languages"`
Language string `json:"language"` Language string `json:"language"`
EnableUploadFileButton bool `json:"enable_upload_file_button"`
} }
func NewConfig() *Config { func NewConfig() *Config {
@ -70,6 +71,7 @@ func NewConfig() *Config {
"YAML", "YAML",
}, },
Language: "text", Language: "text",
EnableUploadFileButton: true,
} }
} }

View file

@ -194,6 +194,7 @@ type PageData struct {
Err error Err error
URL string URL string
Note *Note Note *Note
EnableUploadFileButton bool
} }
type HomeHandler struct { type HomeHandler struct {
@ -431,6 +432,7 @@ func (s *Server) Start() error {
if s.config.ShowVersion { if s.config.ShowVersion {
p.Version = s.version p.Version = s.version
} }
p.EnableUploadFileButton = s.config.EnableUploadFileButton
templates, err := template.New("templates").Funcs(funcs).ParseFS(templatesFS, "templates/*.html") templates, err := template.New("templates").Funcs(funcs).ParseFS(templatesFS, "templates/*.html")
if err != nil { if err != nil {

View file

@ -31,9 +31,11 @@
value="delete-after-read" name="delete-after-read"> 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> <label class="col-form-label col-form-label-sm" for="delete-after-read">Delete after read</label>
</div> </div>
{{if .EnableUploadFileButton}}
<div class="col"> <div class="col">
<input type="file" class="form-control" for="file" id="file" name="file" accept="text/plain" /> <input type="file" class="form-control" for="file" id="file" name="file" accept="text/plain" />
</div> </div>
{{end}}
<div class="col"> <div class="col">
<select class="form-select" aria-label="Expiration" id="expiration" name="expiration"> <select class="form-select" aria-label="Expiration" id="expiration" name="expiration">
<option disabled>Expiration</option> <option disabled>Expiration</option>