Add agus_dev's submission

This commit is contained in:
Ben Visness 2023-07-12 18:06:53 -05:00
parent 0895660972
commit 7b2d016fe2
5 changed files with 95 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -5,23 +5,28 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"net" "net"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"git.handmade.network/hmn/hmn/src/assets"
"git.handmade.network/hmn/hmn/src/auth" "git.handmade.network/hmn/hmn/src/auth"
"git.handmade.network/hmn/hmn/src/config" "git.handmade.network/hmn/hmn/src/config"
"git.handmade.network/hmn/hmn/src/db" "git.handmade.network/hmn/hmn/src/db"
"git.handmade.network/hmn/hmn/src/email" "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/logging"
"git.handmade.network/hmn/hmn/src/models" "git.handmade.network/hmn/hmn/src/models"
"git.handmade.network/hmn/hmn/src/oops" "git.handmade.network/hmn/hmn/src/oops"
"git.handmade.network/hmn/hmn/src/perf" "git.handmade.network/hmn/hmn/src/perf"
"git.handmade.network/hmn/hmn/src/templates" "git.handmade.network/hmn/hmn/src/templates"
"git.handmade.network/hmn/hmn/src/utils"
"git.handmade.network/hmn/hmn/src/website" "git.handmade.network/hmn/hmn/src/website"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5"
@ -583,5 +588,34 @@ func init() {
} }
adminCommand.AddCommand(extractImage) adminCommand.AddCommand(extractImage)
uploadAsset := &cobra.Command{
Use: "uploadasset <file> <content type>",
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) addProjectCommands(adminCommand)
} }

View File

@ -27,12 +27,19 @@
{{ range .Details }} {{ range .Details }}
<div><strong>{{ .Name }}:</strong> {{ .Content }}</div> <div><strong>{{ .Name }}:</strong> {{ .Content }}</div>
{{ end }} {{ end }}
{{ if .Horizontal }}
<div class="bt mv2 b--dimmer dn db-ns"></div>
<div class="post-content mt2 mt0-ns">
{{ .Description }}
</div>
{{ end }}
</div> </div>
</div> </div>
<div class="post-content"> {{ if not .Horizontal }}
{{ .Description }} <div class="post-content">
</div> {{ .Description }}
</div>
{{ end }}
{{ with .AllSubmissionsUrl }} {{ with .AllSubmissionsUrl }}
<div class="flex justify-end g3"> <div class="flex justify-end g3">
<a href="{{ . }}"><div class="win95-btn">See&nbsp;<u>M</u>ore</div></a> <a href="{{ . }}"><div class="win95-btn">See&nbsp;<u>M</u>ore</div></a>

View File

@ -2,8 +2,8 @@
This is a copy-paste from base.html because we want to preserve the unique 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. style of landing pages if we change base.html in the future.
*/}} */}}
<!DOCTYPE html{{ if .OpenGraphItems }} prefix="og: http://ogp.me/ns#"{{ end }}> <!DOCTYPE html>
<html lang="en-US"> <html lang="en-US" {{ if .OpenGraphItems }}prefix="og: http://ogp.me/ns#"{{ end }}>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -34,6 +34,12 @@
<link rel="stylesheet" type="text/css" href="{{ static "style.css" }}"> <link rel="stylesheet" type="text/css" href="{{ static "style.css" }}">
<style> <style>
:root {
--dim-color: #bbb;
--dimmer-color: #999;
--dimmest-color: #777;
}
body { body {
/* /*
This is too light for accessiblity imo. I'll darken them a bit and see how Ben feels This is too light for accessiblity imo. I'll darken them a bit and see how Ben feels

View File

@ -182,6 +182,7 @@ type TimeMachineSubmission struct {
Permalink string // generated for feed Permalink string // generated for feed
Details []TimeMachineSubmissionDetail Details []TimeMachineSubmissionDetail
Description template.HTML Description template.HTML
Horizontal bool
AllSubmissionsUrl string AllSubmissionsUrl string
} }
@ -196,7 +197,47 @@ type TimeMachineSubmissionDetail struct {
Content template.HTML Content template.HTML
} }
// You can re-encode videos for the website using some flavor of the following:
//
// ffmpeg -i input.mp4 -c:v libx264 -profile:v high -preset:v slow -crf:v 24 -c:a aac -b:a 128k -movflags +faststart output.mp4
//
// For 1080p video, you can try 26 or 28 for the video quality and see if it
// looks ok.
//
// Video can be scaled down using `-vf scale=-1:720`, where 720 is the desired
// height of the resulting video. You should probably stick with quality 24 if
// you do this.
var tmSubmissions = []TimeMachineSubmission{ var tmSubmissions = []TimeMachineSubmission{
{
Date: time.Date(2023, 7, 4, 0, 0, 0, 0, time.UTC),
Title: "2011 Philips Media Player",
Url: "https://hmn-assets-2.ams3.cdn.digitaloceanspaces.com/a835cf47-9649-4738-bd58-252a6199863b/agus5.mp4",
Thumbnail: TimeMachineThumbnail{
Filepath: "timemachine/thumbnails/2023-07-04-thumb.png",
Width: 226,
Height: 398,
},
Details: []TimeMachineSubmissionDetail{
{"Device", "Philips SA3047/55"},
{"Submitted by", `<a href="https://handmade.network/m/AgusDev" target="_blank">Agustin</a>`},
{"Release year", "2011"},
{"Processor", "Unknown"},
{"Memory", "Unknown"},
},
Description: `
<p>
My mother used to use this a lot when going to study, to record the classes or just listen to music.
</p>
<p>
I remember also using this a bit as a child, when having something for listening to music while doing other stuff was new to me.
</p>
<p>
<b>Editor's note:</b> I couldn't find any info about the processor for this or the device's RAM. If anyone happens to know this info, <a href="mailto:ben@handmade.network">let me know</a>.
</p>
`,
Horizontal: true,
},
{ {
Date: time.Date(2023, 6, 16, 0, 0, 0, 0, time.UTC), Date: time.Date(2023, 6, 16, 0, 0, 0, 0, time.UTC),
Title: "1992 Intel Professional Workstation", Title: "1992 Intel Professional Workstation",
@ -210,7 +251,7 @@ var tmSubmissions = []TimeMachineSubmission{
{"Device", "Intel Professional Workstation"}, {"Device", "Intel Professional Workstation"},
{"Submitted by", `<a href="https://www.youtube.com/@NCommander" target="_blank">NCommander</a>`}, {"Submitted by", `<a href="https://www.youtube.com/@NCommander" target="_blank">NCommander</a>`},
{"Release year", "~1992"}, {"Release year", "~1992"},
{"Procesor", "33Mhz 486DX"}, {"Processor", "33Mhz 486DX"},
{"Memory", "Originally 8MiB"}, {"Memory", "Originally 8MiB"},
{"Architecture", "EISA"}, {"Architecture", "EISA"},
{"Operating system", "Shipped with Windows 3.x, OS/2, NetWare, or SCO UNIX"}, {"Operating system", "Shipped with Windows 3.x, OS/2, NetWare, or SCO UNIX"},