3 Commits

Author SHA1 Message Date
nkanaev
16a7f3409c youtube shorts in readability 2025-10-06 14:39:23 +01:00
nkanaev
0e11cec99a remove print statements 2025-10-06 14:39:23 +01:00
Nadia Santalla
c158912da4 fix media_links reading from DB
Prior to this commit, `MediaLinks` were always returned as `nil`.
Peeking a bit I figured that's becuase the argument to `MediaLinks.Scan`
is in fact a string, and not a `[]byte` as the code expects. I guess
that might be because `media_links` is a `json` (not `jsonb`) column in
sqlite. I have no idea which of the two is best to use for the DB side,
but it's easy to make the code support both.
2025-10-06 14:18:03 +01:00
4 changed files with 9 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
- (new) serve on unix socket (thanks to @rvighne) - (new) serve on unix socket (thanks to @rvighne)
- (new) more auto-refresh options: 12h & 24h (thanks to @aswerkljh for suggestion) - (new) more auto-refresh options: 12h & 24h (thanks to @aswerkljh for suggestion)
- (fix) smooth scrolling on iOS (thanks to gatheraled) - (fix) smooth scrolling on iOS (thanks to gatheraled)
- (fix) displaying youtube shorts in "Read Here" (thanks to @Dean-Corso for the report)
- (etc) theme-color support (thanks to @asimpson) - (etc) theme-color support (thanks to @asimpson)
- (etc) cookie security measures (thanks to Tom Fitzhenry) - (etc) cookie security measures (thanks to Tom Fitzhenry)
- (etc) restrict access to internal IPs for page crawler (thanks to Omar Kurt) - (etc) restrict access to internal IPs for page crawler (thanks to Omar Kurt)

View File

@@ -8,7 +8,6 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"fmt"
) )
type assetsfs struct { type assetsfs struct {
@@ -20,10 +19,8 @@ var FS assetsfs
func (afs assetsfs) Open(name string) (fs.File, error) { func (afs assetsfs) Open(name string) (fs.File, error) {
if afs.embedded != nil { if afs.embedded != nil {
fmt.Println("serving from embedded")
return afs.embedded.Open(name) return afs.embedded.Open(name)
} }
fmt.Println("serving local")
return os.DirFS("src/assets").Open(name) return os.DirFS("src/assets").Open(name)
} }

View File

@@ -22,6 +22,8 @@ func VideoIFrame(link string) string {
youtubeID := "" youtubeID := ""
if l.Host == "www.youtube.com" && l.Path == "/watch" { if l.Host == "www.youtube.com" && l.Path == "/watch" {
youtubeID = l.Query().Get("v") youtubeID = l.Query().Get("v")
} else if l.Host == "www.youtube.com" && strings.HasPrefix(l.Path, "/shorts/") {
youtubeID = strings.TrimPrefix(l.Path, "/shorts/")
} else if l.Host == "youtu.be" { } else if l.Host == "youtu.be" {
youtubeID = strings.TrimLeft(l.Path, "/") youtubeID = strings.TrimLeft(l.Path, "/")
} }

View File

@@ -54,11 +54,15 @@ type MediaLink struct {
type MediaLinks []MediaLink type MediaLinks []MediaLink
func (m *MediaLinks) Scan(src any) error { func (m *MediaLinks) Scan(src any) error {
if data, ok := src.([]byte); ok { switch data := src.(type) {
case []byte:
return json.Unmarshal(data, m) return json.Unmarshal(data, m)
} case string:
return json.Unmarshal([]byte(data), m)
default:
return nil return nil
} }
}
func (m MediaLinks) Value() (driver.Value, error) { func (m MediaLinks) Value() (driver.Value, error) {
return json.Marshal(m) return json.Marshal(m)
@@ -419,7 +423,6 @@ func (s *Storage) DeleteOldItems() {
where status != ? where status != ?
group by i.feed_id group by i.feed_id
`, itemsKeepSize, STARRED) `, itemsKeepSize, STARRED)
if err != nil { if err != nil {
log.Print(err) log.Print(err)
return return