feat: add possibility to hide upload button #25

Open
tapiron wants to merge 1 commit from tapiron/coller:feat/make_file_upload_button_optional into main
3 changed files with 16 additions and 8 deletions

View file

@ -25,6 +25,7 @@ type Config struct {
ObservationInterval int `json:"observation_internal"`
Languages []string `json:"languages"`
Language string `json:"language"`
UploadFileButton bool `json:"upload_file_button"`

Could you update the README.md file with this new setting please?

Could you update the [README.md](https://git.riou.xyz/jriou/coller/src/branch/main/src/cmd/collerd/README.md) file with this new setting please?

For booleans, I would like to add an "enable" prefix like enable_upload_file_button.

For booleans, I would like to add an "enable" prefix like `enable_upload_file_button`.
}
func NewConfig() *Config {
@ -69,7 +70,8 @@ func NewConfig() *Config {
"SQL",
"YAML",
},
Language: "text",
Language: "text",
UploadFileButton: true,
}
}

View file

@ -186,13 +186,14 @@ func (h *GetProtectedNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
}
type PageData struct {
Title string
Version string
Expirations []int
Languages []string
Err error
URL string
Note *Note
Title string
Version string
Expirations []int
Languages []string
Err error
URL string
Note *Note
UploadFileButton bool
}
type HomeHandler struct {
@ -432,6 +433,9 @@ func (s *Server) Start() error {
if s.config.ShowVersion {
p.Version = s.version
}
if s.config.UploadFileButton {
p.UploadFileButton = true
}
templates, err := template.New("templates").Funcs(funcs).ParseFS(templatesFS, "templates/*.html")
if err != nil {

View file

@ -31,9 +31,11 @@
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 .UploadFileButton}}
<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>