diff --git a/README.md b/README.md index 9669def9..2f66edd7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ Argon 使用 [GPL V3.0](https://github.com/solstice23/argon-theme/blob/master/LI # 更新日志 +## 20200824 v1.0.1 ++ 增加 "评论文字头像" 选项(为无头像评论者生成一个纯色文字头像) ++ Github 短代码新增 Mini 尺寸 + ## 20200823 v1.0.0 + 正式版 diff --git a/argontheme.js b/argontheme.js index 4887bc16..af4dc3c8 100644 --- a/argontheme.js +++ b/argontheme.js @@ -1160,6 +1160,25 @@ foldLongComments(); $(document).on("click" , ".show-full-comment" , function(){ $(this).parent().removeClass("comment-folded").addClass("comment-unfolded"); }); +/*评论文字头像*/ +document.addEventListener("error", function(e){ + let img = $(e.target); + if (!img.hasClass("avatar")){ + return; + } + if (!img.parent().hasClass("comment-item-avatar")){ + return; + } + let emailHash = img.attr("src").match(/([a-f\d]{32}|[A-F\d]{32})/)[0]; + let hash = 0; + for (i in emailHash){ + hash = (hash * 233 + emailHash.charCodeAt(i)) % 16; + } + console.log(hash); + let colors = ['#e25f50', '#f25e90', '#bc67cb', '#9672cf', '#7984ce', '#5c96fa', '#7bdeeb', '#45d0e2', '#48b7ad', '#52bc89', '#9ace5f', '#d4e34a', '#f9d715', '#fac400', '#ffaa00', '#ff8b61', '#c2c2c2', '#8ea3af', '#a1877d', '#a3a3a3', '#b0b6e3', '#b49cde', '#c2c2c2', '#7bdeeb', '#bcaaa4', '#aed77f']; + let text = $(".comment-name", img.parent().parent()).text().trim()[0]; + img.parent().html('
' + text + '
'); +}, true); /*需要密码的文章加载*/ $(document).on("submit" , ".post-password-form" , function(){ $("input[type='submit']", this).attr("disabled", "disabled"); diff --git a/functions.php b/functions.php index c3b328f4..fb376c01 100644 --- a/functions.php +++ b/functions.php @@ -1428,18 +1428,26 @@ function the_content_filter($content){ add_filter('the_content' , 'the_content_filter'); //使用 CDN 加速 gravatar function gravatar_cdn($url){ - $cdn = get_option('argon_gravatar_cdn' , 'gravatar.loli.net/avatar/'); + $cdn = get_option('argon_gravatar_cdn', 'gravatar.loli.net/avatar/'); $cdn = str_replace("http://", "", $cdn); $cdn = str_replace("https://", "", $cdn); if (substr($cdn, -1) != '/'){ $cdn .= "/"; } - $url = preg_replace("/\/\/(.*?).gravatar.com\/avatar\//" , "//" . $cdn , $url); + $url = preg_replace("/\/\/(.*?).gravatar.com\/avatar\//", "//" . $cdn, $url); return $url; } if (get_option('argon_gravatar_cdn' , '') != ''){ add_filter('get_avatar_url', 'gravatar_cdn'); } +function text_gravatar($url){ + $url = preg_replace("/[\?\&]d[^&]+/i", "" , $url); + $url .= '&d=404'; + return $url; +} +if (get_option('argon_text_gravatar', 'false') == 'true'){ + add_filter('get_avatar_url', 'text_gravatar'); +} //说说点赞 function get_shuoshuo_upvotes($ID){ $count_key = 'upvotes'; @@ -1865,7 +1873,7 @@ function shortcode_alert($attr,$content=""){ if (isset($attr['title'])){ $out .= "" . $attr['title'] . " "; } - $out .= $content . ""; + $out .= $content . ""; return $out; } add_shortcode('admonition','shortcode_admonition'); @@ -2172,6 +2180,7 @@ function shortcode_github($attr,$content=""){ $author = isset($attr['author']) ? $attr['author'] : ''; $project = isset($attr['project']) ? $attr['project'] : ''; $getdata = isset($attr['getdata']) ? $attr['getdata'] : 'frontend'; + $size = isset($attr['size']) ? $attr['size'] : 'full'; $description = ""; $stars = ""; @@ -2210,8 +2219,12 @@ function shortcode_github($attr,$content=""){ restore_error_handler(); } - $out = "
"; - $out .= "
Github
"; + $out = "
"; + $out .= ""; $out .= "
"; $out .= "
- + - +
"; @@ -3487,6 +3500,24 @@ function themeoptions_page(){

+ + + + +


gravatar.loli.net/avatar/ , cdn.v2ex.com/gravatar/ , dn-qiniu-avatar.qbox.me/avatar/

+ + + + + + +

+ +

@@ -3560,13 +3591,6 @@ function themeoptions_page(){

- - - - -


gravatar.loli.net/avatar/ , cdn.v2ex.com/gravatar/ , dn-qiniu-avatar.qbox.me/avatar/

- - @@ -3984,6 +4008,7 @@ function argon_update_themeoptions(){ argon_update_option('argon_related_post_sort_order'); argon_update_option('argon_related_post_limit'); argon_update_option('argon_article_header_style'); + argon_update_option('argon_text_gravatar'); //LazyLoad 相关 argon_update_option('argon_enable_lazyload'); diff --git a/info.json b/info.json index 3b932bc8..f6b592d5 100644 --- a/info.json +++ b/info.json @@ -1,5 +1,5 @@ { - "version" : "1.0.0", + "version" : "1.0.1", "details_url" : "https://github.com/solstice23/argon-theme/releases", - "download_url" : "https://github.com/solstice23/argon-theme/releases/download/v1.0.0/argon.zip" + "download_url" : "https://github.com/solstice23/argon-theme/releases/download/v1.0.1/argon.zip" } diff --git a/style.css b/style.css index 8fcd8d9f..de5fd4c4 100644 --- a/style.css +++ b/style.css @@ -3,7 +3,7 @@ Theme Name: argon Author: solstice23 Author URI: https://solstice23.top/ Description: 轻盈、简洁、美观的 Wordpress 主题 -Version: 1.0.0 +Version: 1.0.1 License: GNU General Public License v3.0 License URI: https://www.gnu.org/licenses/gpl-3.0.html Tags: 简约, 两栏, 侧栏在左边, 浮动侧栏, 文章目录, 自适应, 夜间模式, 可自定义 @@ -1711,6 +1711,9 @@ html.filter-grayscale{ height: 40px; width: 40px; } +.comment-text-avatar{ + user-select: none; +} .comment-item-inner{ display: block; position: relative; @@ -2741,6 +2744,54 @@ html.darkmode.amoled-dark .friend-links-style1 .friend-link-description:after { .github-info-card-bottom .github-info-card-meta i { margin-right: 2px; } +/*短代码-Github-Mini*/ +.github-info-card-mini { + display: flex; + flex-direction: row; + white-space: nowrap; + align-items: center; + padding: 15px 20px; +} +.github-info-card-mini .github-info-card-name-a { + display: inline-block; + margin-right: 12px; + font-size: 19px; +} +.github-info-card-mini .github-info-card-description { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + word-break: break-all; + display: inline-block; +} +.github-info-card-mini .github-info-card-body { + flex: 1; + white-space: nowrap; + overflow: hidden; + display: flex; + align-items: center; +} +.github-info-card-mini .github-info-card-bottom { + display: inline-block; + margin-top: 0; + margin-left: 10px; +} +.github-info-card-mini .github-info-card-header { + margin-right: 7px; + margin-bottom: 0; +} +.github-info-card-mini .github-info-card-header a i { + font-size: 19px; + transform: translateY(2px); + margin-right: 2px; +} +.github-info-card-mini .github-info-card-bottom .github-info-card-meta-forks { + display: none; +} +.github-info-card-mini .github-info-card-bottom .github-info-card-meta-stars { + margin-right: 0; +} + /*短代码-进度条*/ html.darkmode .progress {