parent
579f92c720
commit
b7250fde19
|
@ -0,0 +1 @@
|
|||
.lb-loader,.lightbox{text-align:center;line-height:0;position:absolute;left:0}body.lb-disable-scrolling{overflow:hidden}.lightboxOverlay{position:absolute;top:0;left:0;z-index:9999;background-color:#000;filter:alpha(Opacity=80);opacity:.8;display:none}.lightbox{width:100%;z-index:10000;font-weight:400;outline:0}.lightbox .lb-image{display:block;height:auto;max-width:inherit;max-height:none;border-radius:3px;border:4px solid #fff}.lightbox a img{border:none}.lb-outerContainer{position:relative;width:250px;height:250px;margin:0 auto;border-radius:4px;background-color:#fff}.lb-outerContainer:after{content:"";display:table;clear:both}.lb-loader{top:43%;height:25%;width:100%}.lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background:url(../images/loading.gif) no-repeat}.lb-nav{position:absolute;top:0;left:0;height:100%;width:100%;z-index:10}.lb-container>.nav{left:0}.lb-nav a{outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.lb-next,.lb-prev{height:100%;cursor:pointer;display:block}.lb-nav a.lb-prev{width:34%;left:0;float:left;background:url(../images/prev.png) left 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-prev:hover{filter:alpha(Opacity=100);opacity:1}.lb-nav a.lb-next{width:64%;right:0;float:right;background:url(../images/next.png) right 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-next:hover{filter:alpha(Opacity=100);opacity:1}.lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.lb-dataContainer:after{content:"";display:table;clear:both}.lb-data{padding:0 4px;color:#ccc}.lb-data .lb-details{width:85%;float:left;text-align:left;line-height:1.1em}.lb-data .lb-caption{font-size:13px;font-weight:700;line-height:1em}.lb-data .lb-caption a{color:#4ae}.lb-data .lb-number{display:block;clear:left;padding-bottom:1em;font-size:12px;color:#999}.lb-data .lb-close{display:block;float:right;width:30px;height:30px;background:url(../images/close.png) top right no-repeat;text-align:right;outline:0;filter:alpha(Opacity=70);opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.lb-data .lb-close:hover{cursor:pointer;filter:alpha(Opacity=100);opacity:1}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -195,6 +195,53 @@ function notifyQQBot($comment) {
|
|||
}
|
||||
Typecho_Plugin::factory('Widget_Feedback')->finishComment = 'notifyQQBot';
|
||||
|
||||
/**
|
||||
* 图片灯箱
|
||||
*/
|
||||
class ImageStructureProcessor {
|
||||
public static function processContent($content, $widget) {
|
||||
if ($widget instanceof Widget_Archive) {
|
||||
// 使用 DOM 操作确保结构完整性
|
||||
$dom = new DOMDocument();
|
||||
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'),
|
||||
LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$xpath = new DOMXPath($dom);
|
||||
|
||||
// 查找所有没有父 figure 的图片
|
||||
$images = $xpath->query("//img[not(ancestor::figure)]");
|
||||
|
||||
foreach ($images as $img) {
|
||||
// 创建容器元素
|
||||
$figure = $dom->createElement('figure');
|
||||
$figure->setAttribute('class', 'grap--figure');
|
||||
|
||||
// 创建链接元素用于lightbox
|
||||
$link = $dom->createElement('a');
|
||||
$link->setAttribute('href', $img->getAttribute('src'));
|
||||
$link->setAttribute('data-lightbox', 'image-set');
|
||||
$link->setAttribute('data-title', $img->getAttribute('alt'));
|
||||
|
||||
// 创建 figcaption
|
||||
$caption = $dom->createElement('figcaption', $img->getAttribute('alt'));
|
||||
$caption->setAttribute('class', 'imageCaption');
|
||||
|
||||
// 重组 DOM 结构
|
||||
$img->parentNode->replaceChild($figure, $img);
|
||||
$link->appendChild($img);
|
||||
$figure->appendChild($link);
|
||||
$figure->appendChild($caption);
|
||||
}
|
||||
|
||||
$content = $dom->saveHTML();
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
// 挂载到内容输出
|
||||
Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('ImageStructureProcessor', 'processContent');
|
||||
|
||||
//获取文章卡片
|
||||
function get_article_info($atts) {
|
||||
$default_atts = array(
|
||||
|
@ -388,49 +435,7 @@ function commentApprove($widget, $email = NULL)
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片灯箱
|
||||
*/
|
||||
class ImageStructureProcessor {
|
||||
public static function processContent($content, $widget) {
|
||||
if ($widget instanceof Widget_Archive) {
|
||||
$dom = new DOMDocument();
|
||||
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'),
|
||||
LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
$xpath = new DOMXPath($dom);
|
||||
|
||||
// 查找所有没有父 figure 的图片
|
||||
$images = $xpath->query("//img[not(ancestor::figure)]");
|
||||
|
||||
foreach ($images as $img) {
|
||||
// 创建容器元素
|
||||
$figure = $dom->createElement('figure');
|
||||
$figure->setAttribute('class', 'grap--figure');
|
||||
|
||||
// 为图片添加 viewimage 属性
|
||||
$img->setAttribute('data-viewimage', '');
|
||||
// 可选:添加额外属性用于分组
|
||||
$img->setAttribute('data-viewimage-group', 'post');
|
||||
|
||||
// 创建 figcaption
|
||||
$caption = $dom->createElement('figcaption', $img->getAttribute('alt'));
|
||||
$caption->setAttribute('class', 'imageCaption');
|
||||
|
||||
// 重组 DOM 结构
|
||||
$img->parentNode->replaceChild($figure, $img);
|
||||
$figure->appendChild($img);
|
||||
$figure->appendChild($caption);
|
||||
}
|
||||
|
||||
$content = $dom->saveHTML();
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
// 挂载到内容输出
|
||||
Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('ImageStructureProcessor', 'processContent');
|
||||
|
||||
/** 获取评论者地址 */
|
||||
//function get_ip_location($ip) {
|
||||
|
|
19
header.php
19
header.php
|
@ -3,7 +3,6 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<html lang="zh-CN">
|
||||
<meta charset="<?php $this->options->charset(); ?>">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="renderer" content="webkit">
|
||||
|
@ -23,7 +22,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
<?php $this->options->addhead(); ?>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
<script>
|
||||
window.DEFAULT_THEME = "light";
|
||||
if (localStorage.getItem("theme") == null) {
|
||||
localStorage.setItem("theme", window.DEFAULT_THEME);
|
||||
|
@ -60,14 +59,14 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
</ul>
|
||||
</nav>
|
||||
<!-- 这年头谁会用站内的搜索啊 -->
|
||||
<div class="search--area">
|
||||
<form id="search" method="post" action="./" role="search" class="search-form">
|
||||
<label>
|
||||
<input type="text" name="s" class="search-field text" placeholder="Search" required/>
|
||||
</label>
|
||||
<button type="submit" class="search-submit submit">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="search--area">
|
||||
<form id="search" method="post" action="./" role="search" class="search-form">
|
||||
<label>
|
||||
<input type="text" name="s" class="search-field text" placeholder="Search" required/>
|
||||
</label>
|
||||
<button type="submit" class="search-submit submit">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<svg class="svgIcon" width="25" height="25" data-action="show-search">
|
||||
|
|
22
post.php
22
post.php
|
@ -97,7 +97,6 @@
|
|||
//复制方法
|
||||
copy: function () {
|
||||
var that = this;
|
||||
//注意vue umd版本ClipboardJS,而ES包请使用Clipboard
|
||||
var clipboard = new ClipboardJS(".link",{
|
||||
text: function (trigger) {
|
||||
//返回字符串
|
||||
|
@ -118,7 +117,6 @@
|
|||
toast.textContent = "复制成功!";
|
||||
toast.className = "notice--wrapper";
|
||||
document.body.appendChild(toast);
|
||||
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(toast);
|
||||
}, 3000);
|
||||
|
@ -141,7 +139,6 @@
|
|||
<?php
|
||||
// 初始化分类图片地址为空
|
||||
$categoryImage = '';
|
||||
|
||||
// 检查文章是否有分类
|
||||
if ($this->categories) {
|
||||
// 获取第一个分类的信息
|
||||
|
@ -149,15 +146,12 @@
|
|||
$categoryId = $category['mid'];
|
||||
$categoryName = $category['name'];
|
||||
$categoryDescription = $category['description']; // 如果分类有说明(描述)
|
||||
|
||||
// 获取主题选项中的分类图片基本 URL
|
||||
$themeUrl = $this->options->midimg;
|
||||
|
||||
// 生成分类图片地址
|
||||
$categoryImage = $themeUrl . $categoryId . '.jpg';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 显示分类信息 -->
|
||||
<?php if ($category): ?>
|
||||
<div class="category--card__list">
|
||||
|
@ -202,7 +196,6 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||
const targetClassElement = document.querySelector('.post--single__title');
|
||||
const postContent = document.querySelector('.post--single__content');
|
||||
if (!postContent) return;
|
||||
|
||||
let found = false;
|
||||
for (let i = 1; i <= 6 &&!found; i++) {
|
||||
if (postContent.querySelector(`h${i}`)) {
|
||||
|
@ -210,21 +203,17 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||
}
|
||||
}
|
||||
if (!found) return;
|
||||
|
||||
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
const toc = document.createElement('div');
|
||||
toc.id = 'toc';
|
||||
toc.innerHTML = '<details class="toc" open><summary class="toc-title">目录</summary><nav id="TableOfContents"><ul></ul></nav></details>';
|
||||
|
||||
// 插入到指定 class 元素之后
|
||||
if (targetClassElement) {
|
||||
targetClassElement.parentNode.insertBefore(toc, targetClassElement.nextSibling);
|
||||
}
|
||||
|
||||
let currentLevel = 0;
|
||||
let currentList = toc.querySelector('ul');
|
||||
let levelCounts = [0];
|
||||
|
||||
heads.forEach((head, index) => {
|
||||
const level = parseInt(head.tagName.substring(1));
|
||||
if (levelCounts[level] === undefined) {
|
||||
|
@ -293,16 +282,12 @@ function fetchWithRetry(url, retries = 3) {
|
|||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const doubanLinks = document.querySelectorAll('a[href^="https://movie.douban.com/subject/"]');
|
||||
|
||||
doubanLinks.forEach(link => {
|
||||
const url = link.href;
|
||||
const movieId = url.match(/subject\/(\d+)/)[1];
|
||||
|
||||
link.innerHTML += ' <span class="loading">(加载中...)</span>';
|
||||
|
||||
fetchWithRetry(`<?php $this->options->themeUrl('db.php'); ?>?id=${movieId}`)
|
||||
.then(data => {
|
||||
const movieInfo = createMovieInfoHTML(data, url);
|
||||
|
@ -323,12 +308,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
function createMovieInfoHTML(data, originalUrl) {
|
||||
if (!data || data.error || Object.keys(data).length === 0) {
|
||||
return `<a href="${originalUrl}" target="_blank">查看豆瓣电影详情</a>`;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class=doulist-item>
|
||||
<div class=doulist-subject>
|
||||
|
@ -348,10 +331,9 @@ function createMovieInfoHTML(data, originalUrl) {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/lightbox.min.css'); ?>">
|
||||
<script src="<?php $this->options->themeUrl('/dist/js/lightbox-plus-jquery.min.js'); ?>"></script>
|
||||
<?php $this->need('footer.php'); ?>
|
Loading…
Reference in New Issue