added Forms for file submission
parent
2ab0f33d52
commit
6be55038ea
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"git.jmbit.de/filegate/filegate/db"
|
||||
)
|
||||
|
@ -37,13 +38,13 @@ func DownloadFile(rawURL string, blob string, id uint) error {
|
|||
path := fileURL.Path
|
||||
splitPath := strings.Split(path, "/")
|
||||
fileName := splitPath[len(splitPath)-1]
|
||||
log.Printf("Downloading file %s, OG Name: %s, Path: %s \n", id, fileName, path)
|
||||
log.Printf("Downloading file %d, OG Name: %s, Path: %s \n", id, fileName, path)
|
||||
contentType := response.Header.Get("content-type")
|
||||
if contentType == "" {
|
||||
contentType = "application/octet-stream"
|
||||
}
|
||||
db.UpdateOriginalName(id, fileName)
|
||||
objectInfo, err := MinioClient.PutObject(ctx, minioConfig.Bucket, blob, response.Body, response.ContentLength,
|
||||
objectInfo, err := MinioClient.PutObject(ctx, viper.GetString("minio.bucket"), blob, response.Body, response.ContentLength,
|
||||
minio.PutObjectOptions{ContentType: contentType})
|
||||
if err != nil {
|
||||
log.Printf("Could not create File object: %v \n", err)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"git.jmbit.de/filegate/filegate/db"
|
||||
)
|
||||
|
@ -17,7 +18,7 @@ func UploadFile(id uint, blob string, c *gin.Context) error {
|
|||
return err
|
||||
}
|
||||
db.UpdateOriginalName(id, file.Filename)
|
||||
objectInfo, err := MinioClient.PutObject(ctx, minioConfig.Bucket, blob, c.Request.Body, c.Request.ContentLength,
|
||||
objectInfo, err := MinioClient.PutObject(ctx, viper.GetString("minio.bucket"), blob, c.Request.Body, c.Request.ContentLength,
|
||||
minio.PutObjectOptions{ContentType: c.ContentType()})
|
||||
if err != nil {
|
||||
log.Printf("Could not create File object: %v \n", err)
|
||||
|
@ -31,7 +32,7 @@ func UploadFile(id uint, blob string, c *gin.Context) error {
|
|||
// GetFile returns a pointer to a File stored in Minio by passing it the UUID ("Blob"-ID) of the file
|
||||
func GetFile(uuid string) (*minio.Object, error) {
|
||||
ctx := context.Background()
|
||||
object, err := MinioClient.GetObject(ctx, minioConfig.Bucket, uuid, minio.GetObjectOptions{})
|
||||
object, err := MinioClient.GetObject(ctx, viper.GetString("mino.bucket"), uuid, minio.GetObjectOptions{})
|
||||
|
||||
return object, err
|
||||
}
|
||||
|
|
|
@ -15,3 +15,84 @@ templ loginForm() {
|
|||
</div>
|
||||
</form>
|
||||
}
|
||||
|
||||
templ uploadForm() {
|
||||
<form id="uploadForm" name="uploadform" action="/file/new/upload" method="POST" hx-post="/file/new/upload">
|
||||
<h3 class="subtitle">Upload a suspicious File to Filegate </h3>
|
||||
<div class="field">
|
||||
<label class="label">File Name</label>
|
||||
<input class="input" type="text" placeholder="File name" name="filename" required class="input"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Comment/Description</label>
|
||||
<textarea class="textarea" name="comment" placeholder="e.g. This is an old Microsoft Office Format"></textarea>
|
||||
</div>
|
||||
<div class="file has-name is-boxed">
|
||||
<label class="file-label">
|
||||
<input class="file-input" type="file" name="resume"/>
|
||||
<span class="file-cta">
|
||||
<span class="file-icon">
|
||||
<i class="fas fa-upload"></i>
|
||||
</span>
|
||||
<span class="file-label">
|
||||
Choose a file…
|
||||
</span>
|
||||
</span>
|
||||
<span class="file-name">
|
||||
Invoice.docm
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit" hx-trigger="click">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
|
||||
templ urlDownloadForm() {
|
||||
<form id="urldownload" name="urldownload" action="/file/new/download" method="POST" hx-post="/file/new/download">
|
||||
<h3 class="subtitle">tries to directly download a file. Might or might not work, depending on how the Website is made</h3>
|
||||
<div class="field">
|
||||
<label class="label">File Name</label>
|
||||
<input class="input" type="text" placeholder="File name" name="filename" required class="input"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">URL</label>
|
||||
<input class="input" type="text" placeholder="https://example.com" name="fileurl" required class="input"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Comment/Description</label>
|
||||
<textarea class="textarea" name="comment" placeholder="e.g. This is an old Microsoft Office Format"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit" hx-trigger="click">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
|
||||
templ browserDownloadForm() {
|
||||
<form id="urldownload" name="urldownload" action="/file/new/browser" method="POST" hx-post="/file/new/browser">
|
||||
<h3 class="subtitle">Opens a Browser inside a container to download a suspicious file.</h3>
|
||||
<div class="field">
|
||||
<label class="label">File Name</label>
|
||||
<input class="input" type="text" placeholder="File name" name="filename" required class="input"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Start-URL</label>
|
||||
<input class="input" type="text" placeholder="https://example.com" name="fileurl" required class="input"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Comment/Description</label>
|
||||
<textarea class="textarea" name="comment" placeholder="e.g. This is an old Microsoft Office Format"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit" hx-trigger="click">Open</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
|
|
|
@ -60,3 +60,219 @@ func loginForm() templ.Component {
|
|||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func uploadForm() templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var5 == nil {
|
||||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form id=\"uploadForm\" name=\"uploadform\" action=\"/file/new/upload\" method=\"POST\" hx-post=\"/file/new/upload\"><h3 class=\"subtitle\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var6 := `Upload a suspicious File to Filegate `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var7 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <input class=\"input\" type=\"text\" placeholder=\"File name\" name=\"filename\" required class=\"input\"></div><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var8 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <textarea class=\"textarea\" name=\"comment\" placeholder=\"e.g. This is an old Microsoft Office Format\"></textarea></div><div class=\"file has-name is-boxed\"><label class=\"file-label\"><input class=\"file-input\" type=\"file\" name=\"resume\"> <span class=\"file-cta\"><span class=\"file-icon\"><i class=\"fas fa-upload\"></i></span> <span class=\"file-label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var9 := `Choose a file…`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></span> <span class=\"file-name\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var10 := `Invoice.docm`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></label></div><div class=\"field\"><div class=\"control\"><button class=\"button is-primary\" type=\"submit\" hx-trigger=\"click\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var11 := `Submit`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button></div></div></form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func urlDownloadForm() templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var12 == nil {
|
||||
templ_7745c5c3_Var12 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form id=\"urldownload\" name=\"urldownload\" action=\"/file/new/download\" method=\"POST\" hx-post=\"/file/new/download\"><h3 class=\"subtitle\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var13 := `tries to directly download a file. Might or might not work, depending on how the Website is made`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var14 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <input class=\"input\" type=\"text\" placeholder=\"File name\" name=\"filename\" required class=\"input\"></div><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var15 := `URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <input class=\"input\" type=\"text\" placeholder=\"https://example.com\" name=\"fileurl\" required class=\"input\"></div><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var16 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <textarea class=\"textarea\" name=\"comment\" placeholder=\"e.g. This is an old Microsoft Office Format\"></textarea></div><div class=\"field\"><div class=\"control\"><button class=\"button is-primary\" type=\"submit\" hx-trigger=\"click\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var17 := `Submit`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button></div></div></form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func browserDownloadForm() templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var18 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var18 == nil {
|
||||
templ_7745c5c3_Var18 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form id=\"urldownload\" name=\"urldownload\" action=\"/file/new/browser\" method=\"POST\" hx-post=\"/file/new/browser\"><h3 class=\"subtitle\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var19 := `Opens a Browser inside a container to download a suspicious file.`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var20 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <input class=\"input\" type=\"text\" placeholder=\"File name\" name=\"filename\" required class=\"input\"></div><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var21 := `Start-URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <input class=\"input\" type=\"text\" placeholder=\"https://example.com\" name=\"fileurl\" required class=\"input\"></div><div class=\"field\"><label class=\"label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var22 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <textarea class=\"textarea\" name=\"comment\" placeholder=\"e.g. This is an old Microsoft Office Format\"></textarea></div><div class=\"field\"><div class=\"control\"><button class=\"button is-primary\" type=\"submit\" hx-trigger=\"click\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var23 := `Open`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var23)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button></div></div></form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
package templates
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: 0.2.476
|
||||
package templates
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
|
@ -45,6 +45,9 @@ templ navbar(loggedIn bool) {
|
|||
<a class="navbar-item" href="/file/">
|
||||
Files
|
||||
</a>
|
||||
<a class="navbar-item" href="/file/new/">
|
||||
New File
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
|
|
|
@ -292,6 +292,15 @@ func navbar(loggedIn bool) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a> <a class=\"navbar-item\" href=\"/file/new/\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var29 := `New File`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var29)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></div><div class=\"navbar-end\"><div class=\"navbar-item\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
@ -319,9 +328,9 @@ func loginButton(loggedIn bool) templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var29 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var29 == nil {
|
||||
templ_7745c5c3_Var29 = templ.NopComponent
|
||||
templ_7745c5c3_Var30 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var30 == nil {
|
||||
templ_7745c5c3_Var30 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
if loggedIn {
|
||||
|
@ -329,8 +338,8 @@ func loginButton(loggedIn bool) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var30 := `Profile`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var30)
|
||||
templ_7745c5c3_Var31 := `Profile`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var31)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -338,8 +347,8 @@ func loginButton(loggedIn bool) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var31 := `Log out`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var31)
|
||||
templ_7745c5c3_Var32 := `Log out`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var32)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -352,8 +361,8 @@ func loginButton(loggedIn bool) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var32 := `Log in`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var32)
|
||||
templ_7745c5c3_Var33 := `Log in`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var33)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -377,17 +386,17 @@ func errorMessage(title string, content string) templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var33 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var33 == nil {
|
||||
templ_7745c5c3_Var33 = templ.NopComponent
|
||||
templ_7745c5c3_Var34 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var34 == nil {
|
||||
templ_7745c5c3_Var34 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<article class=\"message container\"><div class=\"message-header\"><p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var34 string = title
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
|
||||
var templ_7745c5c3_Var35 string = title
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -395,8 +404,8 @@ func errorMessage(title string, content string) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var35 string = content
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
|
||||
var templ_7745c5c3_Var36 string = content
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
@ -69,3 +69,27 @@ templ FileViewPage(metaContent utils.MetaContent, title string, file db.File, er
|
|||
@FileView(file)
|
||||
}
|
||||
}
|
||||
|
||||
templ NewFilePage(metaContent utils.MetaContent, title string, err error) {
|
||||
@wrapBase(metaContent, title, err) {
|
||||
<div class="section is-medium">
|
||||
<div class="columns is-centered">
|
||||
<div class="column">
|
||||
<div class="container">
|
||||
@uploadForm()
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="container">
|
||||
@urlDownloadForm()
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="container">
|
||||
@browserDownloadForm()
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,3 +285,66 @@ func FileViewPage(metaContent utils.MetaContent, title string, file db.File, err
|
|||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func NewFilePage(metaContent utils.MetaContent, title string, err error) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var15 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var15 == nil {
|
||||
templ_7745c5c3_Var15 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var16 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"section is-medium\"><div class=\"columns is-centered\"><div class=\"column\"><div class=\"container\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = uploadForm().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div><div class=\"column\"><div class=\"container\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = urlDownloadForm().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div><div class=\"column\"><div class=\"container\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = browserDownloadForm().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = wrapBase(metaContent, title, err).Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,5 +10,5 @@ import (
|
|||
)
|
||||
|
||||
func index(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "", templates.Index(utils.GenMetaContent(c)))
|
||||
c.HTML(http.StatusOK, "", templates.Index(utils.GenMetaContent(c), nil))
|
||||
}
|
||||
|
|
|
@ -4,15 +4,16 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.jmbit.de/filegate/filegate/utils"
|
||||
"git.jmbit.de/filegate/filegate/web/auth"
|
||||
"git.jmbit.de/filegate/filegate/web/templates"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func getLogin(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "", templates.Login(utils.GenMetaContent(c), "Login"))
|
||||
c.HTML(http.StatusOK, "", templates.Login(utils.GenMetaContent(c), "Login", nil))
|
||||
}
|
||||
|
||||
func postLogin(c *gin.Context) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.jmbit.de/filegate/filegate/utils"
|
||||
"git.jmbit.de/filegate/filegate/web/templates"
|
||||
)
|
||||
|
||||
func getNewFile(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "", templates.NewFilePage(utils.GenMetaContent(c), "New File", nil))
|
||||
}
|
||||
|
||||
func postNewFile(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "", templates.NewFilePage(utils.GenMetaContent(c), "New File", nil))
|
||||
}
|
|
@ -10,6 +10,9 @@ func GroupWeb(router *gin.Engine) *gin.Engine {
|
|||
router.POST("/", index)
|
||||
router.GET("/login.html", getLogin)
|
||||
router.POST("/login.html", postLogin)
|
||||
router.GET("/file/", getFileListPage)
|
||||
router.GET("/file/new/", getNewFile)
|
||||
router.POST("/file/new/", postNewFile)
|
||||
|
||||
return router
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue