Summary: Lower the barrier to entry for installing and creating skins, so we can kill Wordpress. You can now install skins by dropping them into a directory, and build either "advanced" (full phutil library) skins or "basic" (simple PHP templates) skins. Next up is getting static resources working in an easy way for skins. I put these in `externals/` for now so they don't get hit by lint. Test Plan: Viewed the Pokeblog with the Oblivious skin. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1373 Differential Revision: https://secure.phabricator.com/D3717
98 lines
2.4 KiB
PHP
98 lines
2.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright 2012 Facebook, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
* @group phame
|
|
*/
|
|
final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin {
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
require_once $root.'/support/phame/libskin.php';
|
|
|
|
parent::willProcessRequest($data);
|
|
}
|
|
|
|
public function getName() {
|
|
return $this->getSpecification()->getName();
|
|
}
|
|
|
|
public function getPath($to_file = null) {
|
|
$path = $this->getSpecification()->getRootDirectory();
|
|
if ($to_file) {
|
|
$path = $path.DIRECTORY_SEPARATOR.$to_file;
|
|
}
|
|
return $path;
|
|
}
|
|
|
|
private function renderTemplate($__template__, array $__scope__) {
|
|
chdir($this->getPath());
|
|
ob_start();
|
|
|
|
if (Filesystem::pathExists($this->getPath($__template__))) {
|
|
extract($__scope__ + $this->getDefaultScope());
|
|
require $this->getPath($__template__);
|
|
}
|
|
|
|
return ob_get_clean();
|
|
}
|
|
|
|
private function getDefaultScope() {
|
|
return array(
|
|
'skin' => $this,
|
|
'blog' => $this->getBlog(),
|
|
'uri' => $this->getURI(''),
|
|
);
|
|
}
|
|
|
|
protected function renderHeader() {
|
|
return $this->renderTemplate(
|
|
'header.php',
|
|
array(
|
|
'title' => $this->getBlog()->getName(),
|
|
));
|
|
}
|
|
|
|
protected function renderFooter() {
|
|
return $this->renderTemplate('footer.php', array());
|
|
}
|
|
|
|
protected function render404Page() {
|
|
return $this->renderTemplate('404.php', array());
|
|
}
|
|
|
|
protected function renderPostDetail(PhamePostView $post) {
|
|
return $this->renderTemplate(
|
|
'post-detail.php',
|
|
array(
|
|
'post' => $post,
|
|
));
|
|
}
|
|
|
|
protected function renderPostList(array $posts) {
|
|
return $this->renderTemplate(
|
|
'post-list.php',
|
|
array(
|
|
'posts' => $posts,
|
|
'older' => $this->renderNewerPageLink(),
|
|
'newer' => $this->renderOlderPageLink(),
|
|
));
|
|
}
|
|
|
|
}
|