Permalink
Browse files

Updated to follow most recent QuickStart recommendations

  • Loading branch information...
1 parent 4f9be72 commit 2f9d3dab161456aefd7203fa869e8ecc7dea34ff @weierophinney weierophinney committed Sep 8, 2008
@@ -1,10 +1,12 @@
<?php
-if (isset($bootstrap) && $bootstrap) {
+define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../'));
+defined('APPLICATION_ENV') or define('APPLICATION_ENV', 'development');
+
+if (defined('BOOTSTRAP')) {
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
}
-$base = realpath(dirname(__FILE__) . '/../');
$front = Zend_Controller_Front::getInstance();
-$front->registerPlugin(new My_Plugin_Initialize($base, 'development'))
+$front->registerPlugin(new My_Plugin_Initialize(APPLICATION_ENV))
->addControllerDirectory($base . '/application/controllers');
@@ -0,0 +1,45 @@
+[production]
+paths.init = 0
+
+basePath = APPLICATION_PATH
+appPath = APPLICATION_PATH "/application"
+libPath = APPLICATION_PATH "/library"
+pubPath = APPLICATION_PATH "/public"
+
+db.cxn.adapter = "pdo_sqlite"
+db.cxn.params.dbname = APPLICATION_PATH "/application/data/paste-dev.db"
+db.cache.backendName = "Sqlite"
+db.cache.frontendName = "Core"
+db.cache.frontendOptions.caching = true
+db.cache.frontendOptions.lifetime = 900
+db.cache.frontendOptions.automatic_serialization = true
+db.cache.frontendOptions.automatic_cleaning_factor = 20
+db.cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/application/data/db-cache-dev.db"
+db.cache.backendOptions.automatic_vacuum_factor = 20
+db.profiler.enabled = false
+
+cache.backendName = "Sqlite"
+cache.frontendName = "Core"
+cache.frontendOptions.caching = false
+cache.frontendOptions.lifetime = 900
+cache.frontendOptions.automatic_serialization = true
+cache.frontendOptions.automatic_cleaning_factor = 20
+cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/application/data/cache-dev.db"
+cache.backendOptions.automatic_vacuum_factor = 20
+
+view.dojo.isDebug = false
+
+[development: production]
+db.cxn.params.dbname = APPLICATION_PATH "/application/data/paste-dev.db"
+db.cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/application/data/db-cache-dev.db"
+db.profiler.enabled = true
+cache.frontendOptions.caching = false
+cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/application/data/cache-dev.db"
+view.dojo.isDebug = true
+
+[testing : production]
+db.cxn.params.dbname = APPLICATION_PATH "/application/data/paste-test.db"
+db.cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/application/data/db-cache-test.db"
+cache.frontendOptions.caching = false
+cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/application/data/cache-test.db"
+
@@ -1,35 +0,0 @@
-[development]
-paths.init = 0
-
-db.cxn.adapter = "pdo_sqlite"
-db.cxn.params.dbname = "paste-dev.db"
-db.cache.backendName = "Sqlite"
-db.cache.frontendName = "Core"
-db.cache.frontendOptions.caching = false
-db.cache.frontendOptions.lifetime = 900
-db.cache.frontendOptions.automatic_serialization = true
-db.cache.frontendOptions.automatic_cleaning_factor = 20
-db.cache.backendOptions.cache_db_complete_path = "db-cache-dev.db"
-db.cache.backendOptions.automatic_vacuum_factor = 20
-
-cache.backendName = "Sqlite"
-cache.frontendName = "Core"
-cache.frontendOptions.caching = false
-cache.frontendOptions.lifetime = 900
-cache.frontendOptions.automatic_serialization = true
-cache.frontendOptions.automatic_cleaning_factor = 20
-cache.backendOptions.cache_db_complete_path = "cache-dev.db"
-cache.backendOptions.automatic_vacuum_factor = 20
-
-[testing : development]
-db.cxn.params.dbname = "paste-test.db"
-db.cache.backendOptions.cache_db_complete_path = "db-cache-test.db"
-
-cache.backendOptions.cache_db_complete_path = "cache-test.db"
-
-[production : development]
-db.cxn.params.dbname = "paste-prod.db"
-db.cache.backendOptions.cache_db_complete_path = "db-cache-prod.db"
-
-cache.frontendOptions.caching = true
-cache.backendOptions.cache_db_complete_path = "cache-prod.db"
Binary file not shown.
Binary file not shown.
@@ -34,7 +34,9 @@
</ul>
<? endif ?>
<? endif ?>
-<? if ('text' == $this->paste['type']) {
+<?
+ $this->dojo()->addOnLoad('paste.setStatusFromMetadata');
+ if ('text' == $this->paste['type']) {
return;
}
switch ($this->paste['type']) {
@@ -56,5 +58,4 @@
}
$this->dojo()->addStylesheet("/style/highlight/highlight.css");
$this->dojo()->addStylesheet("/style/highlight/autumn.css");
- $this->dojo()->addOnLoad('paste.formattedShow')
- ->addOnLoad('paste.setStatusFromMetadata');
+ $this->dojo()->addOnLoad('paste.formattedShow');
@@ -20,15 +20,11 @@ class My_Plugin_Initialize extends Zend_Controller_Plugin_Abstract
* @param string $env Application environment
* @return void
*/
- public function __construct($basePath, $env = 'production')
+ public function __construct($env = 'production')
{
- $this->env = $env;
-
- $this->basePath = $basePath;
- $this->appPath = $this->basePath . '/application';
- $this->libPath = $this->basePath . '/library';
- $this->pubPath = $this->basePath . '/public';
- $this->front = Zend_Controller_Front::getInstance();
+ $this->env = $env;
+ $this->initConfig();
+ $this->front = Zend_Controller_Front::getInstance();
}
/**
@@ -39,8 +35,7 @@ public function __construct($basePath, $env = 'production')
*/
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
- $this->initConfig()
- ->initControllers()
+ $this->initControllers()
->initLog()
->initCache()
->initDb()
@@ -54,20 +49,8 @@ public function routeStartup(Zend_Controller_Request_Abstract $request)
*/
public function initConfig()
{
- $config = new Zend_Config_Ini($this->appPath . '/configs/paste.ini', $this->env, true);
-
- $config->paths->basePath = $this->basePath;
- $config->paths->appPath = $this->appPath;
- $config->paths->libPath = $this->libPath;
- $config->paths->pubPath = $this->pubPath;
-
- $config->db->cxn->params->dbname = $config->paths->appPath . '/data/' . $config->db->cxn->params->dbname;
- $config->db->cache->backendOptions->cache_db_complete_path = $config->paths->appPath . '/data/' . $config->db->cache->backendOptions->cache_db_complete_path;
-
- $config->cache->backendOptions->cache_db_complete_path = $config->paths->appPath . '/data/' . $config->cache->backendOptions->cache_db_complete_path;
-
- $this->config = $config;
- Zend_Registry::set('config', $config);
+ $this->config = new Zend_Config_Ini(APPLICATION_PATH . '/application/config/paste.ini', $this->env);
+ Zend_Registry::set('config', $this->config);
return $this;
}
@@ -78,7 +61,7 @@ public function initConfig()
*/
public function initControllers()
{
- $this->front->setControllerDirectory($this->appPath . '/controllers', 'default');
+ $this->front->setControllerDirectory($this->config->appPath . '/controllers', 'default');
return $this;
}
@@ -124,7 +107,7 @@ public function initDb()
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
$db = Zend_Db::factory($config->cxn);
- $profiler->setEnabled(true);
+ $profiler->setEnabled($config->profiler->enabled);
$db->setProfiler($profiler);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
@@ -140,7 +123,7 @@ public function initDb()
public function initView()
{
$layout = Zend_Layout::startMvc(array(
- 'layoutPath' => $this->appPath . '/layouts/scripts'
+ 'layoutPath' => $this->config->appPath . '/layouts/scripts'
));
$view = $layout->getView();
@@ -153,7 +136,7 @@ public function initView()
$view->headTitle('Pastebin');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
$view->dojo()->setDjConfigOption('usePlainJson', true)
- // ->setDjConfigOption('isDebug', true)
+ ->setDjConfigOption('isDebug', $this->config->view->dojo->isDebug)
->addStylesheetModule('dijit.themes.tundra')
->addStylesheet('/js/dojox/grid/_grid/tundraGrid.css')
->setLocalPath('/js/dojo/dojo.js')
View
@@ -1,5 +1,5 @@
<?php
-$bootstrap = true;
+define('BOOTSTRAP', true);
$base = realpath(dirname(__FILE__) . '/../');
$paths = array(
'.',

0 comments on commit 2f9d3da

Please sign in to comment.