This repository has been archived by the owner on Jul 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Lens.php
147 lines (142 loc) · 5.37 KB
/
Lens.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php
/**
* Lens风格照片集
*
* @package custom
*/
?>
<!--
作者:ZhangDi
https://github.com/zzd/photo-page-for-typecho
时间:2022-01-01 版权所有,请勿删除
-->
<!-- jsdelivr公共CDN -->
<?php
function usePublicCdn()
{
echo "https://fastly.jsdelivr.net/gh/zzd/photo-page-for-typecho@master";
}
?>
<!-- 公共CDN结束 -->
<!-- 相册图片对象存储供应商,用以加载缩略图 -->
<!-- 由于Lens模板的缩略图没有固定比例,故将裁剪工作交给云 -->
<?php
function storage($storage)
{
if ($storage == "UPYUN") {
echo "!/fw/640/quality/85/clip/640x400a0a0/gravity/center";
} elseif ($storage == "OSS") {
echo "?x-oss-process=image/crop,x_0,y_0,w_640,h_400,g_center";
} elseif ($storage == "KODO") {
echo "?imageMogr2/gravity/center/crop/!640x400";
} elseif ($storage == "COS") {
echo "?imageMogr2/gravity/center/crop/!640x400";
} else
echo "";
}
?>
<!-- 自动缩略图结束 -->
<!DOCTYPE HTML>
<html>
<head>
<title><?php $this->title() ?> - <?php $this->options->title() ?></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="<?php usePublicCdn(); ?>/Lens/css/main.css" />
<link rel="shortcut icon" href="<?php $this->options->siteUrl(); ?>/favicon.ico">
<noscript>
<link rel="stylesheet" href="<?php usePublicCdn(); ?>/Lens/css/noscript.css" /></noscript>
<!-- 百度统计 -->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?e804e37f8afa68b911afdd756b4314c7";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body class="is-preload-0 is-preload-1 is-preload-2">
<!-- Main -->
<div id="main">
<!-- Header -->
<header id="header">
<h1><?php $this->title() ?></h1>
<?php if ($this->fields->about) : ?>
<p><?php echo $this->fields->about; ?></p>
<?php else : ?>
<p>在自定义字段内添加about字段,即可编辑此内容,现有内容将自动替换。</p>
<?php endif ?>
<ul class="icons">
<?php if ($this->fields->Twitter) : ?>
<li><a href="<?php echo $this->fields->Twitter; ?>" class="icon brands fa-twitter" target="_blank"><span class="label">Twitter</span></a></li>
<?php endif ?>
<?php if ($this->fields->Facebook) : ?>
<li><a href="<?php echo $this->fields->Facebook; ?>" class="icon brands fa-facebook-f" target="_blank"><span class="label">Facebook</span></a></li>
<?php endif ?>
<?php if ($this->fields->Instagram) : ?>
<li><a href="<?php echo $this->fields->Instagram; ?>" class="icon brands fa-instagram" target="_blank"><span class="label">Instagram</span></a></li>
<?php endif ?>
<?php if ($this->fields->GitHub) : ?>
<li><a href="<?php echo $this->fields->GitHub; ?>" class="icon brands fa-github" target="_blank"><span class="label">GitHub</span></a></li>
<?php endif ?>
</ul>
</header>
<!-- Thumbnail -->
<section id="thumbnails">
</section>
<!-- Footer -->
<footer id="footer">
<!-- 虽说本页面制作容易,但也需要一点点时间编辑,请保留版权信息。 -->
<ul class="copyright">
<li>© <?php echo date("Y")?> <a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a></li>
<li>Powered by <a href="https://github.com/zzd/photo-page-for-typecho">ZDSR</a> Based HTML5UP</a>.</li>
</ul>
</footer>
</div>
<!--
动态读取数据 by ZhangDi
https://github.com/zzd/photo-page-for-typecho
-->
<script type="text/javascript">
var datas =
`<?php
$html = $this->row['text'];
echo $html;
?>`;
datas = datas.split("\n");
for (var i = 0; i < datas.length; i++) {
datas[i] = datas[i].split(",");
}
function creatArticle(datas) {
var parent = document.getElementById("thumbnails");
for (var i = 0; i < datas.length; i++) {
var article = document.createElement("article");
article.className = "thumb";
parent.appendChild(article);
var a = document.createElement("a");
a.className = "thumbnail";
a.href = datas[i][2];
article.appendChild(a);
var img = document.createElement("img");
img.src = datas[i][2] + "<?php storage($this->fields->CDN); ?>";
a.appendChild(img);
var h2 = document.createElement("h2");
h2.innerHTML = datas[i][0];
article.appendChild(h2);
var p = document.createElement("p");
p.innerHTML = datas[i][1];
article.appendChild(p);
}
}
creatArticle(datas);
</script>
<!-- Scripts -->
<script src="<?php usePublicCdn(); ?>/Lens/js/jquery.min.js"></script>
<script src="<?php usePublicCdn(); ?>/Lens/js/browser.min.js"></script>
<script src="<?php usePublicCdn(); ?>/Lens/js/breakpoints.min.js"></script>
<script src="<?php usePublicCdn(); ?>/Lens/js/main.js"></script>
</body>
</html>