Compare commits

..

9 commits

Author SHA1 Message Date
2c4ce556dc
Release 1.3.1
All checks were successful
/ pre-commit (push) Successful in 2m9s
Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-14 08:08:47 +02:00
121971210a fix: use innerText instead of innerHTML (#47)
All checks were successful
/ pre-commit (push) Successful in 1m57s
Reviewed-on: #47
Reviewed-by: Julien Riou <jriou@monitoring@riou.xyz>
Co-authored-by: Thibault Piron <thibault.piron.ext@ovhcloud.com>
Co-committed-by: Thibault Piron <thibault.piron.ext@ovhcloud.com>
2025-10-13 17:38:25 +02:00
020b50fb58 fix: add missing return in protected note create handler (#46)
All checks were successful
/ pre-commit (push) Successful in 2m4s
Reviewed-on: #46
Reviewed-by: Julien Riou <jriou@monitoring@riou.xyz>
Co-authored-by: Thibault Piron <thibault.piron.ext@ovhcloud.com>
Co-committed-by: Thibault Piron <thibault.piron.ext@ovhcloud.com>
2025-10-13 17:37:20 +02:00
685914c323
Release 1.3.0
All checks were successful
/ pre-commit (push) Successful in 1m57s
Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-10 17:30:09 +02:00
0ed61db444
docs(README): configuration file is optional
All checks were successful
/ pre-commit (push) Successful in 1m16s
Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-10 13:01:59 +02:00
b35828d909
feat: Add clients base URL
All checks were successful
/ pre-commit (push) Successful in 1m18s
- Add `clients_base_url` to define an alternative URL to download clients

- Rename `clients_directory` to `clients_base_directory` to download clients
  locally based on the version. If `show_version` is disabled and
  `clients_base_directory` are both defined, a redirection to a remote URL with
  the "latest" version is chosen in order to avoid to disclose the server
  version.

Fixes #43.

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-10 12:55:26 +02:00
ab6b03a6d4
feat: serve clients binaries from a local directory
All checks were successful
/ pre-commit (push) Successful in 1m18s
Fixes #44.

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-10 12:30:48 +02:00
b0c0162b06
feat: serve only the bootstrap minimal css file
All checks were successful
/ pre-commit (push) Successful in 1m21s
Fixes #45.

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-10 09:20:12 +02:00
888e2b3278
fix(clients): download URL for copier
All checks were successful
/ pre-commit (push) Successful in 1m25s
The project name is "coller" and not the client name.

Fixes #42.

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-10-06 13:44:36 +02:00
7 changed files with 35 additions and 13 deletions

View file

@ -1 +1 @@
1.2.0
1.3.1

View file

@ -41,9 +41,11 @@ The file format is **JSON**:
* **tls_key_file** (string): Path to TLS key file to enable HTTPS
* **ace_directory** (string): Serve [Ace](hhttps://ace.c9.io/) assets from this local directory (ex: "./node_modules/ace-builds"). See **Dependencies** for details.
* **bootstrap_directory** (string): Serve [Bootstrap](https://getbootstrap.com/) assets from this local directory (ex: "./node_modules/bootstrap/dist"). See **Dependencies** for details.
* **clients_base_directory** (string): Serve clients binaries from this local base directory (ex: "./releases"). The version will be append to the directory. Ignored if `show_version` is disabled.
* **clients_base_url** (string): Define the base URL to download clients (default "https://git.riou.xyz/jriou/coller/releases/download"). The version (or "latest") will be append.
* **disable_editor** (bool): Disable Ace editor.
The configuration file is not required but the service might not be exposed to the public.
The configuration file is optional.
## API

View file

@ -34,6 +34,8 @@ type Config struct {
AceDirectory string `json:"ace_directory"`
BootstrapDirectory string `json:"bootstrap_directory"`
DisableEditor bool `json:"disable_editor"`
ClientsBaseURL string `json:"clients_base_url"`
ClientsBaseDirectory string `json:"clients_base_directory"`
}
func NewConfig() *Config {
@ -80,6 +82,7 @@ func NewConfig() *Config {
Language: "text",
EnableUploadFileButton: true,
EnablePasswordProtection: true,
ClientsBaseURL: "https://git.riou.xyz/jriou/coller/releases/download",
}
}

View file

@ -234,6 +234,8 @@ func (h *GetProtectedNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
type ClientHandler struct {
logger *slog.Logger
version string
baseURL string
baseDirectory string
}
func (h *ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@ -248,10 +250,19 @@ func (h *ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
version := h.version
if version == "" {
version = "latest"
// No disclosure of the version running on the server
if h.version == "" {
http.Redirect(w, r, fmt.Sprintf("%s/%s/%s-%s-%s", h.baseURL, "latest", clientName, os, arch), http.StatusMovedPermanently)
return
}
http.Redirect(w, r, fmt.Sprintf("https://git.riou.xyz/jriou/%s/releases/download/%s/%s-%s-%s", clientName, version, clientName, os, arch), http.StatusMovedPermanently)
if h.baseDirectory != "" {
// Serve file locally
// Example: ./releases/1.2.0/coller-linux-amd64
http.ServeFile(w, r, fmt.Sprintf("%s/%s/%s-%s-%s", h.baseDirectory, h.version, clientName, os, arch))
} else {
// Redirect to a download link
// Example: https://git.riou.xyz/jriou/coller/releases/download/1.2.0/coller-linux-amd64
http.Redirect(w, r, fmt.Sprintf("%s/%s/%s-%s-%s", h.baseURL, h.version, clientName, os, arch), http.StatusMovedPermanently)
}
}

View file

@ -147,10 +147,12 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
if !h.PageData.AllowNoEncryption && noEncryption != "" {
h.WebError(w, logger, ErrEncryptionRequired, nil)
return
}
if !h.PageData.AllowClientEncryptionKey && encryptionKey != "" {
h.WebError(w, logger, ErrClientEncryptionKeyNotAllowed, nil)
return
}
if !h.PageData.AllowClientEncryptionKey && encryptionKey == "" && noEncryption == "" {

View file

@ -135,6 +135,8 @@ func (s *Server) Start() error {
clientHandler := &ClientHandler{
logger: s.logger,
version: p.Version,
baseURL: s.config.ClientsBaseURL,
baseDirectory: s.config.ClientsBaseDirectory,
}
r.Path("/clients/{os:[a-z]+}-{arch:[a-z0-9]+}/{clientName:[a-z]+}").Handler(clientHandler).Methods("GET")
@ -177,7 +179,9 @@ func (s *Server) Start() error {
}
if s.config.BootstrapDirectory != "" {
r.PathPrefix("/static/bootstrap/").Handler(http.StripPrefix("/static/bootstrap/", http.FileServer(http.Dir(s.config.BootstrapDirectory))))
r.HandleFunc("/static/bootstrap/css/bootstrap.min.css", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, s.config.BootstrapDirectory+"/css/bootstrap.min.css")
})
}
r.Path("/").Handler(&HomeHandler{Templates: templates, PageData: p}).Methods("GET")

View file

@ -48,7 +48,7 @@
if (encryptionKey != "") {
copierCommand += "#" + encryptionKey;
}
document.getElementById("copierCommand").innerHTML = copierCommand;
document.getElementById("copierCommand").innerText = copierCommand;
document.getElementById("copier").addEventListener("click", () => {
document.getElementById("copierContainer").style.display = "";
});
@ -77,7 +77,7 @@
curlCommand += " -XPOST -d '" + payload + "'";
}
curlCommand += " " + window.location.origin + "/api/note/{{ .Note.ID }}";
document.getElementById("curlCommand").innerHTML = curlCommand;
document.getElementById("curlCommand").innerText = curlCommand;
document.getElementById("curl").addEventListener("click", () => {
document.getElementById("curlContainer").style.display = "";
});