-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
archive.php
145 lines (135 loc) · 4.09 KB
/
archive.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
<?php
/**
* archive
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
if($this->is('tag')){
$url = strtolower($_SERVER['REQUEST_URI']);
if(substr($url, -1) == '/')$url = substr($url, 0, strlen($url)-1);
if(!array_key_exists('MorechoCore', Typecho_Plugin::export()['activated']))
Header("Location: ".$this->options->siteUrl.'archive.html/?tag='.trim(strrchr($url, '/'),'/'));
else
Header("Location: ".$this->options->siteUrl.'archive/?tag='.trim(strrchr($url, '/'),'/'));
}
$GLOBALS['is_archive'] = true;
$article = $this;
$this->need('_layouts/default-0.php');
?>
<div class="title">
<h1>
<?php $this->archiveTitle(array(
'category' => _t('%s'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
), '', ''); ?>
</h1>
<p>
<?php echo $this->getDescription(); ?>
</p>
</div>
<?php if(!$this->is('tag')): ?>
<div id='tag_cloud' class="tags js-tags">
<a class="tag-button--all" data-encode="">
Show All
<sup><?php echo $article->length ?></sup>
</a>
<?php
$tags = array();
if ($article->have()) while($article->next()) {
foreach ($article->tags as $tag) {
if(array_key_exists($tag['name'], $tags))
$tags[$tag['name']] += 1;
else $tags[$tag['name']] = 1;
}
}
foreach($tags as $tag => $num):
?>
<a data-sort="<?php echo get_post_num() - $num ?>"
data-encode="<?php echo urlencode($tag) ?>" class="tag-button" title="<?php echo $tag ?>" rel="<?php echo $num ?>">
<?php echo $tag ?>
<sup><?php echo $num ?></sup>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div style="overflow:hidden">
<div class="archive timeline">
<div class="js-result <?php if($this->is_archive_all) echo 'd-none'; ?>">
<?php if ($article->have()): $lastDate = 1000000 ?>
<?php
while($article->next()):
if(date('Ym', $article->date->timeStamp) < $lastDate):
if($lastDate != 1000000)echo '</section>';
$lastDate = date('Ym', $article->date->timeStamp);
?>
<section>
<div class="tl-head">
<div class="tl-title"><?php $article->date('y年m月'); ?></div>
</div>
<?php endif ?>
<div class="post-preview item tl-item" data-tags="<?php
if ($article->tags) {
$result = array();
foreach ($article->tags as $tag) {
$result[] = urlencode($tag['name']);
}
echo implode(',', $result);
}
?>">
<div class="tl-date"><?php $article->date('d日') ?></div>
<div class="tl-body">
<div class="tl-content">
<a href="<?php $article->permalink() ?>">
<h2 class="post-title">
<?php $article->title() ?>
</h2>
<?php if($article->fields->subtitle): ?>
<h3 class="post-subtitle">
<?php $article->fields->subtitle() ?>
</h3>
<?php endif ?>
</a>
</div>
</div>
</div>
<?php endwhile; ?>
</section>
<div class="tl-head">
<div class="tl-title bg-white" style="color: #777;">BEGIN</div>
</div>
<?php else: ?>
<article>
<h2 class="post-title"><?php _e('没有找到内容'); ?></h2>
</article>
<?php endif; ?>
</div>
</div>
</div>
<style>
.archive{
padding: 1rem;
}
.archive.timeline{
margin-left: 3rem;
}
.timeline .tl-title{
color: #fff;
}
.archive .post-title{
font-size: 1.1rem;
color: #fff;
margin-bottom: 0;
}
.archive .post-subtitle{
font-size: 0.9rem;
margin-top: .2em;
margin-bottom: 0;
}
body{
overflow-y: scroll;
}
</style>
<?php $this->need('_layouts/default-1.php'); ?>