Skip to content

Commit

Permalink
add vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwei committed Jan 1, 2025
1 parent 2dbcbe6 commit 79f0ff3
Show file tree
Hide file tree
Showing 3,275 changed files with 1,180,334 additions and 22 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/gobuffalo/flect v1.0.2
github.com/gobwas/glob v0.2.3
github.com/gofrs/uuid v4.4.0+incompatible
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e
github.com/gohugoio/locales v0.14.0
github.com/gohugoio/localescompressed v1.0.1
github.com/gorilla/schema v1.2.1
Expand Down Expand Up @@ -98,7 +99,6 @@ require (
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VY
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU=
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down
51 changes: 35 additions & 16 deletions internal/domain/content/entity/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,45 @@ import (
)

func (c *Content) search(contentType string, query string) ([][]byte, error) {
// execute search for query provided, if no index for type send 404
indices, err := c.Search.TypeQuery(contentType, query, 10, 0)
if errors.Is(err, content.ErrNoIndex) {
c.Log.Errorf("Index for type %s not found", contentType)
const pageSize = 100 // 每页最大查询数量
offset := 0

return nil, err
}
if err != nil {
c.Log.Errorf("Error searching for type %s: %v", contentType, err)
return nil, err
}
var allResults [][]byte

// respond with json formatted results
bb, err := c.GetContents(indices)
if err != nil {
c.Log.Errorf("Error getting content: %v", err)
return nil, err
for {
// execute search for query provided, if no index for type send 404
indices, err := c.Search.TypeQuery(contentType, query, pageSize, offset)
if errors.Is(err, content.ErrNoIndex) {
c.Log.Errorf("Index for type %s not found", contentType)

return nil, err
}
if err != nil {
c.Log.Errorf("Error searching for type %s: %v", contentType, err)
return nil, err
}

if len(indices) == 0 {
break
}

// respond with json formatted results
bb, err := c.GetContents(indices)
if err != nil {
c.Log.Errorf("Error getting content: %v", err)
return nil, err
}

allResults = append(allResults, bb...)

if len(indices) < pageSize {
break
}

offset += pageSize
}

return bb, nil
return allResults, nil
}

func (c *Content) termSearch(contentType string, keyValue map[string]string) ([][]byte, error) {
Expand Down
45 changes: 45 additions & 0 deletions internal/domain/content/valueobject/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/gohugonet/hugoverse/pkg/editor"
"github.com/gohugonet/hugoverse/pkg/language"
"net/http"
"strings"
"text/template"
)

Expand All @@ -21,6 +22,7 @@ type Site struct {
Owner string `json:"owner"`
WorkingDir string `json:"working_dir"`
Languages []string `json:"languages"`
Menus []string `json:"menus"`
}

// MarshalEditor writes a buffer of html to edit a Song within the CMS
Expand Down Expand Up @@ -83,6 +85,13 @@ func (s *Site) MarshalEditor() ([]byte, error) {
"placeholder": "Enter the Languages here",
}),
},
editor.Field{
View: editor.Input("Menus", s, map[string]string{
"label": "Menus",
"type": "text",
"placeholder": "Enter the Menus here",
}),
},
)

if err != nil {
Expand Down Expand Up @@ -196,6 +205,7 @@ owner = "{{.Owner}}"
[[module.imports]]
path = "{{.Theme}}"
{{- if .IsMultiLanguages}}
[languages]
{{- range $index, $lang := .Languages }}
Expand All @@ -206,6 +216,18 @@ owner = "{{.Owner}}"
{{- end }}
{{- end }}
{{- if .HasMenus }}
[menu]
{{- range $index, $menu := .Menus }}
[[menu.after]]
name = "{{ index (split $menu ",") 0 }}"
url = "{{ index (split $menu ",") 1 }}"
weight = {{ add $index 1 }}
{{- end }}
{{- end }}
[params]
{{.Params}}
Expand All @@ -214,6 +236,7 @@ owner = "{{.Owner}}"
"add": func(a, b int) int {
return a + b
},
"split": strings.Split,
"getLanguageName": language.GetLanguageName,
}

Expand All @@ -234,11 +257,16 @@ func (s *Site) IsMultiLanguages() bool {
return len(s.Languages) > 1
}

func (s *Site) HasMenus() bool {
return len(s.Menus) > 0
}

func (s *Site) UnmarshalJSON(data []byte) error {
// Create a temporary struct with the same fields
type Alias Site
temp := &struct {
Languages interface{} `json:"languages"`
Menus interface{} `json:"menus"`
*Alias
}{
Alias: (*Alias)(s),
Expand Down Expand Up @@ -266,5 +294,22 @@ func (s *Site) UnmarshalJSON(data []byte) error {
}
}

// Handle the "menus" field
switch v := temp.Menus.(type) {
case nil:
// If it's nil or an empty string, set Menus as an empty array
s.Menus = []string{}
case string:
// If it's a single string, wrap it in an array
s.Menus = []string{v}
case []interface{}:
// If it's an array, convert it into a slice of strings
for _, item := range v {
if str, ok := item.(string); ok {
s.Menus = append(s.Menus, str)
}
}
}

return nil
}
8 changes: 4 additions & 4 deletions internal/interfaces/cli/vercurr.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cli

var CurrentVersion = Version{
Major: 0,
Minor: 1,
PatchLevel: 0,
Suffix: "",
Major: 0,
Minor: 1,
PatchLevel: 1,
Suffix: "",
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.0",
"version": "0.1.1",
"name": "Hugoverse",
"description": "Headless CMS for Hugo",
"author": "sunwei",
Expand Down
Loading

0 comments on commit 79f0ff3

Please sign in to comment.