fix: add Thumbnail field and video result template
MainResult: add Thumbnail field (used by YouTube, images, etc.) video_item.html: new partial for video results with thumbnail display views.go: add templateForResult func + video_item.html to template parse results_inner.html: dispatch to video_item when Template="videos" kafka.css: add .video-result flex layout with thumbnail styling
This commit is contained in:
parent
af23a63a73
commit
4a6559be62
5 changed files with 79 additions and 23 deletions
|
|
@ -14,16 +14,17 @@ type MainResult struct {
|
|||
raw map[string]any
|
||||
|
||||
// Common fields used by templates (RSS uses: title, url, content, pubdate).
|
||||
Template string `json:"template"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
URL *string `json:"url"`
|
||||
Pubdate *string `json:"pubdate"`
|
||||
Template string `json:"template"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
URL *string `json:"url"`
|
||||
Pubdate *string `json:"pubdate"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
|
||||
Engine string `json:"engine"`
|
||||
Score float64 `json:"score"`
|
||||
Category string `json:"category"`
|
||||
Priority string `json:"priority"`
|
||||
Engine string `json:"engine"`
|
||||
Score float64 `json:"score"`
|
||||
Category string `json:"category"`
|
||||
Priority string `json:"priority"`
|
||||
|
||||
Positions []int `json:"positions"`
|
||||
Engines []string `json:"engines"`
|
||||
|
|
@ -54,6 +55,7 @@ func (mr *MainResult) UnmarshalJSON(data []byte) error {
|
|||
mr.Title = stringOrEmpty(m["title"])
|
||||
mr.Content = stringOrEmpty(m["content"])
|
||||
mr.Engine = stringOrEmpty(m["engine"])
|
||||
mr.Thumbnail = stringOrEmpty(m["thumbnail"])
|
||||
mr.Category = stringOrEmpty(m["category"])
|
||||
mr.Priority = stringOrEmpty(m["priority"])
|
||||
|
||||
|
|
@ -93,20 +95,21 @@ func (mr MainResult) MarshalJSON() ([]byte, error) {
|
|||
|
||||
// Otherwise, marshal the known fields.
|
||||
m := map[string]any{
|
||||
"template": mr.Template,
|
||||
"title": mr.Title,
|
||||
"content": mr.Content,
|
||||
"url": mr.URL,
|
||||
"pubdate": mr.Pubdate,
|
||||
"engine": mr.Engine,
|
||||
"score": mr.Score,
|
||||
"category": mr.Category,
|
||||
"priority": mr.Priority,
|
||||
"template": mr.Template,
|
||||
"title": mr.Title,
|
||||
"content": mr.Content,
|
||||
"url": mr.URL,
|
||||
"pubdate": mr.Pubdate,
|
||||
"thumbnail": mr.Thumbnail,
|
||||
"engine": mr.Engine,
|
||||
"score": mr.Score,
|
||||
"category": mr.Category,
|
||||
"priority": mr.Priority,
|
||||
"positions": mr.Positions,
|
||||
"engines": mr.Engines,
|
||||
"open_group": mr.OpenGroup,
|
||||
"open_group": mr.OpenGroup,
|
||||
"close_group": mr.CloseGroup,
|
||||
"parsed_url": mr.ParsedURL,
|
||||
"parsed_url": mr.ParsedURL,
|
||||
}
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue