diff --git a/README.md b/README.md index 3de9dd3..47cdbfb 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,21 @@ Client side highlighting does not require pygments to be installed. This current To use this feature, uncomment and fill out the `disqusShortname` parameter in `config.toml`. +### Staticman support + +Add *staticman* configuration section in `config.toml` or `config.yaml` + +Sample configuration + +``` + staticman: + api: https://api.staticman.net/v2/entry/badele/blog.jesuislibre.org/master/comments + pulls: https://github.com/badele/blog.jesuislibre.org/pulls + recaptcha: + sitekey: "6LeGeTgUAAAAAAqVrfTwox1kJQFdWl-mLzKasV0v" + secret: "hsGjWtWHR4HK4pT7cUsWTArJdZDxxE2pkdg/ArwCguqYQrhuubjj3RS9C5qa8xu4cx/Y9EwHwAMEeXPCZbLR9eW1K9LshissvNcYFfC/b8KKb4deH4V1+oqJEk/JcoK6jp6Rr2nZV4rjDP9M7nunC3WR5UGwMIYb8kKhur9pAic=" +``` + ### Google Analytics To add Google Analytics, simply sign up to [Google Analytics](http://www.google.com/analytics/) to obtain your Google Tracking ID, and add this tracking ID to the `googleAnalytics` parameter in `config.toml`. diff --git a/i18n/de.yaml b/i18n/de.yaml index c2823d8..1dff1eb 100644 --- a/i18n/de.yaml +++ b/i18n/de.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "02.01.2006" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "Gepostet am {{ .Count }}" - id: translationsLabel diff --git a/i18n/en.yaml b/i18n/en.yaml index 64c2f7b..6a5a6af 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "January 2, 2006" +- id: shortdateFormat + translation: "Jan 2, 2006 15:04:05" - id: postedOnDate translation: "Posted on {{ .Count }}" - id: translationsLabel @@ -37,4 +39,3 @@ translation: "Search {{ .Site.Title }}" - id: gcseClose translation: "Close" - diff --git a/i18n/es-ES.yaml b/i18n/es-ES.yaml index b9a5084..cb30d4b 100644 --- a/i18n/es-ES.yaml +++ b/i18n/es-ES.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "2 de enero, 2006" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "Publicado el {{ .Count }}" - id: translationsLabel diff --git a/i18n/fr.yaml b/i18n/fr.yaml index 7541caa..7519c78 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "January 2, 2006" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "Posté le {{ .Count }}" - id: translationsLabel diff --git a/i18n/ja.yaml b/i18n/ja.yaml index c7c77b2..2c38cad 100644 --- a/i18n/ja.yaml +++ b/i18n/ja.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "2006年1月2日" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "{{ .Count }}に投稿" - id: translationsLabel @@ -35,4 +37,3 @@ translation: "{{ .Site.Title }}を検索" - id: gcseClose translation: "閉じる" - diff --git a/i18n/pl.yaml b/i18n/pl.yaml index 2053a17..5bffb35 100644 --- a/i18n/pl.yaml +++ b/i18n/pl.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "02.01.2006" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "Opublikowany {{ .Count }}" - id: translationsLabel @@ -37,4 +39,3 @@ translation: "Szukaj {{ .Site.Title }}" - id: gcseClose translation: "Zamknij" - diff --git a/i18n/ru.yaml b/i18n/ru.yaml index deeaecf..5a9b229 100644 --- a/i18n/ru.yaml +++ b/i18n/ru.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "Январь 2, 2006" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "Опубликовано {{ .Count }}" - id: translationsLabel @@ -37,4 +39,3 @@ translation: "Поиск по {{ .Site.Title }}" - id: gcseClose translation: "Закрыть" - diff --git a/i18n/zh.yaml b/i18n/zh.yaml index 9c44558..59335de 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -1,6 +1,8 @@ # Content - id: dateFormat translation: "January 2, 2006" +- id: shortdateFormat + translation: "2 Jan, 2006 15:04:05" - id: postedOnDate translation: "发表于 {{ .Count }}" - id: translationsLabel @@ -37,4 +39,3 @@ translation: "搜索 {{ .Site.Title }}" - id: gcseClose translation: "关闭" - diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1fddbe8..419edb2 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -19,12 +19,18 @@ {{ end }} + {{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }} {{ if .Site.DisqusShortname }}
{{ template "_internal/disqus.html" . }}
{{ end }} + {{ if .Site.Params.staticman }} +
+ {{ partial "staticman-comments.html" . }} +
+ {{ end }} {{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 99342b7..716243a 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -58,6 +58,9 @@ +{{- if .Site.Params.staticman }} + +{{- end }} {{- if (not ( .Site.Params.UseChroma )) }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d3fbea1..19d5539 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -42,6 +42,9 @@ + {{- if .Site.Params.staticman -}} + + {{- end -}} {{- if (not ( .Site.Params.UseChroma )) }} @@ -52,6 +55,10 @@ {{- end -}} + {{- if .Site.Params.staticman.recaptcha -}} + + {{- end -}} + {{- partial "head_custom.html" . }} {{- partial "load-photoswipe-theme.html" . }} {{ template "_internal/google_analytics_async.html" . }} diff --git a/layouts/partials/staticman-comments.html b/layouts/partials/staticman-comments.html new file mode 100644 index 0000000..d85e895 --- /dev/null +++ b/layouts/partials/staticman-comments.html @@ -0,0 +1,84 @@ +
+

Comments

+ + {{ $slug := replace .URL "/" "" }} + {{ $.Scratch.Add "hasComments" 0 }} + + + {{ range $index, $comments := (index $.Site.Data.comments $slug ) }} + + {{ if eq $index "0" }} + {{ range $comments}} + {{ $.Scratch.Add "hasComments" 1 }} +
+ + {{ if .website }} +

{{ .name }}

+ {{ else }} +

{{ .name }}

+ {{ end }} + +

{{ .comment | markdownify }}

+
+ {{ end }} + {{ end }} + {{ end }} + + + +
+ + + + {{ if .Site.Params.staticman.recaptcha }} + + + {{ end }} + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + {{ if .Site.Params.staticman.recaptcha }} +
+
+
+ {{ end }} + +
+ +
+
+
+ + diff --git a/static/css/staticman.css b/static/css/staticman.css new file mode 100644 index 0000000..29250e8 --- /dev/null +++ b/static/css/staticman.css @@ -0,0 +1,92 @@ +.staticman-comments { + padding: 20px 0px 0px 0px; +} + +.staticman-comments .comment-content{ + border-top: 1px solid #EEEEEE; + padding: 4px 0px 30px 0px; +} + +.staticman-comments .comment-content p { + padding: 5px 0px 5px 0px; + margin: 5px 58px 0px 58px; +} + +.staticman-comments .textfield { + width: 420px; + max-width: 100%; + padding: 0.5rem 0; + width: 100%; +} + +.staticman-comments input { + border: 1px solid rgba(0,0,0,0.12); + padding: 4px 5px; + width: 100%; +} + + +.staticman-comments .g-recaptcha { + padding: 0.5rem 0; +} + +.staticman-comments textarea { + border: 1px solid rgba(0,0,0,0.12); + padding: 4px 5px; + vertical-align: top; + height: 10em; + width: 100%; +} + +.staticman-comments .comment-avatar { + float:left; + width: 48; + height: 48; + margin-right: 10px; +} + +.staticman-comments .show-modal { + overflow: hidden; + position: relative; +} + +.staticman-comments .show-modal:before { + position: absolute; + content: ''; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 999; + background-color: rgba(0, 0, 0, 0.85); +} + +.show-modal .modal { + display: block; +} + +.modal { + display: none; + position: fixed; + width: 300px; + top: 50%; + left: 50%; + margin-left: -150px; + margin-top: -150px; + min-height: 0; + height: 30% + z-index: 9999; + padding: 0.5rem; + border: 1px solid rgba(0,0,0,0.25); + background-color: rgba(220,220,220,0.9); + height: 10em; + +} + +form--loading:before { + content: ''; +} + +.form--loading .form__spinner { + display: block; +} diff --git a/static/js/staticman.js b/static/js/staticman.js new file mode 100644 index 0000000..8aea071 --- /dev/null +++ b/static/js/staticman.js @@ -0,0 +1,40 @@ +// Static comments +// from: https://github.com/eduardoboucas/popcorn/blob/gh-pages/js/main.js +(function ($) { + var $comments = $('.js-comments'); + + $('.js-form').submit(function () { + var form = this; + + $(form).addClass('form--loading'); + + $.ajax({ + type: $(this).attr('method'), + url: $(this).attr('action'), + data: $(this).serialize(), + contentType: 'application/x-www-form-urlencoded', + success: function (data) { + showModal('Perfect !', 'Thanks for your comment! It will show on the site once it has been approved. .'); + $(form).removeClass('form--loading'); + }, + error: function (err) { + console.log(err); + showModal('Error', 'Sorry, there was an error with the submission!'); + $(form).removeClass('form--loading'); + } + }); + + return false; + }); + + $('.js-close-modal').click(function () { + $('body').removeClass('show-modal'); + }); + + function showModal(title, message) { + $('.js-modal-title').text(title); + $('.js-modal-text').html(message); + + $('body').addClass('show-modal'); + } +})(jQuery); diff --git a/theme.toml b/theme.toml index a778852..7ea2c2f 100644 --- a/theme.toml +++ b/theme.toml @@ -3,7 +3,7 @@ license = "MIT" licenselink = "https://github.com/halogenica/Hugo-BeautifulHugo/blob/master/LICENSE" description = "A port of Beautiful Jekyll theme" tags = ["blog", "company", "portfolio", "projects", "minimal", "responsive"] -features = ["blog", "themes", "disqus", "minimal", "responsive"] +features = ["blog", "themes", "disqus", "minimal", "responsive", "staticman"] min_version = 0.17 [author] @@ -15,4 +15,3 @@ min_version = 0.17 author = "dattali" homepage = "http://deanattali.com/beautiful-jekyll/" repo = "https://github.com/daattali/beautiful-jekyll" -