diff --git a/pkg/random/random.go b/pkg/random/random.go index 076c5b5b..aead9330 100644 --- a/pkg/random/random.go +++ b/pkg/random/random.go @@ -4,8 +4,21 @@ import ( "fmt" "math/rand" "time" + "unicode" ) +func randomCaps(input string) string { + output := []rune{} + for _, c := range input { + if rand.Intn(2) == 0 { + output = append(output, unicode.ToUpper(c)) + } else { + output = append(output, c) + } + } + return string(output) +} + var wotds = []string{ "une gomme", "une pomme", "phazms", "08 36 65 65 65", "le mot du jour", "cool", "trop de la balle", "coucou", "salut les copains", @@ -20,7 +33,7 @@ var wotds = []string{ // WOTD returns the word of the day func WOTD() string { - return wotds[time.Now().YearDay()%len(wotds)] + return randomCaps(wotds[time.Now().YearDay()%len(wotds)]) } var alternateLogos = []string{ @@ -43,5 +56,49 @@ var alternateLogos = []string{ func AlternateLogo() string { file := alternateLogos[rand.Intn(len(alternateLogos))] - return fmt.Sprintf("https://camembertaulaitcrew.github.io/assets/logo-alternate-300/%s", file) + return fmt.Sprintf("/img/logo-alternate-300/%s", file) +} + +func MotDebileQuiSeMange() string { + mots := []string{ + "beurre", "lait", "yahourt", "pain", "gruyere", "margarine", + "curcumin", "d'épinard", "banane", "salade", "brioche", + "sucre", "chips", "laitage", "lukum", "flotte", "chupa-chups", + "yogourt", + } + return mots[rand.Intn(len(mots))] +} + +func MotCool() string { + mots := []string{ + "cool", "sympa", "gentil", "genial", "excellent", "superbe", "super", + "vraiment tres bien", "bien", "qui en a dans le pantalon", "top", + } + return mots[rand.Intn(len(mots))] +} + +func MotPasCool() string { + return "pas tres " + MotCool() +} + +func RandomColor(dark bool, light bool, limit int) string { + if limit == 0 { + limit = 80 + } + + var r, g, b int + for good := false; !good; { + r = rand.Intn(256) + g = rand.Intn(256) + b = rand.Intn(256) + + if dark { + good = r < limit || g < limit || b < limit + } else if light { + good = r > 256-limit || g > 256-limit || b > 256-limit + } else { + good = true + } + } + return fmt.Sprintf("#%X%X%X", r, g, b) } diff --git a/templates/layout/base.tmpl b/templates/layout/base.tmpl index aecf5ac2..a1403081 100644 --- a/templates/layout/base.tmpl +++ b/templates/layout/base.tmpl @@ -14,23 +14,19 @@ - -{{/* - {% set sharing_image_url = sharing_image_url | default('http://www.camembertaulaitcrew.biz/static/img/logo-300.png') %} - {% set sharing_description = sharing_description | default('C\'est cool') %} - {% set active_page = active_page | default('home') %} - {% set current_url = request.url %} - {# {% set current_url = url_for(request.endpoint, _external=True) %} #} - + - {# viewport ? #} - - + + + + + + + - {# FACEBOOK #} - + + @@ -39,13 +35,13 @@ - {# GEOLOC #} + - {# TWITTER #} + @@ -54,28 +50,20 @@ + + + - {% assets filters="cssmin", output="bundles/base.css", - "components/bootstrap/dist/css/bootstrap.min.css", - "css/calc.css" - %} - - {% endassets %} + - {% block extra_css %}{% endblock %} -*/}} + + {{ block "extra_css" . }}{{ end }}
- {{template "content" .}} -{{/*- Page générée avec {{ megahertz() }} - mégahertz et beaucoup de {{ mot_debile_qui_se_mange() }}. + Page générée avec {{ megahertz }} + mégahertz et beaucoup de {{ mot_debile_qui_se_mange }}. Salut mec ! @@ -174,26 +217,17 @@