forked from jriou/coller
Compare commits
No commits in common. "cfdf653c47026d3c5575ba36668a1e50d4c28c50" and "792eff78cc154d73a5412c4e6cfec9c57e22fdb6" have entirely different histories.
cfdf653c47
...
792eff78cc
3 changed files with 9 additions and 23 deletions
|
@ -25,7 +25,6 @@ type Config struct {
|
|||
ObservationInterval int `json:"observation_internal"`
|
||||
Languages []string `json:"languages"`
|
||||
Language string `json:"language"`
|
||||
UploadFileButton bool `json:"upload_file_button"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
@ -70,8 +69,7 @@ func NewConfig() *Config {
|
|||
"SQL",
|
||||
"YAML",
|
||||
},
|
||||
Language: "text",
|
||||
UploadFileButton: true,
|
||||
Language: "text",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,14 +186,13 @@ 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
|
||||
UploadFileButton bool
|
||||
Title string
|
||||
Version string
|
||||
Expirations []int
|
||||
Languages []string
|
||||
Err error
|
||||
URL string
|
||||
Note *Note
|
||||
}
|
||||
|
||||
type HomeHandler struct {
|
||||
|
@ -247,7 +246,7 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
|
|||
}
|
||||
|
||||
h.logger.Debug("checking file content type")
|
||||
if !strings.HasPrefix(handler.Header.Get("Content-Type"), "text/") {
|
||||
if handler.Header.Get("Content-Type") != "text/plain" {
|
||||
h.PageData.Err = fmt.Errorf("text file expected (got %s)", handler.Header.Get("Content-Type"))
|
||||
h.Templates.ExecuteTemplate(w, templateName, h.PageData)
|
||||
return
|
||||
|
@ -378,12 +377,6 @@ func (h *GetProtectedWebNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
|
|||
return
|
||||
}
|
||||
|
||||
if note == nil {
|
||||
h.PageData.Err = fmt.Errorf("Note doesn't exist or has been deleted")
|
||||
h.Templates.ExecuteTemplate(w, templateName, h.PageData)
|
||||
return
|
||||
}
|
||||
|
||||
if password != "" && note.Encrypted {
|
||||
note.Content, err = internal.Decrypt(note.Content, password)
|
||||
if err != nil {
|
||||
|
@ -433,9 +426,6 @@ 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 {
|
||||
|
|
|
@ -31,11 +31,9 @@
|
|||
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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue