Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hajime-matsumoto committed Mar 19, 2013
1 parent 49c11b4 commit f53c433
Show file tree
Hide file tree
Showing 851 changed files with 199,270 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .vimrc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set nonumber

" ノラ用のテンプレート
"
autocmd BufNewFile *.php silent! 0r doc/template/skelton.php
57 changes: 57 additions & 0 deletions doc/examples/application/config/module.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#本番用
[ production ]
env = production
static.useCache = 1
# PHPの設定
php.display_errors = 0
# マルチバイト言語用の設定
mb.internal_encoding = utf8
mb.language = ja
# クラスの設定
class.namespace = NoraApplication
class.path = APP_HOME/src/class
###########################################
# ブートストラッパの設定
###########################################
# ブートストラッパの設定
bootstrapper.class = NoraApplication\Bootstrapper

###########################################
# リソースの設定
###########################################
#
# ロガーの設定
resource.logging.loggerName = Application
resource.logging.type = file
resource.logging.file = /tmp/application-log
resource.logging.mode = a
resource.logging.reportingLevel = self::E_ALL ^ self::E_DEBUG
#
# ビューの設定
resource.view.viewPath = APP_HOME/view
#
# レイアウトの設定
resource.layout.path = APP_HOME/layout/script
#
# コントローラの設定
resource.FrontController.controllerPath = APP_HOME/controller
#
# メイラの設定
resource.mailer.smtp.host = tls://smtp.gmail.com
resource.mailer.smtp.port = 465
resource.mailer.smtp.user = [email protected]
resource.mailer.smtp.passwd = bopdtvqfrcvymxmg
#
# モジュールの設定
resource.modules.modulesPath = APP_HOME/modules

# 開発用
[ development : production ]
env = development
static.useCache = 0
# PHPの設定
php.display_errors = 1
resource.logging.reportingLevel = self::E_ALL
resource.logging.loggerName = Application
resource.logging.type = default
resource.logging.logFormat = [:label(:level)] [:name] :message
6 changes: 6 additions & 0 deletions doc/examples/application/modules/theme/config/module.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#本番用
[ production ]
class.namespace = NoraModule\Theme
class.path = NORAMODULE_THEME_HOME/src/class
# 開発用
[ development : production ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* のらプロジェクト:クラスファイル
*
* @category Application
* @package Application
* @author ハジメ <[email protected]>
* @copyright opyright (c) 2013, Nora Project All rights reserved.
* @license http://www.hazime.org/license/bsd.txt 修正BSDライセンス
* @version $Id$
*/
namespace NoraModule\Theme\Controller;

use Nora\Application;

/**
* コントローラー
*/
class StaticController implements Application\ControllerIF
{
use Application\ControllerTrait;

public function actionIndex( $req, $res )
{
if( !isset($req['request_uri']) ) return;

$request_uri = $req['request_uri'];
$file = NORAMODULE_THEME_HOME.'/themes/'.$request_uri;

if(!file_exists($file)) dir(" $file not found ");

// ドキュメントルートに書き出す
$target = $req->getDocumentRoot().'/themes/'.$request_uri;

$dirname = dirname($target);

if( !nora_mkdir_recursive($dirname) ) die("ディレクトリ $dirname が作成できません");

if( is_writable( $target ) die("ターゲット $target に書き込みができません");

file_put_contents( $target, $contents = file_get_contents( $file ) );
echo $contents;
die();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background : red;
}
66 changes: 66 additions & 0 deletions doc/examples/application/src/class/Bootstrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* のらプロジェクト:クラスファイル
*
* @category Application
* @package Application
* @author ハジメ <[email protected]>
* @copyright opyright (c) 2013, Nora Project All rights reserved.
* @license http://www.hazime.org/license/bsd.txt 修正BSDライセンス
* @version $Id$
*/
namespace NoraApplication;

use Nora\Application;

/**
* ブートスラッパ
*/
class Bootstrapper extends Application\Bootstrapper
{

public function _initRouter( $setting )
{
$router = parent::_initRouter( $setting );

$router->addRoute(100, '/themes/:request_uri', array('module'=>'theme','controller'=>'static','action'=>'index'));
$router->addRoute(999, ':request_uri', array('controller'=>'staticPublish','action'=>'index','request_uri'=>'index.html'));

return $router;
}

public function _initView( $setting )
{
$view = parent::_initView( $setting );
$view = $this->initComponent('view', $view );

$view->headMeta( )->charset('utf8');
$view->headMeta( )->name('keyword','test,nora,php,framework,国産');
$view->headMeta( )->httpEquiv('content-type','text/html; charset=UTF-8');
$view->headMeta( )->property('og:title','たいとる');

$view->headMeta( )->twitter('card','summary');
$view->headMeta( )->twitter('site','@hajime-mat');
$view->headMeta( )->twitter('creater','@hajime-mat');
$view->headMeta( )->twitter('url','http://dev.hazime.org/index.php');
$view->headMeta( )->twitter('title','松本ハジメのWEBサイト');
$view->headMeta( )->twitter('description','松本ハジメのWEBサイト');
$view->headMeta( )->twitter('image','');

$view->headMeta( )->og('site_name','松本ハジメのWEBサイト');
$view->headMeta( )->og('title','松本ハジメのWEBサイト');
$view->headMeta( )->og('description','松本ハジメのWEBサイト');
$view->headMeta( )->og('url','http://dev.hazime.org/index.php');
$view->headMeta( )->og('type','profile');
$view->headMeta( )->og('image','profile');

$view->headStyle( )->appendFile('/assets/css/reset.css');
$view->headScript( )->appendFile('/assets/js/jQuery.js');
$view->bodyScript( )->appendCode('alert("loaded");');
$view->googleAnalytics('UA-37941501-1');

return $view;
}
}
30 changes: 30 additions & 0 deletions doc/examples/application/src/class/Controller/Home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* のらプロジェクト:クラスファイル
*
* @category NoraApplication
* @package Controller
* @author ハジメ <[email protected]>
* @copyright opyright (c) 2013, Nora Project All rights reserved.
* @license http://www.hazime.org/license/bsd.txt 修正BSDライセンス
* @version $Id$
*/
namespace NoraApplication\Controller;

use Nora\Controller;

/**
* コントローラー
*/
class Home implements Controller\ControllerIF
{
use Controller\ControllerTrait;

public function indexAction( $req, $res )
{
$res['message'] = 'ようこそ、のらフレームワーク';
return 'success';
}
}
29 changes: 29 additions & 0 deletions doc/examples/application/src/class/Controller/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* のらプロジェクト:クラスファイル
*
* @category Application
* @package Application
* @author ハジメ <[email protected]>
* @copyright opyright (c) 2013, Nora Project All rights reserved.
* @license http://www.hazime.org/license/bsd.txt 修正BSDライセンス
* @version $Id$
*/
namespace NoraApplication\Controller;

use Nora\Application;

/**
* コントローラー
*/
class HomeController implements Application\ControllerIF
{
use Application\ControllerTrait;

public function actionIndex( $req, $res )
{
$view = $this->bootstrap('view');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* のらプロジェクト:クラスファイル
*
* @category Application
* @package Application
* @author ハジメ <[email protected]>
* @copyright opyright (c) 2013, Nora Project All rights reserved.
* @license http://www.hazime.org/license/bsd.txt 修正BSDライセンス
* @version $Id$
*/
namespace NoraApplication\Controller;

use Nora\Application;

/**
* コントローラー
*/
class StaticPublishController implements Application\ControllerIF
{
use Application\ControllerTrait;

public function actionIndex( $req, $res )
{
if( !isset($req['request_uri']) ) return;
$request_uri = trim($req['request_uri']);

if( $request_uri == '' || $request_uri == '/' ) $request_uri = 'index.html';

// 単純なスタティックファイルを探す
$file = APP_HOME.'/static/'.$request_uri;
if(file_exists($file)) return $this->doStaticFile( $file, $request_uri );

$file = APP_HOME.'/static-recipe/'.$request_uri;
if(file_exists($file)) return $this->doRecipeFile( $file, $request_uri );

}

public function doRecipeFile( $file, $request_uri )
{
$config = new \Nora\Config\ConfigINI();
$config->load($file);

switch( $config['type'] )
{
case 'file':
if( !isset($config['file']) || !file_exists($config['file'] ) ) die('Recipe Failed: Cose File Not Found '. $config['file']);
return $this->doStaticFile( $config['file'], $request_uri );
break;
case 'dispatch':
$res = $this->bootstrap('frontController')->dispatch( $config['params'] );
break;
}
}

public function doStaticFile( $file, $request_uri )
{
// ドキュメントルートに書き出す
$target = $this->getRequest()->getDocumentRoot().'/'.$request_uri;

if( $this->bootstrap('config')->getConfig('static.useCache') )
{
nora_copy( $file, $target );
}

echo file_get_contents($file);
}
}
4 changes: 4 additions & 0 deletions doc/examples/application/static-recipe/dispatch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type = dispatch
uri = /home/index
params.controller = home
params.action = index
3 changes: 3 additions & 0 deletions doc/examples/application/static-recipe/top.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type = file
file = APP_HOME/static/index.html

1 change: 1 addition & 0 deletions doc/examples/application/static/top.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
19 changes: 19 additions & 0 deletions doc/examples/application/view/script/home/index.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?=$view->doctype('html5');?>
<!-- vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: -->
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<?=$view->headMeta();?>
<?=$view->headTitle();?>
<?=$view->headStyle();?>
<?=$view->headScript();?>
</head>
<?=$view->placeholder('body')->setPrefix('<body')->setPostfix('>'.PHP_EOL)->setFormat('%s="%s"')?>
<?=$view->githubForkme('hajime-matsumoto/nora'); ?>
<img src="<?=$view->socialGravatar('[email protected]');?>" />
テーマのCSS
<?=$view->placeholder('table');?>

<?=$view->bodyScript()?>
<?=$view->googleAnalytics();?>
</body>
</html>
38 changes: 38 additions & 0 deletions doc/examples/apps/blog/api/Blog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* のらプロジェクト
*
* @author ハジメ <[email protected]>
* @copyright opyright (c) 2013, Nora Project All rights reserved.
* @license http://www.hazime.org/license/bsd.txt 修正BSDライセンス
* @version $Id$
*/
namespace NoraApp\Blog\Api;

use Nora\Controller;

/**
* コントローラー
*/
class Blog extends Controller\ActionController
{
public function indexAction( $response, $request )
{
$response['message'] = 'hello wild';
}

public function createAction( $response, $request )
{
$response->capEnd();

$id = $request['id'];
$title = $request['title'];
$description = $request['description'];

var_dump($this->helper('bootstrapper')->getServiceManager());


}
}
Loading

0 comments on commit f53c433

Please sign in to comment.