diff options
| author | Andrew Lee <alee14498@gmail.com> | 2019-10-27 09:57:37 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@gmail.com> | 2019-10-27 09:57:37 -0400 |
| commit | e62e7bb6b14555c9bbe5d40d217103984f4f80e6 (patch) | |
| tree | 21887d847dccacb47644eb6f74ce31326172303c /_includes/comments-providers | |
| parent | 716ea6ed2b64c921a799d872a07bfbd53b2a3e58 (diff) | |
| download | pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.gz pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.bz2 pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.zip | |
Rewrite progress
Diffstat (limited to '_includes/comments-providers')
| -rw-r--r-- | _includes/comments-providers/custom.html | 3 | ||||
| -rw-r--r-- | _includes/comments-providers/discourse.html | 13 | ||||
| -rw-r--r-- | _includes/comments-providers/disqus.html | 15 | ||||
| -rw-r--r-- | _includes/comments-providers/facebook.html | 8 | ||||
| -rw-r--r-- | _includes/comments-providers/scripts.html | 18 | ||||
| -rw-r--r-- | _includes/comments-providers/staticman.html | 40 | ||||
| -rw-r--r-- | _includes/comments-providers/staticman_v2.html | 40 | ||||
| -rw-r--r-- | _includes/comments-providers/utterances.html | 20 |
8 files changed, 157 insertions, 0 deletions
diff --git a/_includes/comments-providers/custom.html b/_includes/comments-providers/custom.html new file mode 100644 index 0000000..9099369 --- /dev/null +++ b/_includes/comments-providers/custom.html @@ -0,0 +1,3 @@ +<!-- start custom comments snippet --> + +<!-- end custom comments snippet -->
\ No newline at end of file diff --git a/_includes/comments-providers/discourse.html b/_includes/comments-providers/discourse.html new file mode 100644 index 0000000..aca62cc --- /dev/null +++ b/_includes/comments-providers/discourse.html @@ -0,0 +1,13 @@ +{% if site.comments.discourse.server %} +{% capture canonical %}{% if site.permalink contains '.html' %}{{ page.url | absolute_url }}{% else %}{{ page.url | absolute_url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %} +<script type="text/javascript"> + DiscourseEmbed = { discourseUrl: '//{{ site.comments.discourse.server }}/', + discourseEmbedUrl: '{{ canonical }}' }; + (function () { + var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true; + d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d); + })(); +</script> +<noscript>Please enable JavaScript to view the comments powered by <a href="https://www.discourse.org/">Discourse.</a></noscript> +{% endif %} diff --git a/_includes/comments-providers/disqus.html b/_includes/comments-providers/disqus.html new file mode 100644 index 0000000..8cf7aca --- /dev/null +++ b/_includes/comments-providers/disqus.html @@ -0,0 +1,15 @@ +{% if site.comments.disqus.shortname %} + <script> + var disqus_config = function () { + this.page.url = "{{ page.url | absolute_url }}"; // Replace PAGE_URL with your page's canonical URL variable + this.page.identifier = "{{ page.id }}"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable + }; + (function() { // DON'T EDIT BELOW THIS LINE + var d = document, s = d.createElement('script'); + s.src = 'https://{{ site.comments.disqus.shortname }}.disqus.com/embed.js'; + s.setAttribute('data-timestamp', +new Date()); + (d.head || d.body).appendChild(s); + })(); + </script> +<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> +{% endif %} diff --git a/_includes/comments-providers/facebook.html b/_includes/comments-providers/facebook.html new file mode 100644 index 0000000..009dc1c --- /dev/null +++ b/_includes/comments-providers/facebook.html @@ -0,0 +1,8 @@ +<div id="fb-root"></div> +<script>(function(d, s, id) { + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) return; + js = d.createElement(s); js.id = id; + js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5{% if site.comments.facebook.appid %}&appId={{ site.comments.facebook.appid }}{% endif %}"; + fjs.parentNode.insertBefore(js, fjs); +}(document, 'script', 'facebook-jssdk'));</script>
\ No newline at end of file diff --git a/_includes/comments-providers/scripts.html b/_includes/comments-providers/scripts.html new file mode 100644 index 0000000..4e3f585 --- /dev/null +++ b/_includes/comments-providers/scripts.html @@ -0,0 +1,18 @@ +{% if site.comments.provider and page.comments %} +{% case site.comments.provider %} + {% when "disqus" %} + {% include /comments-providers/disqus.html %} + {% when "discourse" %} + {% include /comments-providers/discourse.html %} + {% when "facebook" %} + {% include /comments-providers/facebook.html %} + {% when "staticman" %} + {% include /comments-providers/staticman.html %} + {% when "staticman_v2" %} + {% include /comments-providers/staticman_v2.html %} + {% when "utterances" %} + {% include /comments-providers/utterances.html %} + {% when "custom" %} + {% include /comments-providers/custom.html %} +{% endcase %} +{% endif %}
\ No newline at end of file diff --git a/_includes/comments-providers/staticman.html b/_includes/comments-providers/staticman.html new file mode 100644 index 0000000..ae3991d --- /dev/null +++ b/_includes/comments-providers/staticman.html @@ -0,0 +1,40 @@ +{% if site.repository and site.staticman.branch %} + <script> + (function ($) { + $('#new_comment').submit(function () { + var form = this; + + $(form).addClass('disabled'); + $('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }}'); + + $.ajax({ + type: $(this).attr('method'), + url: $(this).attr('action'), + data: $(this).serialize(), + contentType: 'application/x-www-form-urlencoded', + success: function (data) { + $('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}'); + $('.page__comments-form .js-notice').removeClass('notice--danger'); + $('.page__comments-form .js-notice').addClass('notice--success'); + showAlert('{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}'); + }, + error: function (err) { + console.log(err); + $('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}'); + $('.page__comments-form .js-notice').removeClass('notice--success'); + $('.page__comments-form .js-notice').addClass('notice--danger'); + showAlert('{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}'); + $(form).removeClass('disabled'); + } + }); + + return false; + }); + + function showAlert(message) { + $('.page__comments-form .js-notice').removeClass('hidden'); + $('.page__comments-form .js-notice-text').html(message); + } + })(jQuery); + </script> +{% endif %} diff --git a/_includes/comments-providers/staticman_v2.html b/_includes/comments-providers/staticman_v2.html new file mode 100644 index 0000000..ae3991d --- /dev/null +++ b/_includes/comments-providers/staticman_v2.html @@ -0,0 +1,40 @@ +{% if site.repository and site.staticman.branch %} + <script> + (function ($) { + $('#new_comment').submit(function () { + var form = this; + + $(form).addClass('disabled'); + $('#comment-form-submit').html('<i class="fas fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }}'); + + $.ajax({ + type: $(this).attr('method'), + url: $(this).attr('action'), + data: $(this).serialize(), + contentType: 'application/x-www-form-urlencoded', + success: function (data) { + $('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}'); + $('.page__comments-form .js-notice').removeClass('notice--danger'); + $('.page__comments-form .js-notice').addClass('notice--success'); + showAlert('{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}'); + }, + error: function (err) { + console.log(err); + $('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}'); + $('.page__comments-form .js-notice').removeClass('notice--success'); + $('.page__comments-form .js-notice').addClass('notice--danger'); + showAlert('{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}'); + $(form).removeClass('disabled'); + } + }); + + return false; + }); + + function showAlert(message) { + $('.page__comments-form .js-notice').removeClass('hidden'); + $('.page__comments-form .js-notice-text').html(message); + } + })(jQuery); + </script> +{% endif %} diff --git a/_includes/comments-providers/utterances.html b/_includes/comments-providers/utterances.html new file mode 100644 index 0000000..129ab77 --- /dev/null +++ b/_includes/comments-providers/utterances.html @@ -0,0 +1,20 @@ +<script> + 'use strict'; + + (function() { + var commentContainer = document.querySelector('#utterances-comments'); + + if (!commentContainer) { + return; + } + + var script = document.createElement('script'); + script.setAttribute('src', 'https://utteranc.es/client.js'); + script.setAttribute('repo', '{{ site.repository }}'); + script.setAttribute('issue-term', '{{ site.comments.utterances.issue_term | default: "pathname" }}'); + script.setAttribute('theme', '{{ site.comments.utterances.theme | default: "github-light" }}'); + script.setAttribute('crossorigin', 'anonymous'); + + commentContainer.appendChild(script); + })(); +</script> |
