Skip to content

Commit

Permalink
Merge branch 'release/2013-11.01'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Nov 8, 2013
2 parents ec91ac1 + ea11d56 commit b00e731
Show file tree
Hide file tree
Showing 106 changed files with 2,526 additions and 4,298 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: php

php:
- 5.4
- 5.5

env:
- DB=mysql
Expand Down
27 changes: 26 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ module.exports = function(grunt) {
{
src: ['./app/webroot/dev/bower_components/requirejs/js/require.js'],
dest: './app/webroot/dist/require.js'
},
// font-awesome fonts
{
expand: true,
cwd: './app/webroot/dev/bower_components/font-awesome/fonts/',
src: '*',
dest: './app/webroot/css/stylesheets/fonts/'
},
// font-awesome scss
{
expand: true,
cwd: './app/webroot/dev/bower_components/font-awesome/scss/',
src: '*',
dest: './app/webroot/css/src/partials/lib/font-awesome/'
}
]
},
Expand Down Expand Up @@ -138,6 +152,11 @@ module.exports = function(grunt) {
}
},
clean: {
devsetup: [
// font-awesome
'./app/webroot/css/stylesheets/fonts/',
'./app/webroot/css/src/partials/lib/font-awesome/'
],
release: ['./app/webroot/dist'],
releasePost: ['./app/webroot/release-tmp']
},
Expand Down Expand Up @@ -256,16 +275,22 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-compass');

grunt.registerTask('dev-setup', [ 'bower:devsetup', 'copy:nonmin' ]);
// dev-setup
grunt.registerTask('dev-setup', [
'clean:devsetup', 'bower:devsetup', 'copy:nonmin'
]);

// test
grunt.registerTask('test:js', ['jasmine', 'jshint']);
grunt.registerTask('test:cake', ['shell:testCake']);
grunt.registerTask('test:php', ['test:cake', 'phpcs']);
grunt.registerTask('test', ['test:js', 'test:php']);

// compass
grunt.registerTask('compass:watch', 'concurrent:compassWatch');
grunt.registerTask('compass:compile', ['compass:compileExampleTheme']);

// release
grunt.registerTask('release', [
'clean:release',
'compass:compile',
Expand Down
2 changes: 1 addition & 1 deletion app/Config/version.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
Configure::write('Saito.v', '2013-10.03');
Configure::write('Saito.v', '2013-11.01');
29 changes: 25 additions & 4 deletions app/Controller/SaitosController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,34 @@ class SaitosController extends Controller {
* @throws BadRequestException
*/
public function status() {
$data = [
'lastShoutId' => $this->Shout->findLastId()
];
$data = json_encode($data);
if ($this->request->accepts('text/event-streams')) {
return $this->_statusAsEventStream($data);
} else {
return $this->_statusAsJson($data);
}
}

protected function _statusAsEventStream($data) {
// time in ms to next request
$_retry = '10000';
$this->response->type(['eventstream' => 'text/event-stream']);
$this->response->type('eventstream');
$this->response->disableCache();
$_out = '';
$_out .= "retry: $_retry\n";
$_out .= 'data: ' . $data . "\n\n";
return $_out;
}

protected function _statusAsJson($data) {
if ($this->request->is('ajax') === false) {
throw new BadRequestException();
}
$out = array(
'lastShoutId' => $this->Shout->findLastId()
);
return json_encode($out);
return $data;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions app/Controller/ToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class ToolsController extends AppController {
'JasmineJs.JasmineJs'
);

/**
* Emtpy out all caches
*/
/**
* Empty out all caches
*/
public function admin_emptyCaches() {
$this->CacheSupport->clear();
$this->Session->setFlash(__('Caches have been emptied.'), 'flash/notice');
$this->Session->setFlash(__('Caches cleared.'), 'flash/success');
return $this->redirect($this->referer());
}

Expand All @@ -38,8 +38,8 @@ public function testJs() {
*/
public function clearCache() {
if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
$this->CacheSupport->clear('Apc');
echo json_encode(array('APC Clear Cache' => true));
$this->CacheSupport->clear(['Apc', 'OpCache']);
echo json_encode(['Opcode Clear Cache' => true]);
}
exit;
}
Expand Down
29 changes: 27 additions & 2 deletions app/Lib/CacheSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@ class CacheSupport extends Object {
public function __construct() {
$this->addCache(
[
// php caches
'Apc' => 'ApcCacheSupportCachelet',
'OpCache' => 'OpCacheSupportCachelet',
// application caches
'Cake' => 'CakeCacheSupportCachelet',
'Saito' => 'SaitoCacheSupportCachelet',
'Thread' => 'ThreadCacheSupportCachelet'
]
);
}

/**
* @param mixed $cache cache to clear
* null: all
* string: name of specific cache
* array: multiple name strings
* @param null $id
*/
public function clear($cache = null, $id = null) {
if (is_array($cache)) {
foreach ($cache as $_c) {
$this->clear($_c, $id);
}
}
if ($cache === null) {
foreach ($this->_Caches as $Cachelet) {
$Cachelet->clear();
foreach ($this->_Caches as $_Cache) {
$_Cache->clear();
}
} else {
$this->_Caches[$cache]->clear($id);
Expand Down Expand Up @@ -123,6 +138,16 @@ public function clear($id = null) {

}

class OpCacheSupportCachelet implements CacheSupportCacheletInterface {

public function clear($id = null) {
if (function_exists('opcache_reset')) {
opcache_reset();
}
}

}

class CakeCacheSupportCachelet implements CacheSupportCacheletInterface {

public function clear($id = null) {
Expand Down
2 changes: 1 addition & 1 deletion app/Plugin/M/webroot/dist/common.css

Large diffs are not rendered by default.

121 changes: 69 additions & 52 deletions app/Plugin/Markitup/View/Helper/MarkitupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,54 @@
App::uses('FormHelper', 'View/Helper');

class MarkitupHelper extends AppHelper {

public $helpers = array('Html', 'Form');

public $paths = array(
'css' => '/markitup/js/markitup/',
'js' => '/markitup/js/markitup/',
'js' => '/markitup/js/markitup/'
);

public $vendors = array('markdown' => 'Markitup.Markdown');

public function __construct(View $View, $settings = array()) {
parent::__construct($View, $settings);

$paths = Configure::read('Markitup.paths');
if (empty($paths)) {
return;
}

if (is_string($paths)) {
$paths = array('js' => $paths);
}

$this->paths = array_merge($this->paths, $paths);
}
/**
* Generates a form textarea element complete with label and wrapper div with markItUp! applied.
*
* @param string $fieldName This should be "Modelname.fieldname"
* @param array $settings
* @return string An <textarea /> element.
*/

/**
* Generates a form textarea element complete with label and wrapper div with markItUp! applied.
*
* @param string $name This should be "Modelname.fieldname"
* @param array $settings
* @return string An <textarea /> element.
*/
public function editor($name, $settings = array()) {
echo $this->Html->script($this->paths['js'] . 'jquery.markitup', array('inline' => true));
echo $this->Html->script($this->paths['js'] . 'jquery.markitup',
['inline' => true]);
$config = $this->_build($settings);
$settings = $config['settings'];
$default = $config['default'];
$textarea = array_diff_key($settings, $default);
$textarea = array_merge($textarea, array('type' => 'textarea'));
$id = '#' . $this->Form->domId($name);

// $out[] = 'jQuery.noConflict();';
$class = '';
if (isset($textarea['class'])) {
$class = $textarea['class'];
}
$markItUpInstance = uniqid('markItUp');
$textarea['class'] = $class . ' ' . $markItUpInstance;

$id = '.' . $markItUpInstance;

// $out[] = 'jQuery.noConflict();';
$out[] = 'jQuery(function() {';
$out[] = ' jQuery("' . $id . '").markItUp(';
$out[] = ' ' . $settings['settings'] . ',';
Expand All @@ -50,64 +61,69 @@ public function editor($name, $settings = array()) {
$out[] = ' }';
$out[] = ' );';
$out[] = '});';
return $this->output($this->Form->input($name, $textarea) . $this->Html->scriptBlock(join("\n", $out)));
return $this->Form->input($name, $textarea) . $this->Html->scriptBlock(join("\n", $out));
}
/**
* Link to build markItUp! on a existing textfield
*
* @param string $title The content to be wrapped by <a> tags.
* @param string $fieldName This should be "Modelname.fieldname" or specific domId as #id.
* @param array $settings
* @param array $htmlAttributes Array of HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An <a /> element.
*/

/**
* Link to build markItUp! on a existing textfield
*
* @param string $title The content to be wrapped by <a> tags.
* @param string $fieldName This should be "Modelname.fieldname" or specific domId as #id.
* @param array $settings
* @param array $htmlAttributes Array of HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An <a /> element.
*/
public function create($title, $fieldName = "", $settings = array(), $htmlAttributes = array(), $confirmMessage = false) {
$id = ($fieldName{0} === '#') ? $fieldName : '#'.parent::domId($fieldName);
$id = ($fieldName{0} === '#') ? $fieldName : '#' . parent::domId($fieldName);

$config = $this->_build($settings);
$settings = $config['settings'];
$htmlAttributes = array_merge($htmlAttributes, array('onclick' => 'jQuery("'.$id.'").markItUpRemove(); jQuery("'.$id.'").markItUp('.$settings['settings'].', { previewParserPath:"'.$settings['parser'].'" }); return false;'));
$htmlAttributes = array_merge($htmlAttributes,
array('onclick' => 'jQuery("' . $id . '").markItUpRemove(); jQuery("' . $id . '").markItUp(' . $settings['settings'] . ', { previewParserPath:"' . $settings['parser'] . '" }); return false;'));
return $this->Html->link($title, "#", $htmlAttributes, $confirmMessage, false);
}

/**
* Link to destroy a markItUp! editor from a textfield
* @param string $title The content to be wrapped by <a> tags.
* @param string $fieldName This should be "Modelname.fieldname" or specific domId as #id.
* @param array $htmlAttributes Array of HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An <a /> element.
*/
/**
* Link to destroy a markItUp! editor from a textfield
*
* @param string $title The content to be wrapped by <a> tags.
* @param string $fieldName This should be "Modelname.fieldname" or specific domId as #id.
* @param array $htmlAttributes Array of HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An <a /> element.
*/
public function destroy($title, $fieldName = "", $htmlAttributes = array(), $confirmMessage = false) {
$id = ($fieldName{0} === '#') ? $fieldName : '#'.parent::domId($fieldName);
$htmlAttributes = array_merge($htmlAttributes, array('onclick' => 'jQuery("'.$id.'").markItUpRemove(); return false;'));
$id = ($fieldName{0} === '#') ? $fieldName : '#' . parent::domId($fieldName);
$htmlAttributes = array_merge($htmlAttributes,
array('onclick' => 'jQuery("' . $id . '").markItUpRemove(); return false;'));
return $this->Html->link($title, "#", $htmlAttributes, $confirmMessage, false);
}

/**
* Link to add content to the focused textarea
* @param string $title The content to be wrapped by <a> tags.
* @param string $fieldName This should be "Modelname.fieldname" or specific domId as #id.
* @param mixed $content String or array of markItUp! options (openWith, closeWith, replaceWith, placeHolder and more. See markItUp! documentation for more details : http://markitup.jaysalvat.com/documentation
* @param array $htmlAttributes Array of HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An <a /> element.
*/
/**
* Link to add content to the focused textarea
* @param string $title The content to be wrapped by <a> tags.
* @param string $fieldName This should be "Modelname.fieldname" or specific domId as #id.
* @param mixed $content String or array of markItUp! options (openWith, closeWith, replaceWith, placeHolder and more. See markItUp! documentation for more details : http://markitup.jaysalvat.com/documentation
* @param array $htmlAttributes Array of HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An <a /> element.
*/
public function insert($title, $fieldName = null, $content = array(), $htmlAttributes = array(), $confirmMessage = false) {
if (isset($fieldName)) {
$content['target'] = ($fieldName{0} === '#') ? $fieldName : '#'.parent::domId($fieldName);
$content['target'] = ($fieldName{0} === '#') ? $fieldName : '#' . parent::domId($fieldName);
}
if (!is_array($content)) {
$content['replaceWith'] = $content;
}
$properties = '';
foreach($content as $k => $v) {
$properties .= $k.':"'.addslashes($v).'",';
foreach ($content as $k => $v) {
$properties .= $k . ':"' . addslashes($v) . '",';
}
$properties = substr($properties, 0, -1);

$htmlAttributes = array_merge($htmlAttributes, array('onclick' => '$.markItUp( { '.$properties.' } ); return false;'));
$htmlAttributes = array_merge($htmlAttributes,
array('onclick' => '$.markItUp( { ' . $properties . ' } ); return false;'));
return $this->Html->link($title, "#", $htmlAttributes, $confirmMessage, false);
}

Expand All @@ -130,14 +146,15 @@ public function parse($content, $parser = 'default') {
if (!isset($file)) {
$file = null;
}
App::import('Vendor', $plugin . '.' . $class, null, null, $file);
App::import('Vendor', $plugin . '.' . $class, null, null, $file);
$content = $class($content);
}

echo $this->Html->css($this->paths['css'] . 'templates' . DS . 'preview', null, array('inline' => false));

return $content;
}

protected function _build($settings) {
$default = array(
'set' => 'default',
Expand All @@ -164,5 +181,5 @@ protected function _build($settings) {

return array('settings' => $settings, 'default' => $default);
}

}
?>
Loading

0 comments on commit b00e731

Please sign in to comment.