Skip to content

Commit

Permalink
Merge pull request #166 from cjsaylor/2.4
Browse files Browse the repository at this point in the history
Composer support and bug fix branch.
  • Loading branch information
cjsaylor committed Jan 4, 2014
2 parents cad59a2 + a25adbe commit 75a4007
Show file tree
Hide file tree
Showing 31 changed files with 479 additions and 1,413 deletions.
15 changes: 3 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
._*
.project

# config
app/Config/bootstrap.php
app/Config/core.php
app/Config/database.php
app/Vendor/

# Build config
config/bootstrap.php
config/core.php
config/database.php
# config
app/Config/environment.php

# cache
app/tmp/**/*
app/webroot/tmp/*

# misc
cakephp/
cakephp/*/**

!empty

9 changes: 0 additions & 9 deletions .gitmodules

This file was deleted.

17 changes: 5 additions & 12 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ tells you where it is!
## Requirements

* PHP 5.3+
* Sphinxsearch 0.99+
* Sphinxsearch 2.0.4+

## Setup

1. Configure sphinx search using `app/config/sphinx.conf`
1. Copy application configuration distribution files:
* `app/Config/bootstrap.php`
* `app/Config/core.php`
* `app/Config/database.php`
1. Make temporary directories writable by your webserver

# Build

1. Place production configuration files in `config/`
2. Run `./bin/build.sh` from root application directory.
1. Install composer dependences: `composer install --dev`.
1. Import MySQL tables using `config/boxmeup_2013-08-05.sql`.
1. Configure sphinx search using `config/sphinx.conf`.
1. Make temporary directories writable by your webserver: `chmod 0777 -R app/tmp`
67 changes: 67 additions & 0 deletions app/Config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

// Autoloader
require_once APP . 'Vendor/autoload.php';
spl_autoload_unregister(array('App', 'load'));
spl_autoload_register(array('App', 'load'), true, true);

Cache::config('default', array('engine' => 'File'));
Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher'
));

App::uses('CakeLog', 'Log');
if (Configure::read('debug') > 0) {
CakeLog::config('debug', array(
'engine' => 'FileLog',
'types' => array('notice', 'info', 'debug'),
'file' => 'debug',
));
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach(function(CakeEvent $event) {
CakePlugin::load('DebugKit');
$controller = $event->subject();
$controller->Toolbar = $controller->Components->load('DebugKit.Toolbar', array(
'autoRun' => false
));
}, 'Controller.initialize');
}
CakeLog::config('error', array(
'engine' => 'FileLog',
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
'file' => 'error',
));

// Load Plugins
CakePlugin::load('Api', array(
'bootstrap' => true,
'routes' => true
));
CakePlugin::load('GChart');
CakePlugin::load('Utility');
CakePlugin::load('Feedback');
CakePlugin::load('DebugKit');

// Features
// Site Theme
// Configure::write('Site.theme', 'default');

// Mobile themes
Configure::write('Site.mobile_theme', Configure::read('Env.Site.mobile_theme') ?: 'mobile');
Configure::write('Site.jquery_mobile_theme', Configure::read('Env.Site.jquery_mobile_theme') ?: 'b');

// Analytics
Configure::write('Analytics.tracking_code', Configure::read('Env.Analytics.tracking_code'));

// Feedback plugin
Configure::write('Feedback.github.project', Configure::read('Env.Feedback.github.project') ?: 'cjsaylor/Boxmeup');
Configure::write('Feedback.github.auth_token', Configure::read('Env.Feedback.github.auth_token'));
Configure::write('Feedback.github.labels', array('Feedback'));

// Message
Configure::write('Message.message', Configure::read('Env.Message.message') ?: 'Some user message.');
Configure::write('Message.cookie_suffix', Configure::read('Env.Message.cookie_suffix') ?: '001');

// Feature activation
Configure::write('Feature', Configure::read('Env.Feature'));
63 changes: 0 additions & 63 deletions app/Config/bootstrap.php.default

This file was deleted.

9 changes: 6 additions & 3 deletions app/Config/core.php.default → app/Config/core.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

Configure::write('debug', 0);
// Load in environment configurations.
Configure::load('environment');

Configure::write('debug', Configure::read('Env.debug'));
Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED,
Expand Down Expand Up @@ -31,8 +34,8 @@
));

Configure::write('Security.level', 'medium');
Configure::write('Security.salt', '');
Configure::write('Security.cipherSeed', '');
Configure::write('Security.salt', Configure::read('Env.salt'));
Configure::write('Security.cipherSeed', Configure::read('Env.cipher'));

Configure::write('Asset.timestamp', 'force');

Expand Down
18 changes: 18 additions & 0 deletions app/Config/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

class DATABASE_CONFIG {

public function __construct() {
foreach (Configure::read('Env.Db') as $name => $options) {
$this->$name = array(
'datasource' => 'Database/Mysql',
'persistent' => $options['persistent'] ?: false,
'host' => $options['host'],
'login' => $options['login'],
'password' => $options['password'],
'database' => $options['database']
);
}
}

}
25 changes: 0 additions & 25 deletions app/Config/database.php.default

This file was deleted.

30 changes: 30 additions & 0 deletions app/Config/environment.sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

$config = array(
'Env' => array(
'debug' => 2,
'salt' => '',
'cipher' => '',
'Db' => array(
'default' => array(
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => 'root',
'database' => 'boxmeup'
)
),
'Feature' => array(
'api' => true,
'mobile' => true,
'analytics' => false,
'feedback' => true,
'user_registration' => true,
'bulk_export' => true,
'forgot_password' => true,
'autocomplete' => true,
'https_redirect' => true,
'beta' => true
)
)
);
6 changes: 4 additions & 2 deletions app/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class AppController extends Controller {
'Auth',
'RequestHandler',
'Session',
'Cookie',
'DebugKit.Toolbar'
'Cookie'
);
public $helpers = array('Html', 'Form', 'Session', 'Paginator');

Expand Down Expand Up @@ -108,6 +107,9 @@ protected function checkSsl() {
if ($this->request->action == 'logout' || !$this->RequestHandler->isGet()) {
return;
}
if ($this->request->isAjax()) {
return;
}
if (in_array($this->request->action, $this->ssl)) {
if (env('https') !== 'on') {
$redirect = 'https://' . env('SERVER_NAME') . $this->request->here;
Expand Down
13 changes: 8 additions & 5 deletions app/Controller/ContainersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ public function change_view($view) {

public function view($slug=null) {
$this->helpers[] = 'Time';
$container = $this->Container->getContainerBySlug($slug, $this->Auth->user('id'));
if(!empty($container)) {
$this->verifyUser($container['Container']['id']);
$this->set('container_slug', $container['Container']['slug']);
$this->request->data['ContainerItem']['quantity'] = 1;
$container = $this->Container->getContainerBySlug($slug);
if (empty($container)) {
throw new NotFoundException('Container not found.');
}
if ($container['Container']['user_id'] !== $this->Auth->user('id')) {
throw new ForbiddenException('Not authorized to view this container.');
}
$this->set('container_slug', $container['Container']['slug']);
$this->request->data['ContainerItem']['quantity'] = 1;
$title_for_layout = $container['Container']['name'];
$container_items = $this->Container->ContainerItem->getPaginatedContainerItems($this, $container['Container']['id']);
$this->set(compact('container', 'container_items', 'title_for_layout'));
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UsersController extends AppController {
public $components = array('Email');

protected $ssl = array(
'login', 'signup', 'account', 'reset_password'
'login', 'signup', 'account', 'reset_password', 'auth'
);

public function beforeFilter() {
Expand Down
1 change: 0 additions & 1 deletion app/Model/Behavior/SphinxBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @author Vilen Tambovtsev
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
require_once APP . '/vendors/sphinxapi.php';
class SphinxBehavior extends ModelBehavior
{

Expand Down
5 changes: 2 additions & 3 deletions app/Model/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ public function getPaginatedContainers($controller, $user_id) {
return $controller->paginate($this);
}

public function getContainerBySlug($slug, $user_id) {
public function getContainerBySlug($slug) {
return $this->find('first', array(
'conditions' => array(
'Container.slug' => $slug,
'Container.user_id' => $user_id
'Container.slug' => $slug,
),
'contain' => array(
'ContainerItem',
Expand Down
2 changes: 1 addition & 1 deletion app/Model/ContainerItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getItemByUUID($uuid) {

public function searchContainers(&$controller, $user_id, $query) {
$controller->paginate = array(
'search' => $query,
'search' => rtrim($query, '*') . '*',
'sphinx' => array(
'matchMode' => SPH_MATCH_ALL,
'index' => array('container_items', 'container_items_delta'),
Expand Down
2 changes: 1 addition & 1 deletion app/View/Elements/notification/notice.ctp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="alert">
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<?php echo $message; ?>
</div>
2 changes: 1 addition & 1 deletion app/View/Errors/error400.ctp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="container">
<div class="row">
<div class="col-lg-4 col-offset-4">
<div class="col-lg-4 col-lg-offset-4">
<h2><?php echo __('Not found'); ?></h2>
<br/>
<p style="text-align: center"><?php echo $this->Html->image('missing-box.png'); ?></p>
Expand Down
Loading

0 comments on commit 75a4007

Please sign in to comment.