mirror of
https://github.com/rishikanthc/Scriberr.git
synced 2026-06-29 15:26:02 +00:00
closes #254
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -39,7 +39,7 @@ AGENTS.md
|
||||
scriberr-data
|
||||
whisperx-env
|
||||
|
||||
internal/web
|
||||
# internal/web
|
||||
env-data
|
||||
# main
|
||||
results.json
|
||||
@@ -52,3 +52,4 @@ tests/database_test.db-shm
|
||||
|
||||
# Project documentation (local only)
|
||||
project-docs
|
||||
!internal/web/static.go
|
||||
|
||||
@@ -98,6 +98,43 @@ func SetupStaticRoutes(router *gin.Engine, authService *auth.AuthService) {
|
||||
return
|
||||
}
|
||||
|
||||
// Try to serve file from dist directly (for PWA assets like sw.js, manifest.webmanifest)
|
||||
path := c.Request.URL.Path
|
||||
if strings.HasPrefix(path, "/") {
|
||||
path = path[1:]
|
||||
}
|
||||
|
||||
// Prevent directory traversal (basic check, though embed.FS is safe)
|
||||
if strings.Contains(path, "..") {
|
||||
c.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
// Try to read the file from embedded filesystem
|
||||
fileContent, err := staticFiles.ReadFile("dist/" + path)
|
||||
if err == nil {
|
||||
// File exists, serve it
|
||||
contentType := "application/octet-stream"
|
||||
if strings.HasSuffix(path, ".css") {
|
||||
contentType = "text/css"
|
||||
} else if strings.HasSuffix(path, ".js") {
|
||||
contentType = "application/javascript"
|
||||
} else if strings.HasSuffix(path, ".png") {
|
||||
contentType = "image/png"
|
||||
} else if strings.HasSuffix(path, ".svg") {
|
||||
contentType = "image/svg+xml"
|
||||
} else if strings.HasSuffix(path, ".ico") {
|
||||
contentType = "image/x-icon"
|
||||
} else if strings.HasSuffix(path, ".webmanifest") {
|
||||
contentType = "application/manifest+json"
|
||||
} else if strings.HasSuffix(path, ".html") {
|
||||
contentType = "text/html; charset=utf-8"
|
||||
}
|
||||
|
||||
c.Data(http.StatusOK, contentType, fileContent)
|
||||
return
|
||||
}
|
||||
|
||||
// For all other routes, serve the React app
|
||||
// The React app will handle authentication client-side
|
||||
indexHTML, err := GetIndexHTML()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/scriberr-thumb.png" />
|
||||
<link rel="apple-touch-icon" href="/icon512_rounded.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Scriberr - Audio Transcription</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
|
||||
4609
web/frontend/package-lock.json
generated
4609
web/frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -60,6 +60,7 @@
|
||||
"tw-animate-css": "^1.3.7",
|
||||
"typescript": "~5.8.3",
|
||||
"typescript-eslint": "^8.39.1",
|
||||
"vite": "^7.1.2"
|
||||
"vite": "^7.1.2",
|
||||
"vite-plugin-pwa": "^1.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
web/frontend/public/icon512_maskable.png
Normal file
BIN
web/frontend/public/icon512_maskable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
BIN
web/frontend/public/icon512_rounded.png
Normal file
BIN
web/frontend/public/icon512_rounded.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -3,11 +3,42 @@ import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import path from "path"
|
||||
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'mask-icon.svg'],
|
||||
manifest: {
|
||||
name: 'Scriberr',
|
||||
short_name: 'Scriberr',
|
||||
description: 'Offline Audio Transcription',
|
||||
theme_color: '#8936FF',
|
||||
background_color: '#2EC6FE',
|
||||
display: 'standalone',
|
||||
orientation: 'any',
|
||||
start_url: '/',
|
||||
id: 'scriberr-transcription',
|
||||
icons: [
|
||||
{
|
||||
src: 'icon512_maskable.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'maskable'
|
||||
},
|
||||
{
|
||||
src: 'icon512_rounded.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'any'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
|
||||
Reference in New Issue
Block a user