summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-01-27 23:34:09 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-01-27 23:34:09 +0100
commit71ea7532db3d74cde0dd079777aeb8fca3ec1d89 (patch)
treea0ee5722cd06c7414cd2f0d74ea5eca5a617cf84
parent4799db4ad1f39f7ce6a2815dc6f0a886fe0e2730 (diff)
parent2fe2f876eac5e5fb8730000ef3d32ab45eefa8ea (diff)
Merge branch 'dev' into beta
-rwxr-xr-xapp/Controllers/indexController.php13
-rw-r--r--app/layout/aside_flux.phtml10
-rw-r--r--app/views/helpers/view/global_view.phtml4
-rw-r--r--lib/lib_rss.php2
-rw-r--r--p/scripts/main.js72
5 files changed, 44 insertions, 57 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index c49054a5c..7d6d73c28 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -66,11 +66,11 @@ class FreshRSS_index_Controller extends Minz_ActionController {
// mise à jour des titres
$this->view->rss_title = $this->view->currentName . ' | ' . Minz_View::title();
if ($this->view->nb_not_read > 0) {
- Minz_View::appendTitle (' (' . $this->view->nb_not_read . ')');
+ Minz_View::appendTitle (' (' . formatNumber($this->view->nb_not_read) . ')');
}
Minz_View::prependTitle (
$this->view->currentName .
- ($this->nb_not_read_cat > 0 ? ' (' . $this->nb_not_read_cat . ')' : '') .
+ ($this->nb_not_read_cat > 0 ? ' (' . formatNumber($this->nb_not_read_cat) . ')' : '') .
' · '
);
@@ -194,6 +194,15 @@ class FreshRSS_index_Controller extends Minz_ActionController {
}
public function statsAction () {
+ if (!$this->view->loginOk) {
+ Minz_Error::error (
+ 403,
+ array ('error' => array (Minz_Translate::t ('access_denied')))
+ );
+ }
+
+ Minz_View::prependTitle (Minz_Translate::t ('stats') . ' · ');
+
$statsDAO = new FreshRSS_StatsDAO ();
Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js')));
$this->view->repartition = $statsDAO->calculateEntryRepartition();
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml
index 1e3211886..8454b4459 100644
--- a/app/layout/aside_flux.phtml
+++ b/app/layout/aside_flux.phtml
@@ -21,7 +21,7 @@
?>
<li>
<div class="category all">
- <a data-unread="<?php echo $this->nb_not_read; ?>" class="btn<?php echo $this->get_c == 'a' ? ' active' : ''; ?>" href="<?php echo Minz_Url::display($arUrl); ?>">
+ <a data-unread="<?php echo formatNumber($this->nb_not_read); ?>" class="btn<?php echo $this->get_c == 'a' ? ' active' : ''; ?>" href="<?php echo Minz_Url::display($arUrl); ?>">
<?php echo FreshRSS_Themes::icon('all'); ?>
<?php echo Minz_Translate::t ('main_stream'); ?>
</a>
@@ -30,9 +30,9 @@
<li>
<div class="category favorites">
- <a data-unread="<?php echo $this->nb_favorites['unread']; ?>" class="btn<?php echo $this->get_c == 's' ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 's'; echo Minz_Url::display($arUrl); ?>">
+ <a data-unread="<?php echo formatNumber($this->nb_favorites['unread']); ?>" class="btn<?php echo $this->get_c == 's' ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 's'; echo Minz_Url::display($arUrl); ?>">
<?php echo FreshRSS_Themes::icon('bookmark'); ?>
- <?php echo Minz_Translate::t ('favorite_feeds', $this->nb_favorites['all']); ?>
+ <?php echo Minz_Translate::t('favorite_feeds', formatNumber($this->nb_favorites['all'])); ?>
</a>
</div>
</li>
@@ -47,7 +47,7 @@
$c_active = true;
}
?><div class="category stick<?php echo $c_active ? ' active' : ''; ?>"><?php
- ?><a data-unread="<?php echo $cat->nbNotRead (); ?>" class="btn<?php echo $c_active ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 'c_' . $cat->id(); echo Minz_Url::display($arUrl); ?>"><?php echo $cat->name (); ?></a><?php
+ ?><a data-unread="<?php echo formatNumber($cat->nbNotRead()); ?>" class="btn<?php echo $c_active ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 'c_' . $cat->id(); echo Minz_Url::display($arUrl); ?>"><?php echo $cat->name (); ?></a><?php
?><a class="btn dropdown-toggle" href="#"><?php echo FreshRSS_Themes::icon($c_active ? 'up' : 'down'); ?></a><?php
?></div><?php
?><ul class="feeds<?php echo $c_active ? ' active' : ''; ?>"><?php
@@ -62,7 +62,7 @@
/* feed_config_template */
?></div><?php
?> <img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="✇" /> <?php
- ?><a class="feed" data-unread="<?php echo $feed->nbNotRead (); ?>" data-priority="<?php echo $feed->priority (); ?>" href="<?php $arUrl['params']['get'] = 'f_' . $feed_id; echo Minz_Url::display($arUrl); ?>"><?php echo $feed->name(); ?></a><?php
+ ?><a class="feed" data-unread="<?php echo formatNumber($feed->nbNotRead()); ?>" data-priority="<?php echo $feed->priority (); ?>" href="<?php $arUrl['params']['get'] = 'f_' . $feed_id; echo Minz_Url::display($arUrl); ?>"><?php echo $feed->name(); ?></a><?php
?></li><?php
}
?></ul><?php
diff --git a/app/views/helpers/view/global_view.phtml b/app/views/helpers/view/global_view.phtml
index 4fb807649..db937eeae 100644
--- a/app/views/helpers/view/global_view.phtml
+++ b/app/views/helpers/view/global_view.phtml
@@ -17,7 +17,7 @@
?>
<div class="box-category">
<div class="category">
- <a data-unread="<?php echo $cat->nbNotRead (); ?>" class="btn" href="<?php $arUrl['params']['get'] = 'c_' . $cat->id (); echo Minz_Url::display($arUrl); ?>">
+ <a data-unread="<?php echo formatNumber($cat->nbNotRead()); ?>" class="btn" href="<?php $arUrl['params']['get'] = 'c_' . $cat->id (); echo Minz_Url::display($arUrl); ?>">
<?php echo $cat->name(); ?>
</a>
</div>
@@ -26,7 +26,7 @@
<?php $not_read = $feed->nbNotRead (); ?>
<li id="f_<?php echo $feed->id (); ?>" class="item<?php echo $feed->inError () ? ' error' : ''; ?><?php echo $feed->nbEntries () == 0 ? ' empty' : ''; ?>">
<img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="✇" />
- <a class="feed" data-unread="<?php echo $feed->nbNotRead (); ?>" data-priority="<?php echo $feed->priority (); ?>" href="<?php $arUrl['params']['get'] = 'f_' . $feed->id(); echo Minz_Url::display($arUrl); ?>">
+ <a class="feed" data-unread="<?php echo formatNumber($feed->nbNotRead()); ?>" data-priority="<?php echo $feed->priority (); ?>" href="<?php $arUrl['params']['get'] = 'f_' . $feed->id(); echo Minz_Url::display($arUrl); ?>">
<?php echo $feed->name(); ?>
</a>
</li>
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index b953f96ce..1bb117ab6 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -63,7 +63,7 @@ function small_hash ($txt) {
}
function formatNumber($n, $precision = 0) {
- return str_replace(' ', '&#8239;', //Espace fine insécable
+ return str_replace(' ', ' ', //Espace insécable //TODO: remplacer par une espace _fine_ insécable
number_format($n, $precision, '.', ' ')); //number_format does not seem to be Unicode-compatible
}
diff --git a/p/scripts/main.js b/p/scripts/main.js
index ddfa0aec8..921005e3c 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -21,14 +21,14 @@ function redirect(url, new_tab) {
}
function numberFormat(nStr) {
- // Thx to http://www.mredkj.com/javascript/numberFormat.html
+ // http://www.mredkj.com/javascript/numberFormat.html
nStr += '';
- var x = nStr.split('.');
- var x1 = x[0];
- var x2 = x.length > 1 ? '.' + x[1] : '';
- var rgx = /(\d+)(\d{3})/;
+ var x = nStr.split('.'),
+ x1 = x[0],
+ x2 = x.length > 1 ? '.' + x[1] : '',
+ rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
- x1 = x1.replace(rgx, '$1' + " " + '$2');
+ x1 = x1.replace(rgx, '$1' + ' ' + '$2');
}
return x1 + x2;
}
@@ -42,7 +42,7 @@ function incUnreadsFeed(article, feed_id, nb) {
//Update unread: feed
var elem = $('#' + feed_id + '>.feed').get(0),
- feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0,
+ feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0,
feed_priority = elem ? (parseInt(elem.getAttribute('data-priority'), 10) || 0) : 0;
if (elem) {
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
@@ -50,7 +50,7 @@ function incUnreadsFeed(article, feed_id, nb) {
//Update unread: category
elem = $('#' + feed_id).parent().prevAll('.category').children(':first').get(0);
- feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
+ feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
if (elem) {
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
@@ -59,7 +59,7 @@ function incUnreadsFeed(article, feed_id, nb) {
if (feed_priority > 0) {
elem = $('#aside_flux .all').children(':first').get(0);
if (elem) {
- feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
+ feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
}
@@ -68,22 +68,28 @@ function incUnreadsFeed(article, feed_id, nb) {
if (article && article.closest('div').hasClass('favorite')) {
elem = $('#aside_flux .favorites').children(':first').get(0);
if (elem) {
- feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
+ feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
}
var isCurrentView = false;
//Update unread: title
- document.title = document.title.replace(/((?: \(\d+\))?)( · .*?)((?: \(\d+\))?)$/, function (m, p1, p2, p3) {
+ document.title = document.title.replace(/^([^\(]*)((?: \([0-9 ]+\))?)( · .*?)((?: \([0-9 ]+\))?)$/, function(m, p1, p2, p3, p4) {
var $feed = $('#' + feed_id);
- if (article || ($feed.closest('.active').length > 0 && $feed.siblings('.active').length === 0)) {
+
+ p2 = p2.replace(/ /g, '');
+ p4 = p4.replace(/ /g, '');
+
+ if ($('.category.all > .active').length == 0 && $('.category.favorites > .active').length == 0) { // If the current page is not the home page or the favorites page
isCurrentView = true;
- return incLabel(p1, nb) + p2 + incLabel(p3, feed_priority > 0 ? nb : 0);
+ return p1 + incLabel(p2, nb) + p3 + incLabel(p4, feed_priority > 0 ? nb : 0);
} else {
- return p1 + p2 + incLabel(p3, feed_priority > 0 ? nb : 0);
+ return p1 + p3 + incLabel(p4, feed_priority > 0 ? nb : 0);
}
+
});
+
return isCurrentView;
}
@@ -157,7 +163,7 @@ function mark_favorite(active) {
if (active.closest('div').hasClass('not_read')) {
var elem = $('#aside_flux .favorites').children(':first').get(0),
- feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
+ feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
if (elem) {
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + inc)));
}
@@ -544,7 +550,7 @@ function refreshUnreads() {
$.each(data, function(feed_id, nbUnreads) {
feed_id = 'f_' + feed_id;
var elem = $('#' + feed_id + '>.feed').get(0),
- feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
+ feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
if ((incUnreadsFeed(null, feed_id, nbUnreads - feed_unreads) || isAll) && //Update of current view?
(nbUnreads - feed_unreads > 0)) {
$('#new-article').show();
@@ -649,9 +655,9 @@ function init_loginForm() {
c = dcodeIO.bcrypt.hashSync(data.nonce + s, strong ? 4 : poormanSalt());
$('#challenge').val(c);
if (s == '' || c == '') {
- alert('Crypto error!');
+ alert('Crypto error!');
} else {
- success = true;
+ success = true;
}
} catch (e) {
alert('Crypto exception! ' + e);
@@ -755,34 +761,6 @@ function init_print_action() {
});
}
-function init_number_formats() {
- // Init global counter
- var elem = $('#aside_flux .categories li .all a');
- elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
-
- // Init favorites counters
- elem = $('#aside_flux .categories li .favorites a');
- elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
-
- var numFavorites = elem.text().replace(/((?: \(\d+\))?\s*)$/, function (m, p1) {
- return numberFormat(p1)
- });
- elem.text(numFavorites);
-
- // Init feeds counters
- $('#aside_flux .categories li .stick').each(function() {
- // Category-level counter
- elem = $(this).find('a');
- elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
-
- // Feeds counters
- $(this).parent().find('ul.feeds li.item').each(function() {
- elem = $(this).find('a.feed'); // There are two links here. a.feed is the title.
- elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
- });
- });
-}
-
function init_all() {
if (!(window.$ && window.url_freshrss && ((!full_lazyload) || $.fn.lazyload))) {
if (window.console) {
@@ -813,7 +791,7 @@ function init_all() {
init_print_action();
window.setInterval(refreshUnreads, 120000);
}
- init_number_formats();
+
if (window.console) {
console.log('FreshRSS init done.');
}