Initial commit: Lookbook personal collection app
Pinterest-like app for saving images, videos, quotes, and embeds. Features: - Go backend with PostgreSQL, SSR templates - Console-based admin auth (login/logout via browser console) - Item types: images, videos (ffmpeg transcoding), quotes, embeds - Media stored as BLOBs in PostgreSQL - OpenGraph metadata extraction for links - Embed detection for YouTube, Vimeo, Twitter/X - Masonry grid layout, item detail pages - Tag system with filtering - Refresh metadata endpoint with change warnings - Replace media endpoint for updating item images/videos
This commit is contained in:
commit
cdcc5b5293
45 changed files with 4634 additions and 0 deletions
41
internal/data/admin/queries.go
Normal file
41
internal/data/admin/queries.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Row struct {
|
||||
ID int
|
||||
PasswordHash []byte // nil if not set
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// QGet returns the single admin row.
|
||||
func QGet(ctx context.Context, db *sql.DB) (Row, error) {
|
||||
query := `SELECT id, password_hash, created_at FROM admin WHERE id = 1`
|
||||
|
||||
var row Row
|
||||
err := db.QueryRowContext(ctx, query).Scan(
|
||||
&row.ID,
|
||||
&row.PasswordHash,
|
||||
&row.CreatedAt,
|
||||
)
|
||||
return row, err
|
||||
}
|
||||
|
||||
// QSetPassword sets the admin password hash.
|
||||
func QSetPassword(ctx context.Context, db *sql.DB, hash []byte) error {
|
||||
query := `UPDATE admin SET password_hash = $1 WHERE id = 1`
|
||||
_, err := db.ExecContext(ctx, query, hash)
|
||||
return err
|
||||
}
|
||||
|
||||
// QHasPassword returns true if a password has been set.
|
||||
func QHasPassword(ctx context.Context, db *sql.DB) (bool, error) {
|
||||
query := `SELECT password_hash IS NOT NULL FROM admin WHERE id = 1`
|
||||
var has bool
|
||||
err := db.QueryRowContext(ctx, query).Scan(&has)
|
||||
return has, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue