~evanj/evanjon.es

1945c2ac2ace3de4f3819301989cc88af79a0b5b — Evan M Jones 1 year, 5 months ago 39a9390
Feat(cms update): Updating evanjon.es cms usage per cms updates on tip.
2 files changed, 18 insertions(+), 10 deletions(-)

M internal/s/tmpl/tmpls_embed.go
M pkg/cms/cms.go
M internal/s/tmpl/tmpls_embed.go => internal/s/tmpl/tmpls_embed.go +1 -1
@@ 14,7 14,7 @@ func tostring(in string) string {
func init() {
	tmpls = make(map[string]string)

	tmpls["css/main.css"] = tostring("Ym9keSB7IAogIGxpbmUtaGVpZ2h0OiAxLjQ7Cn0KCnByZSB7IAogIGxpbmUtaGllZ2h0OiAxOwp9CgpoZWFkZXIgaDEgeyAKICBtYXJnaW46IDA7Cn0KCmhlYWRlciBoMSBhLAphIHsKICB0ZXh0LWRlY29yYXRpb246IG5vbmU7Cn0KCmE6aG92ZXIgewogIHRleHQtZGVjb3JhdGlvbjogdW5kZXJsaW5lOwp9Cgpib2R5IG1haW4geyAKICBwYWRkaW5nOiAxNXB4OwogIG1heC13aWR0aDogNTAwcHg7CiAgbWFyZ2luLWxlZnQ6IGF1dG87CiAgbWFyZ2luLXJpZ2h0OiBhdXRvOwp9CgpibG9ja3F1b3RlIHsgCiAgbWFyZ2luLWxlZnQ6IGluaXRpYWw7CiAgZm9udC1zdHlsZTogaXRhbGljOwp9CgpibG9ja3F1b3RlICsgY2l0ZSwKYmxvY2txdW90ZSArIHAgPiBjaXRlLApibG9ja3F1b3RlICsgcCA+IGVtIHsKICBkaXNwbGF5OiBibG9jazsgCiAgbWFyZ2luLXRvcDogLTEwcHg7Cn0KCmJsb2NrcXVvdGUgKyBjaXRlOmJlZm9yZSwKYmxvY2txdW90ZSArIHAgPiBjaXRlOmJlZm9yZSwKYmxvY2txdW90ZSArIHAgPiBlbTpiZWZvcmUgeyAKICBmb250LXN0eWxlOiBpdGFsaWM7CiAgY29udGVudDogJy0tICc7CiAgcGFkZGluZy1sZWZ0OiA0MHB4Owp9Cgpib2R5Lmx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TEwcHg7Cn0KCmJsb2NrcXVvdGUgKyBjaXRlOmJlZm9yZSwKYmxvY2txdW90ZSArIHAgPiBjaXRlOmJlZm9yZSwKYmxvY2txdW90ZSArIHAgPiBlbTpiZWZvcmUgeyAKICBmb250LXN0eWxlOiBpdGFsaWM7CiAgY29udGVudDogJy0tICc7CiAgcGFkZGluZy1sZWZ0OiA0MHB4Owp9Cgpib2R5Lmxpc3QgPiBtYWluID4gYSB7CiAgdGV4dC1kZWNvcmF0aW9uOiBub25lOwp9Cgpib2R5Lmxpc3QgPiBtYWluID4gYTpob3ZlciA+IHNlY3Rpb24gPiBoMiB7CiAgdGV4dC1kZWNvcmF0aW9uOiB1bmRlcmxpbmU7Cn0KCmJvZHkubGlzdCA+IG1haW4gPiBhID4gc2VjdGlvbiA+IGgyIHsKICBtYXJnaW4tdG9wOiAwOwogIG1hcmdpbi1ib3R0b206IDA7Cn0KCmJvZHkubGlzdCA+IG1haW4gPiBhID4gc2VjdGlvbiA+IGRpdiB7IAogIG1hcmdpbi1sZWZ0OiA0MHB4Owp9CgppbWcgeyAKICBtYXgtd2lkdGg6IDEwMCU7CiAgdmVydGljYWwtYWxpZ246IG1pZGRsZTsKfQo=")

	tmpls["html/_head.html"] = tostring("PG1ldGEgY2hhcnNldD0idXRmLTgiPgo8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEiPgo=")


M pkg/cms/cms.go => pkg/cms/cms.go +17 -9
@@ 26,6 26,12 @@ type Content struct {
	ContentValues       []ContentValue
}

type ContentList struct {
	ContentList []Content
	ContentMore bool
	// ContentLast Content
}

type ContentValue struct {
	FieldType  string
	FieldName  string


@@ 47,7 53,10 @@ func NewWithClient(user, pass, baseURL string, space int, client *http.Client) *
}

func (cms *CMS) List(ctx context.Context, typeID int, order, field string) ([]Content, error) {
	url := fmt.Sprintf("%s/contenttype/%d/%d?order=%s&field=%s", cms.baseURL, cms.space, typeID, order, field)
	var (
		url  = fmt.Sprintf("%s/contenttype/%d/%d?order=%s&field=%s", cms.baseURL, cms.space, typeID, order, field)
		body struct{ ContentList ContentList }
	)

	req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
	if err != nil {


@@ 66,18 75,18 @@ func (cms *CMS) List(ctx context.Context, typeID int, order, field string) ([]Co
		return nil, err
	}

	var body struct {
		ContentList []Content
	}
	if err := json.Unmarshal(bytes, &body); err != nil {
		return nil, err
	}

	return body.ContentList, nil
	return body.ContentList.ContentList, nil
}

func (cms *CMS) Find(ctx context.Context, typeID int, field, query string) (*Content, error) {
	url := fmt.Sprintf("%s/content/search?space=%d&contenttype=%d&field=%s&query=%s", cms.baseURL, cms.space, typeID, field, query)
	var (
		url  = fmt.Sprintf("%s/content/search?space=%d&contenttype=%d&field=%s&query=%s", cms.baseURL, cms.space, typeID, field, query)
		body ContentList
	)

	req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
	if err != nil {


@@ 96,14 105,13 @@ func (cms *CMS) Find(ctx context.Context, typeID int, field, query string) (*Con
		return nil, err
	}

	var body []Content
	if err := json.Unmarshal(bytes, &body); err != nil {
		return nil, err
	}

	if len(body) < 1 {
	if len(body.ContentList) < 1 {
		return nil, ErrNoContent
	}

	return &body[0], nil
	return &body.ContentList[0], nil
}