Skip to content

Commit

Permalink
Merge branch 'release/2013-11.03'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Nov 14, 2013
2 parents d2488fa + e4330de commit 292df32
Show file tree
Hide file tree
Showing 37 changed files with 583 additions and 1,191 deletions.
9 changes: 5 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module.exports = function(grunt) {
marionette: {
deps: ['underscore', 'backbone' /*, 'jquery' */],
exports: 'Marionette'
},
jqueryTinyTimer: {
deps: [/* 'jquery' */]
}
},
// paths used by r.js
Expand All @@ -39,6 +42,7 @@ module.exports = function(grunt) {
humanize: '../dev/bower_components/humanize/js/humanize',
jquery: '../dev/bower_components/jquery/jquery',
jqueryAutosize: '../dev/bower_components/jquery-autosize/js/jquery.autosize',
jqueryTinyTimer: '../dev/bower_components/jquery-tinytimer/jquery.tinytimer',
jqueryUi: 'lib/jquery-ui/jquery-ui-1.9.2.custom.min',
marionette: '../dev/bower_components/marionette/backbone.marionette',
text: '../dev/bower_components/requirejs-text/js/text',
Expand All @@ -60,6 +64,7 @@ module.exports = function(grunt) {
'marionette',
'humanize',
'jqueryAutosize',
'jqueryTinyTimer',
'jqueryUi',
'text',
'underscore'
Expand Down Expand Up @@ -138,10 +143,6 @@ module.exports = function(grunt) {
src: ['./app/webroot/release-tmp/main.js'],
dest: './app/webroot/dist/main.js'
},
{
src: ['./app/webroot/dev/vendors/countdown/jquery.countdown.min.js'],
dest: './app/webroot/dist/jquery.countdown.min.js'
},
{
expand: true,
cwd: './app/webroot/dev/vendors/farbtastic/',
Expand Down
2 changes: 1 addition & 1 deletion app/Config/saito_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Saito Enduser Configuration
*/

/**
* Setting default language (mandantory)
*
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-11.02');
Configure::write('Saito.v', '2013-11.03');
19 changes: 1 addition & 18 deletions app/Plugin/M/Controller/MsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class MsController extends AppController {
];

public function index() {
$this->layout = 'default';
$this->theme = 'default';
$this->layout = 'plugin-m';
$this->set('title_for_layout', 'Mobile');
$this->set(
'short_title_for_layout',
Expand All @@ -31,22 +30,6 @@ public function manifest() {
$this->autoLayout = false;
$this->response->type('appcache');
$this->response->disableCache();

$this->set(
'touch',
md5(
Configure::read('debug') .
filemtime(App::pluginPath('M') . 'webroot/touch.txt') .
filemtime(App::pluginPath('M') . 'View/Elements/custom_html_header.ctp') .
filemtime(App::pluginPath('M') . 'webroot/dist/js.js') .
filemtime(
App::pluginPath('M') . 'webroot/dist/common.css'
) .
filemtime(
App::pluginPath('M') . 'webroot/dist/theme.css'
)
)
);
}

public function clientLog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
<meta name="apple-mobile-web-app-title" content="<?= $short_title_for_layout ?>">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="initial-scale=1.0">
<?= $this->Html->css(['M.../dist/common.css', 'M.../dist/theme.css']) ?>
<?php
$_cssOptions = ['ext' => '.css', 'fullBase' => true];
echo $_commonCssUrl = $this->Html->css([
$this->Html->assetUrl('M.dist/common', $_cssOptions),
$this->Html->assetUrl('M.dist/theme', $_cssOptions)
]);
?>
<script>
window.Saito = {
webroot: "<?= $this->webroot ?>",
Expand Down
21 changes: 21 additions & 0 deletions app/Plugin/M/View/Ms/manifest.ctp
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
CACHE MANIFEST
<?php
$_customCtpPath = 'Elements/custom_html_header.ctp';
// default place in plugin
$_ctpPath = App::pluginPath('M') . 'View' . DS . $_customCtpPath;
$_ctpPathTheme = App::themePath($this->theme) . 'Plugin' . DS . 'M' .
DS . $_customCtpPath;
if (file_exists($_ctpPathTheme)) {
$_ctpPath = $_ctpPathTheme;
}
$touch = md5(
Configure::read('debug') .
// static location in plugin path
filemtime(App::pluginPath('M') . 'webroot/touch.txt') .
filemtime(App::pluginPath('M') . 'webroot/dist/js.js') .
filemtime(App::pluginPath('M') . 'webroot/dist/common.css') .
// dynamic location in plugin or theme path
filemtime($_ctpPath) .
$this->Html->getAssetTimestamp($this->Html->webroot('M/dist/theme.css'))
);
?>

# Version: <?= $touch ?>


Expand Down
8 changes: 8 additions & 0 deletions app/Plugin/Stopwatch/Lib/Stopwatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class Stopwatch {

protected static $_startupTime = 0;

protected static $_instance = null;

protected static $_enableTimer = false;
Expand Down Expand Up @@ -107,6 +109,8 @@ public static function getString() {
self::start('now');

$out = "";
$out .= 'Time to Cake: ' . sprintf('%05.3f', TIME_START - $_SERVER['REQUEST_TIME_FLOAT']) . " s\n";
$out .= 'Cake bootstrap: ' . sprintf('%05.3f', self::$_startupTime - TIME_START) . " s\n";

$out .= "W\tU\tW_delta\tU_delta\tMem [MB]\n";
$_seriesIndex = 1;
Expand Down Expand Up @@ -173,6 +177,10 @@ public static function getJs() {
return $out;
}

public static function init() {
self::$_startupTime = microtime(true);
}

public static function enable() {
self::$_enableTimer = true;
}
Expand Down
1 change: 1 addition & 0 deletions app/Plugin/Stopwatch/Routing/Filter/StopwatchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class StopwatchFilter extends DispatcherFilter {
public $priority = 1;

public function beforeDispatch(CakeEvent $event) {
Stopwatch::init();
Stopwatch::enable();
Stopwatch::start('----------------------- Dispatch -----------------------');
}
Expand Down
6 changes: 6 additions & 0 deletions app/Test/Case/Model/UserOnlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ public function testSetOnline() {

$this->UserOnline->contain();
$result = $this->UserOnline->find('all', $this->_fields);

$_time = $result[0]['UserOnline']['time'];
unset($result[0]['UserOnline']['time']);
$this->assertWithinMargin($_time, time(), 1);

$expected = $this->_startUsersOnline;
unset($expected[0]['UserOnline']['time']);
$this->assertEqual($result, $expected);

//* insert anonymous user
Expand Down
26 changes: 15 additions & 11 deletions app/View/Elements/entry/view_posting.ctp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
### setup ###
if (!isset($level)) $level = 0;
if (!isset($last_action)) $last_action = null;
// setup
if (!isset($level)) { $level = 0; }
if (!isset($last_action)) { $last_action = null; }
$editLinkIsShown = false;

//data passed as json model
$_jsEntry = json_encode([
'pid' => (int)$entry['Entry']['pid'],
'isBookmarked' => $entry['isBookmarked'],
'isSolves' => (bool)$entry['Entry']['solves'],
'rootEntryUserId' => (int)$rootEntry['Entry']['user_id']
'rootEntryUserId' => (int)$rootEntry['Entry']['user_id'],
'time' => $this->TimeH->mysqlTimestampToIso($entry['Entry']['time'])
]);
###
?>
<div class="js-entry-view-core" data-id="<?php echo $entry['Entry']['id'] ?>">
<div class="content">
Expand Down Expand Up @@ -75,14 +76,17 @@
);
};
?>
<?php if (isset($entry['rights']['isEditingAsUserForbidden']) && $entry['rights']['isEditingAsUserForbidden'] == false) : ?>
<?php if (isset($entry['rights']['isEditingAsUserForbidden']) &&
!$entry['rights']['isEditingAsUserForbidden']
) : ?>
&nbsp;
<span class="small">
<?php echo $this->Html->link(
__('edit_linkname'),
'/entries/edit/' . $entry['Entry']['id'],
array ( 'class' => 'btn btn-edit', 'accesskey' => "e" )
);
<?=
$this->Html->link(
__('edit_linkname'),
'/entries/edit/' . $entry['Entry']['id'],
['class' => 'btn btn-edit js-btn-edit', 'accesskey' => 'e']
);
?>
</span>
<?php endif; ?>
Expand Down
46 changes: 13 additions & 33 deletions app/View/Entries/add.ctp
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<?php
//data passed as json model
$_jsMeta = json_encode([
'action' => $this->request->action
]);
$_jsEntry = '{}';
if ($this->request->action === 'edit') {
$_jsEntry = json_encode([
'time' => $this->TimeH->mysqlTimestampToIso($this->request->data['Entry']['time'])
]);
}

// header subnav
$this->start('headerSubnavLeft');
echo $this->Html->link(
Expand Down Expand Up @@ -119,7 +130,7 @@
__('submit_button'),
[
'id' => 'btn-submit',
'class' => 'btn btn-submit',
'class' => 'btn btn-submit js-btn-submit',
'tabindex' => 4,
'type' => 'button'
]
Expand Down Expand Up @@ -223,36 +234,5 @@
<!-- content -->
</div>
<!-- postingform -->
<div class='js-data' data-entry='<?= $_jsEntry ?>' data-meta='<?= $_jsMeta ?>'></div>
</div> <!-- entry add/reply -->

<?php if ($this->request->action === 'edit'): ?>
<span id="submit-countdown" class="countdown" style="display: none;"></span>
<?php
echo $this->Html->script('../dist/jquery.countdown.min');
$sbl = __('submit_button');
$st = (Configure::read('Saito.Settings.edit_period') * 60 ) - (time() - (strtotime($this->request->data['Entry']['time'])));
$this->Js->buffer(<<<EOF
$('#submit-countdown').countdown({
until: +$st,
compact: true,
format: 'MS',
onTick: function(periods) {
var setButtonText = function(text) {
$('#btn-submit').text(text);
};
if (periods[5] > 1 || (periods[5] == 1 && periods[6] > 30)) {
periods[5] = periods[5] + 1;
setButtonText('$sbl' + ' (' + periods[5] + ' min)');
} else if (periods[5] == 1) {
setButtonText('$sbl' + ' (' + periods[5] + ' min ' + periods[6] + ' s)');
} else {
setButtonText('$sbl' + ' (' + periods[6] + ' s)');
}
},
onExpiry: function() {
$('#btn-submit').attr('disabled', 'disabled');
}
});
EOF
);
endif; ?>
13 changes: 11 additions & 2 deletions app/View/Helper/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@
*/
class AppHelper extends Helper {

/**
* Returns the unix timestamp for a file
*
* @param $path as url `m/dist/theme.css
* @return int
* @throws InvalidArgumentException
*/
public function getAssetTimestamp($path) {
$pathWithTimestamp = $this->assetTimestamp($path);
// extracts integer unixtimestamp from `path/asset.ext?<unixtimestamp>
if ($pathWithTimestamp) {
preg_match('/(?<=\?)[\d]+(?=$|\?|\&)/', $pathWithTimestamp, $matches);
return (int)$matches[0];
if (preg_match('/(?<=\?)[\d]+(?=$|\?|\&)/', $pathWithTimestamp, $matches)) {
return (int)$matches[0];
}
}
throw new InvalidArgumentException("File $path not found.");
}

}
31 changes: 16 additions & 15 deletions app/View/Helper/JsDataHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,37 @@ public function __construct(View $view, $settings = array()) {

public function getAppJs(View $View) {
$js = $this->_JsData->getJs();
$js += array (
'app' => array(
$js += [
'app' => [
'version' => Configure::read('Saito.v'),
'settings' => array (
'webroot' => $View->request->webroot,
'embedly_enabled' => (bool)Configure::read('Saito.Settings.embedly_enabled'),
'upload_max_number_of_uploads' => (int)Configure::read('Saito.Settings.upload_max_number_of_uploads'),
'upload_max_img_size' => (int)Configure::read('Saito.Settings.upload_max_img_size') * 1024,
'settings' => [
'autoPageReload' => (isset($View->viewVars['autoPageReload']) ? $View->viewVars['autoPageReload'] : 0),
'embedly_enabled' => (bool)Configure::read('Saito.Settings.embedly_enabled'),
'editPeriod' => (int)Configure::read('Saito.Settings.edit_period'),
'notificationIcon' => $this->assetUrl(
'apple-touch-icon-precomposed.png',
[
'pathPrefix' => Configure::read('App.imageBaseUrl'),
'fullBase' => true
])
)
),
'request' => array(
]),
'upload_max_img_size' => (int)Configure::read('Saito.Settings.upload_max_img_size') * 1024,
'upload_max_number_of_uploads' => (int)Configure::read('Saito.Settings.upload_max_number_of_uploads'),
'webroot' => $View->request->webroot
]
],
'request' => [
'action' => $View->request->action,
'controller' => $View->request->controller,
'isMobile' => $View->request->isMobile(),
'isPreview' => $View->request->isPreview()
),
'currentUser' => array(
],
'currentUser' => [
'id' => (int)$View->viewVars['CurrentUser']['id'],
'username' => $View->viewVars['CurrentUser']['username'],
'user_show_inline' => $View->viewVars['CurrentUser']['inline_view_on_click'] || false,
'user_show_thread_collapsed' => $View->viewVars['CurrentUser']['user_show_thread_collapsed'] || false
)
);
]
];
$out = 'var SaitoApp = ' . json_encode($js);
$out .= '; SaitoApp.timeAppStart = new Date().getTime();';
return $out;
Expand Down
8 changes: 8 additions & 0 deletions app/View/Helper/TimeHHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,12 @@ protected function _glasen($timestamp) {
return $time;
}

public function mysqlTimestampToIso($date) {
$unixTimeStamp = strtotime($date);
if ($unixTimeStamp < 0) {
$unixTimeStamp = 0;
}
return date('c', $unixTimeStamp);
}

}
8 changes: 5 additions & 3 deletions app/View/Layouts/default.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
?>
<div id="claim"></div>
</div> <!-- .left -->
<div class="l-top-menu top-menu">
<?php echo $this->element('layout/header_login'); ?>
</div>
</div> <!-- #top -->
<div class="l-top-menu-wrapper">
<div class="l-top-menu top-menu">
<?php echo $this->element('layout/header_login'); ?>
</div>
</div>
<div id="topnav" class="navbar">
<div>
<div>
Expand Down
Loading

0 comments on commit 292df32

Please sign in to comment.