Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed Aug 24, 2020
1 parent 32a1ed2 commit 8f7cac6
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 17 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
+ 正式版

Expand Down
19 changes: 19 additions & 0 deletions argontheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div class="avatar avatar-40 photo comment-text-avatar" style="background-color: ' + colors[hash] + ';">' + text + '</div>');
}, true);
/*需要密码的文章加载*/
$(document).on("submit" , ".post-password-form" , function(){
$("input[type='submit']", this).attr("disabled", "disabled");
Expand Down
53 changes: 39 additions & 14 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1865,7 +1873,7 @@ function shortcode_alert($attr,$content=""){
if (isset($attr['title'])){
$out .= "<strong>" . $attr['title'] . "</strong> ";
}
$out .= $content . "</div>";
$out .= $content . "</span></div>";
return $out;
}
add_shortcode('admonition','shortcode_admonition');
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -2210,8 +2219,12 @@ function shortcode_github($attr,$content=""){
restore_error_handler();
}

$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 . "'>";
$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>";
$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 . "'>";
$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>";
if ($size != "mini"){
$out .= " GitHub";
}
$out .= "</span></a></div>";
$out .= "<div class='github-info-card-body'>
<div class='github-info-card-name-a'>
<a href='https://github.com/" . $author . "/" . $project . "' target='_blank' no-pjax>
Expand All @@ -2221,10 +2234,10 @@ function shortcode_github($attr,$content=""){
<div class='github-info-card-description'></div>
</div>";
$out .= "<div class='github-info-card-bottom'>
<span class='github-info-card-meta'>
<span class='github-info-card-meta github-info-card-meta-stars'>
<i class='fa fa-star'></i> <span class='github-info-card-stars'></span>
</span>
<span class='github-info-card-meta'>
<span class='github-info-card-meta github-info-card-meta-forks'>
<i class='fa fa-code-fork'></i> <span class='github-info-card-forks'></span>
</span>
</div>";
Expand Down Expand Up @@ -3487,6 +3500,24 @@ function themeoptions_page(){
<p class="description"><?php _e('开启后,过长的评论会被折叠,需要手动展开', 'argon');?></p>
</td>
</tr>
<tr>
<th><label>Gravatar CDN</label></th>
<td>
<input type="text" class="regular-text" name="argon_gravatar_cdn" value="<?php echo get_option('argon_gravatar_cdn' , ''); ?>"/>
<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>
</td>
</tr>
<tr>
<th><label>评论文字头像</label></th>
<td>
<select name="argon_text_gravatar">
<?php $argon_text_gravatar = get_option('argon_text_gravatar'); ?>
<option value="false" <?php if ($argon_text_gravatar=='false'){echo 'selected';} ?>><?php _e('禁用', 'argon');?></option>
<option value="true" <?php if ($argon_text_gravatar=='true'){echo 'selected';} ?>><?php _e('启用', 'argon');?></option>
</select>
<p class="description"><?php _e('在评论者没有设置 Gravatar 时自动生成文字头像,头像颜色由邮箱哈希计算。生成时会在 Console 中抛出 404 错误,但没有影响。', 'argon');?></p>
</td>
</tr>
<tr><th class="subtitle"><h2><?php _e('杂项', 'argon');?></h2></th></tr>
<tr>
<th><label><?php _e('是否启用 Pjax', 'argon');?></label></th>
Expand Down Expand Up @@ -3560,13 +3591,6 @@ function themeoptions_page(){
<p class="description"><?php _e('开启后,博客首页文章和说说穿插显示', 'argon');?></p>
</td>
</tr>
<tr>
<th><label>Gravatar CDN</label></th>
<td>
<input type="text" class="regular-text" name="argon_gravatar_cdn" value="<?php echo get_option('argon_gravatar_cdn' , ''); ?>"/>
<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>
</td>
</tr>
<tr>
<th><label><?php _e('是否修正时区错误', 'argon');?></label></th>
<td>
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -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"
}
53 changes: 52 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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: 简约, 两栏, 侧栏在左边, 浮动侧栏, 文章目录, 自适应, 夜间模式, 可自定义
Expand Down Expand Up @@ -1711,6 +1711,9 @@ html.filter-grayscale{
height: 40px;
width: 40px;
}
.comment-text-avatar{
user-select: none;
}
.comment-item-inner{
display: block;
position: relative;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8f7cac6

Please sign in to comment.