17 Commits

Author SHA1 Message Date
Adrian Zürcher
8165b2d843 fix workflow take 3
All checks were successful
Build Slideshow App / build (amd64, , linux) (push) Successful in 1m24s
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m20s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m23s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m26s
2026-01-18 17:06:59 +01:00
Adrian Zürcher
e480141e89 fix workflow take 2 only linux
All checks were successful
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m23s
2026-01-18 17:04:52 +01:00
Adrian Zürcher
e1ae34a336 update workflow
Some checks failed
Build Slideshow App / build (amd64, , linux) (push) Has been cancelled
Build Slideshow App / build (amd64, .exe, windows) (push) Has been cancelled
Build Slideshow App / build (arm, 7, , linux) (push) Has been cancelled
Build Slideshow App / build (arm64, , linux) (push) Has been cancelled
2026-01-18 15:27:39 +01:00
Adrian Zürcher
3aac950b9c add new debian install workflow for linux
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m49s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m8s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m53s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m51s
2026-01-17 22:42:16 +01:00
Adrian Zürcher
96bfcb7d0e add new set function 2026-01-17 22:41:54 +01:00
Adrian Zürcher
64744e218a add feature check if ip is active 2026-01-17 22:41:42 +01:00
Adrian Zürcher
7d3db6b485 remove schedule.json file 2026-01-17 22:41:21 +01:00
Adrian Zürcher
9cde384a36 add browser open function 2026-01-17 22:39:50 +01:00
f9a92e4e4a Fix appname artifact
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m56s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m2s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m42s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m48s
2026-01-17 18:12:49 +01:00
40b13a0661 Change upload v4 to v3
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m2s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m16s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m50s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m45s
2026-01-17 15:10:58 +01:00
Adrian Zürcher
ff473d0e8d since v6 is not supported downgrade to v4
Some checks failed
Build Slideshow App / build (amd64, .exe, windows) (push) Failing after 2m36s
Build Slideshow App / build (amd64, , linux) (push) Failing after 2m39s
Build Slideshow App / build (arm, 6, , linux) (push) Failing after 1m59s
Build Slideshow App / build (arm64, , linux) (push) Failing after 1m58s
2026-01-17 00:27:16 +01:00
Adrian Zürcher
4798b76b2d update workflow
Some checks failed
Build Slideshow App / build (amd64, , linux) (push) Failing after 29s
Build Slideshow App / build (amd64, .exe, windows) (push) Failing after 30s
Build Slideshow App / build (arm, 6, , linux) (push) Failing after 13s
Build Slideshow App / build (arm64, , linux) (push) Failing after 13s
2026-01-17 00:16:22 +01:00
Adrian Zürcher
80d637f03e add new build workflow
All checks were successful
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 2m6s
Build Slideshow App / build (amd64, , linux) (push) Successful in 2m10s
Build Slideshow App / build (arm, 6, , linux) (push) Successful in 1m54s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m54s
2026-01-17 00:05:30 +01:00
Adrian Zürcher
793929ad82 change default interval 2026-01-17 00:05:18 +01:00
Adrian Zürcher
281548c166 add additional ignore 2026-01-17 00:05:06 +01:00
Adrian Zürcher
9543bf407b fix missing static folder 2026-01-17 00:04:52 +01:00
Adrian Zürcher
45c400e7d3 move html to static folder 2026-01-16 07:57:33 +01:00
12 changed files with 314 additions and 25 deletions

2
.env
View File

@@ -2,4 +2,4 @@ ENV= #empty|development
PHOTO_DIR=images
HOST=0.0.0.0
PORT=8080
INTERVAL_DEFAULT=120
INTERVAL_DEFAULT=10

189
.gitea/workflows/build.yml Normal file
View File

@@ -0,0 +1,189 @@
name: Build Slideshow App
on:
push:
tags:
- '*'
env:
APP_NAME: slideshowApp
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: windows
arch: amd64
ext: .exe
- os: linux
arch: amd64
ext: ""
- os: linux
arch: arm64
ext: ""
- os: linux
arch: arm
arm_version: 7
ext: ""
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Ensure latest Go is installed in /data/go
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
if [ ! -x "$GOROOT/bin/go" ]; then
echo "Go not found in $GOROOT, downloading latest stable..."
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
echo "Latest version is $GO_VERSION"
mkdir -p /data/go
curl -sSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
tar -C /data/go -xzf /tmp/go.tar.gz
else
echo "Using cached Go from $GOROOT"
fi
go version
- name: Download Go dependencies
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
go mod download
- name: Build binary
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
OUTPUT="${APP_NAME}"
if [ -n "${{ matrix.arm_version }}" ]; then
export GOARM=${{ matrix.arm_version }}
fi
OUTPUT="${OUTPUT}${{ matrix.ext }}"
echo "Building $OUTPUT"
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
shell: bash
- name: Create Debian Package
if: matrix.os == 'linux'
run: |
# 1. Setup Variables
VERSION=${GITHUB_REF_NAME#v} # Extracts 1.0.0 from v1.0.0
ARCH=${{ matrix.arch }}
if [ "$ARCH" == "arm" ]; then ARCH="armhf"; fi
PKG_NAME="slideshowapp"
BUILD_DIR="${PKG_NAME}_${VERSION}_${ARCH}"
# 2. Create Directory Structure
mkdir -p $BUILD_DIR/usr/bin
mkdir -p $BUILD_DIR/usr/share/$PKG_NAME
mkdir -p $BUILD_DIR/etc/systemd/system
mkdir -p $BUILD_DIR/DEBIAN
# 3. Copy Files
cp ${APP_NAME} $BUILD_DIR/usr/bin/$PKG_NAME
cp -r ./web $BUILD_DIR/usr/share/$PKG_NAME/
chmod +x $BUILD_DIR/usr/bin/$PKG_NAME
# 4. Handle .env (Copy as a .template so it doesn't overwrite existing ones)
if [ -f ".env" ]; then
cp .env $BUILD_DIR/usr/share/$PKG_NAME/.env.template
else
echo "PORT=8080" > $BUILD_DIR/usr/share/$PKG_NAME/.env.template
fi
# 5. Create the systemd Service File
cat <<EOF > $BUILD_DIR/etc/systemd/system/$PKG_NAME.service
[Unit]
Description=Slideshow Application Service
After=graphical.target
[Service]
Type=simple
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/youruser/.Xauthority
ExecStart=/usr/bin/$PKG_NAME
WorkingDirectory=/usr/share/$PKG_NAME
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
# 6. Create Control File
cat <<EOF > $BUILD_DIR/DEBIAN/control
Package: $PKG_NAME
Version: $VERSION
Section: utils
Priority: optional
Architecture: $ARCH
Maintainer: Your Name <you@example.com>
Description: Slideshow Application
EOF
# 7. Optional: Add post-install script to enable service automatically
echo "create service"
cat <<EOF > $BUILD_DIR/DEBIAN/postinst
#!/bin/sh
# Check if .env exists in the target share folder
if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
echo "Creating new .env from template..."
cp /usr/share/$PKG_NAME/.env.template /usr/share/$PKG_NAME/.env
else
echo ".env already exists, skipping template copy to preserve settings."
fi
echo "reload"
systemctl daemon-reload
echo "enable service"
systemctl enable $PKG_NAME.service
echo "start service"
systemctl start $PKG_NAME.service
EOF
chmod 555 $BUILD_DIR/DEBIAN/postinst
# 8. Build .deb
dpkg-deb --build $BUILD_DIR
shell: bash
# Upload for Windows (Binary + Web folder)
- name: Upload Windows Artifact
if: matrix.os == 'windows'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-windows
path: |
${{ env.APP_NAME }}.exe
./web
# Upload for Linux (Binary + .deb)
- name: Upload Linux Artifact
if: matrix.os == 'linux'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-linux-${{ matrix.arch }}
path: |
${{ env.APP_NAME }}
*.deb

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
images/
slideshow_app
slideshowApp
schedule.json

4
env/enviroment.go vendored
View File

@@ -28,6 +28,10 @@ func (key EnvKey) GetValue() string {
return os.Getenv(string(key))
}
func (key EnvKey) SetValue(value string) {
os.Setenv(string(key), value)
}
func (key EnvKey) GetBoolValue() bool {
value := strings.ToLower(os.Getenv(string(key)))
return value == "true" || value == "1"

View File

@@ -5,30 +5,32 @@ import (
"net"
"net/http"
"slideshowApp/env"
"strings"
)
// Helper to get the local network IP address
func getLocalIP() string {
func GetLocalIP() string {
if env.Host.GetValue() != "0.0.0.0" && env.Host.GetValue() != "localhost" {
return env.Host.GetValue()
}
addrs, err := net.InterfaceAddrs()
if ip := getActiveIP(); ip != "" {
return ip
}
return "localhost"
}
func getActiveIP() string {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
return "localhost"
return ""
}
for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
if env.Env.GetValue() == "development" && !strings.Contains(ipnet.IP.String(), "192.168") {
continue
defer conn.Close()
addr := conn.LocalAddr()
if udpAddr, ok := addr.(*net.UDPAddr); ok {
return udpAddr.IP.String()
}
return ipnet.IP.String()
}
}
}
return "localhost"
return ""
}
func InfoHandler(w http.ResponseWriter, r *http.Request) {
@@ -43,7 +45,7 @@ func InfoHandler(w http.ResponseWriter, r *http.Request) {
}
data := map[string]string{
"ip": getLocalIP(),
"ip": GetLocalIP(),
"port": port,
"speed": speed,
}

22
main.go
View File

@@ -7,10 +7,14 @@ import (
"os"
"slideshowApp/env"
"slideshowApp/handlers"
"slideshowApp/utils"
"time"
"github.com/gorilla/mux"
)
var staticFolder = "./web/static/"
func main() {
env.Load(".env")
@@ -21,38 +25,46 @@ func main() {
if _, err := os.Stat(uploadFolder); err != nil {
fmt.Println("upload folder for images not found: ", uploadFolder)
fmt.Println("use fallback")
fmt.Println("use fallback folder")
uploadFolder = "./images"
env.PhotoDir.SetValue(uploadFolder)
}
fmt.Println("upload folder for images: ", uploadFolder)
r.PathPrefix("/uploads/").Handler(http.StripPrefix("/uploads/", http.FileServer(http.Dir(uploadFolder))))
r.HandleFunc("/api/images", handlers.ListFilesHandler).Methods("GET")
r.HandleFunc("/ws", handlers.Websocket)
r.HandleFunc("/upload", handlers.UploadHandler).Methods("POST")
r.HandleFunc("/settings", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, "settings.html") })
r.HandleFunc("/settings", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, staticFolder+"settings.html") })
r.HandleFunc("/api/save-schedule", handlers.SaveSchedule).Methods("POST")
r.HandleFunc("/api/get-schedule", handlers.GetSchedule).Methods("GET")
r.HandleFunc("/api/delete", handlers.DeleteHandler).Methods("POST")
r.HandleFunc("/manage", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "manage.html")
http.ServeFile(w, r, staticFolder+"manage.html")
})
r.HandleFunc("/api/info", handlers.InfoHandler).Methods("GET")
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "index.html")
http.ServeFile(w, r, staticFolder+"index.html")
})
// We add a route for the slideshow page specifically
r.HandleFunc("/slideshow", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "frame.html")
http.ServeFile(w, r, staticFolder+"frame.html")
})
host := env.Host.GetValue()
port := env.Port.GetValue()
url := fmt.Sprintf("%s:%s", host, port)
go func() {
time.Sleep(3 * time.Second)
if err := utils.OpenBrowser(fmt.Sprintf("%s:%s/slideshow", handlers.GetLocalIP(), port)); err != nil {
fmt.Println(err)
}
}()
fmt.Println("Server running at", url)
log.Fatal(http.ListenAndServe(url, r))
}

View File

@@ -1 +0,0 @@
{"Friday_active":false,"Friday_end":"07:38","Friday_start":"07:00","Monday_active":false,"Monday_end":"22:00","Monday_start":"08:00","Saturday_active":false,"Saturday_end":"22:00","Saturday_start":"08:00","Sunday_active":false,"Sunday_end":"22:00","Sunday_start":"08:00","Thursday_active":false,"Thursday_end":"22:00","Thursday_start":"08:00","Tuesday_active":false,"Tuesday_end":"22:00","Tuesday_start":"08:00","Wednesday_active":false,"Wednesday_end":"22:00","Wednesday_start":"08:00"}

81
utils/utils.go Normal file
View File

@@ -0,0 +1,81 @@
package utils
import (
"fmt"
"os"
"os/exec"
"runtime"
)
func OpenBrowser(url string) error {
var commands [][]string
switch runtime.GOOS {
case "windows":
commands = [][]string{
// Chrome (most common)
{`C:\Program Files\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
{`C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`, "--kiosk", url},
// Edge (default on modern Windows)
{`C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`, "--kiosk", url},
{`C:\Program Files\Microsoft\Edge\Application\msedge.exe`, "--kiosk", url},
// Firefox (no true kiosk, but fullscreen)
{`C:\Program Files\Mozilla Firefox\firefox.exe`, "--kiosk", url},
{`C:\Program Files (x86)\Mozilla Firefox\firefox.exe`, "--kiosk", url},
// System default browser (always works)
{"rundll32", "url.dll,FileProtocolHandler", url},
}
case "darwin":
commands = [][]string{
// Chrome
{"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--kiosk", url},
// Edge
{"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", "--kiosk", url},
// Firefox
{"/Applications/Firefox.app/Contents/MacOS/firefox", "--kiosk", url},
// Safari (no kiosk flag, opens normally)
{"open", "-a", "Safari", url},
// System default browser
{"open", url},
}
default: // Linux
if os.Getenv("DISPLAY") == "" &&
os.Getenv("WAYLAND_DISPLAY") == "" &&
os.Getenv("XDG_SESSION_TYPE") != "wayland" {
return fmt.Errorf("os is running in headless mode; do not start browser")
}
commands = [][]string{
// Chromium / Chrome
{"chromium-browser", "--kiosk", url},
{"chromium", "--kiosk", url},
{"google-chrome", "--kiosk", url},
// Firefox
{"firefox", "--kiosk", url},
// System default browser (best universal fallback)
{"xdg-open", url},
}
}
for _, cmd := range commands {
execCmd := exec.Command(cmd[0], cmd[1:]...)
if err := execCmd.Start(); err == nil {
return nil
} else {
return err
}
}
return fmt.Errorf("could not open browser")
}

View File

@@ -193,6 +193,7 @@
const res = await fetch('/api/info');
const data = await res.json();
const uploadUrl = `http://${data.ip}:${data.port}/`;
new QRCode(document.getElementById("qrcode"), {
text: uploadUrl,
width: 128,

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Go File Center</title>
<title>Slideshow App</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center p-6">