소스 검색

Move config.php to config/; Add CONFIG_DIR and VENDOR_DIR constants

Daniel Rudolf 10 년 전
부모
커밋
399b73aa3b
3개의 변경된 파일11개의 추가작업 그리고 58개의 파일을 삭제
  1. 0 54
      config.php.template
  2. 5 2
      index.php
  3. 6 2
      lib/pico.php

+ 0 - 54
config.php.template

@@ -1,54 +0,0 @@
-<?php
-/**
- * Pico Configuration
- *
- *  This is the configuration file for Pico. It comes loaded with the
- *  default values, which can be found in the get_config() method of
- *  the Pico class (lib/pico.php).
- *
- * @author Gilbert Pellegrom
- * @link http://picocms.org
- * @license http://opensource.org/licenses/MIT
- * @version 0.9
- *
- * To override any of the default settings below, uncomment the line,
- * make and save the changes, then rename this file to `config.php`
- */
-
-/*
- * BASIC
- */
-// $config['site_title'] = 'Pico';              // Site title
-// $config['base_url'] = '';                    // Override base URL (e.g. http://example.com)
-
-/*
- * THEME
- */
-// $config['theme'] = 'default';                // Set the theme (defaults to "default")
-// $config['twig_config'] = array(              // Twig settings
-//	'cache' => false,	                        // To enable Twig caching change this to CACHE_DIR
-//	'autoescape' => false,                      // Autoescape Twig vars
-//	'debug' => false                            // Enable Twig debug
-// );
-
-/*
- * CONTENT
- */
-// $config['date_format'] = '%D %T';             // Set the PHP date format as described here: http://php.net/manual/en/function.strftime.php
-// $config['pages_order_by'] = 'alpha';           // Order pages by "alpha" or "date"
-// $config['pages_order'] = 'asc';                // Order pages "asc" or "desc"
-// $config['excerpt_length'] = 50;                // The pages excerpt length (in words)
-// $config['content_dir'] = 'content-sample/';    // Content directory
-
-/*
- * TIMEZONE
- */
-// date_default_timezone_set('UTC');              // Timezone may be reqired by your php install
-
-/*
- * CUSTOM
- */
-// $config['custom_setting'] = 'Hello';           // Can be accessed by {{ config.custom_setting }} in a theme
-
-// Keep this line
-return $config;

+ 5 - 2
index.php

@@ -1,12 +1,15 @@
 <?php
 <?php
 
 
 define('ROOT_DIR', realpath(dirname(__FILE__)) . '/');
 define('ROOT_DIR', realpath(dirname(__FILE__)) . '/');
-define('CONTENT_EXT', '.md');
 define('LIB_DIR', ROOT_DIR . 'lib/');
 define('LIB_DIR', ROOT_DIR . 'lib/');
+define('VENDOR_DIR', ROOT_DIR . 'vendor/');
 define('PLUGINS_DIR', ROOT_DIR . 'plugins/');
 define('PLUGINS_DIR', ROOT_DIR . 'plugins/');
 define('THEMES_DIR', ROOT_DIR . 'themes/');
 define('THEMES_DIR', ROOT_DIR . 'themes/');
+define('CONFIG_DIR', ROOT_DIR . 'config/');
 define('CACHE_DIR', LIB_DIR . 'cache/');
 define('CACHE_DIR', LIB_DIR . 'cache/');
 
 
-require_once(ROOT_DIR . 'vendor/autoload.php');
+define('CONTENT_EXT', '.md');
+
+require_once(VENDOR_DIR . 'autoload.php');
 require_once(LIB_DIR . 'pico.php');
 require_once(LIB_DIR . 'pico.php');
 $pico = new Pico();
 $pico = new Pico();

+ 6 - 2
lib/pico.php

@@ -199,8 +199,12 @@ class Pico
      */
      */
     protected function get_config()
     protected function get_config()
     {
     {
-
-        $this->config = @include_once(ROOT_DIR . 'config.php');
+        if (file_exists(CONFIG_DIR . 'config.php')) {
+            $this->config = require(CONFIG_DIR . 'config.php');
+        } else if (file_exists(ROOT_DIR . 'config.php')) {
+            // deprecated
+            $this->config = require(ROOT_DIR . 'config.php');
+        }
 
 
         $defaults = array(
         $defaults = array(
             'site_title' => 'Pico',
             'site_title' => 'Pico',