Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xoan committed May 12, 2011
0 parents commit c36ee62
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "libraries/flourish"]
path = libraries/flourish
url = git://github.com/wbond/flourish.git
[submodule "libraries/moor"]
path = libraries/moor
url = git://github.com/wbond/moor.git
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Simple Unframework based on Flourish and Moor.

$ git clone git://github.com/xoan/sunframework.git project
$ cd project
$ git submodule init
$ git submodule update
10 changes: 10 additions & 0 deletions application/classes/ApplicationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
class ApplicationController extends MoorActionController
{
protected $data = array();

protected function afterAction()
{
render($this->data);
}
}
8 changes: 8 additions & 0 deletions application/controllers/Welcome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
class Welcome extends ApplicationController
{
public function index()
{
//
}
}
Empty file added application/models/.empty
Empty file.
2 changes: 2 additions & 0 deletions application/views/footer.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
</body>
</html>
7 changes: 7 additions & 0 deletions application/views/header.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title><?php echo $this->get('title'); ?></title>
</head>
<body>
11 changes: 11 additions & 0 deletions application/views/welcome/index.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$tmpl->set('title', 'Welcome#index');
$tmpl->place('header');
?>

<p>
Welcome#index<br />
<tt>application/views/welcome/index.html.php</tt>
</p>

<?php $tmpl->place('footer'); ?>
17 changes: 17 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
$config['db'] = array(
'development' => array(
'type' => 'sqlite',
'name' => DB_PATH.'/sqlite.db',
'user' => '',
'pass' => '',
'host' => ''
),
'production' => array(
'type' => '',
'name' => '',
'user' => '',
'pass' => '',
'host' => ''
)
);
59 changes: 59 additions & 0 deletions config/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
function __autoload($class)
{
$dirs = array(
LIB_PATH.'/flourish/classes',
LIB_PATH.'/moor',
APP_PATH.'/classes',
APP_PATH.'/controllers',
APP_PATH.'/models'
);
foreach ($dirs as $dir) {
if (file_exists($file = $dir.'/'.$class.'.php')) {
return require $file;
}
}
throw new Exception('The class '.$class.' could not be loaded');
}

function render($data = null, $callback = null, $format = 'html')
{
static $called = false;
if ($called) {
return;
} else {
$called = true;
}
extract($data);
if (is_null($callback)) {
$callback = Moor::getActiveCallback();
}
$format = fRequest::getValid('format', array($format, 'rss', 'json'));
$tmpl = new fTemplating(APP_PATH.'/views');
$tmpl->set(array(
'header' => 'header.'.$format.'.php',
'footer' => 'footer.'.$format.'.php'
));
$view = APP_PATH.'/views'.Moor::pathTo($callback).'.'.$format.'.php';
if (file_exists($view)) {
return include $view;
} else {
throw new MoorNotFoundException();
}
}

function not_found()
{
header('HTTP/1.1 404 Not Found');
fHTML::sendHeader();
exit('<h1>404 Not Found</h1>'."\n".
'<p>The page that you have requested could not be found.</p>'."\n");
}

function link_to()
{
$args = func_get_args();
return call_user_func_array(
'Moor::linkTo', $args
);
}
6 changes: 6 additions & 0 deletions config/route.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
Moor::setNotFoundCallback('not_found');

Moor::route('/', 'Welcome::index');

Moor::run();
Binary file added database/sqlite.db
Binary file not shown.
17 changes: 17 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
define('ROOT_PATH', dirname(__FILE__));
define('CONF_PATH', ROOT_PATH.'/config');
define('DB_PATH', ROOT_PATH.'/database');
define('LIB_PATH', ROOT_PATH.'/libraries');
define('APP_PATH', ROOT_PATH.'/application');

include CONF_PATH.'/config.php';
include CONF_PATH.'/functions.php';

$db = $config['db'][ENV];
$database = new fDatabase($db['type'], $db['name'], $db['user'], $db['pass'], $db['host']);
fORMDatabase::attach($database);

fSession::open();

include CONF_PATH.'/route.php';
1 change: 1 addition & 0 deletions libraries/flourish
Submodule flourish added at 45b38a
1 change: 1 addition & 0 deletions libraries/moor
Submodule moor added at f0d8d0
5 changes: 5 additions & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
RewriteRule ^.*$ index.php [QSA,NS]
Empty file added public/DEVELOPMENT
Empty file.
10 changes: 10 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
define('ENV', file_exists('DEVELOPMENT') ? 'development' : 'production');
define('PUB_PATH', dirname(__FILE__));

switch (ENV) {
case 'development':
case 'production':
default:
include '../init.php';
}

0 comments on commit c36ee62

Please sign in to comment.