From 2374374ba972eb4cca84d7f71b1900f806c2b914 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Feb 2019 15:06:28 +0100 Subject: Less jQuery (#2234) * Less jQuery Follow-up of https://github.com/FreshRSS/FreshRSS/pull/2199 * Even less jQuery + global view unread title fix * Even less jQuery * Yet even less jQuery * Even less jQuery * Reduce some events * Even less jQuery * jQuery gone from main view +Fixed English i18n * Fix feed folded view * Remove Firefox 64 workaround Remove workaround for Gecko bug 1514498 in Firefox 64, fixed in Firefox 65 * Split to extra.js Avoid loading unneeded JavaScript code for the main view. + several adjustements * Improve CSS transition fold category * Rewrite shortcuts Remove library. Much faster, shorter, one listener instead of many. Control of the shortcut context. Fix https://github.com/FreshRSS/FreshRSS/issues/2215 * Remove debug * Minor syntax * Filter out unwanted shortcut modifiers * Menu overflow fix * Typo * Fix unfolding in mobile view * Remove jQuery from category.js * Remove jQuery from Global view --- lib/Minz/Request.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib') diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 8b2b610d6..912c354ac 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -95,6 +95,7 @@ class Minz_Request { */ public static function init() { self::magicQuotesOff(); + self::initJSON(); } /** @@ -237,6 +238,30 @@ class Minz_Request { } } + /** + * Allows receiving POST data as application/json + */ + private static function initJSON() { + $contentType = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : ''; + if ($contentType == '') { //PHP < 5.3.16 + $contentType = isset($_SERVER['HTTP_CONTENT_TYPE']) ? $_SERVER['HTTP_CONTENT_TYPE'] : ''; + } + $contentType = strtolower(trim($contentType)); + if ($contentType === 'application/json') { + $ORIGINAL_INPUT = file_get_contents('php://input', false, null, 0, 1048576); + if ($ORIGINAL_INPUT != '') { + $json = json_decode($ORIGINAL_INPUT, true); + if ($json != null) { + foreach ($json as $k => $v) { + if (!isset($_POST[$k])) { + $_POST[$k] = $v; + } + } + } + } + } + } + /** * Permet de récupérer une variable de type $_POST * @param $param nom de la variable -- cgit v1.2.3 From 834ffacce22ff6a2c0f1459476dc4a45e8ea06f9 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 19 Mar 2019 20:14:31 +0100 Subject: No old ID (#2276) * No old ID https://github.com/FreshRSS/FreshRSS/issues/2273 * PostgreSQL insert or ignore --- app/Controllers/feedController.php | 10 +++------- app/Controllers/importExportController.php | 2 +- app/Models/EntryDAOPGSQL.php | 4 +++- lib/lib_rss.php | 7 +------ 4 files changed, 8 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index d5ae235ad..7f36e0388 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -377,17 +377,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $read_upon_reception = $feed->attributes('read_upon_reception') !== null ? ( $feed->attributes('read_upon_reception') ) : FreshRSS_Context::$user_conf->mark_when['reception']; - if ($isNewFeed) { - $id = min(time(), $entry_date) . uSecString(); - $entry->_isRead($read_upon_reception); - } elseif ($entry_date < $date_min) { - $id = min(time(), $entry_date) . uSecString(); + $id = uTimeString(); + $entry->_id($id); + if ($entry_date < $date_min) { $entry->_isRead(true); //Old article that was not in database. Probably an error, so mark as read } else { - $id = uTimeString(); $entry->_isRead($read_upon_reception); } - $entry->_id($id); $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry === null) { diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 80b9868ec..1d7176929 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -585,7 +585,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $feed_id, $item['id'], $item['title'], $author, $content, $url, $published, $is_read, $is_starred ); - $entry->_id(min(time(), $entry->date(true)) . uSecString()); + $entry->_id(uTimeString()); $entry->_tags($tags); if (isset($newGuids[$entry->guid()])) { diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index aef258b6f..e571e457f 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -37,7 +37,9 @@ BEGIN INSERT INTO `' . $this->prefix . 'entry` (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) (SELECT rank + row_number() OVER(ORDER BY date) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` AS etmp - WHERE NOT EXISTS (SELECT 1 FROM `' . $this->prefix . 'entry` AS ereal WHERE etmp.id_feed = ereal.id_feed AND etmp.guid = ereal.guid) + WHERE NOT EXISTS ( + SELECT 1 FROM `' . $this->prefix . 'entry` AS ereal + WHERE (etmp.id = ereal.id) OR (etmp.id_feed = ereal.id_feed AND etmp.guid = ereal.guid)) ORDER BY date); DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= maxrank; END $$;'; diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 89e9ddfea..bff59d5cc 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -303,12 +303,7 @@ function lazyimg($content) { function uTimeString() { $t = @gettimeofday(); - return $t['sec'] . str_pad($t['usec'], 6, '0'); -} - -function uSecString() { - $t = @gettimeofday(); - return str_pad($t['usec'], 6, '0'); + return $t['sec'] . str_pad($t['usec'], 6, '0', STR_PAD_LEFT); } function invalidateHttpCache($username = '') { -- cgit v1.2.3 From f2925594c7caf2753e1ac44941e029a3c1496117 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 23 Mar 2019 23:17:22 +0100 Subject: Add header to cli (#2296) * Add header to cli Now there is a switch to display the header on user info. While doing that, I've changed how the command is working to display all users by default and to accept more than one user at once. I also changed the display to make it more pleasing. As this command displays all users by default. I wonder if we still need the list user command. See #2294 * Minor format --- cli/user-info.php | 77 ++++++++++++++++++++++++++++++++++--------------------- lib/lib_rss.php | 2 +- 2 files changed, 49 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/cli/user-info.php b/cli/user-info.php index 125408c10..aa4db7c2f 100755 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -2,19 +2,46 @@ default_user ? '*' : ' ', "\t"; $catDAO = FreshRSS_Factory::createCategoryDao(); $feedDAO = FreshRSS_Factory::createFeedDao($username); @@ -25,31 +52,23 @@ foreach ($users as $username) { $nbEntries = $entryDAO->countUnreadRead(); $nbFavorites = $entryDAO->countUnreadReadFavorites(); + $data = array( + 'default' => $username === FreshRSS_Context::$system_conf->default_user ? '*' : '', + 'user' => $username, + 'lastUpdate' => FreshRSS_UserDAO::mtime($username), + 'spaceUsed' => $databaseDAO->size(), + 'categories' => $catDAO->count(), + 'feeds' => count($feedDAO->listFeedsIds()), + 'reads' => $nbEntries['read'], + 'unreads' => $nbEntries['unread'], + 'favourites' => $nbFavorites['all'], + 'tags' => $tagDAO->count(), + ); if (isset($options['h'])) { //Human format - echo - $username, "\t", - date('c', FreshRSS_UserDAO::mtime($username)), "\t", - format_bytes($databaseDAO->size()), "\t", - $catDAO->count(), " categories\t", - count($feedDAO->listFeedsIds()), " feeds\t", - $nbEntries['read'], " reads\t", - $nbEntries['unread'], " unreads\t", - $nbFavorites['all'], " favourites\t", - $tagDAO->count(), " tags\t", - "\n"; - } else { - echo - $username, "\t", - FreshRSS_UserDAO::mtime($username), "\t", - $databaseDAO->size(), "\t", - $catDAO->count(), "\t", - count($feedDAO->listFeedsIds()), "\t", - $nbEntries['read'], "\t", - $nbEntries['unread'], "\t", - $nbFavorites['all'], "\t", - $tagDAO->count(), "\t", - "\n"; + $data['lastUpdate'] = date('c', $data['lastUpdate']); + $data['spaceUsed'] = format_bytes($data['spaceUsed']); } + vprintf(DATA_FORMAT, $data); } done(); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index bff59d5cc..3e0033a61 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -170,7 +170,7 @@ function format_bytes($bytes, $precision = 2, $system = 'IEC') { $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base)); $pow = min($pow, count($units) - 1); $bytes /= pow($base, $pow); - return format_number($bytes, $precision) . ' ' . $units[$pow]; + return format_number($bytes, $precision) . ' ' . $units[$pow]; } function timestamptodate ($t, $hour = true) { -- cgit v1.2.3