shortcut

package
v1.261023.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MPL-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shortcut exposes the /api/v1/shortcut HTTP endpoints that let the frontend create (or check for) the desktop / start-menu shortcut the CLI's `tingly-box shortcut` command already writes. All actual file-writing logic lives in internal/shortcut, which has no HTTP or CLI dependency — this package only adapts it to gin, mirroring the "future HTTP handler" sketch in .design/shortcut.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler carries the minimal server state needed to serve /api/v1/shortcut. launchSource and version are known once, at boot, from how this process itself was started (see internal/command's --source flag); they are never persisted, matching the CLI's own "no detection, no persistence" design.

func NewHandler

func NewHandler(launchSource, version string) *Handler

NewHandler creates a Handler.

func (*Handler) Create

func (h *Handler) Create(c *gin.Context)

Create handles POST /api/v1/shortcut: (re)writes the desktop / start-menu shortcut(s) and the Linux headless launcher script, and returns the real paths written. Deliberately zero-config beyond an optional display name — no --no-desktop/--no-menu equivalent — and idempotent, so the frontend can let the user click it again any time (after an upgrade, a source change, or just to recover a deleted shortcut) without needing to track state.

func (*Handler) RegisterRoutes added in v1.261002.1

func (h *Handler) RegisterRoutes(rt *module.Routes)

func (*Handler) Status

func (h *Handler) Status(c *gin.Context)

Status handles GET /api/v1/shortcut: reports whether every artifact Create would write already exists, without writing anything itself. Best-effort — see shortcut.ExpectedPaths for the Windows OneDrive-redirection caveat.

type ShortcutCreateRequest

type ShortcutCreateRequest struct {
	Name string `json:"name,omitempty" example:"Tingly Box"`
}

ShortcutCreateRequest is the JSON body for POST /api/v1/shortcut. Empty is a valid request — Name defaults to "Tingly Box" and both desktop/menu artifacts are always written (no --no-desktop/--no-menu equivalent exposed here: the CLI flags exist for scripting, but the UI has one zero-config action). Named with the module's own prefix, not the generic "CreateRequest" — swagger's model registry keys schemas by Go type name, and several other modules (team, imbot) already have their own CreateRequest, so a bare name here would silently collide with one of theirs in the generated schema.

type ShortcutCreateResponse

type ShortcutCreateResponse struct {
	Success bool         `json:"success" example:"true"`
	Error   string       `json:"error,omitempty"`
	Data    ShortcutInfo `json:"data,omitempty"`
}

ShortcutCreateResponse is the JSON envelope for POST /api/v1/shortcut.

type ShortcutInfo

type ShortcutInfo struct {
	// Created lists every path written (or, for status, that already exists),
	// e.g. ["/home/user/Desktop/tingly-box.desktop", "/home/user/.local/bin/tingly-box.sh"].
	Created []string `json:"created"`
	// ScriptPath is the headless launcher script's path (Linux-only), or ""
	// when none was written/found — lets the frontend swap "double-click" for
	// "run this command" without re-deriving platform logic.
	ScriptPath string `json:"script_path,omitempty" example:"/home/user/.local/bin/tingly-box.sh"`
}

ShortcutInfo describes the outcome of a create (or status) call.

type ShortcutStatusResponse

type ShortcutStatusResponse struct {
	Success bool         `json:"success" example:"true"`
	Data    ShortcutInfo `json:"data"`
	Exists  bool         `json:"exists" example:"false"`
}

ShortcutStatusResponse is the JSON envelope for GET /api/v1/shortcut. Exists is true only when every artifact this platform would write is already present on disk (a partial/stale set still reads as "not created" — the Create action rewrites everything in one pass anyway). Named with the module's own prefix for the same reason as ShortcutCreateRequest — a bare "StatusResponse" already collides with internal/server's own type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL