-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
85 lines (76 loc) · 2.5 KB
/
index.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
<?php
lot('links', $links = new Anemone((static function ($links, $state, $url) {
$index = LOT . D . 'page' . D . trim(strtr($state->route ?? 'index', '/', D), D) . '.page';
$path = $url->path . '/';
foreach (g(LOT . D . 'page', 'page') as $k => $v) {
// Exclude home page
if ($k === $index) {
continue;
}
$v = new Page($k);
// Add current state
$v->current = 0 === strpos($path, '/' . $v->name . '/');
$links[$k] = $v;
}
ksort($links);
return $links;
})([], $state, $url)));
$z = defined('TEST') && TEST ? '.' : '.min.';
Asset::set(__DIR__ . D . 'index' . $z . 'css', 20);
Asset::set(__DIR__ . D . 'index' . $z . 'js', 20);
State::set('widget', require __DIR__ . D . 'state' . D . 'widget.php');
$defaults = [
'route-blog' => '/article',
'x.comment.page.type' => 'Markdown',
'x.page.page.chunk' => 14,
'x.page.page.sort' => [1, 'time'],
'x.page.page.type' => 'Markdown'
];
foreach ($defaults as $k => $v) {
!State::get($k) && State::set($k, $v);
}
if (isset($state->x->alert)) {
Hook::set('y.alert', function ($y) {
foreach ($y[1] as &$v) {
if (!$n = $v[2]['type'] ?? $v['type'] ?? "") {
continue;
}
if (isset($v[2]['class'])) {
$v[2]['class'] .= ' ' . $n;
} else {
$v[2]['class'] = $n;
}
}
unset($v);
return $y;
});
}
if (isset($state->x->excerpt) && $state->is('page')) {
Hook::set('page.content', function ($content) {
return null !== $content ? strtr($content, ["\f" => '<span id="next:' . $this->id . '" role="doc-pagebreak"></span>']) : null;
});
}
if (isset($state->x->pass)) {
// Add legacy form class name
Hook::set('y.form.pass', function ($y) use ($state) {
$suffix = ':' . ($state->has('user') ? 'exit' : 'enter');
if (isset($y[2]['class'])) {
$y[2]['class'] .= ' form-pass form-pass' . $suffix;
} else {
$y[2]['class'] = 'form-pass form-pass' . $suffix;
}
return $y;
});
}
if (isset($state->x->user)) {
// Add legacy form class name
Hook::set('y.form.user', function ($y) use ($state) {
$suffix = ':' . ($state->has('user') ? 'exit' : 'enter');
if (isset($y[2]['class'])) {
$y[2]['class'] .= ' form-user form-user' . $suffix;
} else {
$y[2]['class'] = 'form-user form-user' . $suffix;
}
return $y;
});
}