mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-08 17:15:56 +01:00
Swapped to image-based list; video first frames
This commit is contained in:
parent
791fd82f64
commit
9f0791391f
6 changed files with 98 additions and 11 deletions
|
@ -15,6 +15,8 @@ enableGitInfo = false
|
||||||
enableEmoji = true
|
enableEmoji = true
|
||||||
disableRSS = false
|
disableRSS = false
|
||||||
|
|
||||||
|
paginate = 36
|
||||||
|
|
||||||
[markup]
|
[markup]
|
||||||
[markup.goldmark]
|
[markup.goldmark]
|
||||||
[markup.goldmark.extensions]
|
[markup.goldmark.extensions]
|
||||||
|
|
29
layouts/instagram-posts/list.html
Normal file
29
layouts/instagram-posts/list.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{{ define "main" }}
|
||||||
|
{{ $paginator := .Paginate .Data.Pages }}
|
||||||
|
|
||||||
|
<main class="posts instagram">
|
||||||
|
<h1>{{ title (replace .Title "-" " ") }}</h1>
|
||||||
|
|
||||||
|
{{ if .Content }}
|
||||||
|
<div class="content">{{ .Content }}</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range $paginator.Pages.GroupByDate "2006" }}
|
||||||
|
<div class="posts-group">
|
||||||
|
<div class="post-year">{{ .Key }}</div>
|
||||||
|
|
||||||
|
<ul class="posts-list">
|
||||||
|
{{ range .Pages }}
|
||||||
|
<li class="post-item">
|
||||||
|
<a href="{{.Permalink}}">
|
||||||
|
{{ $firstMedia := index .Params.Media 0 }}
|
||||||
|
<img src="{{.Permalink}}{{ $firstMedia }}{{if hasSuffix $firstMedia ".mp4"}}.jpg{{ end }}" />
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
{{ partial "pagination-list.html" . }}
|
||||||
|
</main>
|
||||||
|
{{ end }}
|
|
@ -1,10 +1,12 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<main class="post">
|
<main class="post instagram">
|
||||||
<article>
|
<article>
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
{{ range .Params.Media }}
|
<div class="instagram-media">
|
||||||
<figure><img src="{{ . }}" /></figure>
|
{{ range .Params.Media }}
|
||||||
{{ end }}
|
{{ partial "imgorvid.html" . }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
|
|
11
layouts/partials/imgorvid.html
Normal file
11
layouts/partials/imgorvid.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<figure>
|
||||||
|
{{ if hasSuffix . ".mp4" }}
|
||||||
|
<video controls loop>
|
||||||
|
<source src="{{.}}" type="video/mp4">
|
||||||
|
<img src="{{ . }}.jpg" />
|
||||||
|
(Your browser can't play videos. <a href="{{.}}">Download instead</a>.)
|
||||||
|
</video>
|
||||||
|
{{ else }}
|
||||||
|
<img src="{{ . }}" />
|
||||||
|
{{ end }}
|
||||||
|
</figure>
|
|
@ -153,6 +153,40 @@ img.profile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.instagram {
|
||||||
|
.posts-list {
|
||||||
|
li {
|
||||||
|
border: 0;
|
||||||
|
display: inline;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: inline;
|
||||||
|
|
||||||
|
figure, img, video {
|
||||||
|
display: inline;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: center;
|
||||||
|
height: 200px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.instagram-media {
|
||||||
|
figure {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
video, img {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 75vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
img, postcard-display {
|
img, postcard-display {
|
||||||
display: block;
|
display: block;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -69,12 +70,11 @@ type location struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type frontMatter struct {
|
type frontMatter struct {
|
||||||
Title string
|
Title string
|
||||||
Media []string
|
Media []string
|
||||||
Date string
|
Date string
|
||||||
Draft bool
|
Draft bool
|
||||||
Tags []string
|
Tags []string
|
||||||
Locations []location
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type post struct {
|
type post struct {
|
||||||
|
@ -87,7 +87,6 @@ type media struct {
|
||||||
URI string
|
URI string
|
||||||
CreationTimestamp int64 `json:"creation_timestamp"`
|
CreationTimestamp int64 `json:"creation_timestamp"`
|
||||||
Title string
|
Title string
|
||||||
MediaMetadata map[string]interface{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -295,6 +294,16 @@ func copyMedia(zf *zip.ReadCloser, mediaMap map[string]string) error {
|
||||||
defer doClose(mediaFile, "Unable to close media file in blog archive")
|
defer doClose(mediaFile, "Unable to close media file in blog archive")
|
||||||
|
|
||||||
io.Copy(mediaFile, mf)
|
io.Copy(mediaFile, mf)
|
||||||
|
|
||||||
|
if strings.HasSuffix(dst, ".mp4") {
|
||||||
|
makeThumbnail(dst, dst+".jpg")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeThumbnail(video, output string) error {
|
||||||
|
cmd := exec.Command("ffmpeg", "-y", "-i", video, "-vf", "select=eq(n\\,0)", "-q:v", "3", output)
|
||||||
|
fmt.Println(cmd.String())
|
||||||
|
return cmd.Run()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue