diff --git a/public/timemachine/thumbnails/2023-07-04-thumb.png b/public/timemachine/thumbnails/2023-07-04-thumb.png new file mode 100644 index 00000000..d8b68539 Binary files /dev/null and b/public/timemachine/thumbnails/2023-07-04-thumb.png differ diff --git a/src/admintools/admintools.go b/src/admintools/admintools.go index 43748b52..600b9d0f 100644 --- a/src/admintools/admintools.go +++ b/src/admintools/admintools.go @@ -5,23 +5,28 @@ import ( "context" "errors" "fmt" + "io" "io/ioutil" "net" "os" "os/exec" + "path/filepath" "strconv" "strings" "time" + "git.handmade.network/hmn/hmn/src/assets" "git.handmade.network/hmn/hmn/src/auth" "git.handmade.network/hmn/hmn/src/config" "git.handmade.network/hmn/hmn/src/db" "git.handmade.network/hmn/hmn/src/email" + "git.handmade.network/hmn/hmn/src/hmnurl" "git.handmade.network/hmn/hmn/src/logging" "git.handmade.network/hmn/hmn/src/models" "git.handmade.network/hmn/hmn/src/oops" "git.handmade.network/hmn/hmn/src/perf" "git.handmade.network/hmn/hmn/src/templates" + "git.handmade.network/hmn/hmn/src/utils" "git.handmade.network/hmn/hmn/src/website" "github.com/google/uuid" "github.com/jackc/pgx/v5" @@ -583,5 +588,34 @@ func init() { } adminCommand.AddCommand(extractImage) + uploadAsset := &cobra.Command{ + Use: "uploadasset ", + Short: "Upload a file to our asset CDN", + Run: func(cmd *cobra.Command, args []string) { + if len(args) < 2 { + cmd.Usage() + os.Exit(1) + } + fname := args[0] + contentType := args[1] + + ctx := context.Background() + conn := db.NewConn() + defer conn.Close(ctx) + + assetContents := utils.Must1(io.ReadAll(utils.Must1(os.Open(fname)))) + assetFilename := filepath.Base(fname) + + fmt.Printf("Uploading %s with content type %s...\n", assetFilename, contentType) + asset := utils.Must1(assets.Create(ctx, conn, assets.CreateInput{ + Content: assetContents, + Filename: assetFilename, + ContentType: contentType, + })) + fmt.Printf("Uploaded and accessible at %s\n", hmnurl.BuildS3Asset(asset.S3Key)) + }, + } + adminCommand.AddCommand(uploadAsset) + addProjectCommands(adminCommand) } diff --git a/src/templates/src/include/timemachine_submission.html b/src/templates/src/include/timemachine_submission.html index 7445bd4d..fb7fbcde 100644 --- a/src/templates/src/include/timemachine_submission.html +++ b/src/templates/src/include/timemachine_submission.html @@ -27,12 +27,19 @@ {{ range .Details }}
{{ .Name }}: {{ .Content }}
{{ end }} - + {{ if .Horizontal }} +
+
+ {{ .Description }} +
+ {{ end }} -
- {{ .Description }} -
+ {{ if not .Horizontal }} +
+ {{ .Description }} +
+ {{ end }} {{ with .AllSubmissionsUrl }}
See More
diff --git a/src/templates/src/layouts/timemachine_base.html b/src/templates/src/layouts/timemachine_base.html index 16da33b4..fd2e9290 100644 --- a/src/templates/src/layouts/timemachine_base.html +++ b/src/templates/src/layouts/timemachine_base.html @@ -2,8 +2,8 @@ This is a copy-paste from base.html because we want to preserve the unique style of landing pages if we change base.html in the future. */}} - - + + @@ -34,6 +34,12 @@