Skip to content

Commit

Permalink
remove tipme, add support to gitment and gitalk
Browse files Browse the repository at this point in the history
  • Loading branch information
taoalpha committed Jun 30, 2020
1 parent 7748379 commit 5fd24b7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 65 deletions.
21 changes: 9 additions & 12 deletions _config.yml
Expand Up @@ -2,9 +2,6 @@ menus:
# myliks:
# name: mylinks
# icon: fa-anchor
tipme:
name: tipme
icon: fa-gratipay
search:
name: search
icon: fa-search
Expand All @@ -18,19 +15,19 @@ logo: favicon.png

# google-analytics:
ga: UA-46725017-2
# baidu-analytics:
ba:

# settings
swiftype: true

## for duoshuo
comments :
provider : duoshuo
duoshuo :
short_name : taoalpha
api :
commentCount: "http://api.duoshuo.com/threads/counts.json?short_name=taoalpha&threads="
comments:
gitment:
css: https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/default.css
js: https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/gitment.browser.js
gitalk:
css: https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css
js: https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js



og:
image: http://taoalpha.github.io/images/newblog.jpg
Expand Down
3 changes: 0 additions & 3 deletions layout/mixins/post.jade
Expand Up @@ -30,6 +30,3 @@ mixin post(item)
span.readspeed= Math.floor(strip_html(item.content).length / 350 + 1) +" minutes to read"
div.entry-content
!=item.content
if item.pname != "tipme"
include widget
+tipme()
43 changes: 30 additions & 13 deletions layout/partial/comment.jade
@@ -1,18 +1,35 @@
if theme.comments.duoshuo
if config.comments == 'gitment'
link(rel="stylesheet" href='#{theme.comments.gitment.css}')
script(src='#{theme.comments.gitment.js}')
.comments
.ds-thread(data-thread-key=page.path, data-title=page.title, data-url=page.permalink, data-author-key='1')
script.
var duoshuoQuery = {short_name:"taoalpha"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();

if theme.comments.disqus
const gitment = new Gitment({
id: '#{page.path}',
owner: '#{config.gitment.owner}',
repo: '#{config.gitment.repo}',
oauth: {
client_id: '#{config.gitment.client_id}',
client_secret: '#{config.gitment.client_secret}',
},
});
gitment.render(document.querySelector('.comments'));

if config.comments == 'gitalk'
link(rel="stylesheet" href='#{theme.comments.gitalk.css}')
script(src='#{theme.comments.gitalk.js}')
.comments
script.
const gitalk = new Gitalk({
id: '#{page.path}',
owner: '#{config.gitalk.owner}',
repo: '#{config.gitalk.repo}',
clientID: '#{config.gitalk.client_id}',
clientSecret: '#{config.gitalk.client_secret}',
distractionFreeMode: false,
});
gitalk.render(document.querySelector('.comments'));

if config.comments == 'disqus'
.comments
#disqus_thread
script.
Expand Down
3 changes: 0 additions & 3 deletions layout/post.jade
Expand Up @@ -19,9 +19,6 @@ block container

block scripts
script(src=url_for("js/post.js"))
if page.pname == "tipme"
script(type="text/javascript").
showMyWishBooks()
if page.encrypt
script(src=url_for("js/aes.js"))
script(type="text/javascript").
Expand Down
2 changes: 1 addition & 1 deletion source/api/pageview.json

Large diffs are not rendered by default.

34 changes: 1 addition & 33 deletions source/js/functions.es6
Expand Up @@ -199,7 +199,7 @@ window.randomImage = (path, retry = 0) => {
success: (data) => {
$(".aside").css("background-image", "url(" + data.hits[0].largeImageURL + ")");
return $.cookie(path + "weatherImgUrl", data.hits[0].largeImageURL, {
expires: 0.05,
expires: 5,
path: '/blog'
});
},
Expand Down Expand Up @@ -262,38 +262,6 @@ window.parsePageViewData = (rows) => {
})
}

// load my wish books from douban
window.showMyWishBooks = () => {
var bookapi = "https://api.douban.com/v2/book/user/129154019/collections?status=wish&tag=MyWish"
$.ajax({
url: bookapi,
dataType: 'jsonp',
timeout: 1000 * 3,
success: (data) => {
parseBookDatas(data.collections);
},
error: () => {
console.log('Failed to get pageview from Douban!');
$.ajax({
url: '/blog/api/doubanbooks.json',
dataType: 'json',
success: function(data) {
console.log('Local mybooks.data backup file.');
return parseBookDatas(data.collections);
}
})
}
})
}

window.parseBookDatas = (data) => {
var template = "<li class='book_item'><a href='__book_url__' alt='__book_alt_title__'><img src='__book_img__'><span>__book_title__</span></a></li>"
$.each(data,(key,item) => {
var bookitem = template.replace("__book_url__",item.book.alt).replace("__book_alt_title__",item.book.alt_title).replace("__book_title__",item.book.title).replace("__book_img__",item.book.images.large)
$('.books').append(bookitem)
})
}

window.search = (query) => {
var inverted_index = JSON.parse($('p#indexdata').text()),result = [],dict = $('p#worddicts').text().split(",")
,stop = ["the","of","is","and","to","in","that","we","for","an","are","by","be","as","on","with","can","if","from","which","you","it","this","then","at","have","all","not","one","has","or","that","的","了","和","是","就","都","而","及","與","著","或","一個","沒有","我們","你們","妳們","他們","她們","是否"]
Expand Down

0 comments on commit 5fd24b7

Please sign in to comment.