Compare commits

...

1 commit

Author SHA1 Message Date
Thibault Piron
4944e47e76
feat: add possibility to hide upload button 2025-09-14 19:10:57 +02:00
4 changed files with 33 additions and 26 deletions

View file

@ -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.

View file

@ -7,24 +7,25 @@ import (
)
type Config struct {
Title string `json:"title"`
DatabaseType string `json:"database_type"`
DatabaseDsn string `json:"database_dsn"`
IDLength int `json:"id_length"`
PasswordLength int `json:"password_length"`
ExpirationInterval int `json:"expiration_interval"`
ListenAddress string `json:"listen_address"`
ListenPort int `json:"listen_port"`
Expirations []int `json:"expirations"`
Expiration int `json:"expiration"`
MaxUploadSize int64 `json:"max_upload_size"`
ShowVersion bool `json:"show_version"`
EnableMetrics bool `json:"enable_metrics"`
PrometheusRoute string `json:"prometheus_route"`
PrometheusNotesMetric string `json:"prometheus_notes_metric"`
ObservationInterval int `json:"observation_internal"`
Languages []string `json:"languages"`
Language string `json:"language"`
Title string `json:"title"`
DatabaseType string `json:"database_type"`
DatabaseDsn string `json:"database_dsn"`
IDLength int `json:"id_length"`
PasswordLength int `json:"password_length"`
ExpirationInterval int `json:"expiration_interval"`
ListenAddress string `json:"listen_address"`
ListenPort int `json:"listen_port"`
Expirations []int `json:"expirations"`
Expiration int `json:"expiration"`
MaxUploadSize int64 `json:"max_upload_size"`
ShowVersion bool `json:"show_version"`
EnableMetrics bool `json:"enable_metrics"`
PrometheusRoute string `json:"prometheus_route"`
PrometheusNotesMetric string `json:"prometheus_notes_metric"`
ObservationInterval int `json:"observation_internal"`
Languages []string `json:"languages"`
Language string `json:"language"`
EnableUploadFileButton bool `json:"enable_upload_file_button"`
}
func NewConfig() *Config {
@ -69,7 +70,8 @@ func NewConfig() *Config {
"SQL",
"YAML",
},
Language: "text",
Language: "text",
EnableUploadFileButton: 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
EnableUploadFileButton bool
}
type HomeHandler struct {
@ -432,6 +433,7 @@ func (s *Server) Start() error {
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 {

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 .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>