Skip to content

Commit

Permalink
gitalk
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzh committed Dec 8, 2018
1 parent 806bc11 commit fc53e34
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 24 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ fancybox: true

# Local search
search_text: Search

# Gitalk
gitalk:
enable: false # true
clientID: # GitHub Application Client ID
clientSecret: # Client Secret
repo: # Repository name
owner: GitHub ID
admin: GitHub ID
```
The [feathericon](https://feathericon.com) in the menu is programmed ordely in "CSS `source/css/_partial/navbar.styl` " and can be changed or added if needed.
Expand Down
11 changes: 10 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ local_search:
trigger: auto
# show top n results per article, show all results by setting to -1
top_n_per_article: 1
unescape: true
unescape: true

# Gitalk
gitalk:
enable: false # true
clientID: # GitHub Application Client ID
clientSecret: # Client Secret
repo: # Repository name
owner: # GitHub ID
admin: # GitHub ID
8 changes: 6 additions & 2 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<article id="<%= post.layout %>-<%= post.slug %>" class="article article-type-<%= post.layout %>" itemscope
itemprop="blogPost">
<article id="<%= post.layout %>-<%= post.slug %>" class="article article-type-<%= post.layout %>" itemscope itemprop="blogPost">

<div class="article-inner">
<% if (post.link || post.title){ %>
Expand Down Expand Up @@ -32,12 +31,17 @@
class="article-share-link"><%- theme.share_text %></a>
<%- partial('post/tag') %>
</footer>

</div>

<% if (!index){ %>
<%- partial('post/nav') %>
<% } %>

<% if (is_post()) { %>
<%- partial('post/gitalk') %>
<%} %>

</article>


3 changes: 3 additions & 0 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<li>&copy; <%= date(new Date(), 'YYYY') %> <%= config.title %></li>
<li><%= __('Powered by') %> <a href="http://hexo.io/" target="_blank">Hexo</a></li>
<li><%= __('Theme ') %> <a href="https://zhwangart.github.io">zhwangart</a></li>
<!--
<li><a href="/"><%= config.author %></a></li>
-->
</ul>
</div>
</footer>
3 changes: 0 additions & 3 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
<link rel="shortcut icon" href="<%- theme.favicon %>">
<% } %>
<%- css('css/style') %>
<% if (theme.rss){ %>
<link rel="alternate" href="<%= url_for(theme.rss) %>" title="<%= config.title %>" type="application/atom+xml">
<% } %>
<% if (theme.fancybox){ %>
<%- css('fancybox/jquery.fancybox.min') %>
<% } %>
Expand Down
20 changes: 20 additions & 0 deletions layout/_partial/post/gitalk.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<% if (theme.gitalk.enable) { %>
<div class="gitalk" id="gitalk-container"></div>
<%- css('https://unpkg.com/gitalk/dist/gitalk.css') %>
<%- js('https://unpkg.com/gitalk/dist/gitalk.min.js') %>
<%- js('https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js') %>
<script type="text/javascript">
var gitalk = new Gitalk({
clientID: '<%- theme.gitalk.clientID %>',
clientSecret: '<%- theme.gitalk.clientSecret %>',
repo: '<%- theme.gitalk.repo %>',
owner: '<%- theme.gitalk.owner %>',
admin: ['<%- theme.gitalk.admin %>'],
// id: location.pathname, // Ensure uniqueness and length less than 50
id: md5(location.pathname),
distractionFreeMode: false // Facebook-like distraction free mode
})
gitalk.render('gitalk-container')
</script>
<% } %>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ocean",
"light"
],
"author": "",
"author": "zhwangart",
"license": "ISC",
"bugs": {
"url": "https://github.com/zhwangart/hexo-theme-ocean/issues"
Expand Down
3 changes: 3 additions & 0 deletions source/css/_partial/gitalk.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gitalk,.markdown-body
font-size font-size-base!important

1 change: 1 addition & 0 deletions source/css/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ img
@import "_partial/highlight"
@import "_partial/mobile"
@import "_partial/pace"
@import "_partial/gitalk.styl"

if sidebar
@import "_partial/sidebar"
19 changes: 2 additions & 17 deletions source/js/ocean.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
$searchWrap.removeClass('on');
}
});

// 移动设备侦测
var isMobile = {
Android: function () {
Expand Down Expand Up @@ -110,23 +111,7 @@
window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
});

// Caption ------------
$('.article-entry').each(function (i) {
$(this).find('img').each(function () {
if ($(this).parent().hasClass('fancybox')) return;

var alt = this.alt;

if (alt) $(this).after('<span class="caption">' + alt + '</span>');

$(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
});

$(this).find('.fancybox').each(function () {
$(this).attr('rel', 'article' + i);
});
});

// fancybox
if ($.fancybox) {
$('[data-fancybox]').fancybox({
protect: true
Expand Down

0 comments on commit fc53e34

Please sign in to comment.