Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kibble/api/films.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"kibble/models"

"github.com/gosimple/slug"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// loadFilmSummary - load the bios request
Expand Down Expand Up @@ -125,7 +127,7 @@ func (f filmV2) mapToModel(serviceConfig models.ServiceConfig, itemIndex models.
key = "background"
}

titleCaseKey := strings.Title(strings.ToLower(key))
titleCaseKey := cases.Title(language.Und).String(strings.ToLower(key))
titleCaseKey = strings.Replace(titleCaseKey, "_image", "", -1)

if titleCaseKey != key {
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/bundle_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"kibble/models"
"kibble/utils"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var bundleArgs = []models.RouteArgument{
Expand Down
3 changes: 2 additions & 1 deletion kibble/datastore/bundle_index_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package datastore
import (
"reflect"

"github.com/CloudyKit/jet"
"kibble/models"

"github.com/CloudyKit/jet/v6"
)

// BundleIndexDataSource - a list of all bundles
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/collection_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"kibble/models"
"kibble/utils"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var collectionArgs = []models.RouteArgument{
Expand Down
3 changes: 2 additions & 1 deletion kibble/datastore/collection_index_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package datastore
import (
"reflect"

"github.com/CloudyKit/jet"
"kibble/models"

"github.com/CloudyKit/jet/v6"
)

// CollectionIndexDataSource - a list of all Collections
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/file_system_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"reflect"
"strings"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var fileSystemArgs = []models.RouteArgument{}
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/film_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var filmArgs = []models.RouteArgument{
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/film_index_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"kibble/models"
"reflect"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"

logging "github.com/op/go-logging"
)
Expand Down
21 changes: 12 additions & 9 deletions kibble/datastore/films_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (

"kibble/models"
"kibble/test"
"github.com/CloudyKit/jet"

"github.com/CloudyKit/jet/v6"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -105,10 +106,13 @@ func TestFilmDataStore(t *testing.T) {

func TestRenderingGlobal(t *testing.T) {

view := jet.NewHTMLSet("../templates/")
view.AddGlobal("version", "v1.1.145")
loader := jet.NewInMemLoader()
loader.Set("version.jet", "{{ version }}")

view := jet.NewSet(loader)
view.AddGlobal("version", "v1.1.146")

tem, _ := view.LoadTemplate("", "{{ version }}")
tem, _ := view.GetTemplate("version.jet")

renderer1 := &test.InMemoryTemplateRenderer{
View: view,
Expand Down Expand Up @@ -138,7 +142,7 @@ func TestRenderingGlobal(t *testing.T) {
var fds FilmDataSource
fds.Iterator(ctx, renderer1)

if renderer1.Result.Output() != "v1.1.145" {
if renderer1.Result.Output() != "v1.1.146" {
t.Error("Unexpected output")
}
}
Expand Down Expand Up @@ -176,8 +180,7 @@ func TestRenderingSlug(t *testing.T) {
assert.NoError(t, err)

view := models.CreateTemplateView(routeRegistry, i18n.IdentityTfunc(), &ctx, "./templates")

tem, _ := view.LoadTemplate("", "{{ routeToSlug(film.Slug, \"filmItem\") }}")
tem, _ := view.GetTemplate("film_slug.jet")

renderer := &test.InMemoryTemplateRenderer{
View: view,
Expand Down Expand Up @@ -226,7 +229,7 @@ func TestRouteToFilm(t *testing.T) {

view := models.CreateTemplateView(routeRegistry, i18n.IdentityTfunc(), &ctx, "./templates")

tem, _ := view.LoadTemplate("", "{{ routeTo(film, \"filmItem\") }}")
tem, _ := view.GetTemplate("film_route.jet")

renderer := &test.InMemoryTemplateRenderer{
View: view,
Expand Down Expand Up @@ -274,7 +277,7 @@ func TestTransLanguage(t *testing.T) {

view := models.CreateTemplateView(routeRegistry, i18n.IdentityTfunc(), &ctx, "./templates")

tem, _ := view.LoadTemplate("", "MSG {{ i18n(\"settings_title\") }}")
tem, _ := view.GetTemplate("film_translation.jet")

renderer := &test.InMemoryTemplateRenderer{
View: view,
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/page_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"kibble/models"
"kibble/utils"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var pageArgs = []models.RouteArgument{
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/page_index_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var indexArgs = []models.RouteArgument{
Expand Down
3 changes: 2 additions & 1 deletion kibble/datastore/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/nicksnyder/go-i18n/i18n"
"github.com/stretchr/testify/assert"

"github.com/CloudyKit/jet"
"kibble/models"
"kibble/test"

"github.com/CloudyKit/jet/v6"
)

func TestSitePlans(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions kibble/datastore/templates/echo.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="echo">slug:{{slug}}</div>
1 change: 1 addition & 0 deletions kibble/datastore/templates/film_route.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ routeTo(film, "filmItem") }}
1 change: 1 addition & 0 deletions kibble/datastore/templates/film_slug.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ routeToSlug(film.Slug) }}
1 change: 1 addition & 0 deletions kibble/datastore/templates/film_translation.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MSG {{ i18n("settings_title") }}
1 change: 1 addition & 0 deletions kibble/datastore/templates/tv_show_slug.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ routeToSlug(site.TVShows[0].Slug) }}
3 changes: 3 additions & 0 deletions kibble/datastore/templates/youtube.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div {{isset(class) ? "class=\"" + class + "\"" : "style=\"position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;\"" | raw }} >
<iframe src="//www.youtube.com/embed/{{id}}" {{isset(class) ? "class=\"" + class + "\"" : "style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\"" | raw }}{{if isset(autoplay) && autoplay=="true" }} autoplay=1{{end}} allowfullscreen frameborder="0"></iframe>
</div>
2 changes: 1 addition & 1 deletion kibble/datastore/tv_episode_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var tvEpisodeArgs = []models.RouteArgument{
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/tv_season_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var tvSeasonArgs = []models.RouteArgument{
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/tv_season_index_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

// TVSeasonIndexDataSource - a list of all films
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/tv_show_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

var tvShowArgs = []models.RouteArgument{
Expand Down
2 changes: 1 addition & 1 deletion kibble/datastore/tv_show_index_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"kibble/models"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

// TVShowIndexDataSource - a list of all films
Expand Down
5 changes: 2 additions & 3 deletions kibble/datastore/tv_show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
package datastore

import (
"testing"

"kibble/models"
"kibble/test"
"testing"

"github.com/nicksnyder/go-i18n/i18n"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -58,7 +57,7 @@ func TestRenderingShowSlug(t *testing.T) {

view := models.CreateTemplateView(routeRegistry, i18n.IdentityTfunc(), &ctx, "./templates")

tem, _ := view.LoadTemplate("", "{{ routeToSlug(site.TVShows[0].Slug) }}")
tem, _ := view.GetTemplate("tv_show_slug.jet")

renderer := &test.InMemoryTemplateRenderer{
View: view,
Expand Down
4 changes: 2 additions & 2 deletions kibble/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module kibble
go 1.17

require (
github.com/CloudyKit/jet v2.1.1+incompatible
github.com/CloudyKit/jet/v6 v6.1.0
github.com/araddon/dateparse v0.0.0-20210207001429-0eec95c9db7e
github.com/aws/aws-sdk-go v1.12.2
github.com/gosimple/slug v1.1.1
Expand All @@ -24,7 +24,7 @@ require (

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a // indirect
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-ini/ini v1.28.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions kibble/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a h1:3SgJcK9l5uPdBC/X17wanyJAMxM33+4ZhEIV96MIH8U=
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw=
github.com/CloudyKit/jet v2.1.1+incompatible h1:FgCzTmQg2GEqM3Xo3pvMYmJdYjqycdapGxRoyJ68O1c=
github.com/CloudyKit/jet v2.1.1+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
github.com/CloudyKit/jet/v6 v6.1.0 h1:hvO96X345XagdH1fAoBjpBYG4a1ghhL/QzalkduPuXk=
github.com/CloudyKit/jet/v6 v6.1.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
github.com/araddon/dateparse v0.0.0-20210207001429-0eec95c9db7e h1:OjdSMCht0ZVX7IH0nTdf00xEustvbtUGRgMh3gbdmOg=
github.com/araddon/dateparse v0.0.0-20210207001429-0eec95c9db7e/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/aws/aws-sdk-go v1.12.2 h1:wY/ELcBLPYpPgFtzSLzfvk06ERAyyfJ7xp1h56VKXAk=
Expand Down
2 changes: 1 addition & 1 deletion kibble/models/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package models

import (
"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

// RenderContext - Context passed during rendering / serving
Expand Down
20 changes: 4 additions & 16 deletions kibble/models/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"kibble/version"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
strip "github.com/grokify/html-strip-tags-go"
"github.com/microcosm-cc/bluemonday"
"github.com/nicksnyder/go-i18n/i18n"
Expand All @@ -37,7 +37,7 @@ var shortCodeView *jet.Set
// CreateTemplateView - create a template view
func CreateTemplateView(routeRegistry *RouteRegistry, trans i18n.TranslateFunc, ctx *RenderContext, templatePath string) *jet.Set {

view := jet.NewHTMLSet(templatePath)
view := jet.NewSet(jet.NewOSFileSystemLoader(templatePath))
view.AddGlobal("version", version.Version)
view.AddGlobal("lang", ctx.Language)
view.AddGlobal("routeTo", func(entity interface{}, routeName string) string {
Expand Down Expand Up @@ -250,20 +250,8 @@ func ConfigureShortcodeTemplatePath(cfg *Config) {

if shortCodeView == nil {
// get the template view
shortCodeView = jet.NewHTMLSet(cfg.ShortCodePath())

// built-in templates
_, err := shortCodeView.LoadTemplate("echo.jet", "<div class=\"echo\">slug:{{slug}}</div>")
if err != nil {
log.Error("template loading failed for echo.jet")
}
_, err = shortCodeView.LoadTemplate("youtube.jet", `
<div {{isset(class) ? "class=\"" + class + "\"" : "style=\"position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;\"" | raw }} >
<iframe src="//www.youtube.com/embed/{{id}}" {{isset(class) ? "class=\"" + class + "\"" : "style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\"" | raw }}{{if isset(autoplay) && autoplay=="true" }} autoplay=1{{end}} allowfullscreen frameborder="0"></iframe>
</div>`)
if err != nil {
log.Error("template loading failed for youtube.jet")
}
loader := jet.NewOSFileSystemLoader(cfg.ShortCodePath())
shortCodeView = jet.NewSet(loader)
}
}

Expand Down
2 changes: 1 addition & 1 deletion kibble/models/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"kibble/utils"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/stretchr/testify/assert"
)
Expand Down
3 changes: 2 additions & 1 deletion kibble/render/console_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
"bytes"
"fmt"

"github.com/CloudyKit/jet"
"kibble/models"

"github.com/CloudyKit/jet/v6"
)

// ConsoleRenderer - designed to render to the console for testing
Expand Down
2 changes: 1 addition & 1 deletion kibble/render/file_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"kibble/utils"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

// FileRenderer - designed to render to the file system for testing
Expand Down
1 change: 1 addition & 0 deletions kibble/sample_site/templates/shortcodes/echo.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="echo">slug:{{slug}}</div>
4 changes: 4 additions & 0 deletions kibble/sample_site/templates/shortcodes/youtube.jet
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<div {{isset(class) ? "class=\"" + class + "\"" : "style=\"position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;\"" | raw }} >
<iframe src="//www.youtube.com/embed/{{id}}" {{isset(class) ? "class=\"" + class + "\"" : "style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\"" | raw }}{{if isset(autoplay) && autoplay=="true" }} autoplay=1{{end}} allowfullscreen frameborder="0"></iframe>
</div>
2 changes: 1 addition & 1 deletion kibble/test/inmemory_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"
"testing"

"github.com/CloudyKit/jet"
"github.com/CloudyKit/jet/v6"
)

// InMemoryRenderer - render to memory for testing
Expand Down
Loading