Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Gitment comment support #456

Merged
merged 5 commits into from
Nov 25, 2017

Conversation

deamwork
Copy link
Contributor

@deamwork deamwork commented Nov 1, 2017

Configuration

  • Operating system with version : macOS Sirrea 10.12.6 (Darwin 16.7.0 darwin x64)
  • Node version : v7.8.0
  • Hexo version : v3.2 (Maybe? Not sure how to check it.)
  • Hexo-cli version : v1.0.3

Changes proposed

@deamwork
Copy link
Contributor Author

deamwork commented Nov 1, 2017

Well, this is my first PR on this repo.

Not sure how you think about that tweak on the archive page, but showing all lowercase letter seems to be pretty odd to me.

So if you feel uncomfortable with this tweak, just ignore that commit (67e7f49).

Copy link
Owner

@LouisBarranqueiro LouisBarranqueiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @deamwork, thanks for this cool feature! 😄

Can you write a quick guide to enable me to test it and make sure it works with the theme please?

_config.yml Outdated
@@ -174,6 +174,22 @@ archive_pagination: true
category_pagination: true
tag_pagination: true

# Gitment - A github issue comment tool.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncomment these lines

@@ -0,0 +1 @@
<div id="gcomment"></div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think gitment or gitment-comments would be more appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as requested. :)

<a class="post-action-btn btn btn--default" href="#gcomment">
<i class="fa fa-comment-o"></i>
</a>
<% } else { %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to check else if (theme.disqus_shortname || theme.duoshuo_shortname) otherwise it will display empty elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another careless action... omg...

@@ -34,7 +34,7 @@
<% } %>
<li class="archive-post archive-day" data-date="<%= post.date.format('YYYYMMDD') %>">
<a class="archive-post-title" href="<%- url_for(post.path) %>"><%= post.title || '(' + __('post.no_title') + ')' %></a>
<span class="archive-post-date"><%= ' - ' + post.date.locale(page.lang).format(__('date_format')).toLowerCase() %></span>
<span class="archive-post-date"><%= ' - ' + post.date.locale(page.lang).format(__('date_format')) %></span>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this and let's focus on the gitment feature :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's okay, reverted.

_config.yml Outdated
# # Switch
# enable: false
# # Your Github ID here (Github username):
# githubID:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use snake case in yaml file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, I didn't even notice about that. 👍
My habit prefers CamelCase.

@deamwork
Copy link
Contributor Author

Pushed (83534bf), little tweaks for this merge

@deamwork deamwork changed the title add Gitment comment support & little tweak about date display add Gitment comment support Nov 23, 2017
@deamwork
Copy link
Contributor Author

deamwork commented Nov 23, 2017

Document:

  1. Go to Github applications page.
  2. Create a new application.
  3. Put your blog home URL for Homepage URL & Authorization callback URL (Important).
  4. Confirm to register that application.
  5. Get Client ID & Client Secret of this application.
  6. Edit your _config.yml file, put those data into this theme config file.
  7. Enable Gitment by set enable: false to enable: true.

You have to fill in your callback URL because your Client Secret is hard-coded in Gitment configuration.
For more security details, please read it here: https://github.com/imsun/gitment#about-security

Copy link
Owner

@LouisBarranqueiro LouisBarranqueiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add Gitment in Integrated services in the user documentation? 😄

@@ -36,6 +36,33 @@
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<% } else if (theme.gitment.enable) { %>
<script type="text/javascript">
(function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated a bit the script to init Gitment when the gitment script is loaded because if network is slow, it will throw an error ReferenceError: Can't find variable: Gitment

(function() {
                function render() {
                    new Gitment({
                        id: '<%= post.permalink %>',
                        owner: '<%- theme.gitment.github_id %>',
                        repo: '<%- theme.gitment.repo %>',
                        oauth: {
                            client_id: '<%- theme.gitment.client_id %>',
                            client_secret: '<%- theme.gitment.client_secret %>',
                        }
                    }).render('gitment');
                }
                var gc = document.createElement('script');
                gc.type = 'text/javascript';
                gc.src = 'http://imsun.github.io/gitment/dist/gitment.browser.js';
                gc.charset = 'UTF-8';
                gc.onload = render;
                gc.async = true;
                document.querySelector('body').appendChild(gc);
                var gcs = document.createElement('link');
                gcs.href = '//imsun.github.io/gitment/style/default.css';
                gcs.type = 'text/css';
                gcs.rel = 'stylesheet';
                gcs.media = 'screen,print';
                document.querySelector('head').appendChild(gcs);
            })();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the doc, it works well. Very simple and powerful comment system! 😎

_config.yml Outdated
# Repository: https://github.com/imsun/gitment
# Demo: https://imsun.github.io/gitment/
# Introduction: https://imsun.net/posts/gitment-introduction/
# Quick link to setup a new Github application: https://github.com/settings/applications/new

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have multiple comment systems, let's create a section for them before Integrated services. It will be well organized.

# Comments
# You can only use one of this service
# Your Disqus shortname
disqus_shortname:
# Your Duoshuo shortname
duoshuo_shortname:
# Your Gitment information
# Read https://github.com/imsun/gitment#get-started to setup Gitment
gitment:
    ...
``

_config.yml Outdated
@@ -174,6 +174,22 @@ archive_pagination: true
category_pagination: true
tag_pagination: true

# Gitment - A github issue comment tool.
# Repository: https://github.com/imsun/gitment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just put Read https://github.com/imsun/gitment#get-started to setup Gitment.

It will be easier to maintain (less links)

@deamwork
Copy link
Contributor Author

deamwork commented Nov 25, 2017

Changed as your request. 🎉

@LouisBarranqueiro
Copy link
Owner

LGTM. Thanks buddy 😄

@LouisBarranqueiro LouisBarranqueiro merged commit 294966b into LouisBarranqueiro:master Nov 25, 2017
LouisBarranqueiro pushed a commit that referenced this pull request Nov 27, 2017
* add Gitment comment support.

* tweak date display in archive page.

* fix code indentation issue, update config.

* Tweaks for merge.

* update load script & config file change.
@deamwork
Copy link
Contributor Author

deamwork commented Jun 12, 2018

BTW, which commit management tool you are using?
I can see that you pushed my pr as your commit but not changing the author.
I was wondering how did you do that...
In this commit: 557ec3f.

@LouisBarranqueiro
Copy link
Owner

I just used the squash and merge feature of GitHub

@deamwork
Copy link
Contributor Author

Okay, I got it. I thought it was a feature of some commit management software.
Thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants