Compare commits

..

No commits in common. "ad4f9576d01ad3dc6e6ecd37b53ec38ebfc3cb1b" and "eea3203a3b9fa3372909f5f7c5de743745a176bb" have entirely different histories.

22 changed files with 351 additions and 1107 deletions

1
.gitignore vendored
View file

@ -3,7 +3,6 @@ venv/
/storage/
scanners/ole/venv/
tmp/
temp/
**/__pycache__
# Created by https://www.toptal.com/developers/gitignore/api/linux,go,vim,visualstudiocode,macos,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,go,vim,visualstudiocode,macos,windows

View file

@ -22,29 +22,15 @@ func GetFileByID(fileID string) (sqlc.File, error) {
return file, nil
}
func DeleteFileByID(fileID string) error {
var pgUUID pgtype.UUID
err := pgUUID.Scan(fileID)
if err != nil {
slog.Error("Unable to convert string to UUID", "file-uuid", fileID, "error", err)
}
query := sqlc.New(pool)
err = query.DeleteFile(context.Background(), pgUUID)
if err != nil {
slog.Error("Unable to delete file", "file-uuid", fileID, "error", err)
}
return err
}
func InsertFileProperties(properties sqlc.InsertFilePropertiesParams) error {
query := sqlc.New(pool)
slog.Debug("InsertFileProperties", "file-uuid", properties.FileID.String(), "file-sha256",
slog.Debug("InsertFileProperties", "file-uuid", properties.ID.String(), "file-sha256",
hex.EncodeToString(properties.Sha256), "file-md5", hex.EncodeToString(properties.Md5),
"file-mime", properties.LibmagicMime.String, "file-extension", properties.LibmagicExtension.String,
"file-apple", properties.LibmagicApple.String)
err := query.InsertFileProperties(context.Background(), properties)
if err != nil {
slog.Error("Unable to add file properties", "file-uuid", properties.FileID.String(), "error", err)
slog.Error("Unable to add file properties", "file-uuid", properties.ID.String(), "error", err)
}
return err
}

View file

@ -1,12 +1,11 @@
-- name: InsertFileProperties :exec
INSERT INTO file_properties (
file_id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple
) VALUES ($1, $2, $3, $4, $5, $6)
;
id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple
) VALUES ($1, $2, $3, $4, $5, $6);
-- name: GetFileProperties :one
SELECT * FROM file_properties
WHERE file_id = $1;
WHERE id = $1;
-- name: InsertFileDIEC :exec
INSERT INTO diec (

View file

@ -69,8 +69,7 @@ CREATE TABLE IF NOT EXISTS msoffice (
CREATE TABLE IF NOT EXISTS file_properties (
id BIGSERIAL PRIMARY KEY,
file_id UUID REFERENCES files (id) ON DELETE CASCADE,
id UUID PRIMARY KEY,
sha256 BYTEA,
md5 BYTEA,
libmagic_mime TEXT,
@ -92,6 +91,5 @@ CREATE INDEX idx_msoffice_oleid_file_id ON msoffice_oleid (file_id);
CREATE INDEX idx_msoffice_olevba_file_id ON msoffice_olevba (file_id);
CREATE INDEX idx_msoffice_mraptor_file_id ON msoffice_mraptor (file_id);
CREATE INDEX idx_msoffice_results_file_id ON msoffice (file_id);
CREATE INDEX idx_file_properties_file_id ON file_properties (file_id);
CREATE INDEX idx_file_properties_id ON file_properties (id);
CREATE INDEX idx_file_id ON files (id);
CREATE INDEX idx_yara_results_file_id ON yara_results (file_id);

View file

@ -28,10 +28,7 @@ func BasicProcessing(job sqlc.ProcessingJob) error {
}
fileProperties := sqlc.InsertFilePropertiesParams{}
fileProperties.LibmagicMime.Valid = true
fileProperties.LibmagicApple.Valid = true
fileProperties.LibmagicExtension.Valid = true
fileProperties.FileID = job.FileID
fileProperties.ID = job.FileID
fileProperties.Md5 = md5sum[:]
fileProperties.Sha256 = sha256sum[:]
fileProperties.LibmagicMime.String = fileCmdResult.MimeType

View file

@ -18,7 +18,7 @@ var startup time.Time
func Setup(wg *sync.WaitGroup) {
startup = time.Now()
go yara.InitYara()
yara.InitYara()
}
// Submit() starts the analysis process for a file.
@ -31,14 +31,6 @@ func Submit(ctx context.Context, file pgtype.UUID) error {
}
go basic.BasicProcessing(job)
yaraJob, err := database.NewProcessingJob(ctx, file, TypeYARA)
if err != nil {
slog.Error("Could not submit processing job", "error", err, "file-uuid", file, "type", TypeBasic)
return err
}
go yara.YaraProcessing(yaraJob)
mimeType, err := database.GetFileMime(file)
if err != nil {
slog.Error("Could not retrieve MimeType", "error", err, "file-uuid", file)

View file

@ -25,9 +25,6 @@ const TypeArchive = "Archive"
// Anything not implemented (yet)
const TypeOther = "Other"
// Yara Scan (can be done for all filetypes)
const TypeYARA = "Yara"
var MSOfficeMime = []string{
"application/msword",
"application/vnd.ms-excel",

View file

@ -21,8 +21,7 @@ func compileSourcesFromFiles() error {
return err
}
cmd := exec.Command("/usr/local/bin/yr", "compile","--path-as-namespace", "--relaxed-re-syntax", "--output", outputPath, root)
slog.Debug("Yara compile command", "cmd", cmd.String())
cmd := exec.Command("/usr/local/bin/yr", "compile","-path-as-namespace", "--relaxed-re-syntax", "--output", outputPath, root)
result, err := cmd.Output()
if err != nil {
slog.Error("Error compiling yara rules", "error", err, "result", string(result))
@ -47,7 +46,6 @@ func scanFile(fileName string) ([]string, error) {
return matched, err
}
cmd := exec.Command("/usr/local/bin/yr", "scan", "--output-format ndjson", "--print-namespace","--compiled-rules", outputPath, fullPath)
slog.Debug("Yara scan command", "cmd", cmd.String())
result, err := cmd.Output()
if err != nil {
slog.Error("Error scanning file with yara", "error", err, "file-uuid", fileName,"result", string(result))

View file

@ -14,9 +14,6 @@ func RegisterRoutes() *http.ServeMux {
mux.HandleFunc("/about", web.AboutWebHandler)
mux.HandleFunc("/admin", web.AdminWebHandler)
mux.HandleFunc("/files/{uuid}", web.FileViewWebHandler)
mux.HandleFunc("/files/{uuid}/msoffice", web.FileViewMSOWebHandler)
mux.HandleFunc("/files/{uuid}/download", web.FileViewDownloadWebHandler)
mux.HandleFunc("/files/{uuid}/delete", web.FileViewDeleteWebHandler)
mux.HandleFunc("POST /upload", web.IndexUploadHandler)
mux.Handle("/assets/", http.FileServer(http.FS(web.Files)))

View file

@ -26,8 +26,7 @@ type File struct {
}
type FileProperty struct {
ID int64
FileID pgtype.UUID
ID pgtype.UUID
Sha256 []byte
Md5 []byte
LibmagicMime pgtype.Text

View file

@ -12,16 +12,15 @@ import (
)
const getFileProperties = `-- name: GetFileProperties :one
SELECT id, file_id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple FROM file_properties
WHERE file_id = $1
SELECT id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple FROM file_properties
WHERE id = $1
`
func (q *Queries) GetFileProperties(ctx context.Context, fileID pgtype.UUID) (FileProperty, error) {
row := q.db.QueryRow(ctx, getFileProperties, fileID)
func (q *Queries) GetFileProperties(ctx context.Context, id pgtype.UUID) (FileProperty, error) {
row := q.db.QueryRow(ctx, getFileProperties, id)
var i FileProperty
err := row.Scan(
&i.ID,
&i.FileID,
&i.Sha256,
&i.Md5,
&i.LibmagicMime,
@ -49,12 +48,12 @@ func (q *Queries) InsertFileDIEC(ctx context.Context, arg InsertFileDIECParams)
const insertFileProperties = `-- name: InsertFileProperties :exec
INSERT INTO file_properties (
file_id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple
id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple
) VALUES ($1, $2, $3, $4, $5, $6)
`
type InsertFilePropertiesParams struct {
FileID pgtype.UUID
ID pgtype.UUID
Sha256 []byte
Md5 []byte
LibmagicMime pgtype.Text
@ -64,7 +63,7 @@ type InsertFilePropertiesParams struct {
func (q *Queries) InsertFileProperties(ctx context.Context, arg InsertFilePropertiesParams) error {
_, err := q.db.Exec(ctx, insertFileProperties,
arg.FileID,
arg.ID,
arg.Sha256,
arg.Md5,
arg.LibmagicMime,

View file

@ -11,6 +11,5 @@ func AboutWebHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
slog.Error("Error rendering in AboutWebHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}

View file

@ -1,25 +1,16 @@
package web
import (
"git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
)
templ About() {
@Base("About") {
<h1>About</h1>
<p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p>
<h2>Used tools</h2>
<p>Scanfile uses a variety of open source software:</p>
<div class="w-full max-w-sm">
@accordion.Accordion(accordion.Props{
Class: "w-full",
}) {
@accordion.Item() {
@accordion.Trigger() {
<a href="http://www.decalage.info">Oletools</a>
}
@accordion.Content() {
The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info)
<ul>
<li>
<h3><a href="http://www.decalage.info">Oletools</a></h3>
<pre>
The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info)
All rights reserved.
@ -29,10 +20,9 @@ Redistribution and use in source and binary forms, with or without modification,
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
}
}
</div>
}
</pre>
</li>
</ul>
}
}

View file

@ -8,10 +8,6 @@ package web
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import (
"git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
)
func About() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
@ -45,97 +41,7 @@ func About() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<h1>About</h1><p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p><h2>Used tools</h2><p>Scanfile uses a variety of open source software:</p><div class=\"w-full max-w-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<a href=\"http://www.decalage.info\">Oletools</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Trigger().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Content().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Item().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Accordion(accordion.Props{
Class: "w-full",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<h1>About</h1><p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p><h2>Used tools</h2><p>Scanfile uses a variety of open source software:</p><ul><li><h3><a href=\"http://www.decalage.info\">Oletools</a></h3><pre>The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</pre></li></ul>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View file

@ -1,4 +1,4 @@
/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */
/*! tailwindcss v4.1.10 | MIT License | https://tailwindcss.com */
@layer properties;
@layer theme, base, components, utilities;
@layer theme {
@ -243,9 +243,6 @@
.static {
position: static;
}
.sticky {
position: sticky;
}
.inset-0 {
inset: calc(var(--spacing) * 0);
}
@ -297,9 +294,6 @@
.z-20 {
z-index: 20;
}
.z-40 {
z-index: 40;
}
.z-50 {
z-index: 50;
}
@ -345,9 +339,6 @@
.mt-4 {
margin-top: calc(var(--spacing) * 4);
}
.mt-24 {
margin-top: calc(var(--spacing) * 24);
}
.mt-auto {
margin-top: auto;
}
@ -363,9 +354,6 @@
.mb-4 {
margin-bottom: calc(var(--spacing) * 4);
}
.mb-12 {
margin-bottom: calc(var(--spacing) * 12);
}
.ml-1 {
margin-left: calc(var(--spacing) * 1);
}
@ -449,9 +437,6 @@
.h-8 {
height: calc(var(--spacing) * 8);
}
.h-9 {
height: calc(var(--spacing) * 9);
}
.h-10 {
height: calc(var(--spacing) * 10);
}
@ -461,18 +446,6 @@
.h-16 {
height: calc(var(--spacing) * 16);
}
.h-48 {
height: calc(var(--spacing) * 48);
}
.h-64 {
height: calc(var(--spacing) * 64);
}
.h-80 {
height: calc(var(--spacing) * 80);
}
.h-96 {
height: calc(var(--spacing) * 96);
}
.h-\[1px\] {
height: 1px;
}
@ -503,9 +476,6 @@
.min-h-\[80px\] {
min-height: 80px;
}
.min-h-screen {
min-height: 100vh;
}
.w-0 {
width: calc(var(--spacing) * 0);
}
@ -560,15 +530,6 @@
.w-16 {
width: calc(var(--spacing) * 16);
}
.w-24 {
width: calc(var(--spacing) * 24);
}
.w-32 {
width: calc(var(--spacing) * 32);
}
.w-80 {
width: calc(var(--spacing) * 80);
}
.w-\[1px\] {
width: 1px;
}
@ -731,12 +692,6 @@
.columns-4 {
columns: 4;
}
.grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-cols-7 {
grid-template-columns: repeat(7, minmax(0, 1fr));
}
@ -779,12 +734,6 @@
.gap-4 {
gap: calc(var(--spacing) * 4);
}
.gap-6 {
gap: calc(var(--spacing) * 6);
}
.gap-8 {
gap: calc(var(--spacing) * 8);
}
.space-y-1 {
:where(& > :not(:last-child)) {
--tw-space-y-reverse: 0;
@ -806,13 +755,6 @@
margin-block-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)));
}
}
.space-y-3 {
:where(& > :not(:last-child)) {
--tw-space-y-reverse: 0;
margin-block-start: calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));
margin-block-end: calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)));
}
}
.-space-x-1 {
:where(& > :not(:last-child)) {
--tw-space-x-reverse: 0;
@ -1006,12 +948,6 @@
background-color: color-mix(in oklab, var(--background) 80%, transparent);
}
}
.bg-background\/95 {
background-color: var(--background);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--background) 95%, transparent);
}
}
.bg-black {
background-color: var(--color-black);
}
@ -1051,12 +987,6 @@
.bg-muted {
background-color: var(--muted);
}
.bg-muted\/30 {
background-color: var(--muted);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--muted) 30%, transparent);
}
}
.bg-muted\/50 {
background-color: var(--muted);
@supports (color: color-mix(in lab, red, red)) {
@ -1072,18 +1002,6 @@
.bg-primary {
background-color: var(--primary);
}
.bg-primary\/10 {
background-color: var(--primary);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--primary) 10%, transparent);
}
}
.bg-primary\/80 {
background-color: var(--primary);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--primary) 80%, transparent);
}
}
.bg-red-500 {
background-color: var(--color-red-500);
}
@ -1162,9 +1080,6 @@
.py-8 {
padding-block: calc(var(--spacing) * 8);
}
.py-12 {
padding-block: calc(var(--spacing) * 12);
}
.pt-0 {
padding-top: calc(var(--spacing) * 0);
}
@ -1385,11 +1300,6 @@
.filter {
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
.backdrop-blur {
--tw-backdrop-blur: blur(8px);
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
}
.backdrop-blur-xs {
--tw-backdrop-blur: blur(var(--blur-xs));
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
@ -1915,14 +1825,6 @@
background-color: var(--muted);
}
}
.supports-\[backdrop-filter\]\:bg-background\/60 {
@supports (backdrop-filter: var(--tw)) {
background-color: var(--background);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--background) 60%, transparent);
}
}
}
.sm\:my-8 {
@media (width >= 40rem) {
margin-block: calc(var(--spacing) * 8);
@ -1987,41 +1889,11 @@
max-width: 420px;
}
}
.md\:grid-cols-2 {
@media (width >= 48rem) {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.lg\:flex {
@media (width >= 64rem) {
display: flex;
}
}
.lg\:hidden {
@media (width >= 64rem) {
display: none;
}
}
.lg\:w-1\/3 {
@media (width >= 64rem) {
width: calc(1/3 * 100%);
}
}
.lg\:grid-cols-2 {
@media (width >= 64rem) {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.lg\:grid-cols-3 {
@media (width >= 64rem) {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
.lg\:px-6 {
@media (width >= 64rem) {
padding-inline: calc(var(--spacing) * 6);
}
}
.lg\:px-8 {
@media (width >= 64rem) {
padding-inline: calc(var(--spacing) * 8);

View file

@ -13,20 +13,17 @@ func FileViewWebHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
slog.Error("Error getting File in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
fileProperties, err := database.GetFileProperties(file.ID)
if err != nil {
slog.Error("Error getting FileProperties in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
component := FileView(file, fileProperties)
err = component.Render(r.Context(), w)
if err != nil {
slog.Error("Error rendering in FileViewWebHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}
@ -35,42 +32,20 @@ func FileViewMSOWebHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
slog.Error("Error getting Data in FileViewMSOWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
component := FileViewMsoffice(data)
err = component.Render(r.Context(), w)
if err != nil {
slog.Error("Error rendering in FileViewMSOWebHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}
func FileViewDeleteWebHandler(w http.ResponseWriter, r *http.Request) {
func FileViewDeleteHandler(w http.ResponseWriter, r *http.Request) {
fileID := r.PathValue("uuid")
err := store.DeleteFile(fileID)
if err != nil {
slog.Error("Error deleting File in FileViewDeleteHandler", "error", err, "file-uuid", fileID)
}
w.Header().Set("HX-Redirect", "/")
}
func FileViewDownloadWebHandler(w http.ResponseWriter, r *http.Request) {
file, err := database.GetFileByID(r.PathValue("uuid"))
if err != nil {
slog.Error("Error getting file info in FileViewDownloadWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
filePath, err := store.AbsPath(file.ID.String())
if err != nil {
slog.Error("Error getting absolute path in FileViewDownloadWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
w.Header().Set("Content-Disposition", "attachment; filename="+file.Name)
w.Header().Set("Content-Type", file.Mimetype)
http.ServeFile(w, r, filePath)
}

View file

@ -5,29 +5,21 @@ import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
import "encoding/hex"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/modal"
import "git.jmbit.de/jmb/scanfile/server/internal/processing"
import "fmt"
templ FileView(file sqlc.File, fileProperties sqlc.FileProperty) {
@Base(file.Name) {
<div class="w-full">
<h1 class="text-4xl">File Name: {file.Name}</h1>
@FileViewDeleteModal(file.ID.String())
@FileViewDownloadModal(file.ID.String())
<br/>
</div>
<div class="grid grid-cols-2 gap-4">
@FileViewGenericTable(file, fileProperties)
if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
@FileViewMsofficeLoader(file.ID.String())
}
</div>
}
}
templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
<div class="w-full">
<div class=" max-w-min w-full">
<h2 class="text-3xl">Generic Information</h2>
@table.Table() {
@table.Row() {
@ -111,12 +103,12 @@ templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
}
}
</div>
}
templ FileViewDeleteModal(fileid string) {
@modal.Trigger(modal.TriggerProps{
ModalID: "delete-modal",
Class: "p-1",
ModalID: "default-modal",
}) {
@button.Button(button.Props{
Variant: button.VariantDestructive,
@ -148,7 +140,6 @@ templ FileViewDeleteModal(fileid string) {
}) {
@button.Button(button.Props{
Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/delete", fileid),
}) {
Delete
}
@ -156,52 +147,5 @@ templ FileViewDeleteModal(fileid string) {
</div>
}
}
@modal.Script()
}
templ FileViewDownloadModal(fileid string) {
@modal.Trigger(modal.TriggerProps{
ModalID: "download-modal",
Class: "p-1",
}) {
@button.Button(button.Props{
Variant: button.VariantDefault,
}) {
Download
}
}
@modal.Modal(modal.Props{
ID: "download-modal",
Class: "max-w-md",
}) {
@modal.Header() {
Download this file?
}
@modal.Body() {
files downloaded from scanfile can be harmful to your system. Are you sure you want to continue?
}
@modal.Footer() {
<div class="flex gap-2">
@modal.Close(modal.CloseProps{
ModalID: "download-modal",
}) {
@button.Button() {
Cancel
}
}
@modal.Close(modal.CloseProps{
ModalID: "download-modal",
}) {
@button.Button(button.Props{
Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/download", fileid),
}) {
Download
}
}
</div>
}
}
@modal.Script()
@modal.Script()
}

View file

@ -1,26 +1,15 @@
package web
import (
"git.jmbit.de/jmb/scanfile/server/internal/sqlc"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/badge"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/code"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/skeleton"
"fmt"
)
import "git.jmbit.de/jmb/scanfile/server/internal/sqlc"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/badge"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/code"
// Loads MSOffice data if required
templ FileViewMsofficeLoader(fileid string) {
<div class="w-full" hx-get={fmt.Sprintf("/files/%s/msoffice", fileid)} hx-trigger="load">
@skeleton.Skeleton(skeleton.Props{Class: "h-12 w-12 rounded-full"})
<p> loading <a href={templ.URL(fmt.Sprintf("/files/%s/msoffice", fileid))}>Microsoft Office Info</a></p>
</div>
}
templ FileViewMsoffice(data sqlc.Msoffice) {
<div class="w-full">
<div class=" max-w-min w-full">
<h2 class="text-3xl">Microsoft Office</h2>
if data.Verdict.String == "suspicious" {
@badge.Badge(badge.Props{
@ -45,7 +34,6 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
Encrypted
}
@table.Cell() {
{fmt.Sprintf("%v",data.Encrypted.Bool)}
}
}
@table.Row() {
@ -53,7 +41,6 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
File Format
}
@table.Cell() {
{data.FileFormat.String}
}
}
@table.Row() {
@ -61,7 +48,6 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
VBA Macros Result
}
@table.Cell() {
{data.VbaMacros.String}
}
}
@ -70,7 +56,6 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
XLM Macros Result
}
@table.Cell() {
{data.XlmMacros.String}
}
}
@table.Row() {
@ -78,7 +63,6 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
VBA Stomping
}
@table.Cell() {
{fmt.Sprintf("%v",data.VbaStomping.Bool)}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -13,8 +13,6 @@ import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
import "encoding/hex"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/modal"
import "git.jmbit.de/jmb/scanfile/server/internal/processing"
import "fmt"
func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
@ -56,7 +54,7 @@ func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(file.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 14, Col: 48}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 12, Col: 48}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
@ -70,11 +68,7 @@ func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = FileViewDownloadModal(file.ID.String()).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<br></div><div class=\"grid grid-cols-2 gap-4\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<br></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -82,16 +76,6 @@ func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
templ_7745c5c3_Err = FileViewMsofficeLoader(file.ID.String()).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = Base(file.Name).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
@ -123,7 +107,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
templ_7745c5c3_Var4 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<div class=\"w-full\"><h2 class=\"text-3xl\">Generic Information</h2>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\" max-w-min w-full\"><h2 class=\"text-3xl\">Generic Information</h2>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -163,7 +147,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "Size")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "Size")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -173,7 +157,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -192,13 +176,13 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(file.Size)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 38, Col: 22}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 30, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " Bytes")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " Bytes")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -214,7 +198,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -242,7 +226,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "Filetype")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "Filetype")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -252,7 +236,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -271,7 +255,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(file.Mimetype)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 46, Col: 26}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 38, Col: 26}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
@ -289,7 +273,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -317,7 +301,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "Blake2b Hash")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "Blake2b Hash")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -327,7 +311,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -346,7 +330,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(file.Blake2))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 55, Col: 44}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 47, Col: 44}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
@ -364,7 +348,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -392,7 +376,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "SHA256 Hash")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "SHA256 Hash")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -402,7 +386,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -421,7 +405,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(fileProperties.Sha256))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 63, Col: 54}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 55, Col: 54}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
@ -439,7 +423,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -467,7 +451,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "MD5 Hash")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "MD5 Hash")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -477,7 +461,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -496,7 +480,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var25 string
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(fileProperties.Md5))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 71, Col: 51}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 63, Col: 51}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
if templ_7745c5c3_Err != nil {
@ -514,7 +498,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -543,7 +527,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "Mimetype")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "Mimetype")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -553,7 +537,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -572,7 +556,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var29 string
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicMime.String)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 80, Col: 49}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 72, Col: 49}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
if templ_7745c5c3_Err != nil {
@ -591,7 +575,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -620,7 +604,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "File Extensions")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "File Extensions")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -630,7 +614,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -649,7 +633,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var33 string
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicExtension.String)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 90, Col: 54}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 82, Col: 54}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
if templ_7745c5c3_Err != nil {
@ -668,7 +652,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -697,7 +681,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "Apple Filetype")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "Apple Filetype")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -707,7 +691,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -726,7 +710,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var37 string
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicApple.String)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 100, Col: 50}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 92, Col: 50}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
if templ_7745c5c3_Err != nil {
@ -745,7 +729,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -773,7 +757,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "Uploaded")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "Uploaded")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -783,7 +767,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -802,7 +786,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var41 string
templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(file.Created.Time.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 109, Col: 39}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 101, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
if templ_7745c5c3_Err != nil {
@ -826,7 +810,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -879,7 +863,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "Delete")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "Delete")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -894,8 +878,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
return nil
})
templ_7745c5c3_Err = modal.Trigger(modal.TriggerProps{
ModalID: "delete-modal",
Class: "p-1",
ModalID: "default-modal",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var43), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@ -924,7 +907,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "Are you sure you want to delete this file?")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "Are you sure you want to delete this file?")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -934,7 +917,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -950,7 +933,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "This action cannot be undone. This will permanently delete the file from the server.\t\t\t\t")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "This action cannot be undone. This will permanently delete the file from the server.\t\t\t\t")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -960,7 +943,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, " ")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -976,7 +959,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<div class=\"flex gap-2\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<div class=\"flex gap-2\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -1004,7 +987,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "Cancel")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "Cancel")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -1046,7 +1029,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "Delete")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "Delete")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -1054,7 +1037,6 @@ func FileViewDeleteModal(fileid string) templ.Component {
})
templ_7745c5c3_Err = button.Button(button.Props{
Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/delete", fileid),
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var52), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@ -1067,7 +1049,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "</div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -1094,264 +1076,4 @@ func FileViewDeleteModal(fileid string) templ.Component {
})
}
func FileViewDownloadModal(fileid string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var53 := templ.GetChildren(ctx)
if templ_7745c5c3_Var53 == nil {
templ_7745c5c3_Var53 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var54 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var55 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "Download")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = button.Button(button.Props{
Variant: button.VariantDefault,
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var55), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Trigger(modal.TriggerProps{
ModalID: "download-modal",
Class: "p-1",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var54), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var56 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var57 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "Download this file?")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Header().Render(templ.WithChildren(ctx, templ_7745c5c3_Var57), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var58 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "files downloaded from scanfile can be harmful to your system. Are you sure you want to continue?")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Body().Render(templ.WithChildren(ctx, templ_7745c5c3_Var58), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var59 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "<div class=\"flex gap-2\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var60 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var61 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "Cancel")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = button.Button().Render(templ.WithChildren(ctx, templ_7745c5c3_Var61), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Close(modal.CloseProps{
ModalID: "download-modal",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var60), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var62 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var63 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "Download")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = button.Button(button.Props{
Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/download", fileid),
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var63), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Close(modal.CloseProps{
ModalID: "download-modal",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var62), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Footer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var59), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Modal(modal.Props{
ID: "download-modal",
Class: "max-w-md",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var56), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = modal.Script().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate

View file

@ -31,19 +31,19 @@ func IndexUploadHandler(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, maxUploadSize)
defer r.Body.Close()
fileData, fileHeader, err := r.FormFile("file")
slog.Debug("File form submitted", "file-name", fileHeader.Filename, "file-size", fileHeader.Size)
if err != nil {
slog.Error("Error parsing form in IndexUploadHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
slog.Debug("File form submitted", "file-name", fileHeader.Filename, "file-size", fileHeader.Size)
fileBytes, err := io.ReadAll(fileData)
slog.Debug("File from form read", "file-name", fileHeader.Filename, "file-size", len(fileBytes))
if err != nil {
slog.Error("Error reading file in IndexUploadHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
slog.Debug("File from form read", "file-name", fileHeader.Filename, "file-size", len(fileBytes))
file, err := database.CreateFile(r.Context(), fileHeader.Filename, fileBytes)
if err != nil {
@ -58,7 +58,6 @@ func IndexUploadHandler(w http.ResponseWriter, r *http.Request) {
return
}
//w.Header().Set("HX-Redirect", fmt.Sprintf("/files/%s", file.ID.String()))
component := UploadSuccessCard(file)
err = component.Render(r.Context(), w)
if err != nil {

1
tmp/build-errors.log Normal file
View file

@ -0,0 +1 @@
exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1