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
|
<?php
#===============================================================================
# INCLUDE: Initialization
#===============================================================================
require 'core/application.php';
#===============================================================================
# ROUTE: Item controllers
#===============================================================================
foreach(['category', 'page', 'post', 'user'] as $item) {
$slug = Application::get(strtoupper($item).'.DIRECTORY');
# Item list controller
Router::add("{$slug}/", function() use($item) {
require "core/include/{$item}/list.php";
});
# Item show controller
Router::add("{$slug}/([^/]+)/", function($param) use($item) {
require "core/include/{$item}/main.php";
});
# Item controllers (ensure trailing slashes)
Router::addRedirect($slug, Application::getURL("{$slug}/"));
Router::addRedirect("{$slug}/([^/]+)", Application::getURL("{$slug}/$1/"));
}
#===============================================================================
# ROUTE: Home
#===============================================================================
Router::add('', function() {
require 'core/include/home.php';
});
#===============================================================================
# ROUTE: Feed and Search
#===============================================================================
Router::add('(feed|search)/', function($slug) {
require "core/include/{$slug}/main.php";
});
#===============================================================================
# REDIRECT: Feed and Search (trailing slash)
#===============================================================================
Router::addRedirect('(feed|search)', Application::getURL('$1/'));
#===============================================================================
# REDIRECT: Favicon
#===============================================================================
Router::addRedirect('favicon.ico', Application::getTemplateURL('static/favicon.ico'));
#===============================================================================
# BACKWARD COMPATIBILITY: Redirect to the new post feed URL
#===============================================================================
Router::addRedirect('feed/post/', Application::getURL('feed/'), 301);
#===============================================================================
# Execute router and route requests
#===============================================================================
Router::execute(parse_url(HTTP::requestURI(), PHP_URL_PATH));
|