Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d637f03e | ||
|
|
793929ad82 | ||
|
|
281548c166 | ||
|
|
9543bf407b | ||
|
|
45c400e7d3 |
2
.env
2
.env
@@ -2,4 +2,4 @@ ENV= #empty|development
|
|||||||
PHOTO_DIR=images
|
PHOTO_DIR=images
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
PORT=8080
|
PORT=8080
|
||||||
INTERVAL_DEFAULT=120
|
INTERVAL_DEFAULT=10
|
||||||
93
.gitea/workflows/build.yml
Normal file
93
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
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: 6
|
||||||
|
ext: ""
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- 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
|
||||||
|
OUTPUT="${OUTPUT}v${{ matrix.arm_version }}"
|
||||||
|
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: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
|
||||||
|
path: |
|
||||||
|
./web
|
||||||
|
${APP_NAME}
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
images/
|
images/
|
||||||
slideshow_app
|
slideshowApp
|
||||||
11
main.go
11
main.go
@@ -11,6 +11,8 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var staticFolder = "./web/static/"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
env.Load(".env")
|
env.Load(".env")
|
||||||
@@ -23,7 +25,6 @@ func main() {
|
|||||||
fmt.Println("upload folder for images not found: ", uploadFolder)
|
fmt.Println("upload folder for images not found: ", uploadFolder)
|
||||||
fmt.Println("use fallback")
|
fmt.Println("use fallback")
|
||||||
uploadFolder = "./images"
|
uploadFolder = "./images"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("upload folder for images: ", uploadFolder)
|
fmt.Println("upload folder for images: ", uploadFolder)
|
||||||
@@ -31,23 +32,23 @@ func main() {
|
|||||||
r.HandleFunc("/api/images", handlers.ListFilesHandler).Methods("GET")
|
r.HandleFunc("/api/images", handlers.ListFilesHandler).Methods("GET")
|
||||||
r.HandleFunc("/ws", handlers.Websocket)
|
r.HandleFunc("/ws", handlers.Websocket)
|
||||||
r.HandleFunc("/upload", handlers.UploadHandler).Methods("POST")
|
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/save-schedule", handlers.SaveSchedule).Methods("POST")
|
||||||
r.HandleFunc("/api/get-schedule", handlers.GetSchedule).Methods("GET")
|
r.HandleFunc("/api/get-schedule", handlers.GetSchedule).Methods("GET")
|
||||||
|
|
||||||
r.HandleFunc("/api/delete", handlers.DeleteHandler).Methods("POST")
|
r.HandleFunc("/api/delete", handlers.DeleteHandler).Methods("POST")
|
||||||
r.HandleFunc("/manage", func(w http.ResponseWriter, r *http.Request) {
|
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("/api/info", handlers.InfoHandler).Methods("GET")
|
||||||
|
|
||||||
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
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
|
// We add a route for the slideshow page specifically
|
||||||
r.HandleFunc("/slideshow", func(w http.ResponseWriter, r *http.Request) {
|
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()
|
host := env.Host.GetValue()
|
||||||
|
|||||||
@@ -193,6 +193,7 @@
|
|||||||
const res = await fetch('/api/info');
|
const res = await fetch('/api/info');
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const uploadUrl = `http://${data.ip}:${data.port}/`;
|
const uploadUrl = `http://${data.ip}:${data.port}/`;
|
||||||
|
|
||||||
new QRCode(document.getElementById("qrcode"), {
|
new QRCode(document.getElementById("qrcode"), {
|
||||||
text: uploadUrl,
|
text: uploadUrl,
|
||||||
width: 128,
|
width: 128,
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-gray-50 min-h-screen flex items-center justify-center p-6">
|
<body class="bg-gray-50 min-h-screen flex items-center justify-center p-6">
|
||||||
Reference in New Issue
Block a user