Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c87187c6d | |||
| f628b489af |
34
README.md
34
README.md
@@ -54,6 +54,37 @@ links from `/admin/users`.
|
|||||||
The env admin token still exists as emergency fallback access. Set `WARPBOX_ADMIN_TOKEN` and use it
|
The env admin token still exists as emergency fallback access. Set `WARPBOX_ADMIN_TOKEN` and use it
|
||||||
at `/admin/login` if you need to recover access without a user session.
|
at `/admin/login` if you need to recover access without a user session.
|
||||||
|
|
||||||
|
## Emoji reaction packs
|
||||||
|
|
||||||
|
File reactions use emoji packs from the runtime data directory, not from the application code. By
|
||||||
|
default that means `./data/emoji`; if you change `WARPBOX_DATA_DIR`, use
|
||||||
|
`$WARPBOX_DATA_DIR/emoji` instead.
|
||||||
|
|
||||||
|
Each folder under `./data/emoji` becomes one emoji tab in the reaction picker. Put image files
|
||||||
|
directly inside the pack folder:
|
||||||
|
|
||||||
|
```text
|
||||||
|
data/
|
||||||
|
├── db/
|
||||||
|
├── files/
|
||||||
|
├── logs/
|
||||||
|
└── emoji/
|
||||||
|
├── openmoji/
|
||||||
|
│ ├── 1F600.svg
|
||||||
|
│ ├── 1F44D.svg
|
||||||
|
│ └── 2764.svg
|
||||||
|
├── pixel-pack/
|
||||||
|
│ ├── happy.webp
|
||||||
|
│ ├── fire.webp
|
||||||
|
│ └── star.webp
|
||||||
|
└── custom-work/
|
||||||
|
├── approved.png
|
||||||
|
└── shipped.png
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, the picker shows tabs named `Openmoji`, `Pixel pack`, and `Custom work`.
|
||||||
|
Supported emoji image extensions are `.svg`, `.webp`, `.png`, `.jpg`, `.jpeg`, and `.gif`.
|
||||||
|
|
||||||
For one-off Go commands, run them from the backend module:
|
For one-off Go commands, run them from the backend module:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -77,8 +108,7 @@ The compose example also works with Podman compatible compose tools. Its data vo
|
|||||||
`./data:/data:Z` for SELinux relabeling, and the container overrides runtime paths to use
|
`./data:/data:Z` for SELinux relabeling, and the container overrides runtime paths to use
|
||||||
`/data`, `/app/static`, and `/app/templates`.
|
`/data`, `/app/static`, and `/app/templates`.
|
||||||
|
|
||||||
The image exposes `/health`, `/healthz`, and `/api/v1/health`. Docker and compose healthchecks
|
The image exposes the health endpoint: `/health`. Docker and compose healthchecks use it.
|
||||||
use `/health`.
|
|
||||||
|
|
||||||
## Reverse Proxy Security
|
## Reverse Proxy Security
|
||||||
|
|
||||||
|
|||||||
@@ -1770,7 +1770,7 @@ func isHealthCheckLogEntry(raw map[string]any) bool {
|
|||||||
if idx := strings.IndexByte(path, '?'); idx >= 0 {
|
if idx := strings.IndexByte(path, '?'); idx >= 0 {
|
||||||
path = path[:idx]
|
path = path[:idx]
|
||||||
}
|
}
|
||||||
return path == "/health" || path == "/healthz" || path == "/api/v1/health"
|
return path == "/health"
|
||||||
}
|
}
|
||||||
|
|
||||||
func logEntryFromMap(raw map[string]any) adminLogEntry {
|
func logEntryFromMap(raw map[string]any) adminLogEntry {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
type apiDocsData struct {
|
type apiDocsData struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
UploadURL string
|
UploadURL string
|
||||||
HealthURL string
|
|
||||||
RequestSchemaURL string
|
RequestSchemaURL string
|
||||||
ResponseSchemaURL string
|
ResponseSchemaURL string
|
||||||
ShareXExamplePath string
|
ShareXExamplePath string
|
||||||
@@ -39,7 +38,6 @@ func (a *App) APIDocs(w http.ResponseWriter, r *http.Request) {
|
|||||||
Data: apiDocsData{
|
Data: apiDocsData{
|
||||||
BaseURL: a.cfg.BaseURL,
|
BaseURL: a.cfg.BaseURL,
|
||||||
UploadURL: a.cfg.BaseURL + "/api/v1/upload",
|
UploadURL: a.cfg.BaseURL + "/api/v1/upload",
|
||||||
HealthURL: a.cfg.BaseURL + "/api/v1/health",
|
|
||||||
RequestSchemaURL: a.cfg.BaseURL + "/api/v1/schemas/upload-request.json",
|
RequestSchemaURL: a.cfg.BaseURL + "/api/v1/schemas/upload-request.json",
|
||||||
ResponseSchemaURL: a.cfg.BaseURL + "/api/v1/schemas/upload-response.json",
|
ResponseSchemaURL: a.cfg.BaseURL + "/api/v1/schemas/upload-response.json",
|
||||||
ShareXExamplePath: "examples/sharex/warpbox-anonymous.sxcu",
|
ShareXExamplePath: "examples/sharex/warpbox-anonymous.sxcu",
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ type App struct {
|
|||||||
uploadService *services.UploadService
|
uploadService *services.UploadService
|
||||||
authService *services.AuthService
|
authService *services.AuthService
|
||||||
settingsService *services.SettingsService
|
settingsService *services.SettingsService
|
||||||
|
reactionService *services.ReactionService
|
||||||
banService *services.BanService
|
banService *services.BanService
|
||||||
rateLimiter *rateLimiter
|
rateLimiter *rateLimiter
|
||||||
uploadGroups *uploadGrouper
|
uploadGroups *uploadGrouper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApp(cfg config.Config, logger *slog.Logger, renderer *web.Renderer, uploadService *services.UploadService, authService *services.AuthService, settingsService *services.SettingsService, banService *services.BanService) *App {
|
func NewApp(cfg config.Config, logger *slog.Logger, renderer *web.Renderer, uploadService *services.UploadService, authService *services.AuthService, settingsService *services.SettingsService, reactionService *services.ReactionService, banService *services.BanService) *App {
|
||||||
return &App{
|
return &App{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
@@ -29,6 +30,7 @@ func NewApp(cfg config.Config, logger *slog.Logger, renderer *web.Renderer, uplo
|
|||||||
uploadService: uploadService,
|
uploadService: uploadService,
|
||||||
authService: authService,
|
authService: authService,
|
||||||
settingsService: settingsService,
|
settingsService: settingsService,
|
||||||
|
reactionService: reactionService,
|
||||||
banService: banService,
|
banService: banService,
|
||||||
rateLimiter: newRateLimiter(),
|
rateLimiter: newRateLimiter(),
|
||||||
uploadGroups: newUploadGrouper(),
|
uploadGroups: newUploadGrouper(),
|
||||||
@@ -121,16 +123,22 @@ func (a *App) RegisterRoutes(mux *http.ServeMux) {
|
|||||||
mux.HandleFunc("GET /d/{boxID}/manage/{token}/delete", a.ManageDeleteBox)
|
mux.HandleFunc("GET /d/{boxID}/manage/{token}/delete", a.ManageDeleteBox)
|
||||||
mux.HandleFunc("POST /d/{boxID}/unlock", a.UnlockBox)
|
mux.HandleFunc("POST /d/{boxID}/unlock", a.UnlockBox)
|
||||||
mux.HandleFunc("GET /d/{boxID}/zip", a.DownloadZip)
|
mux.HandleFunc("GET /d/{boxID}/zip", a.DownloadZip)
|
||||||
|
mux.HandleFunc("POST /d/{boxID}/f/{fileID}/react", a.ReactToFile)
|
||||||
mux.HandleFunc("GET /d/{boxID}/f/{fileID}", a.DownloadFile)
|
mux.HandleFunc("GET /d/{boxID}/f/{fileID}", a.DownloadFile)
|
||||||
mux.HandleFunc("GET /d/{boxID}/f/{fileID}/download", a.DownloadFileContent)
|
mux.HandleFunc("GET /d/{boxID}/f/{fileID}/download", a.DownloadFileContent)
|
||||||
mux.HandleFunc("GET /d/{boxID}/thumb/{fileID}", a.Thumbnail)
|
mux.HandleFunc("GET /d/{boxID}/thumb/{fileID}", a.Thumbnail)
|
||||||
mux.HandleFunc("GET /d/{boxID}/og-image.jpg", a.BoxOGImage)
|
mux.HandleFunc("GET /d/{boxID}/og-image.jpg", a.BoxOGImage)
|
||||||
mux.HandleFunc("GET /health", a.Health)
|
mux.HandleFunc("GET /health", a.Health)
|
||||||
mux.HandleFunc("GET /healthz", a.Health)
|
mux.HandleFunc("GET /healthz", notFound)
|
||||||
mux.HandleFunc("GET /api/v1/health", a.Health)
|
mux.HandleFunc("GET /api/v1/health", notFound)
|
||||||
mux.HandleFunc("GET /api/v1/sharex/warpbox-anonymous.sxcu", a.ShareXAnonymousConfig)
|
mux.HandleFunc("GET /api/v1/sharex/warpbox-anonymous.sxcu", a.ShareXAnonymousConfig)
|
||||||
mux.HandleFunc("GET /api/v1/schemas/upload-request.json", a.UploadRequestSchema)
|
mux.HandleFunc("GET /api/v1/schemas/upload-request.json", a.UploadRequestSchema)
|
||||||
mux.HandleFunc("GET /api/v1/schemas/upload-response.json", a.UploadResponseSchema)
|
mux.HandleFunc("GET /api/v1/schemas/upload-response.json", a.UploadResponseSchema)
|
||||||
mux.HandleFunc("POST /api/v1/upload", a.Upload)
|
mux.HandleFunc("POST /api/v1/upload", a.Upload)
|
||||||
|
mux.HandleFunc("GET /emoji/{pack}/{file}", a.EmojiAsset)
|
||||||
mux.Handle("GET /static/", a.Static())
|
mux.Handle("GET /static/", a.Static())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func notFound(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ type downloadPageData struct {
|
|||||||
DownloadCount int
|
DownloadCount int
|
||||||
MaxDownloads int
|
MaxDownloads int
|
||||||
ExpiresLabel string
|
ExpiresLabel string
|
||||||
|
EmojiTabs []emojiTabView
|
||||||
}
|
}
|
||||||
|
|
||||||
type boxView struct {
|
type boxView struct {
|
||||||
@@ -41,6 +45,28 @@ type fileView struct {
|
|||||||
URL string
|
URL string
|
||||||
DownloadURL string
|
DownloadURL string
|
||||||
ThumbnailURL string
|
ThumbnailURL string
|
||||||
|
ReactURL string
|
||||||
|
Reactions []reactionView
|
||||||
|
Reacted bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type reactionView struct {
|
||||||
|
EmojiID string `json:"emojiId"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Label string `json:"label"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type emojiTabView struct {
|
||||||
|
ID string
|
||||||
|
Label string
|
||||||
|
Emojis []emojiOptionView
|
||||||
|
}
|
||||||
|
|
||||||
|
type emojiOptionView struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Label string `json:"label"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type previewPageData struct {
|
type previewPageData struct {
|
||||||
@@ -70,13 +96,22 @@ func (a *App) DownloadPage(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
locked := a.uploadService.IsProtected(box) && !a.isBoxUnlocked(r, box)
|
locked := a.uploadService.IsProtected(box) && !a.isBoxUnlocked(r, box)
|
||||||
|
visitorID := a.reactionVisitorID(w, r)
|
||||||
|
reactionsByFile, reactedByFile, err := a.reactionService.SummaryForBox(box.ID, visitorID)
|
||||||
|
if err != nil {
|
||||||
|
a.logger.Warn("failed to load file reactions", withRequestLogAttrs(r, "source", "reactions", "severity", "warn", "code", 4300, "box_id", box.ID, "error", err.Error())...)
|
||||||
|
}
|
||||||
|
|
||||||
files := make([]fileView, 0, len(box.Files))
|
files := make([]fileView, 0, len(box.Files))
|
||||||
if !(locked && box.Obfuscate) {
|
if !(locked && box.Obfuscate) {
|
||||||
for _, file := range box.Files {
|
for _, file := range box.Files {
|
||||||
files = append(files, a.fileView(box, file))
|
files = append(files, a.fileViewWithReactions(box, file, reactionsByFile[file.ID], reactedByFile[file.ID]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emojiTabs, err := a.emojiTabs()
|
||||||
|
if err != nil {
|
||||||
|
a.logger.Warn("failed to load emoji tabs", withRequestLogAttrs(r, "source", "reactions", "severity", "warn", "code", 4301, "box_id", box.ID, "error", err.Error())...)
|
||||||
|
}
|
||||||
|
|
||||||
expiresLabel := boxExpiryLabel(box.ExpiresAt, "Jan 2, 2006 15:04 MST")
|
expiresLabel := boxExpiryLabel(box.ExpiresAt, "Jan 2, 2006 15:04 MST")
|
||||||
title := "Shared files on Warpbox"
|
title := "Shared files on Warpbox"
|
||||||
@@ -99,6 +134,7 @@ func (a *App) DownloadPage(w http.ResponseWriter, r *http.Request) {
|
|||||||
DownloadCount: box.DownloadCount,
|
DownloadCount: box.DownloadCount,
|
||||||
MaxDownloads: box.MaxDownloads,
|
MaxDownloads: box.MaxDownloads,
|
||||||
ExpiresLabel: expiresLabel,
|
ExpiresLabel: expiresLabel,
|
||||||
|
EmojiTabs: emojiTabs,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
a.logger.Info("download page viewed", withRequestLogAttrs(r, "source", "download", "severity", "user_activity", "code", 2003, "box_id", box.ID, "locked", locked)...)
|
a.logger.Info("download page viewed", withRequestLogAttrs(r, "source", "download", "severity", "user_activity", "code", 2003, "box_id", box.ID, "locked", locked)...)
|
||||||
@@ -310,6 +346,10 @@ func (a *App) DownloadZip(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) fileView(box services.Box, file services.File) fileView {
|
func (a *App) fileView(box services.Box, file services.File) fileView {
|
||||||
|
return a.fileViewWithReactions(box, file, nil, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) fileViewWithReactions(box services.Box, file services.File, reactions []services.ReactionSummary, reacted bool) fileView {
|
||||||
return fileView{
|
return fileView{
|
||||||
ID: file.ID,
|
ID: file.ID,
|
||||||
Name: file.Name,
|
Name: file.Name,
|
||||||
@@ -319,9 +359,171 @@ func (a *App) fileView(box services.Box, file services.File) fileView {
|
|||||||
URL: fmt.Sprintf("/d/%s/f/%s", box.ID, file.ID),
|
URL: fmt.Sprintf("/d/%s/f/%s", box.ID, file.ID),
|
||||||
DownloadURL: fmt.Sprintf("/d/%s/f/%s/download", box.ID, file.ID),
|
DownloadURL: fmt.Sprintf("/d/%s/f/%s/download", box.ID, file.ID),
|
||||||
ThumbnailURL: fmt.Sprintf("/d/%s/thumb/%s", box.ID, file.ID),
|
ThumbnailURL: fmt.Sprintf("/d/%s/thumb/%s", box.ID, file.ID),
|
||||||
|
ReactURL: fmt.Sprintf("/d/%s/f/%s/react", box.ID, file.ID),
|
||||||
|
Reactions: a.reactionViews(reactions),
|
||||||
|
Reacted: reacted,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) ReactToFile(w http.ResponseWriter, r *http.Request) {
|
||||||
|
box, file, ok := a.loadFileForRequest(w, r)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if a.uploadService.IsProtected(box) && !a.isBoxUnlocked(r, box) {
|
||||||
|
http.Error(w, "password required", http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
http.Error(w, "invalid reaction", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
emojiID := strings.TrimSpace(r.FormValue("emoji_id"))
|
||||||
|
if !a.validEmojiID(emojiID) {
|
||||||
|
http.Error(w, "unknown emoji", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
visitorID := a.reactionVisitorID(w, r)
|
||||||
|
reactions, err := a.reactionService.Add(box.ID, file.ID, visitorID, emojiID)
|
||||||
|
if errors.Is(err, os.ErrExist) {
|
||||||
|
writeJSON(w, http.StatusConflict, map[string]any{"error": "already reacted"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
a.logger.Warn("file reaction failed", withRequestLogAttrs(r, "source", "reactions", "severity", "warn", "code", 4302, "box_id", box.ID, "file_id", file.ID, "error", err.Error())...)
|
||||||
|
http.Error(w, "could not save reaction", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
a.logger.Info("file reaction added", withRequestLogAttrs(r, "source", "reactions", "severity", "user_activity", "code", 2301, "box_id", box.ID, "file_id", file.ID, "emoji_id", emojiID)...)
|
||||||
|
writeJSON(w, http.StatusCreated, map[string]any{
|
||||||
|
"reactions": a.reactionViews(reactions),
|
||||||
|
"reacted": true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) reactionViews(reactions []services.ReactionSummary) []reactionView {
|
||||||
|
views := make([]reactionView, 0, len(reactions))
|
||||||
|
for _, reaction := range reactions {
|
||||||
|
views = append(views, reactionView{
|
||||||
|
EmojiID: reaction.EmojiID,
|
||||||
|
URL: emojiURL(reaction.EmojiID),
|
||||||
|
Label: emojiLabel(reaction.EmojiID),
|
||||||
|
Count: reaction.Count,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return views
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) emojiTabs() ([]emojiTabView, error) {
|
||||||
|
root := a.emojiRoot()
|
||||||
|
entries, err := os.ReadDir(root)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tabs := make([]emojiTabView, 0, len(entries))
|
||||||
|
for _, entry := range entries {
|
||||||
|
if !entry.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tabID := entry.Name()
|
||||||
|
files, err := os.ReadDir(filepath.Join(root, tabID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tab := emojiTabView{ID: tabID, Label: emojiTabLabel(tabID)}
|
||||||
|
for _, file := range files {
|
||||||
|
if file.IsDir() || !isEmojiFile(file.Name()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
emojiID := tabID + "/" + file.Name()
|
||||||
|
tab.Emojis = append(tab.Emojis, emojiOptionView{
|
||||||
|
ID: emojiID,
|
||||||
|
URL: emojiURL(emojiID),
|
||||||
|
Label: emojiLabel(emojiID),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
sort.Slice(tab.Emojis, func(i, j int) bool { return tab.Emojis[i].ID < tab.Emojis[j].ID })
|
||||||
|
if len(tab.Emojis) > 0 {
|
||||||
|
tabs = append(tabs, tab)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort.Slice(tabs, func(i, j int) bool { return tabs[i].ID < tabs[j].ID })
|
||||||
|
return tabs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) validEmojiID(id string) bool {
|
||||||
|
id = strings.TrimSpace(id)
|
||||||
|
if id == "" || strings.Contains(id, "\\") || strings.Contains(id, "..") || strings.HasPrefix(id, "/") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
parts := strings.Split(id, "/")
|
||||||
|
if len(parts) != 2 || parts[0] == "" || parts[1] == "" || !isEmojiFile(parts[1]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
info, err := os.Stat(filepath.Join(a.emojiRoot(), parts[0], parts[1]))
|
||||||
|
return err == nil && !info.IsDir()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) emojiRoot() string {
|
||||||
|
return filepath.Join(a.cfg.DataDir, "emoji")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) reactionVisitorID(w http.ResponseWriter, r *http.Request) string {
|
||||||
|
const cookieName = "warpbox_reactor"
|
||||||
|
if cookie, err := r.Cookie(cookieName); err == nil && strings.TrimSpace(cookie.Value) != "" {
|
||||||
|
return cookie.Value
|
||||||
|
}
|
||||||
|
visitorID := services.RandomPublicToken(32)
|
||||||
|
http.SetCookie(w, &http.Cookie{
|
||||||
|
Name: cookieName,
|
||||||
|
Value: visitorID,
|
||||||
|
Path: "/",
|
||||||
|
HttpOnly: true,
|
||||||
|
SameSite: http.SameSiteLaxMode,
|
||||||
|
Secure: r.TLS != nil,
|
||||||
|
Expires: time.Now().AddDate(1, 0, 0),
|
||||||
|
})
|
||||||
|
return visitorID
|
||||||
|
}
|
||||||
|
|
||||||
|
func isEmojiFile(name string) bool {
|
||||||
|
ext := strings.ToLower(filepath.Ext(name))
|
||||||
|
return ext == ".svg" || ext == ".webp" || ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif"
|
||||||
|
}
|
||||||
|
|
||||||
|
func emojiTabLabel(id string) string {
|
||||||
|
label := strings.NewReplacer("-", " ", "_", " ").Replace(id)
|
||||||
|
if label == "" {
|
||||||
|
return "Emoji"
|
||||||
|
}
|
||||||
|
return strings.ToUpper(label[:1]) + label[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
func emojiLabel(id string) string {
|
||||||
|
base := strings.TrimSuffix(filepath.Base(id), filepath.Ext(id))
|
||||||
|
return strings.ReplaceAll(base, "-", " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func emojiURL(id string) string {
|
||||||
|
parts := strings.Split(id, "/")
|
||||||
|
if len(parts) != 2 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return "/emoji/" + url.PathEscape(parts[0]) + "/" + url.PathEscape(parts[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeJSON(w http.ResponseWriter, status int, value any) {
|
||||||
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
w.WriteHeader(status)
|
||||||
|
_ = json.NewEncoder(w).Encode(value)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) isBoxUnlocked(r *http.Request, box services.Box) bool {
|
func (a *App) isBoxUnlocked(r *http.Request, box services.Box) bool {
|
||||||
if !a.uploadService.IsProtected(box) {
|
if !a.uploadService.IsProtected(box) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ type healthResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) Health(w http.ResponseWriter, r *http.Request) {
|
func (a *App) Health(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path != "/health" {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
helpers.WriteJSON(w, http.StatusOK, healthResponse{
|
helpers.WriteJSON(w, http.StatusOK, healthResponse{
|
||||||
Status: "ok",
|
Status: "ok",
|
||||||
Time: time.Now().UTC().Format(time.RFC3339),
|
Time: time.Now().UTC().Format(time.RFC3339),
|
||||||
|
|||||||
@@ -13,16 +13,20 @@ func TestHealthRoutes(t *testing.T) {
|
|||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
app.RegisterRoutes(mux)
|
app.RegisterRoutes(mux)
|
||||||
|
|
||||||
for _, path := range []string{"/health", "/healthz", "/api/v1/health"} {
|
request := httptest.NewRequest(http.MethodGet, "/health", nil)
|
||||||
t.Run(path, func(t *testing.T) {
|
response := httptest.NewRecorder()
|
||||||
request := httptest.NewRequest(http.MethodGet, path, nil)
|
|
||||||
response := httptest.NewRecorder()
|
|
||||||
|
|
||||||
mux.ServeHTTP(response, request)
|
mux.ServeHTTP(response, request)
|
||||||
|
|
||||||
if response.Code != http.StatusOK {
|
if response.Code != http.StatusOK {
|
||||||
t.Fatalf("status = %d, body = %s", response.Code, response.Body.String())
|
t.Fatalf("status = %d, body = %s", response.Code, response.Body.String())
|
||||||
}
|
}
|
||||||
})
|
for _, path := range []string{"/healthz", "/api/v1/health"} {
|
||||||
|
request := httptest.NewRequest(http.MethodGet, path, nil)
|
||||||
|
response := httptest.NewRecorder()
|
||||||
|
mux.ServeHTTP(response, request)
|
||||||
|
if response.Code != http.StatusNotFound {
|
||||||
|
t.Fatalf("%s status = %d, want 404", path, response.Code)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -15,6 +16,24 @@ func (a *App) Static() http.Handler {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) EmojiAsset(w http.ResponseWriter, r *http.Request) {
|
||||||
|
pack := strings.TrimSpace(r.PathValue("pack"))
|
||||||
|
file := strings.TrimSpace(r.PathValue("file"))
|
||||||
|
if pack == "" || file == "" || strings.Contains(pack, "/") || strings.Contains(pack, "\\") || strings.Contains(pack, "..") || strings.Contains(file, "/") || strings.Contains(file, "\\") || strings.Contains(file, "..") || !isEmojiFile(file) {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
path := filepath.Join(a.emojiRoot(), pack, file)
|
||||||
|
info, err := os.Stat(path)
|
||||||
|
if err != nil || info.IsDir() {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setStaticCacheHeaders(w, r.URL.Path)
|
||||||
|
http.ServeFile(w, r, path)
|
||||||
|
}
|
||||||
|
|
||||||
func setStaticCacheHeaders(w http.ResponseWriter, path string) {
|
func setStaticCacheHeaders(w http.ResponseWriter, path string) {
|
||||||
ext := strings.ToLower(filepath.Ext(path))
|
ext := strings.ToLower(filepath.Ext(path))
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,42 @@ func TestUploadJSONIncludesManageURLsAndAcceptsShareXField(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFileReactionCanBeAddedOncePerVisitor(t *testing.T) {
|
||||||
|
app, cleanup := newTestApp(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
payload := uploadThroughApp(t, app)
|
||||||
|
if len(payload.Files) != 1 {
|
||||||
|
t.Fatalf("uploaded files = %d", len(payload.Files))
|
||||||
|
}
|
||||||
|
|
||||||
|
request := httptest.NewRequest(http.MethodPost, "/d/"+payload.BoxID+"/f/"+payload.Files[0].ID+"/react", strings.NewReader("emoji_id=openmoji/1F600.svg"))
|
||||||
|
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
request.SetPathValue("boxID", payload.BoxID)
|
||||||
|
request.SetPathValue("fileID", payload.Files[0].ID)
|
||||||
|
response := httptest.NewRecorder()
|
||||||
|
app.ReactToFile(response, request)
|
||||||
|
if response.Code != http.StatusCreated {
|
||||||
|
t.Fatalf("first reaction status = %d, body = %s", response.Code, response.Body.String())
|
||||||
|
}
|
||||||
|
if !strings.Contains(response.Body.String(), `"count":1`) {
|
||||||
|
t.Fatalf("reaction response missing count: %s", response.Body.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
retry := httptest.NewRequest(http.MethodPost, "/d/"+payload.BoxID+"/f/"+payload.Files[0].ID+"/react", strings.NewReader("emoji_id=openmoji/1F600.svg"))
|
||||||
|
retry.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
retry.SetPathValue("boxID", payload.BoxID)
|
||||||
|
retry.SetPathValue("fileID", payload.Files[0].ID)
|
||||||
|
for _, cookie := range response.Result().Cookies() {
|
||||||
|
retry.AddCookie(cookie)
|
||||||
|
}
|
||||||
|
retryResponse := httptest.NewRecorder()
|
||||||
|
app.ReactToFile(retryResponse, retry)
|
||||||
|
if retryResponse.Code != http.StatusConflict {
|
||||||
|
t.Fatalf("second reaction status = %d, body = %s", retryResponse.Code, retryResponse.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUploadTextResponseReturnsOnlyBoxURL(t *testing.T) {
|
func TestUploadTextResponseReturnsOnlyBoxURL(t *testing.T) {
|
||||||
app, cleanup := newTestApp(t)
|
app, cleanup := newTestApp(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
@@ -198,6 +234,14 @@ func newTestApp(t *testing.T) (*App, func()) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewUploadService returned error: %v", err)
|
t.Fatalf("NewUploadService returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
if err := os.MkdirAll(filepath.Join(cfg.DataDir, "emoji", "openmoji"), 0o755); err != nil {
|
||||||
|
service.Close()
|
||||||
|
t.Fatalf("create emoji test dir: %v", err)
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(filepath.Join(cfg.DataDir, "emoji", "openmoji", "1F600.svg"), []byte(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"></svg>`), 0o644); err != nil {
|
||||||
|
service.Close()
|
||||||
|
t.Fatalf("write emoji test file: %v", err)
|
||||||
|
}
|
||||||
renderer, err := web.NewRenderer(cfg.TemplateDir, cfg.AppName, cfg.AppVersion, cfg.BaseURL)
|
renderer, err := web.NewRenderer(cfg.TemplateDir, cfg.AppName, cfg.AppVersion, cfg.BaseURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
service.Close()
|
service.Close()
|
||||||
@@ -213,12 +257,17 @@ func newTestApp(t *testing.T) (*App, func()) {
|
|||||||
service.Close()
|
service.Close()
|
||||||
t.Fatalf("NewSettingsService returned error: %v", err)
|
t.Fatalf("NewSettingsService returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
reactionService, err := services.NewReactionService(service.DB())
|
||||||
|
if err != nil {
|
||||||
|
service.Close()
|
||||||
|
t.Fatalf("NewReactionService returned error: %v", err)
|
||||||
|
}
|
||||||
banService, err := services.NewBanService(service.DB())
|
banService, err := services.NewBanService(service.DB())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
service.Close()
|
service.Close()
|
||||||
t.Fatalf("NewBanService returned error: %v", err)
|
t.Fatalf("NewBanService returned error: %v", err)
|
||||||
}
|
}
|
||||||
return NewApp(cfg, logger, renderer, service, authService, settingsService, banService), func() {
|
return NewApp(cfg, logger, renderer, service, authService, settingsService, reactionService, banService), func() {
|
||||||
if err := service.Close(); err != nil {
|
if err := service.Close(); err != nil {
|
||||||
t.Fatalf("Close returned error: %v", err)
|
t.Fatalf("Close returned error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,13 +32,18 @@ func New(cfg config.Config, logger *slog.Logger) (*http.Server, error) {
|
|||||||
uploadService.Close()
|
uploadService.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reactionService, err := services.NewReactionService(uploadService.DB())
|
||||||
|
if err != nil {
|
||||||
|
uploadService.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
banService, err := services.NewBanService(uploadService.DB())
|
banService, err := services.NewBanService(uploadService.DB())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
uploadService.Close()
|
uploadService.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
stopJobs := jobs.StartAll(cfg, logger, uploadService, banService)
|
stopJobs := jobs.StartAll(cfg, logger, uploadService, banService)
|
||||||
app := handlers.NewApp(cfg, logger, renderer, uploadService, authService, settingsService, banService)
|
app := handlers.NewApp(cfg, logger, renderer, uploadService, authService, settingsService, reactionService, banService)
|
||||||
|
|
||||||
router := http.NewServeMux()
|
router := http.NewServeMux()
|
||||||
app.RegisterRoutes(router)
|
app.RegisterRoutes(router)
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ func (s *BanService) MaliciousPattern(path string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func shouldSkipMaliciousPath(path string) bool {
|
func shouldSkipMaliciousPath(path string) bool {
|
||||||
return path == "/health" || path == "/healthz" || path == "/api/v1/health" || strings.HasPrefix(path, "/static/")
|
return path == "/health" || strings.HasPrefix(path, "/static/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BanService) RecordAbuse(ip, kind, detail string, threshold int, now time.Time) (AbuseResult, error) {
|
func (s *BanService) RecordAbuse(ip, kind, detail string, threshold int, now time.Time) (AbuseResult, error) {
|
||||||
|
|||||||
166
backend/libs/services/reactions.go
Normal file
166
backend/libs/services/reactions.go
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.etcd.io/bbolt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var reactionsBucket = []byte("file_reactions")
|
||||||
|
|
||||||
|
type ReactionService struct {
|
||||||
|
db *bbolt.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileReaction struct {
|
||||||
|
BoxID string `json:"boxId"`
|
||||||
|
FileID string `json:"fileId"`
|
||||||
|
EmojiID string `json:"emojiId"`
|
||||||
|
VisitorHash string `json:"visitorHash"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReactionSummary struct {
|
||||||
|
EmojiID string `json:"emojiId"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewReactionService(db *bbolt.DB) (*ReactionService, error) {
|
||||||
|
if err := db.Update(func(tx *bbolt.Tx) error {
|
||||||
|
_, err := tx.CreateBucketIfNotExists(reactionsBucket)
|
||||||
|
return err
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ReactionService{db: db}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ReactionService) Add(boxID, fileID, visitorID, emojiID string) ([]ReactionSummary, error) {
|
||||||
|
boxID = strings.TrimSpace(boxID)
|
||||||
|
fileID = strings.TrimSpace(fileID)
|
||||||
|
visitorHash := reactionVisitorHash(visitorID)
|
||||||
|
emojiID = strings.TrimSpace(emojiID)
|
||||||
|
if boxID == "" || fileID == "" || visitorHash == "" || emojiID == "" {
|
||||||
|
return nil, errors.New("missing reaction data")
|
||||||
|
}
|
||||||
|
|
||||||
|
reaction := FileReaction{
|
||||||
|
BoxID: boxID,
|
||||||
|
FileID: fileID,
|
||||||
|
EmojiID: emojiID,
|
||||||
|
VisitorHash: visitorHash,
|
||||||
|
CreatedAt: time.Now().UTC(),
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(reaction)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
key := reactionKey(boxID, fileID, visitorHash)
|
||||||
|
if err := s.db.Update(func(tx *bbolt.Tx) error {
|
||||||
|
bucket := tx.Bucket(reactionsBucket)
|
||||||
|
if bucket.Get([]byte(key)) != nil {
|
||||||
|
return os.ErrExist
|
||||||
|
}
|
||||||
|
return bucket.Put([]byte(key), data)
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.SummaryForFile(boxID, fileID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ReactionService) SummaryForBox(boxID, visitorID string) (map[string][]ReactionSummary, map[string]bool, error) {
|
||||||
|
visitorHash := reactionVisitorHash(visitorID)
|
||||||
|
summaries := make(map[string]map[string]int)
|
||||||
|
viewerReacted := make(map[string]bool)
|
||||||
|
err := s.db.View(func(tx *bbolt.Tx) error {
|
||||||
|
bucket := tx.Bucket(reactionsBucket)
|
||||||
|
if bucket == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return bucket.ForEach(func(_, data []byte) error {
|
||||||
|
var reaction FileReaction
|
||||||
|
if err := json.Unmarshal(data, &reaction); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if reaction.BoxID != boxID {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if summaries[reaction.FileID] == nil {
|
||||||
|
summaries[reaction.FileID] = make(map[string]int)
|
||||||
|
}
|
||||||
|
summaries[reaction.FileID][reaction.EmojiID]++
|
||||||
|
if visitorHash != "" && reaction.VisitorHash == visitorHash {
|
||||||
|
viewerReacted[reaction.FileID] = true
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(map[string][]ReactionSummary, len(summaries))
|
||||||
|
for fileID, counts := range summaries {
|
||||||
|
result[fileID] = reactionCountsToSummaries(counts)
|
||||||
|
}
|
||||||
|
return result, viewerReacted, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ReactionService) SummaryForFile(boxID, fileID string) ([]ReactionSummary, error) {
|
||||||
|
counts := make(map[string]int)
|
||||||
|
err := s.db.View(func(tx *bbolt.Tx) error {
|
||||||
|
bucket := tx.Bucket(reactionsBucket)
|
||||||
|
if bucket == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return bucket.ForEach(func(_, data []byte) error {
|
||||||
|
var reaction FileReaction
|
||||||
|
if err := json.Unmarshal(data, &reaction); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if reaction.BoxID == boxID && reaction.FileID == fileID {
|
||||||
|
counts[reaction.EmojiID]++
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return reactionCountsToSummaries(counts), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func reactionCountsToSummaries(counts map[string]int) []ReactionSummary {
|
||||||
|
summaries := make([]ReactionSummary, 0, len(counts))
|
||||||
|
for emojiID, count := range counts {
|
||||||
|
summaries = append(summaries, ReactionSummary{EmojiID: emojiID, Count: count})
|
||||||
|
}
|
||||||
|
sort.Slice(summaries, func(i, j int) bool {
|
||||||
|
if summaries[i].Count == summaries[j].Count {
|
||||||
|
return summaries[i].EmojiID < summaries[j].EmojiID
|
||||||
|
}
|
||||||
|
return summaries[i].Count > summaries[j].Count
|
||||||
|
})
|
||||||
|
return summaries
|
||||||
|
}
|
||||||
|
|
||||||
|
func reactionKey(boxID, fileID, visitorHash string) string {
|
||||||
|
return boxID + "\x00" + fileID + "\x00" + visitorHash
|
||||||
|
}
|
||||||
|
|
||||||
|
func reactionVisitorHash(visitorID string) string {
|
||||||
|
visitorID = strings.TrimSpace(visitorID)
|
||||||
|
if visitorID == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
sum := sha256.Sum256([]byte(visitorID))
|
||||||
|
return hex.EncodeToString(sum[:])
|
||||||
|
}
|
||||||
@@ -137,6 +137,9 @@ func NewUploadService(maxUploadSize int64, dataDir, baseURL string, logger *slog
|
|||||||
if err := os.MkdirAll(dbDir, 0o755); err != nil {
|
if err := os.MkdirAll(dbDir, 0o755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := os.MkdirAll(filepath.Join(dataDir, "emoji"), 0o755); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
db, err := bbolt.Open(filepath.Join(dbDir, "warpbox.bbolt"), 0o600, &bbolt.Options{Timeout: time.Second})
|
db, err := bbolt.Open(filepath.Join(dbDir, "warpbox.bbolt"), 0o600, &bbolt.Options{Timeout: time.Second})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -957,6 +960,10 @@ func randomID(byteCount int) string {
|
|||||||
return base64.RawURLEncoding.EncodeToString(data)
|
return base64.RawURLEncoding.EncodeToString(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RandomPublicToken(byteCount int) string {
|
||||||
|
return randomID(byteCount)
|
||||||
|
}
|
||||||
|
|
||||||
func hashPassword(password string) (string, string) {
|
func hashPassword(password string) (string, string) {
|
||||||
salt := randomID(18)
|
salt := randomID(18)
|
||||||
return salt, passwordHash(salt, password)
|
return salt, passwordHash(salt, password)
|
||||||
|
|||||||
@@ -65,6 +65,242 @@
|
|||||||
|
|
||||||
.file-card {
|
.file-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
padding-bottom: 2.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-reaction-dock {
|
||||||
|
position: absolute;
|
||||||
|
right: 0.65rem;
|
||||||
|
bottom: 0.55rem;
|
||||||
|
z-index: 2;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
max-width: calc(100% - 1.3rem);
|
||||||
|
gap: 0.35rem;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-reactions {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
min-width: 0;
|
||||||
|
gap: 0.25rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-pill {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.2rem;
|
||||||
|
min-height: 1.6rem;
|
||||||
|
padding: 0.16rem 0.38rem;
|
||||||
|
border: 1px solid color-mix(in srgb, var(--border) 84%, var(--primary));
|
||||||
|
border-radius: 999px;
|
||||||
|
background: color-mix(in srgb, var(--card) 88%, #000);
|
||||||
|
color: var(--foreground);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-pill img {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-button {
|
||||||
|
width: 2.1rem;
|
||||||
|
height: 2.1rem;
|
||||||
|
display: inline-grid;
|
||||||
|
place-items: center;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: color-mix(in srgb, var(--card) 92%, #000);
|
||||||
|
color: var(--foreground);
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(0.3rem) scale(0.94);
|
||||||
|
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
|
||||||
|
transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease, background 150ms ease;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-button svg {
|
||||||
|
width: 1.15rem;
|
||||||
|
height: 1.15rem;
|
||||||
|
fill: none;
|
||||||
|
stroke: currentColor;
|
||||||
|
stroke-width: 1.9;
|
||||||
|
stroke-linecap: round;
|
||||||
|
stroke-linejoin: round;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-card:hover .reaction-button,
|
||||||
|
.file-card:focus-within .reaction-button,
|
||||||
|
.reaction-button:focus-visible {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-button:hover,
|
||||||
|
.reaction-button:focus-visible {
|
||||||
|
border-color: var(--primary);
|
||||||
|
background: var(--primary);
|
||||||
|
color: var(--primary-foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 70;
|
||||||
|
width: min(21rem, calc(100vw - 1rem));
|
||||||
|
}
|
||||||
|
|
||||||
|
html.reaction-picker-open,
|
||||||
|
html.reaction-picker-open body {
|
||||||
|
overflow: hidden;
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker.is-mobile {
|
||||||
|
inset: 0;
|
||||||
|
width: auto;
|
||||||
|
height: 100dvh;
|
||||||
|
display: grid;
|
||||||
|
place-items: end center;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0.75rem 0.75rem max(1.5rem, env(safe-area-inset-bottom));
|
||||||
|
background: rgba(0, 0, 0, 0.54);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker-panel {
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
background: color-mix(in srgb, var(--card) 97%, #000);
|
||||||
|
box-shadow: 0 26px 70px rgba(0, 0, 0, 0.52);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker.is-mobile .reaction-picker-panel {
|
||||||
|
width: min(100%, 34rem);
|
||||||
|
height: 75dvh;
|
||||||
|
max-height: 75dvh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.7rem;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker-close {
|
||||||
|
min-height: 2rem;
|
||||||
|
padding: 0.3rem 0.55rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.35rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
padding: 0.55rem 0.7rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-tab {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
min-height: 1.8rem;
|
||||||
|
padding: 0.25rem 0.55rem;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--muted);
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-tab.is-active {
|
||||||
|
border-color: var(--primary);
|
||||||
|
background: var(--primary);
|
||||||
|
color: var(--primary-foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-search {
|
||||||
|
display: block;
|
||||||
|
padding: 0.55rem 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-search input {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 2.15rem;
|
||||||
|
padding: 0.35rem 0.55rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-grid-wrap {
|
||||||
|
max-height: 18rem;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 0 0.7rem 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker.is-mobile .reaction-grid-wrap {
|
||||||
|
max-height: none;
|
||||||
|
flex: 1;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-grid {
|
||||||
|
display: none;
|
||||||
|
grid-template-columns: repeat(8, minmax(0, 1fr));
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-grid.is-active {
|
||||||
|
display: grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-picker.is-mobile .reaction-grid {
|
||||||
|
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-emoji {
|
||||||
|
aspect-ratio: 1;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0.18rem;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: calc(var(--radius) - 0.25rem);
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-emoji:hover,
|
||||||
|
.reaction-emoji:focus-visible {
|
||||||
|
border-color: var(--border);
|
||||||
|
background: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-emoji[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-emoji img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumb-link {
|
.thumb-link {
|
||||||
|
|||||||
@@ -220,6 +220,16 @@
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-reaction-dock {
|
||||||
|
right: 0.5rem;
|
||||||
|
bottom: 0.45rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reaction-button {
|
||||||
|
opacity: 1;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
.file-progress-side {
|
.file-progress-side {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
198
backend/static/js/12-reactions.js
Normal file
198
backend/static/js/12-reactions.js
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
(function () {
|
||||||
|
const picker = document.querySelector("[data-reaction-picker]");
|
||||||
|
const panel = picker ? picker.querySelector(".reaction-picker-panel") : null;
|
||||||
|
const search = picker ? picker.querySelector("[data-reaction-search]") : null;
|
||||||
|
const closeButton = picker ? picker.querySelector("[data-reaction-close]") : null;
|
||||||
|
const tabs = picker ? Array.from(picker.querySelectorAll("[data-reaction-tab]")) : [];
|
||||||
|
const panels = picker ? Array.from(picker.querySelectorAll("[data-reaction-panel]")) : [];
|
||||||
|
|
||||||
|
let activeButton = null;
|
||||||
|
let activeCard = null;
|
||||||
|
|
||||||
|
document.querySelectorAll("[data-reaction-button]").forEach((button) => {
|
||||||
|
button.addEventListener("click", (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
openPicker(button);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!picker || !panel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aurora's glass card uses backdrop-filter, and the main content animates
|
||||||
|
// with transform. Both can create a containing block for fixed descendants,
|
||||||
|
// so keep the floating picker at body level where viewport coordinates mean
|
||||||
|
// what they say.
|
||||||
|
document.body.appendChild(picker);
|
||||||
|
|
||||||
|
picker.addEventListener("click", (event) => {
|
||||||
|
if (event.target === picker) {
|
||||||
|
closePicker();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
panel.addEventListener("click", async (event) => {
|
||||||
|
const emoji = event.target.closest("[data-emoji-id]");
|
||||||
|
if (!emoji || !activeButton || !activeCard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await submitReaction(emoji);
|
||||||
|
});
|
||||||
|
|
||||||
|
tabs.forEach((tab) => {
|
||||||
|
tab.addEventListener("click", () => {
|
||||||
|
setActiveTab(tab.dataset.reactionTab);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (search) {
|
||||||
|
search.addEventListener("input", () => filterEmoji(search.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closeButton) {
|
||||||
|
closeButton.addEventListener("click", closePicker);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("click", (event) => {
|
||||||
|
if (picker.hidden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (panel.contains(event.target) || event.target.closest("[data-reaction-button]")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
closePicker();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
closePicker();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("resize", () => {
|
||||||
|
if (activeButton && !picker.hidden) {
|
||||||
|
positionPicker(activeButton);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function openPicker(button) {
|
||||||
|
activeButton = button;
|
||||||
|
activeCard = button.closest("[data-reaction-card]");
|
||||||
|
picker.hidden = false;
|
||||||
|
picker.classList.add("is-open");
|
||||||
|
if (search) {
|
||||||
|
search.value = "";
|
||||||
|
filterEmoji("");
|
||||||
|
}
|
||||||
|
positionPicker(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closePicker() {
|
||||||
|
picker.hidden = true;
|
||||||
|
picker.classList.remove("is-open", "is-mobile");
|
||||||
|
document.documentElement.classList.remove("reaction-picker-open");
|
||||||
|
picker.style.left = "";
|
||||||
|
picker.style.top = "";
|
||||||
|
activeButton = null;
|
||||||
|
activeCard = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function positionPicker(button) {
|
||||||
|
if (isMobilePicker()) {
|
||||||
|
picker.classList.add("is-mobile");
|
||||||
|
document.documentElement.classList.add("reaction-picker-open");
|
||||||
|
picker.style.left = "0px";
|
||||||
|
picker.style.top = "0px";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
picker.classList.remove("is-mobile");
|
||||||
|
document.documentElement.classList.remove("reaction-picker-open");
|
||||||
|
picker.style.left = "0px";
|
||||||
|
picker.style.top = "0px";
|
||||||
|
const buttonRect = button.getBoundingClientRect();
|
||||||
|
const pickerRect = panel.getBoundingClientRect();
|
||||||
|
const margin = 10;
|
||||||
|
const preferredLeft = buttonRect.left + (buttonRect.width / 2) - (pickerRect.width / 2);
|
||||||
|
const preferredTop = buttonRect.bottom + 8;
|
||||||
|
const left = Math.min(Math.max(margin, preferredLeft), window.innerWidth - pickerRect.width - margin);
|
||||||
|
const top = Math.min(Math.max(margin, preferredTop), window.innerHeight - pickerRect.height - margin);
|
||||||
|
picker.style.left = `${left}px`;
|
||||||
|
picker.style.top = `${top}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMobilePicker() {
|
||||||
|
return window.matchMedia("(max-width: 820px), (pointer: coarse)").matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setActiveTab(tabID) {
|
||||||
|
tabs.forEach((tab) => {
|
||||||
|
const active = tab.dataset.reactionTab === tabID;
|
||||||
|
tab.classList.toggle("is-active", active);
|
||||||
|
tab.setAttribute("aria-selected", active ? "true" : "false");
|
||||||
|
});
|
||||||
|
panels.forEach((item) => {
|
||||||
|
item.classList.toggle("is-active", item.dataset.reactionPanel === tabID);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterEmoji(value) {
|
||||||
|
const query = value.trim().toLowerCase();
|
||||||
|
picker.querySelectorAll("[data-emoji-id]").forEach((button) => {
|
||||||
|
const haystack = `${button.dataset.emojiId} ${button.dataset.emojiLabel}`.toLowerCase();
|
||||||
|
button.hidden = query !== "" && !haystack.includes(query);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitReaction(emoji) {
|
||||||
|
const body = new URLSearchParams();
|
||||||
|
body.set("emoji_id", emoji.dataset.emojiId);
|
||||||
|
|
||||||
|
activeButton.disabled = true;
|
||||||
|
const response = await fetch(activeButton.dataset.reactUrl, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
},
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
activeButton.disabled = false;
|
||||||
|
closePicker();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = await response.json();
|
||||||
|
renderReactions(activeCard, payload.reactions || []);
|
||||||
|
activeButton.remove();
|
||||||
|
closePicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderReactions(card, reactions) {
|
||||||
|
const list = card.querySelector("[data-reaction-list]");
|
||||||
|
if (!list) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
list.replaceChildren();
|
||||||
|
reactions.forEach((reaction) => {
|
||||||
|
const pill = document.createElement("span");
|
||||||
|
pill.className = "reaction-pill";
|
||||||
|
pill.title = reaction.label || reaction.emojiId;
|
||||||
|
|
||||||
|
const image = document.createElement("img");
|
||||||
|
image.src = reaction.url;
|
||||||
|
image.alt = reaction.label || reaction.emojiId;
|
||||||
|
image.loading = "lazy";
|
||||||
|
|
||||||
|
const count = document.createElement("span");
|
||||||
|
count.textContent = reaction.count;
|
||||||
|
|
||||||
|
pill.append(image, count);
|
||||||
|
list.append(pill);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/90-responsive.css?version={{.AppVersion}}">
|
<link rel="stylesheet" href="/static/css/90-responsive.css?version={{.AppVersion}}">
|
||||||
<script defer src="/static/js/00-utils.js?version={{.AppVersion}}"></script>
|
<script defer src="/static/js/00-utils.js?version={{.AppVersion}}"></script>
|
||||||
<script defer src="/static/js/10-file-browser.js?version={{.AppVersion}}"></script>
|
<script defer src="/static/js/10-file-browser.js?version={{.AppVersion}}"></script>
|
||||||
|
<script defer src="/static/js/12-reactions.js?version={{.AppVersion}}"></script>
|
||||||
<script defer src="/static/js/20-storage-admin.js?version={{.AppVersion}}"></script>
|
<script defer src="/static/js/20-storage-admin.js?version={{.AppVersion}}"></script>
|
||||||
<script defer src="/static/js/25-admin-charts.js?version={{.AppVersion}}"></script>
|
<script defer src="/static/js/25-admin-charts.js?version={{.AppVersion}}"></script>
|
||||||
<script defer src="/static/js/30-token-copy.js?version={{.AppVersion}}"></script>
|
<script defer src="/static/js/30-token-copy.js?version={{.AppVersion}}"></script>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<h2>Endpoints</h2>
|
<h2>Endpoints</h2>
|
||||||
<dl class="endpoint-list">
|
<dl class="endpoint-list">
|
||||||
<div><dt>Upload</dt><dd><code>POST /api/v1/upload</code></dd></div>
|
<div><dt>Upload</dt><dd><code>POST /api/v1/upload</code></dd></div>
|
||||||
<div><dt>Health</dt><dd><code>GET /api/v1/health</code></dd></div>
|
<div><dt>Health</dt><dd><code>GET /health</code></dd></div>
|
||||||
<div><dt>Request schema</dt><dd><a href="/api/v1/schemas/upload-request.json"><code>/api/v1/schemas/upload-request.json</code></a></dd></div>
|
<div><dt>Request schema</dt><dd><a href="/api/v1/schemas/upload-request.json"><code>/api/v1/schemas/upload-request.json</code></a></dd></div>
|
||||||
<div><dt>Response schema</dt><dd><a href="/api/v1/schemas/upload-response.json"><code>/api/v1/schemas/upload-response.json</code></a></dd></div>
|
<div><dt>Response schema</dt><dd><a href="/api/v1/schemas/upload-response.json"><code>/api/v1/schemas/upload-response.json</code></a></dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<div class="download-list file-browser is-list" data-file-browser>
|
<div class="download-list file-browser is-list" data-file-browser>
|
||||||
{{range .Data.Files}}
|
{{range .Data.Files}}
|
||||||
<article class="download-item file-card" data-kind="{{.PreviewKind}}" data-file-context data-preview-url="{{.URL}}" data-view-url="{{.DownloadURL}}?inline=1" data-download-url="{{.DownloadURL}}" data-file-name="{{.Name}}">
|
<article class="download-item file-card" data-kind="{{.PreviewKind}}" data-file-context data-preview-url="{{.URL}}" data-view-url="{{.DownloadURL}}?inline=1" data-download-url="{{.DownloadURL}}" data-file-name="{{.Name}}" data-reaction-card>
|
||||||
<a class="thumb-link" href="{{.DownloadURL}}?inline=1" aria-label="View {{.Name}}">
|
<a class="thumb-link" href="{{.DownloadURL}}?inline=1" aria-label="View {{.Name}}">
|
||||||
<img src="{{.ThumbnailURL}}" alt="" loading="lazy">
|
<img src="{{.ThumbnailURL}}" alt="" loading="lazy">
|
||||||
</a>
|
</a>
|
||||||
@@ -64,11 +64,54 @@
|
|||||||
Download
|
Download
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="file-reaction-dock" data-reaction-dock>
|
||||||
|
<div class="file-reactions" data-reaction-list>
|
||||||
|
{{range .Reactions}}
|
||||||
|
<span class="reaction-pill" title="{{.Label}}">
|
||||||
|
<img src="{{.URL}}" alt="{{.Label}}" loading="lazy">
|
||||||
|
<span>{{.Count}}</span>
|
||||||
|
</span>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
{{if not .Reacted}}
|
||||||
|
<button class="reaction-button" type="button" data-reaction-button data-react-url="{{.ReactURL}}" aria-label="React to {{.Name}}" title="React">
|
||||||
|
<svg viewBox="0 0 24 24" role="img" focusable="false" aria-hidden="true"><path d="M12 21a9 9 0 1 0-9-9 9 9 0 0 0 9 9Z" /><path d="M8 14s1.4 2 4 2 4-2 4-2" /><path d="M9 9h.01M15 9h.01" /></svg>
|
||||||
|
</button>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</article>
|
</article>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{if not .Data.Locked}}
|
{{if not .Data.Locked}}
|
||||||
|
<div class="reaction-picker" data-reaction-picker hidden>
|
||||||
|
<div class="reaction-picker-panel" role="dialog" aria-modal="false" aria-label="Choose a reaction">
|
||||||
|
<div class="reaction-picker-head">
|
||||||
|
<strong>React</strong>
|
||||||
|
<button class="button button-ghost reaction-picker-close" type="button" data-reaction-close aria-label="Close reaction picker">Close</button>
|
||||||
|
</div>
|
||||||
|
<div class="reaction-picker-tabs" role="tablist" aria-label="Emoji themes">
|
||||||
|
{{range $index, $tab := .Data.EmojiTabs}}
|
||||||
|
<button type="button" class="reaction-tab {{if eq $index 0}}is-active{{end}}" data-reaction-tab="{{$tab.ID}}" role="tab" aria-selected="{{if eq $index 0}}true{{else}}false{{end}}">{{$tab.Label}}</button>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
<label class="reaction-search">
|
||||||
|
<span class="sr-only">Search emoji</span>
|
||||||
|
<input type="search" data-reaction-search placeholder="Search emoji">
|
||||||
|
</label>
|
||||||
|
<div class="reaction-grid-wrap">
|
||||||
|
{{range $index, $tab := .Data.EmojiTabs}}
|
||||||
|
<div class="reaction-grid {{if eq $index 0}}is-active{{end}}" data-reaction-panel="{{$tab.ID}}" role="tabpanel">
|
||||||
|
{{range $tab.Emojis}}
|
||||||
|
<button class="reaction-emoji" type="button" data-emoji-id="{{.ID}}" data-emoji-label="{{.Label}}" title="{{.Label}}" aria-label="{{.Label}}">
|
||||||
|
<img src="{{.URL}}" alt="" loading="lazy">
|
||||||
|
</button>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="context-menu" data-file-context-menu role="menu" aria-label="File actions" hidden>
|
<div class="context-menu" data-file-context-menu role="menu" aria-label="File actions" hidden>
|
||||||
<div class="context-menu-top">
|
<div class="context-menu-top">
|
||||||
<small>File actions</small>
|
<small>File actions</small>
|
||||||
|
|||||||
Reference in New Issue
Block a user