diff --git a/layout/comment/webmention-timeline.jsx b/layout/comment/webmention-timeline.jsx index 733a56b..b8c73db 100644 --- a/layout/comment/webmention-timeline.jsx +++ b/layout/comment/webmention-timeline.jsx @@ -14,17 +14,13 @@ class WebmentionTimeline extends Component { return
-

长短波

+

网络回响

- -
- - } } diff --git a/layout/common/article.jsx b/layout/common/article.jsx index 6d741f0..c124ff6 100644 --- a/layout/common/article.jsx +++ b/layout/common/article.jsx @@ -50,17 +50,20 @@ module.exports = class extends Component { {page.layout !== 'page' ?
{/* Creation Date */} - {page.date && ${date(page.date)}`) - }}>} + {page.date && +   + + } {/* Last Update Date */} - {shouldShowUpdated && ${date(page.updated)}`) - }}>} + {shouldShowUpdated && +   + + } {/* author */} - {config.author ? {config.author} : null} + {page.author ? {page.author} : null} {/* Categories */} {page.categories && page.categories.length ? +   {(() => { const categories = []; page.categories.forEach((category, i) => { @@ -74,6 +77,7 @@ module.exports = class extends Component { : null} {/* Read time */} {article && article.readtime && article.readtime === true ? +   {(() => { const words = getWordCount(page._content); const time = moment.duration((words / 150.0) * 60, 'seconds'); @@ -82,7 +86,7 @@ module.exports = class extends Component { : null} {/* Visitor counter */} {!index && plugins && plugins.busuanzi === true ? 0') + __html: _p('plugin.visit_count', ' 0') }}> : null}
: null} @@ -129,11 +133,11 @@ module.exports = class extends Component { : null} : null} - {/* Comment */} - {!index ? : null} {/* Webmention */} {!index ? :null} - {!index ? :null} + {!index ? :null} + {/* Comment */} + {!index ? : null} ; } }; diff --git a/source/css/xry.styl b/source/css/xry.styl index d501bb1..ddadc4f 100644 --- a/source/css/xry.styl +++ b/source/css/xry.styl @@ -414,4 +414,37 @@ a.avatar-wrapper { .reply-author-name { font-weight: 500; +} +.form-webmention { + display: flex +} + +.form-webmention-btn { + flex: 0 0 auto; + margin-left: 12px; + align-items: baseline; + border: 0; + cursor: pointer; +} + +.form-webmention-btn, a.retweetBtn { + display: flex; + justify-content: center; + padding: 0 12px; + background: #2196f3; + color: #fff; +} + +#form-webmention-source { + flex: 1 0 auto; + border: 1px solid; + padding: 0 8px; + background: var(--quoteColor); +} + +#form-webmention-source,.form-webmention-btn,a.retweetBtn { + height: 36px; + line-height: 36px; + font-size: 16px; + border-radius: 8px } \ No newline at end of file diff --git a/source/js/webmention-timeline.js b/source/js/webmention-timeline.js index cac6274..23b6ec9 100644 --- a/source/js/webmention-timeline.js +++ b/source/js/webmention-timeline.js @@ -1,44 +1,42 @@ window.addEventListener('load', function () { const webmentionsPromise = window.webmentionContext.webmentionsPromise; - const webmentionCountPromise = window.webmentionContext.webmentionCountPromise; - - // console.log(JSON.stringify(webmentionsPromise, null, "\t")) + let html = ''; + html +=`
` + html +=`

你有对这篇文章写回应吗? 你可以在这里提交你的文章网址或推特链接(文章或推特内容需要包含这篇文章的地址,点击这里了解 Webmention):


` + html +=`

` + html +=`
` webmentionsPromise && webmentionsPromise .then(function (data) { - let html = ''; - // if(webmentionCountPromise && webmentionCountPromise.hasOwnProperty("count")) { - // html += `

${webmentionCountPromise.count}

` - // } - // html += `

${webmentionCountPromise.type}

` + const distinctMentions = [ ...new Map(data.children.map((item) => [item.author.url, item])).values()].sort((a, b) => new Date(a['wm-received']) - new Date(b['wm-received'])); - const replies = distinctMentions.filter( - (mention) => 'in-reply-to' in mention && 'content' in mention - ); + html += `

`; if (distinctMentions.length > 0) { - html += `Already ${distinctMentions.length} awesome people liked, shared or talked about this article:

`; - } else { - html += `Be the first one to share this article!`; + html += `已经有 ${distinctMentions.length} 朋友喜欢、分享或讨论这篇文章:

`; } html += `
`; distinctMentions.forEach(function (reply) { - html += `${reply.author.name}`; + html += ``; }); html += `
`; + + const replies = distinctMentions.filter( + (mention) => ('in-reply-to' in mention || 'mention-of' in mention)&& 'content' in mention + ); if (replies && replies.length) { html += `
`; - html += `

Replies

`; + html += `

引用或评论(${replies.length})

`; html += `
    `; replies.forEach(function (reply){ - html += `
  • `; + html += `
  • `; html += `
    `; - html += `${reply.author.name}`; + html += `${reply.author.name}`; html += `
    `; html += `
    `; - html += `

    ${reply.author.name}

    `; - html += `

    ${reply.content.text}

    `; + html += `

    ${reply.author.name}

    `; + html += `

    ${reply.content.text.slice(0, 200)}

    `; html += `
    `; html += `
  • `; @@ -47,9 +45,8 @@ window.addEventListener('load', function () { html += `
`; } document.querySelector('div.webmention-timeline').innerHTML = html; - }) .catch(function (ex) { - console.error('fetch mastodon webmention error' + ex); + console.error('fetch webmention error' + ex); }); }); \ No newline at end of file diff --git a/source/js/webmention.js b/source/js/webmention.js index 98d1162..37ec8ef 100644 --- a/source/js/webmention.js +++ b/source/js/webmention.js @@ -12,14 +12,4 @@ .catch(function (ex) { console.error('fetch webmention error' + ex); }); - - webmentionContext.webmentionCountPromise = fetch(webmentionBaseUrl + "/api/count.json?target=" + encodeURIComponent(url)) - .then(function (response) { - console.log('sucess ' + webmentionBaseUrl + "/api/count.json?target=" + url); - return response.json(); - }) - .catch(function (ex) { - console.error('fetch webmention count error' + ex); - }); - })(window.webmentionContext); \ No newline at end of file