From 3c9a6ca645d16a9803472572ac36e37e6b7cdcf8 Mon Sep 17 00:00:00 2001
From: ppoffice <ppoffice@users.noreply.github.com>
Date: Sat, 29 Aug 2020 00:42:43 -0400
Subject: [PATCH] feat(layout): add article licensing block

---
 include/schema/common/article.json | 20 +++++++++++++
 include/style/article.styl         | 48 ++++++++++++++++++++++++++++++
 languages/de.yml                   |  5 ++++
 languages/en.yml                   |  5 ++++
 languages/es.yml                   |  5 ++++
 languages/fr.yml                   |  5 ++++
 languages/id.yml                   |  5 ++++
 languages/ja.yml                   |  5 ++++
 languages/ko.yml                   |  5 ++++
 languages/pl.yml                   |  5 ++++
 languages/pt-BR.yml                |  5 ++++
 languages/ru.yml                   |  5 ++++
 languages/tr.yml                   |  5 ++++
 languages/vn.yml                   |  5 ++++
 languages/zh-CN.yml                |  5 ++++
 languages/zh-TW.yml                |  5 ++++
 layout/common/article.jsx          |  4 +++
 package.json                       |  2 +-
 18 files changed, 143 insertions(+), 1 deletion(-)

diff --git a/include/schema/common/article.json b/include/schema/common/article.json
index ba23ba9..529725b 100644
--- a/include/schema/common/article.json
+++ b/include/schema/common/article.json
@@ -39,6 +39,26 @@
             "description": "Whether to show estimated article reading time",
             "default": true,
             "nullable": true
+        },
+        "licenses": {
+            "$ref": "/misc/article_licensing.json",
+            "description": "Article licensing block",
+            "examples": [
+                {
+                    "Creative Commons": {
+                      "icon": "fab fa-creative-commons",
+                      "url": "https://creativecommons.org/"
+                    },
+                    "Attribution": {
+                      "icon": "fab fa-creative-commons-by",
+                      "url": "https://creativecommons.org/licenses/by/4.0/"
+                    },
+                    "Noncommercial": {
+                      "icon": "fab fa-creative-commons-nc",
+                      "url": "https://creativecommons.org/licenses/by-nc/4.0/"
+                    }
+                }
+            ]
         }
     }
 }
\ No newline at end of file
diff --git a/include/style/article.styl b/include/style/article.styl
index fb0fbfb..f1d9eac 100644
--- a/include/style/article.styl
+++ b/include/style/article.styl
@@ -99,3 +99,51 @@ article
         left: 0
         width: 100%
         height: 100%
+
+.article-licensing
+    position: relative
+    z-index: 1
+    box-shadow: none
+    background: $white-ter
+    border-radius: $radius
+    overflow: hidden
+
+    &:after
+        position: absolute
+        z-index: -1
+        right: -50px
+        top: -87.87px
+        content: '\f25e'
+        font-size: 200px
+        font-family: 'Font Awesome 5 Brands'
+        opacity: 0.1
+
+    .level-left
+        flex-wrap: wrap
+        max-width: 100%
+
+    .licensing-title
+        @extend .mb-3
+        line-height: 1.2
+
+        p:not(:last-child)
+            @extend .mb-1
+
+        a
+            @extend .size-small, .has-text-grey
+
+    .licensing-meta
+        .level-item
+            @extend .mr-4
+
+        .icon
+            @extend .mr-1
+            width: 1.2em
+            height: 1.2em
+            font-size: 1.2em
+
+        h6
+            @extend .size-small
+        
+        a
+            @extend .has-text-black
diff --git a/languages/de.yml b/languages/de.yml
index 83f5d1f..09aecfb 100644
--- a/languages/de.yml
+++ b/languages/de.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Über %d Wort'
         other: 'Über %d Wörter'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Gefällt Ihnen der Artikel? Unterstützen Sie den Autor mit'
     afdian: 'Afdian.net'
diff --git a/languages/en.yml b/languages/en.yml
index 66355ad..e8f594f 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'About %d word'
         other: 'About %d words'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Like this article? Support the author with'
     afdian: 'Afdian.net'
diff --git a/languages/es.yml b/languages/es.yml
index 7833063..984357b 100644
--- a/languages/es.yml
+++ b/languages/es.yml
@@ -34,6 +34,11 @@ article:
     word_count:
         one: 'Aproximadamente %d palabra'
         other: 'Aproximadamente %d palabras'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: '¿Te gusta este artículo? Apoya al autor con'
     afdian: 'Afdian.net'
diff --git a/languages/fr.yml b/languages/fr.yml
index db81c91..6c33bf1 100644
--- a/languages/fr.yml
+++ b/languages/fr.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Environ %d mot'
         other: 'Environ %d mots'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: "Vous aimez cet article? Soutenez l'auteur avec"
     afdian: 'Afdian.net'
diff --git a/languages/id.yml b/languages/id.yml
index e03cbee..97c99d9 100644
--- a/languages/id.yml
+++ b/languages/id.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Sekitar %d kata'
         other: 'Sekitar %d kata'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Suka dengan artikel ini? Bantu penulis dengan donasi melalui'
     afdian: 'Afdian.net'
diff --git a/languages/ja.yml b/languages/ja.yml
index c37ddb7..aa286ea 100644
--- a/languages/ja.yml
+++ b/languages/ja.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: '約%d語'
         other: '約%d語'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'この記事は気に入りましたか? 著者をサポートする'
     afdian: 'Afdian.net'
diff --git a/languages/ko.yml b/languages/ko.yml
index 401d3d8..5ce8653 100644
--- a/languages/ko.yml
+++ b/languages/ko.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: '약 %d 단어'
         other: '약 %d 단어'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: '이 기사처럼? 저자 지원'
     afdian: 'Afdian.net'
diff --git a/languages/pl.yml b/languages/pl.yml
index 320692c..67a7db6 100644
--- a/languages/pl.yml
+++ b/languages/pl.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Około %d słowa'
         other: 'Około %d słów'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Podoba Ci się ten artykuł? Wesprzyj autora za pomocą'
     afdian: 'Afdian.net'
diff --git a/languages/pt-BR.yml b/languages/pt-BR.yml
index 175fd20..5dbb2bf 100644
--- a/languages/pt-BR.yml
+++ b/languages/pt-BR.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Cerca de %d palavra'
         other: 'Cerca de %d palavras'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Gostou deste artigo? Apoie o autor com'
     afdian: 'Afdian.net'
diff --git a/languages/ru.yml b/languages/ru.yml
index 4c80ed2..dc88909 100644
--- a/languages/ru.yml
+++ b/languages/ru.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Около %d слова'
         other: 'Примерно %d слова'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Понравилась эта статья? Поддержите автора'
     afdian: 'Afdian.net'
diff --git a/languages/tr.yml b/languages/tr.yml
index daa55c1..68a2898 100644
--- a/languages/tr.yml
+++ b/languages/tr.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Yaklaşık %d kelime'
         other: 'Yaklaşık %d kelime'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Bu makaleyi beğendiniz mi? Yazarı şununla destekleyin'
     afdian: 'Afdian.net'
diff --git a/languages/vn.yml b/languages/vn.yml
index 8686f2d..d72027e 100644
--- a/languages/vn.yml
+++ b/languages/vn.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: 'Khoảng %d từ'
         other: 'Khoảng %d từ'
+    licensing:
+        author: 'Author'
+        created_at: 'Posted on'
+        updated_at: 'Updated on'
+        licensed_under: 'Licensed under'
 donate:
     title: 'Bạn đọc có thể ủng hộ blog qua'
     afdian: 'Afdian.net'
diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml
index 3a1b183..890faaa 100644
--- a/languages/zh-CN.yml
+++ b/languages/zh-CN.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: '大约%d个字'
         other: '大约%d个字'
+    licensing:
+        author: '作者'
+        created_at: '发布于'
+        updated_at: '更新于'
+        licensed_under: '许可协议'
 donate:
     title: '喜欢这篇文章?打赏一下作者吧'
     afdian: '爱发电'
diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml
index cf9ec00..555a4cb 100644
--- a/languages/zh-TW.yml
+++ b/languages/zh-TW.yml
@@ -33,6 +33,11 @@ article:
     word_count:
         one: '大約%d個字'
         other: '大約%d個字'
+    licensing:
+        author: '作者'
+        created_at: '發表於'
+        updated_at: '更新於'
+        licensed_under: '許可協議'
 donate:
     title: '喜歡這篇文章嗎? 贊助一下作者吧!'
     afdian: '愛發電'
diff --git a/layout/common/article.jsx b/layout/common/article.jsx
index 5a16974..3deba8f 100644
--- a/layout/common/article.jsx
+++ b/layout/common/article.jsx
@@ -3,6 +3,7 @@ const { Component, Fragment } = require('inferno');
 const Share = require('./share');
 const Donates = require('./donates');
 const Comment = require('./comment');
+const ArticleLicensing = require('hexo-component-inferno/lib/view/misc/article_licensing');
 
 /**
  * Get the word count of text.
@@ -84,6 +85,9 @@ module.exports = class extends Component {
                     </h1>
                     {/* Content/Excerpt */}
                     <div class="content" dangerouslySetInnerHTML={{ __html: index && page.excerpt ? page.excerpt : page.content }}></div>
+                    {/* Licensing block */}
+                    {!index && article && article.licenses && Object.keys(article.licenses)
+                        ? <ArticleLicensing.Cacheable page={page} config={config} helper={helper} /> : null}
                     {/* Tags */}
                     {!index && page.tags && page.tags.length ? <div class="article-tags size-small mb-4">
                         <span class="mr-2">#</span>
diff --git a/package.json b/package.json
index 0588d28..a527acb 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
     "bulma-stylus": "0.8.0",
     "deepmerge": "^4.2.2",
     "hexo": "^5.0.2",
-    "hexo-component-inferno": "^0.7.0",
+    "hexo-component-inferno": "^0.8.0",
     "hexo-log": "^2.0.0",
     "hexo-pagination": "^1.0.0",
     "hexo-renderer-inferno": "^0.1.3",