2025-12-13 15:47:16+04:00
Some checks failed
CI/CD Pipeline / Test (push) Has been cancelled
CI/CD Pipeline / Lint (push) Has been cancelled
CI/CD Pipeline / Build (386, linux, linkbeam-linux-386) (push) Has been cancelled
CI/CD Pipeline / Build (386, windows, linkbeam-windows-386.exe) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, darwin, linkbeam-darwin-amd64) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, linux, linkbeam-linux-amd64) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, windows, linkbeam-windows-amd64.exe) (push) Has been cancelled
CI/CD Pipeline / Build (arm, 7, linux, linkbeam-linux-armv7) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, darwin, linkbeam-darwin-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, linux, linkbeam-linux-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, windows, linkbeam-windows-arm64.exe) (push) Has been cancelled
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Create Release (push) Has been cancelled
Some checks failed
CI/CD Pipeline / Test (push) Has been cancelled
CI/CD Pipeline / Lint (push) Has been cancelled
CI/CD Pipeline / Build (386, linux, linkbeam-linux-386) (push) Has been cancelled
CI/CD Pipeline / Build (386, windows, linkbeam-windows-386.exe) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, darwin, linkbeam-darwin-amd64) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, linux, linkbeam-linux-amd64) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, windows, linkbeam-windows-amd64.exe) (push) Has been cancelled
CI/CD Pipeline / Build (arm, 7, linux, linkbeam-linux-armv7) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, darwin, linkbeam-darwin-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, linux, linkbeam-linux-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, windows, linkbeam-windows-arm64.exe) (push) Has been cancelled
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Create Release (push) Has been cancelled
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
# Build artifacts
|
# Build artifacts
|
||||||
/dist/
|
/dist/
|
||||||
linkbeam
|
/linkbeam
|
||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
*.test
|
*.test
|
||||||
@@ -40,8 +40,4 @@ config.yaml
|
|||||||
.pre-commit-cache/
|
.pre-commit-cache/
|
||||||
|
|
||||||
static/
|
static/
|
||||||
!static/favicon.png
|
|
||||||
!static/logo.png
|
|
||||||
!static/ada-256x256.png
|
|
||||||
|
|
||||||
!.gitignore
|
!.gitignore
|
||||||
|
|||||||
99
cmd/linkbeam/main.go
Normal file
99
cmd/linkbeam/main.go
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
// main.go
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for more information.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
flag "github.com/spf13/pflag"
|
||||||
|
|
||||||
|
"linkbeam/internal/config"
|
||||||
|
"linkbeam/internal/generator"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Version is set during build
|
||||||
|
Version = "dev"
|
||||||
|
// Commit is set during build
|
||||||
|
Commit = "unknown"
|
||||||
|
|
||||||
|
fmtPrintf = fmt.Printf
|
||||||
|
)
|
||||||
|
|
||||||
|
func run(loader func(string) (*config.Config, error), configPath string) error {
|
||||||
|
cfg, err := loader(configPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, _ = fmtPrintf("Hello, %s!\n", cfg.Name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Usage = func() {
|
||||||
|
out := flag.CommandLine.Output()
|
||||||
|
_, _ = fmt.Fprintf(out, "LinkBeam - Static site generator for link-in-bio pages\n\n")
|
||||||
|
_, _ = fmt.Fprintf(out, "Usage:\n")
|
||||||
|
_, _ = fmt.Fprintf(out, " linkbeam [options]\n\n")
|
||||||
|
_, _ = fmt.Fprintf(out, "Options:\n")
|
||||||
|
flag.PrintDefaults()
|
||||||
|
_, _ = fmt.Fprintf(out, "\nExamples:\n")
|
||||||
|
_, _ = fmt.Fprintf(out, " linkbeam --config myconfig.yaml\n")
|
||||||
|
_, _ = fmt.Fprintf(out, " linkbeam -c config.yaml -o public/index.html\n")
|
||||||
|
_, _ = fmt.Fprintf(out, " linkbeam --version\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
configPath := flag.StringP("config", "c", "config.yaml", "path to config YAML file")
|
||||||
|
templatePath := flag.StringP("template", "t", "templates/base.html", "path to HTML template")
|
||||||
|
outputPath := flag.StringP("output", "o", "dist/index.html", "path to output HTML file")
|
||||||
|
showVersion := flag.BoolP("version", "v", false, "print version information")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Printf("LinkBeam %s (commit: %s)\n", Version, Commit)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := runMain(*configPath, *templatePath, *outputPath); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func runMain(configPath, templatePath, outputPath string) error {
|
||||||
|
cfg, err := config.Load(configPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("config load failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate theme against available themes
|
||||||
|
if err := cfg.ValidateWithThemes("themes"); err != nil {
|
||||||
|
return fmt.Errorf("config validation failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := generator.GenerateSite(cfg, templatePath, outputPath); err != nil {
|
||||||
|
return fmt.Errorf("site generation failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
distDir := filepath.Dir(outputPath)
|
||||||
|
if err := generator.CopyAssets(distDir, "themes"); err != nil {
|
||||||
|
return fmt.Errorf("asset copy failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := generator.CopyStaticFiles(distDir); err != nil {
|
||||||
|
return fmt.Errorf("static files copy failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := generator.CopyAvatar(cfg, distDir); err != nil {
|
||||||
|
return fmt.Errorf("avatar copy failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Site generated at %s\n", outputPath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
38
cmd/linkbeam/main_test.go
Normal file
38
cmd/linkbeam/main_test.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// main_test.go
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) - All Rights Reserved.
|
||||||
|
*
|
||||||
|
* See the LICENCE file for more information.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"linkbeam/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRun(t *testing.T) {
|
||||||
|
mockLoader := func(path string) (*config.Config, error) {
|
||||||
|
return &config.Config{Name: "Test User"}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
fmtPrintf = func(format string, args ...interface{}) (int, error) {
|
||||||
|
return fmt.Fprintf(&buf, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := run(mockLoader, "test-config.yaml")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("run failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
got := buf.String()
|
||||||
|
want := "Hello, Test User!\n"
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("unexpected output:\ngot: %q\nwant: %q", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,13 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: docker.io/5mdt/linkbeam:latest
|
image: docker.io/5mdt/linkbeam:latest
|
||||||
build: .
|
build:
|
||||||
|
context: ./
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
x-bake:
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
volumes:
|
volumes:
|
||||||
# Mount your config file
|
# Mount your config file
|
||||||
- ./config.yaml:/app/config/config.yaml:ro
|
- ./config.yaml:/app/config/config.yaml:ro
|
||||||
|
|||||||
Reference in New Issue
Block a user