forked from Archeb/Candy-Rebirth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
article-list.php
48 lines (44 loc) · 2.31 KB
/
article-list.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
<?php
if (!defined('__TYPECHO_ROOT_DIR__'))
exit;
?>
<?php function listArticles($art){
$delay=0;
print<<<EOF
<script lang="javascript">
function showArticleWithJs(permalink){
//Your script goes here
showArticle(permalink);
}
</script>
EOF;
while($art->next()):
$delay++; ?>
<?php if ($art->fields->previewImage && $art->fields->previewImage!==""): ?>
<div class="article-with-preview right-in-animation" style="animation-duration:<?php echo 0.5+$delay*0.1?>s">
<div class="cover" onclick="showArticleWithJs('<?php $art->permalink() ?>')">
<div class="cover-image" style="background-image:url(<?php $art->fields->previewImage(); ?>)"><div class="title"><?php $art->title(); ?></div></div>
</div>
<div class="content" onclick="showArticleWithJs('<?php $art->permalink() ?>')">
<div class="text">
<?php $art->excerpt(50, '') ?>
</div>
</div>
<div class="meta">
<div class="group">
<?php array_map(function($v){echo '<a class="category" onclick="showArchive(\''.$v['permalink'].'\')" style="'.$v['description'].'">'.$v['name'].'</a>';},$art->categories) ?>
</div>
<div class="group date"><?php echo time_elapsed_string('@'.$art->created) ?>前 · <?php $art->author(); ?></div>
</div>
</div>
<?php else: ?>
<div class="article right-in-animation">
<div class="title"><a onclick="showArticleWithJs('<?php $art->permalink() ?>')"><?php $art->title(); ?></a>
<div class="meta"><?php array_map(function($v){echo '<a class="category" onclick="showArchive(\''.$v['permalink'].'\')" style="'.$v['description'].'">'.$v['name'].'</a>';},$art->categories) ?> <?php $art->author(); ?> · <?php echo time_elapsed_string('@'.$art->created) ?>前</div>
</div>
<div class="content" onclick="showArticleWithJs('<?php $art->permalink() ?>')">
<?php $art->content(); ?>
</div>
</div>
<?php endif; endwhile;?>
<?php } ?>