feat: add version and hash
This commit is contained in:
parent
1a02ad4084
commit
c90da29b09
7 changed files with 76 additions and 15 deletions
6
app.go
6
app.go
|
@ -12,7 +12,13 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
hash = "unknown"
|
||||||
|
version = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
fmt.Printf("Kuma Archive %s-%s\n", version, hash)
|
||||||
command := commando.NewCommando(os.Args[1:])
|
command := commando.NewCommando(os.Args[1:])
|
||||||
cnf := config.Get()
|
cnf := config.Get()
|
||||||
|
|
||||||
|
|
17
internal/middleware/cors.go
Normal file
17
internal/middleware/cors.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package middleware
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
func CORS(ctx *gin.Context) {
|
||||||
|
ctx.Writer.Header().Set("Access-Control-Allow-Origin", ctx.Request.Header.Get("Origin"))
|
||||||
|
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
||||||
|
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||||
|
ctx.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
|
|
||||||
|
if ctx.Request.Method == "OPTIONS" {
|
||||||
|
ctx.AbortWithStatus(204)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Next()
|
||||||
|
}
|
|
@ -5,12 +5,15 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"git.wh64.net/devproje/kuma-archive/internal/middleware"
|
||||||
"git.wh64.net/devproje/kuma-archive/internal/service"
|
"git.wh64.net/devproje/kuma-archive/internal/service"
|
||||||
"github.com/gin-contrib/static"
|
"github.com/gin-contrib/static"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(app *gin.Engine, apiOnly bool) {
|
func New(app *gin.Engine, apiOnly bool) {
|
||||||
|
app.Use(middleware.CORS)
|
||||||
|
|
||||||
api := app.Group("/api")
|
api := app.Group("/api")
|
||||||
{
|
{
|
||||||
api.GET("/path/*path", func(ctx *gin.Context) {
|
api.GET("/path/*path", func(ctx *gin.Context) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:view": "tsc -b && vite build",
|
"build:view": "tsc -b && vite build",
|
||||||
"build:server": "go build -o kuma-archive",
|
"build:server": "go build -ldflags \"-X main.version=$(jq -r .version package.json) -X main.hash=$(git rev-parse --short=6 HEAD)\" -o kuma-archive",
|
||||||
"build": "bun run build:view && bun run build:server",
|
"build": "bun run build:view && bun run build:server",
|
||||||
"dev:view": "vite",
|
"dev:view": "vite",
|
||||||
"dev:server": "go run ./app.go daemon -d --api-only",
|
"dev:server": "go run ./app.go daemon -d --api-only",
|
||||||
|
|
15
src/App.scss
15
src/App.scss
|
@ -31,15 +31,22 @@
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
|
flex-direction: column;
|
||||||
transform: translateX(-100%);
|
transform: translateX(-100%);
|
||||||
|
justify-content: space-between;
|
||||||
background-color: var(--nav-color);
|
background-color: var(--nav-color);
|
||||||
transition: transform 0.3s ease-in-out;
|
transition: transform 0.3s ease-in-out;
|
||||||
|
|
||||||
&.open {
|
&.open {
|
||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ka-menu-group {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.ka-menu-item {
|
.ka-menu-item {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -61,6 +68,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ka-menu-footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
padding: 1rem 1.5rem;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
40
src/App.tsx
40
src/App.tsx
|
@ -57,7 +57,7 @@ function Dashboard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
// const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="ka-nav">
|
<nav className="ka-nav">
|
||||||
|
@ -68,26 +68,38 @@ function Header() {
|
||||||
|
|
||||||
<a onClick={ev => {
|
<a onClick={ev => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
console.log("not provide features");
|
setOpen(!open);
|
||||||
// setOpen(!open);
|
|
||||||
}}>
|
}}>
|
||||||
<DynamicIcon className="link" name="more-vertical" />
|
<DynamicIcon className="link" name="more-vertical" />
|
||||||
</a>
|
</a>
|
||||||
{/* <MenuView open={open} setOpen={setOpen} /> */}
|
<MenuView open={open} setOpen={setOpen} />
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: create menu modal
|
function MenuView({ open, setOpen }: { open: boolean; setOpen: (value: boolean) => void }) {
|
||||||
// function MenuView({ open, setOpen }: { open: boolean; setOpen: (value: boolean) => void }) {
|
return (
|
||||||
// return (
|
<div className={`ka-menu ${open ? "open" : ""}`}>
|
||||||
// <div className={`ka-menu ${open ? "open" : ""}`}>
|
<div className="ka-menu-group"></div>
|
||||||
// <MenuItem icon="panel-left-close" name="Close" block={() => {
|
<div className="ka-menu-group">
|
||||||
// setOpen(false);
|
<div className="ka-menu-footer">
|
||||||
// }} />
|
<a className="btn link" href="https://git.wh64.net/devproje/kuma-archive">
|
||||||
// </div>
|
<DynamicIcon name="git-fork" />
|
||||||
// );
|
</a>
|
||||||
// }
|
<a className="btn link" href="https://projecttl.net">
|
||||||
|
<DynamicIcon name="globe" />
|
||||||
|
</a>
|
||||||
|
<a className="btn link" onClick={ev => {
|
||||||
|
ev.preventDefault();
|
||||||
|
setOpen(false);
|
||||||
|
}}>
|
||||||
|
<DynamicIcon name="panel-left-close" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// function MenuItem({ icon, name, block }: { icon: IconName, name: string, block?: () => void }) {
|
// function MenuItem({ icon, name, block }: { icon: IconName, name: string, block?: () => void }) {
|
||||||
// return (
|
// return (
|
||||||
|
|
|
@ -30,6 +30,14 @@ function FileView() {
|
||||||
<a className="btn link" href={`/api/raw${location.pathname}`}>
|
<a className="btn link" href={`/api/raw${location.pathname}`}>
|
||||||
<DynamicIcon name="file" size={21} />
|
<DynamicIcon name="file" size={21} />
|
||||||
</a>
|
</a>
|
||||||
|
<a className="btn link" onClick={ev => {
|
||||||
|
ev.preventDefault();
|
||||||
|
navigator.clipboard.writeText(`${document.location.origin}/api/raw${location.pathname}`)
|
||||||
|
.then(() => alert("url copied to clipboard"))
|
||||||
|
.catch(err => console.error("Failed to copy text: ", err));
|
||||||
|
}}>
|
||||||
|
<DynamicIcon name="link" size={21} />
|
||||||
|
</a>
|
||||||
<a className="btn link" onClick={ev => {
|
<a className="btn link" onClick={ev => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
fetch(`/api/download${location.pathname}`)
|
fetch(`/api/download${location.pathname}`)
|
||||||
|
|
Loading…
Reference in a new issue