Skip to content

Commit 8f7cac6

Browse files
committed
1.0.1
1 parent 32a1ed2 commit 8f7cac6

File tree

5 files changed

+116
-17
lines changed

5 files changed

+116
-17
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Argon 使用 [GPL V3.0](https://github.com/solstice23/argon-theme/blob/master/LI
6969

7070
# 更新日志
7171

72+
## 20200824 v1.0.1
73+
+ 增加 "评论文字头像" 选项(为无头像评论者生成一个纯色文字头像)
74+
+ Github 短代码新增 Mini 尺寸
75+
7276
## 20200823 v1.0.0
7377
+ 正式版
7478

argontheme.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,25 @@ foldLongComments();
11601160
$(document).on("click" , ".show-full-comment" , function(){
11611161
$(this).parent().removeClass("comment-folded").addClass("comment-unfolded");
11621162
});
1163+
/*评论文字头像*/
1164+
document.addEventListener("error", function(e){
1165+
let img = $(e.target);
1166+
if (!img.hasClass("avatar")){
1167+
return;
1168+
}
1169+
if (!img.parent().hasClass("comment-item-avatar")){
1170+
return;
1171+
}
1172+
let emailHash = img.attr("src").match(/([a-f\d]{32}|[A-F\d]{32})/)[0];
1173+
let hash = 0;
1174+
for (i in emailHash){
1175+
hash = (hash * 233 + emailHash.charCodeAt(i)) % 16;
1176+
}
1177+
console.log(hash);
1178+
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'];
1179+
let text = $(".comment-name", img.parent().parent()).text().trim()[0];
1180+
img.parent().html('<div class="avatar avatar-40 photo comment-text-avatar" style="background-color: ' + colors[hash] + ';">' + text + '</div>');
1181+
}, true);
11631182
/*需要密码的文章加载*/
11641183
$(document).on("submit" , ".post-password-form" , function(){
11651184
$("input[type='submit']", this).attr("disabled", "disabled");

functions.php

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,18 +1428,26 @@ function the_content_filter($content){
14281428
add_filter('the_content' , 'the_content_filter');
14291429
//使用 CDN 加速 gravatar
14301430
function gravatar_cdn($url){
1431-
$cdn = get_option('argon_gravatar_cdn' , 'gravatar.loli.net/avatar/');
1431+
$cdn = get_option('argon_gravatar_cdn', 'gravatar.loli.net/avatar/');
14321432
$cdn = str_replace("http://", "", $cdn);
14331433
$cdn = str_replace("https://", "", $cdn);
14341434
if (substr($cdn, -1) != '/'){
14351435
$cdn .= "/";
14361436
}
1437-
$url = preg_replace("/\/\/(.*?).gravatar.com\/avatar\//" , "//" . $cdn , $url);
1437+
$url = preg_replace("/\/\/(.*?).gravatar.com\/avatar\//", "//" . $cdn, $url);
14381438
return $url;
14391439
}
14401440
if (get_option('argon_gravatar_cdn' , '') != ''){
14411441
add_filter('get_avatar_url', 'gravatar_cdn');
14421442
}
1443+
function text_gravatar($url){
1444+
$url = preg_replace("/[\?\&]d[^&]+/i", "" , $url);
1445+
$url .= '&d=404';
1446+
return $url;
1447+
}
1448+
if (get_option('argon_text_gravatar', 'false') == 'true'){
1449+
add_filter('get_avatar_url', 'text_gravatar');
1450+
}
14431451
//说说点赞
14441452
function get_shuoshuo_upvotes($ID){
14451453
$count_key = 'upvotes';
@@ -1865,7 +1873,7 @@ function shortcode_alert($attr,$content=""){
18651873
if (isset($attr['title'])){
18661874
$out .= "<strong>" . $attr['title'] . "</strong> ";
18671875
}
1868-
$out .= $content . "</div>";
1876+
$out .= $content . "</span></div>";
18691877
return $out;
18701878
}
18711879
add_shortcode('admonition','shortcode_admonition');
@@ -2172,6 +2180,7 @@ function shortcode_github($attr,$content=""){
21722180
$author = isset($attr['author']) ? $attr['author'] : '';
21732181
$project = isset($attr['project']) ? $attr['project'] : '';
21742182
$getdata = isset($attr['getdata']) ? $attr['getdata'] : 'frontend';
2183+
$size = isset($attr['size']) ? $attr['size'] : 'full';
21752184

21762185
$description = "";
21772186
$stars = "";
@@ -2210,8 +2219,12 @@ function shortcode_github($attr,$content=""){
22102219
restore_error_handler();
22112220
}
22122221

2213-
$out = "<div class='github-info-card card shadow-sm' data-author='" . $author . "' data-project='" . $project . "' githubinfo-card-id='" . $github_info_card_id . "' data-getdata='" . $getdata . "' data-description='" . $description . "' data-stars='" . $stars . "' data-forks='" . $forks . "'>";
2214-
$out .= "<div class='github-info-card-header'><a href='https://github.com/' ref='nofollow' target='_blank' title='Github' no-pjax><span><i class='fa fa-github'></i> Github</span></a></div>";
2222+
$out = "<div class='github-info-card github-info-card-" . $size . " card shadow-sm' data-author='" . $author . "' data-project='" . $project . "' githubinfo-card-id='" . $github_info_card_id . "' data-getdata='" . $getdata . "' data-description='" . $description . "' data-stars='" . $stars . "' data-forks='" . $forks . "'>";
2223+
$out .= "<div class='github-info-card-header'><a href='https://github.com/' ref='nofollow' target='_blank' title='Github' no-pjax><span><i class='fa fa-github'></i>";
2224+
if ($size != "mini"){
2225+
$out .= " GitHub";
2226+
}
2227+
$out .= "</span></a></div>";
22152228
$out .= "<div class='github-info-card-body'>
22162229
<div class='github-info-card-name-a'>
22172230
<a href='https://github.com/" . $author . "/" . $project . "' target='_blank' no-pjax>
@@ -2221,10 +2234,10 @@ function shortcode_github($attr,$content=""){
22212234
<div class='github-info-card-description'></div>
22222235
</div>";
22232236
$out .= "<div class='github-info-card-bottom'>
2224-
<span class='github-info-card-meta'>
2237+
<span class='github-info-card-meta github-info-card-meta-stars'>
22252238
<i class='fa fa-star'></i> <span class='github-info-card-stars'></span>
22262239
</span>
2227-
<span class='github-info-card-meta'>
2240+
<span class='github-info-card-meta github-info-card-meta-forks'>
22282241
<i class='fa fa-code-fork'></i> <span class='github-info-card-forks'></span>
22292242
</span>
22302243
</div>";
@@ -3487,6 +3500,24 @@ function themeoptions_page(){
34873500
<p class="description"><?php _e('开启后,过长的评论会被折叠,需要手动展开', 'argon');?></p>
34883501
</td>
34893502
</tr>
3503+
<tr>
3504+
<th><label>Gravatar CDN</label></th>
3505+
<td>
3506+
<input type="text" class="regular-text" name="argon_gravatar_cdn" value="<?php echo get_option('argon_gravatar_cdn' , ''); ?>"/>
3507+
<p class="description"><?php _e('使用 CDN 来加速 Gravatar 在某些地区的访问,填写 CDN 地址,留空则不使用。', 'argon');?></br><?php _e('在中国速度较快的一些 CDN :', 'argon');?><code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">gravatar.loli.net/avatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">cdn.v2ex.com/gravatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">dn-qiniu-avatar.qbox.me/avatar/</code></p>
3508+
</td>
3509+
</tr>
3510+
<tr>
3511+
<th><label>评论文字头像</label></th>
3512+
<td>
3513+
<select name="argon_text_gravatar">
3514+
<?php $argon_text_gravatar = get_option('argon_text_gravatar'); ?>
3515+
<option value="false" <?php if ($argon_text_gravatar=='false'){echo 'selected';} ?>><?php _e('禁用', 'argon');?></option>
3516+
<option value="true" <?php if ($argon_text_gravatar=='true'){echo 'selected';} ?>><?php _e('启用', 'argon');?></option>
3517+
</select>
3518+
<p class="description"><?php _e('在评论者没有设置 Gravatar 时自动生成文字头像,头像颜色由邮箱哈希计算。生成时会在 Console 中抛出 404 错误,但没有影响。', 'argon');?></p>
3519+
</td>
3520+
</tr>
34903521
<tr><th class="subtitle"><h2><?php _e('杂项', 'argon');?></h2></th></tr>
34913522
<tr>
34923523
<th><label><?php _e('是否启用 Pjax', 'argon');?></label></th>
@@ -3560,13 +3591,6 @@ function themeoptions_page(){
35603591
<p class="description"><?php _e('开启后,博客首页文章和说说穿插显示', 'argon');?></p>
35613592
</td>
35623593
</tr>
3563-
<tr>
3564-
<th><label>Gravatar CDN</label></th>
3565-
<td>
3566-
<input type="text" class="regular-text" name="argon_gravatar_cdn" value="<?php echo get_option('argon_gravatar_cdn' , ''); ?>"/>
3567-
<p class="description"><?php _e('使用 CDN 来加速 Gravatar 在某些地区的访问,填写 CDN 地址,留空则不使用。', 'argon');?></br><?php _e('在中国速度较快的一些 CDN :', 'argon');?><code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">gravatar.loli.net/avatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">cdn.v2ex.com/gravatar/</code> , <code onclick="$('input[name=\'argon_gravatar_cdn\']').val(this.innerText);" style="cursor: pointer;">dn-qiniu-avatar.qbox.me/avatar/</code></p>
3568-
</td>
3569-
</tr>
35703594
<tr>
35713595
<th><label><?php _e('是否修正时区错误', 'argon');?></label></th>
35723596
<td>
@@ -3984,6 +4008,7 @@ function argon_update_themeoptions(){
39844008
argon_update_option('argon_related_post_sort_order');
39854009
argon_update_option('argon_related_post_limit');
39864010
argon_update_option('argon_article_header_style');
4011+
argon_update_option('argon_text_gravatar');
39874012

39884013
//LazyLoad 相关
39894014
argon_update_option('argon_enable_lazyload');

info.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version" : "1.0.0",
2+
"version" : "1.0.1",
33
"details_url" : "https://github.com/solstice23/argon-theme/releases",
4-
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v1.0.0/argon.zip"
4+
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v1.0.1/argon.zip"
55
}

style.css

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Theme Name: argon
33
Author: solstice23
44
Author URI: https://solstice23.top/
55
Description: 轻盈、简洁、美观的 Wordpress 主题
6-
Version: 1.0.0
6+
Version: 1.0.1
77
License: GNU General Public License v3.0
88
License URI: https://www.gnu.org/licenses/gpl-3.0.html
99
Tags: 简约, 两栏, 侧栏在左边, 浮动侧栏, 文章目录, 自适应, 夜间模式, 可自定义
@@ -1711,6 +1711,9 @@ html.filter-grayscale{
17111711
height: 40px;
17121712
width: 40px;
17131713
}
1714+
.comment-text-avatar{
1715+
user-select: none;
1716+
}
17141717
.comment-item-inner{
17151718
display: block;
17161719
position: relative;
@@ -2741,6 +2744,54 @@ html.darkmode.amoled-dark .friend-links-style1 .friend-link-description:after {
27412744
.github-info-card-bottom .github-info-card-meta i {
27422745
margin-right: 2px;
27432746
}
2747+
/*短代码-Github-Mini*/
2748+
.github-info-card-mini {
2749+
display: flex;
2750+
flex-direction: row;
2751+
white-space: nowrap;
2752+
align-items: center;
2753+
padding: 15px 20px;
2754+
}
2755+
.github-info-card-mini .github-info-card-name-a {
2756+
display: inline-block;
2757+
margin-right: 12px;
2758+
font-size: 19px;
2759+
}
2760+
.github-info-card-mini .github-info-card-description {
2761+
white-space: nowrap;
2762+
text-overflow: ellipsis;
2763+
overflow: hidden;
2764+
word-break: break-all;
2765+
display: inline-block;
2766+
}
2767+
.github-info-card-mini .github-info-card-body {
2768+
flex: 1;
2769+
white-space: nowrap;
2770+
overflow: hidden;
2771+
display: flex;
2772+
align-items: center;
2773+
}
2774+
.github-info-card-mini .github-info-card-bottom {
2775+
display: inline-block;
2776+
margin-top: 0;
2777+
margin-left: 10px;
2778+
}
2779+
.github-info-card-mini .github-info-card-header {
2780+
margin-right: 7px;
2781+
margin-bottom: 0;
2782+
}
2783+
.github-info-card-mini .github-info-card-header a i {
2784+
font-size: 19px;
2785+
transform: translateY(2px);
2786+
margin-right: 2px;
2787+
}
2788+
.github-info-card-mini .github-info-card-bottom .github-info-card-meta-forks {
2789+
display: none;
2790+
}
2791+
.github-info-card-mini .github-info-card-bottom .github-info-card-meta-stars {
2792+
margin-right: 0;
2793+
}
2794+
27442795

27452796
/*短代码-进度条*/
27462797
html.darkmode .progress {

0 commit comments

Comments
 (0)