Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "vendors/Twig"] | ||
path = vendors/Twig | ||
url = git://github.com/fabpot/Twig.git | ||
[submodule "vendors/yaml"] | ||
path = vendors/yaml | ||
url = git://github.com/fabpot/yaml.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
include FileUtils | ||
|
||
BASE_FOLDER = File.expand_path(File.dirname(__FILE__)) | ||
BUILD = File.join(BASE_FOLDER, "build") | ||
PUBLIC = File.join(BASE_FOLDER, "public") | ||
TEMPLATES = File.join(BASE_FOLDER, "templates") | ||
|
||
task :build do | ||
cd BASE_FOLDER | ||
rm_rf BUILD | ||
mkdir_p BUILD | ||
|
||
# copy assets | ||
cd PUBLIC | ||
cp_r "static", BUILD | ||
|
||
# get list of templates to process | ||
cd TEMPLATES | ||
templates = Dir["**/*"].delete_if { |p| not p =~ /\.html$/ } | ||
|
||
cd BUILD | ||
mkdirs = templates.map { |t| File.dirname(t) }.uniq | ||
mkdir_p(mkdirs) | ||
|
||
cd BASE_FOLDER | ||
templates.each do |path| | ||
sh "php #{PUBLIC}/index.php #{path} > #{BUILD}/#{path}" | ||
end | ||
end | ||
|
||
task :default => :build | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Options +FollowSymLinks | ||
<IfModule mod_rewrite.c> | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] | ||
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', true); | ||
|
||
define('BASE_FOLDER', dirname(dirname(__FILE__)) . '/'); | ||
define('DATA', BASE_FOLDER . 'data/'); | ||
define('PUBLIC', BASE_FOLDER . 'public/'); | ||
define('TEMPLATES', BASE_FOLDER . 'templates/'); | ||
define('VENDORS', BASE_FOLDER . 'vendors/'); | ||
|
||
set_include_path(implode(PATH_SEPARATOR, array_merge(glob(VENDORS . '*/lib'), array(get_include_path())))); | ||
|
||
require 'sfYaml.php'; | ||
require 'Twig/Autoloader.php'; | ||
|
||
Twig_Autoloader::register(); | ||
|
||
if (isset($argv) and count($argv) == 2) { | ||
$url = $argv[1]; | ||
} | ||
else if (isset($_GET['url'])) { | ||
$url = $_GET['url']; | ||
} | ||
else { | ||
$url = ''; | ||
} | ||
|
||
if (empty($url)) { | ||
$url = 'index'; | ||
} | ||
|
||
$url = trim($url, '/'); | ||
|
||
if (is_dir(TEMPLATES . $url)) { | ||
$url .= '/index'; | ||
} | ||
$url = str_replace('.html', '', $url); | ||
$url .= '.html'; | ||
|
||
$loader = new Twig_Loader_Filesystem(TEMPLATES); | ||
$twig = new Twig_Environment($loader, array( | ||
'debug' => true, | ||
)); | ||
|
||
$data = array(); | ||
|
||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DATA), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { | ||
if (preg_match('/\.ya?ml$/', $file)) { | ||
if ($loaded = sfYaml::load($file->getRealPath())) { | ||
$data = array_merge($data, $loaded); | ||
} | ||
} | ||
} | ||
|
||
$template = $twig->loadTemplate($url); | ||
$template->display($data); |
Empty file.
Empty file.
Submodule Twig
added at
0593d7
Submodule yaml
added at
9e767c