summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-04-23 22:03:07 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-04-23 22:03:07 +0200
commitae6ade25d59942a25c79155c90fc76fb22d08cea (patch)
tree89a74359074cad1d62bc844ed3bc6be719c2ee3c /app
parentbe4f588911c5ef4ad2108154fea0433a90b6e791 (diff)
parentb042d3a7728037db90a9306c61091be0a8ac42c4 (diff)
Merge branch 'http2_headers' into dev
Diffstat (limited to 'app')
-rwxr-xr-xapp/Controllers/indexController.php64
-rw-r--r--app/FreshRSS.php37
-rw-r--r--app/Models/Themes.php4
-rw-r--r--app/layout/layout.phtml40
4 files changed, 73 insertions, 72 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index baaf99065..7e626720e 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -32,42 +32,44 @@ class FreshRSS_index_Controller extends Minz_ActionController {
Minz_Error::error(404);
}
- try {
- $entries = $this->listEntriesByContext();
-
- $nb_entries = count($entries);
- if ($nb_entries > FreshRSS_Context::$number) {
- // We have more elements for pagination
- $last_entry = array_pop($entries);
- FreshRSS_Context::$next_id = $last_entry->id();
- }
+ $this->view->callbackBeforeContent = function() {
+ try {
+ $entries = $this->listEntriesByContext();
+
+ $nb_entries = count($entries);
+ if ($nb_entries > FreshRSS_Context::$number) {
+ // We have more elements for pagination
+ $last_entry = array_pop($entries);
+ FreshRSS_Context::$next_id = $last_entry->id();
+ }
- $first_entry = $nb_entries > 0 ? $entries[0] : null;
- FreshRSS_Context::$id_max = $first_entry === null ?
- (time() - 1) . '000000' :
- $first_entry->id();
- if (FreshRSS_Context::$order === 'ASC') {
- // In this case we do not know but we guess id_max
- $id_max = (time() - 1) . '000000';
- if (strcmp($id_max, FreshRSS_Context::$id_max) > 0) {
- FreshRSS_Context::$id_max = $id_max;
+ $first_entry = $nb_entries > 0 ? $entries[0] : null;
+ FreshRSS_Context::$id_max = $first_entry === null ?
+ (time() - 1) . '000000' :
+ $first_entry->id();
+ if (FreshRSS_Context::$order === 'ASC') {
+ // In this case we do not know but we guess id_max
+ $id_max = (time() - 1) . '000000';
+ if (strcmp($id_max, FreshRSS_Context::$id_max) > 0) {
+ FreshRSS_Context::$id_max = $id_max;
+ }
}
- }
- $this->view->entries = $entries;
- } catch (FreshRSS_EntriesGetter_Exception $e) {
- Minz_Log::notice($e->getMessage());
- Minz_Error::error(404);
- }
+ $this->view->entries = $entries;
+ } catch (FreshRSS_EntriesGetter_Exception $e) {
+ Minz_Log::notice($e->getMessage());
+ Minz_Error::error(404);
+ }
- $this->view->categories = FreshRSS_Context::$categories;
+ $this->view->categories = FreshRSS_Context::$categories;
- $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title();
- $title = FreshRSS_Context::$name;
- if (FreshRSS_Context::$get_unread > 0) {
- $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title;
- }
- Minz_View::prependTitle($title . ' · ');
+ $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title();
+ $title = FreshRSS_Context::$name;
+ if (FreshRSS_Context::$get_unread > 0) {
+ $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title;
+ }
+ Minz_View::prependTitle($title . ' · ');
+ };
}
/**
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index bafa970da..562d8e2cd 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -34,7 +34,7 @@ class FreshRSS extends Minz_FrontController {
// Auth has to be initialized before using currentUser session parameter
// because it's this part which create this parameter.
- $this->initAuth();
+ self::initAuth();
// Then, register the user configuration and use the configuration setter
// created above.
@@ -46,10 +46,7 @@ class FreshRSS extends Minz_FrontController {
// Finish to initialize the other FreshRSS / Minz components.
FreshRSS_Context::init();
- $this->initI18n();
- FreshRSS_Share::load(join_path(DATA_PATH, 'shares.php'));
- $this->loadStylesAndScripts();
- $this->loadNotifications();
+ self::initI18n();
// Enable extensions for the current (logged) user.
if (FreshRSS_Auth::hasAccess()) {
$ext_list = FreshRSS_Context::$user_conf->extensions_enabled;
@@ -57,7 +54,7 @@ class FreshRSS extends Minz_FrontController {
}
}
- private function initAuth() {
+ private static function initAuth() {
FreshRSS_Auth::init();
if (Minz_Request::isPost() && !is_referer_from_same_domain()) {
// Basic protection against XSRF attacks
@@ -74,12 +71,12 @@ class FreshRSS extends Minz_FrontController {
}
}
- private function initI18n() {
+ private static function initI18n() {
Minz_Session::_param('language', FreshRSS_Context::$user_conf->language);
Minz_Translate::init(FreshRSS_Context::$user_conf->language);
}
- private function loadStylesAndScripts() {
+ private static function loadStylesAndScripts() {
$theme = FreshRSS_Themes::load(FreshRSS_Context::$user_conf->theme);
if ($theme) {
foreach($theme['files'] as $file) {
@@ -91,9 +88,9 @@ class FreshRSS extends Minz_FrontController {
$filename = $file;
}
$filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename);
- Minz_View::appendStyle(Minz_Url::display(
- '/themes/' . $theme_id . '/' . $filename . '?' . $filetime
- ));
+ $url = '/themes/' . $theme_id . '/' . $filename . '?' . $filetime;
+ header('Link: <' . Minz_Url::display($url, '', 'root') . '>;rel=preload', false); //HTTP2
+ Minz_View::appendStyle(Minz_Url::display($url));
}
}
@@ -110,6 +107,14 @@ class FreshRSS extends Minz_FrontController {
}
}
+ private static function loadNotifications() {
+ $notif = Minz_Session::param('notification');
+ if ($notif) {
+ Minz_View::_param('notification', $notif);
+ Minz_Session::_param('notification');
+ }
+ }
+
public static function preLayout() {
switch (Minz_Request::controllerName()) {
case 'index':
@@ -123,13 +128,9 @@ class FreshRSS extends Minz_FrontController {
break;
}
header("X-Content-Type-Options: nosniff");
- }
- private function loadNotifications() {
- $notif = Minz_Session::param('notification');
- if ($notif) {
- Minz_View::_param('notification', $notif);
- Minz_Session::_param('notification');
- }
+ FreshRSS_Share::load(join_path(DATA_PATH, 'shares.php'));
+ self::loadStylesAndScripts();
+ self::loadNotifications();
}
}
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index e3b260261..5a6ec0a05 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -116,7 +116,3 @@ class FreshRSS_Themes extends Minz_Model {
'<img class="icon" src="' . Minz_Url::display($url) . '" alt="' . $alts[$name] . '" />';
}
}
-
-function _i($icon, $url_only = false) {
- return FreshRSS_Themes::icon($icon, $url_only);
-}
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 99a3717bc..6906fa05f 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -1,17 +1,32 @@
-<?php
- FreshRSS::preLayout();
-?>
+<?php FreshRSS::preLayout(); ?>
<!DOCTYPE html>
<html lang="<?php echo FreshRSS_Context::$user_conf->language; ?>" xml:lang="<?php echo FreshRSS_Context::$user_conf->language; ?>">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1.0" />
- <?php echo self::headTitle(); ?>
<?php echo self::headStyle(); ?>
<script id="jsonVars" type="application/json">
<?php $this->renderHelper('javascript_vars'); ?>
</script>
<?php echo self::headScript(); ?>
+ <link rel="shortcut icon" id="favicon" type="image/x-icon" sizes="16x16 64x64" href="<?php echo Minz_Url::display('/favicon.ico'); ?>" />
+ <link rel="icon msapplication-TileImage apple-touch-icon" type="image/png" sizes="256x256" href="<?php echo Minz_Url::display('/themes/icons/favicon-256.png'); ?>" />
+ <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('starred', true); ?>">
+ <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('non-starred', true); ?>">
+ <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('read', true); ?>">
+ <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('unread', true); ?>">
+ <link rel="apple-touch-icon" href="<?php echo Minz_Url::display('/themes/icons/apple-touch-icon.png'); ?>">
+ <meta name="apple-mobile-web-app-capable" content="yes" />
+ <meta name="apple-mobile-web-app-status-bar-style" content="black" />
+ <meta name="apple-mobile-web-app-title" content="<?php echo FreshRSS_Context::$system_conf->title; ?>">
+ <meta name="msapplication-TileColor" content="#FFF" />
+<?php
+ flush();
+ if (isset($this->callbackBeforeContent)) {
+ call_user_func($this->callbackBeforeContent);
+ }
+?>
+ <?php echo self::headTitle(); ?>
<?php
$url_base = Minz_Request::currentRequest();
if (FreshRSS_Context::$next_id !== '') {
@@ -20,26 +35,13 @@
$url_next['params']['ajax'] = 1;
?>
<link id="prefetch" rel="next prefetch" href="<?php echo Minz_Url::display($url_next); ?>" />
-<?php } ?>
- <link rel="shortcut icon" id="favicon" type="image/x-icon" sizes="16x16 64x64" href="<?php echo Minz_Url::display('/favicon.ico'); ?>" />
- <link rel="icon msapplication-TileImage apple-touch-icon" type="image/png" sizes="256x256" href="<?php echo Minz_Url::display('/themes/icons/favicon-256.png'); ?>" />
<?php
- if (isset($this->rss_title)) {
+ } if (isset($this->rss_title)) {
$url_rss = $url_base;
$url_rss['a'] = 'rss';
?>
<link rel="alternate" type="application/rss+xml" title="<?php echo $this->rss_title; ?>" href="<?php echo Minz_Url::display($url_rss); ?>" />
-<?php } ?>
- <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('starred', true); ?>">
- <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('non-starred', true); ?>">
- <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('read', true); ?>">
- <link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('unread', true); ?>">
- <link rel="apple-touch-icon" href="<?php echo Minz_Url::display('/themes/icons/apple-touch-icon.png'); ?>">
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="apple-mobile-web-app-title" content="<?php echo FreshRSS_Context::$system_conf->title; ?>">
- <meta name="msapplication-TileColor" content="#FFF" />
-<?php if (FreshRSS_Context::$system_conf->allow_robots) { ?>
+<?php } if (FreshRSS_Context::$system_conf->allow_robots) { ?>
<meta name="description" content="<?php echo htmlspecialchars(FreshRSS_Context::$name . ' | ' . FreshRSS_Context::$description, ENT_COMPAT, 'UTF-8'); ?>" />
<?php } else { ?>
<meta name="robots" content="noindex,nofollow" />