From f3b284bbe7b8a438c9e3d83fb8380591549adb73 Mon Sep 17 00:00:00 2001 From: Pat Collins Date: Tue, 6 Apr 2010 18:09:45 -0400 Subject: [PATCH] initial commit --- .gitmodules | 6 +++++ Rakefile | 32 +++++++++++++++++++++++ data/.gitignore | 0 public/.htaccess | 7 +++++ public/index.php | 56 ++++++++++++++++++++++++++++++++++++++++ public/static/.gitignore | 0 templates/.gitignore | 0 vendors/Twig | 1 + vendors/yaml | 1 + 9 files changed, 103 insertions(+) create mode 100644 .gitmodules create mode 100644 Rakefile create mode 100644 data/.gitignore create mode 100644 public/.htaccess create mode 100644 public/index.php create mode 100644 public/static/.gitignore create mode 100644 templates/.gitignore create mode 160000 vendors/Twig create mode 160000 vendors/yaml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..27de9d4 --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..efea38b --- /dev/null +++ b/Rakefile @@ -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 + diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..14098f1 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,7 @@ +Options +FollowSymLinks + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] + \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..7308d70 --- /dev/null +++ b/public/index.php @@ -0,0 +1,56 @@ + 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); \ No newline at end of file diff --git a/public/static/.gitignore b/public/static/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/templates/.gitignore b/templates/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/vendors/Twig b/vendors/Twig new file mode 160000 index 0000000..0593d7f --- /dev/null +++ b/vendors/Twig @@ -0,0 +1 @@ +Subproject commit 0593d7fb4863c6c50dc900006549f074faae0f94 diff --git a/vendors/yaml b/vendors/yaml new file mode 160000 index 0000000..9e767c9 --- /dev/null +++ b/vendors/yaml @@ -0,0 +1 @@ +Subproject commit 9e767c91651817d8973e66d5db6e6cc65e7eb90b