예제 #1
0
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/BookPage.php";
$page_name = isset($_GET['p']) && $_GET['p'] ? trim($_GET['p']) : 'index';
try {
    ensure_page_name_safe($page_name);
    $page = new BookPage($page_name);
    // 线下模式不显示修改时间,因为从Github读取需要的时间太长
    $page_last_update_time = IN_PROD_MODE ? $page->getLastUpdatedAt(true, "Y-m-d H:h") : false;
    // 如果获取修改时间失败,则先暂时禁用缓存,否则无法重新获取最后修改时间
    if ($page_last_update_time === false) {
        PageCache::disable();
    }
    $view = new SimpieView($page->toHtml(), "../templates/layout/book.php", SimpieView::IS_RAW_TEXT);
    $view->render(array('title' => $page->getTitle(), 'page' => $page, 'chapt_list' => BookPage::getChapterList(), 'is_detail_view' => $page_name != 'index', 'page_last_update_time' => $page_last_update_time));
} catch (PageNotFoundException $e) {
    // 尝试查找是否是因为章节调整导致地址发生变化导致的404
    // 通过永久重定向解决搜索引擎和错误地址的问题
    if ($similar_page_name = BookPage::getMostSimilarPageFromPageName($page_name)) {
        redirect_to("/book?p=" . $similar_page_name, 301);
    }
    header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
    header("Status: 404 Not Found");
    $view = 404;
    $title = "Page Not Found";
    $view = new SimpieView("../templates/book_page_{$view}.php", "../templates/layout/book.php");
    $view->render(array('book_page' => $page_name, 'exception' => $e, 'title' => $title, 'rev' => $rev, 'exception' => $e, 'is_detail_view' => true, 'chapt_list' => $chapt_list));
}
예제 #2
0
파일: index.php 프로젝트: formatcc/tipi
<?php

require_once "../../web/lib/common.inc.php";
require_once "../../web/lib/SimpieView.php";
require_once "../../web/lib/TIPI.php";
require_once "../../web/models/BookPage.php";
require_once dirname(__FILE__) . "/TipiCHM.php";
set_time_limit(0);
$pages = BookPage::getFlatPagesArrayForPrint();
$view = new SimpieView('../../web/templates/chm/print.php');
$chapt_list = BookPage::getChapterList();
#array_shift($chapt_list);
$data = array('page_name' => 'ch/home', 'list' => $chapt_list, 'title' => 'TIPI');
define('ROOT', dirname(__FILE__) . "/");
$filename = TIPI::getVersion();
$tipichm = new TipiCHM($filename, $data);
/* 执行HTML help Workshop的complie后 */
if ($_GET['complied'] == 1) {
    $tipichm->copyCHM();
    die;
}
$tipichm->copyCSS(ROOT_PATH . "/css/book.css");
$tipichm->copyCSS(ROOT_PATH . "/css/main.css");
$tipichm->copyCSS(ROOT_PATH . "/css/chm.css");
$tipichm->copyCSS(ROOT_PATH . "/css/highlight.css");
$tipichm->copyImages(ROOT_PATH . "/images/get-lastest.png");
$tipichm->createHome();
$tipichm->copyImagesOfDiretory();
$tipichm->createFiles($view, $pages);
$tipichm->createHHC();
$tipichm->createHHK();