This commit is contained in:
rishikanthc
2025-11-25 13:01:04 -08:00
parent e5a45ca469
commit 28dd97cfa6
8 changed files with 4636 additions and 48 deletions

3
.gitignore vendored
View File

@@ -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

View File

@@ -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()

View File

@@ -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">

File diff suppressed because it is too large Load Diff

View File

@@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -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: {