Skip to content

Commit

Permalink
0.830
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed Feb 10, 2020
1 parent 2b4e35b commit 03fb17a
Show file tree
Hide file tree
Showing 8 changed files with 2,199 additions and 15 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Argon 使用 [GPL V3.0](https://github.com/solstice23/argon-theme/blob/master/LI

# 更新日志

## 20200128 v0.830
+ 增加评论区 Markdown 支持
+ 优化夜间模式在页面刚载入时的体验

## 20200128 v0.820
+ 增加博客背景图片设置选项
+ 增加 沉浸式 Banner (透明) 和 毛玻璃 Banner 选项 来增强背景图片的显示效果
Expand Down
52 changes: 44 additions & 8 deletions argontheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,14 @@
if ($("html").hasClass("darkmode")){
$('#fab_toggle_darkmode .btn-inner--icon').html("<i class='fa fa-lightbulb-o'></i>");
$("#blog_setting_darkmode_switch")[0].checked = true;
localStorage['Argon_Enable_Dark_Mode'] = "true";
setCookie("argon_enable_dark_mode", "true", 365*24*60*60);
}else{
$('#fab_toggle_darkmode .btn-inner--icon').html("<i class='fa fa-moon-o'></i>");
$("#blog_setting_darkmode_switch")[0].checked = false;
localStorage['Argon_Enable_Dark_Mode'] = "false";
setCookie("argon_enable_dark_mode", "false", 365*24*60*60);
}
$(window).trigger("scroll");
}
if (localStorage['Argon_Enable_Dark_Mode'] == "true"){
toggleDarkmode();
}
$toggleDarkmode.on("click" , function(){
toggleDarkmode();
});
Expand Down Expand Up @@ -260,6 +257,7 @@
commentEmail = $("#post_comment_email").val();
commentLink = $("#post_comment_link").val();
commentCaptcha = $("#post_comment_captcha").val();
useMarkdown = $("#comment_post_use_markdown")[0].checked;

postID = $("#post_comment_post_id").val();
commentCaptchaSeed = $("#post_comment_captcha_seed").val();
Expand Down Expand Up @@ -347,7 +345,8 @@
comment_post_ID: postID,
comment_parent: replyID,
comment_captcha_seed: commentCaptchaSeed,
comment_captcha: commentCaptcha
comment_captcha: commentCaptcha,
use_markdown: useMarkdown,
},
success: function(result){
$("#post_comment_content").removeAttr("disabled");
Expand Down Expand Up @@ -567,7 +566,9 @@ function pjaxLoadUrl(url , pushstate){
let scripts = $("#content script:not([no-pjax]):not(.no-pjax)" , $vdom);
for (let script of scripts){
if (script.innerHTML.indexOf("\/*NO-PJAX*\/") == -1){
eval(script.innerHTML);
try{
eval(script.innerHTML);
}catch (err){}
}
}

Expand Down Expand Up @@ -610,6 +611,9 @@ function pjaxLoadUrl(url , pushstate){
}
$(document).ready(function(){
$(document).on("click" , "a[href]:not([no-pjax]):not(.no-pjax):not([href^='#']):not([target='_blank'])" , function(){
if (pjaxLoading){
return false;
}
//对文章预览卡片使用过渡动画
if ($(this).is("#main article.post-preview a.post-title")){
let $card = $($(this).parents("article.post-preview")[0]);
Expand Down Expand Up @@ -1012,4 +1016,36 @@ function updateThemeColor(color, setcookie){
if (setcookie){
setCookie("argon_custom_theme_color", themecolor, 365*24*60*60);
}
}
}

/*评论区图片链接点击处理*/
!function(){
let invid = 0;
let activeImg = null;
$(document).on("click" , ".comment-item-text .comment-image" , function(){
if (!$(this).hasClass("comment-image-preview-zoomed")){
activeImg = this;
$(this).addClass("comment-image-preview-zoomed");
if (!$(this).hasClass("loaded")){
$(".comment-image-preview", this).attr('src', $(this).attr("data-src"));
}
$(".comment-image-preview", this).zoomify('zoomIn');
if (!$(this).hasClass("loaded")){
invid = setInterval(function(){
if (activeImg.width != 0){
$("html").trigger("scroll");
console.log($(activeImg).parent());
$(activeImg).addClass("loaded");
clearInterval(invid);
activeImg = null;
}
}, 50);
}
}else{
clearInterval(invid);
activeImg = null;
$(this).removeClass("comment-image-preview-zoomed");
$(".comment-image-preview", this).zoomify('zoomOut');
}
});
}();
4 changes: 4 additions & 0 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
</div></div>
<div class="row" style="margin-top: 5px; margin-bottom: 10px;">
<div class="col-md-12">
<div class="custom-control custom-checkbox comment-post-use-markdown">
<input class="custom-control-input" id="comment_post_use_markdown" type="checkbox" checked="true">
<label class="custom-control-label" for="comment_post_use_markdown" style="line-height: 25px;">Markdown</label>
</div>
<button id="post_comment_send" class="btn btn-icon btn-primary pull-right" type="button">
<span class="btn-inner--icon"><i class="fa fa-send"></i></span>
<span class="btn-inner--text">发送</span>
Expand Down
49 changes: 47 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,51 @@ function check_comment_captcha($comment){
if($comment_data['comment_type'] == ''){
add_filter('preprocess_comment' , 'check_comment_captcha');
}
//评论 Markdown 解析
require_once(get_template_directory() . '/parsedown.php');
function comment_markdown_render($comment_content){
if ($_POST['use_markdown'] != 'true'){
return $comment_content;
}
//HTML 过滤
global $allowedtags;
//$comment_content = wp_kses($comment_content, $allowedtags);
//允许评论中额外的 HTML Tag
$allowedtags['pre'] = array('class' => array());
$allowedtags['i'] = array('class' => array(), 'aria-hidden' => array());
$allowedtags['img'] = array('src' => array(), 'alt' => array(), 'class' => array());
$allowedtags['ul_'] = array();
$allowedtags['li_'] = array();
$allowedtags['a']['class'] = array();
$allowedtags['a']['data-src'] = array();
$allowedtags['a']['target'] = array();

//解析 Markdown
$parsedown = new Parsedown();
$res = $parsedown -> text($comment_content);
/*$res = preg_replace(
'/<code>([\s\S]*?)<\/code>/',
'<pre>$1</pre>',
$res
);*/
$res = preg_replace(
'/<img src="(.*?)" alt="(.*?)" \/>/',
'<a data-src="$1" title="$2" class="comment-image">
<i class="fa fa-image" aria-hidden="true"></i>
查看图片
<img src="" alt="$2" class="comment-image-preview">
<i class="comment-image-preview-mask"></i>
</a>',
$res
);
$res = preg_replace(
'/<a (.*?)>(.*?)<\/a>/',
'<a $1 target="_blank">$2</a>',
$res
);
return $res;
}
add_filter('pre_comment_content' , 'comment_markdown_render');
//获取顶部 Banner 背景图(用户指定或必应日图)
function get_banner_background_url(){
$url = get_option("argon_banner_background_url");
Expand Down Expand Up @@ -488,7 +533,7 @@ function argon_zoomify($content){
);
});
</script>';

return $content;
}
function the_content_filter($content){
Expand Down Expand Up @@ -939,7 +984,7 @@ function shortcode_friend_link($attr,$content=""){
<div class='card shadow-sm'>
<div class='d-flex'>
<div class='friend-link-avatar'>
<a target='_blink' href='" . $now[1] . "'>";
<a target='_blank' href='" . $now[1] . "'>";
if (!ctype_space($now[4]) && $now[4] != '' && isset($now[4])){
$out .= "<img src='" . $now[4] . "' class='icon bg-gradient-secondary rounded-circle text-white' style='pointer-events: none;'>
</img>";
Expand Down
8 changes: 7 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js">
<?php
$htmlclasses = "";
if ($_COOKIE["argon_enable_dark_mode"] == "true"){
$htmlclasses .= "darkmode ";
}
?>
<html <?php language_attributes(); ?> class="no-js <?php echo $htmlclasses;?>">
<?php
$themecolor = get_option('argon_theme_color');
if ($themecolor == ""){
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" : "0.820",
"version" : "0.830",
"details_url" : "https://github.com/solstice23/argon-theme/releases",
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v0.820/argon.zip"
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v0.830/argon.zip"
}
Loading

0 comments on commit 03fb17a

Please sign in to comment.