From 729c2bfb426e26c59e4028018a6ecf50d4d30894 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 3 May 2015 08:56:41 -0400 Subject: [PATCH] Fix Fever API bug: enable send bookmark to third-party services --- fever/.htaccess | 20 +++++++++++--------- fever/index.php | 9 +++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/fever/.htaccess b/fever/.htaccess index 7084940..d67a105 100644 --- a/fever/.htaccess +++ b/fever/.htaccess @@ -1,13 +1,15 @@ -RewriteEngine on + + RewriteEngine on -RewriteBase / + RewriteBase / -# only if the requested file does not exists -RewriteCond %{REQUEST_FILENAME} !-f + # only if the requested file does not exists + RewriteCond %{REQUEST_FILENAME} !-f -# Store the current location in an environment variable CWD -RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$ -RewriteRule ^.*$ - [E=CWD:%2] + # Store the current location in an environment variable CWD + RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$ + RewriteRule ^.*$ - [E=CWD:%2] -# Just by prefixing the environment variable, we can safely rewrite anything now -RewriteRule ^([^/]*) %{ENV:CWD}index.php?database=$1 [QSA,L] \ No newline at end of file + # Just by prefixing the environment variable, we can safely rewrite anything now + RewriteRule ^([^/]*) %{ENV:CWD}index.php?database=$1 [QSA,L] + \ No newline at end of file diff --git a/fever/index.php b/fever/index.php index 0bd3f9a..6f23a4d 100644 --- a/fever/index.php +++ b/fever/index.php @@ -3,6 +3,7 @@ require '../common.php'; use Model\Feed; +use Model\Service; use PicoDb\Database; // Route handler @@ -262,6 +263,14 @@ route('write_items', function() { if ($_POST['as'] === 'saved') { $query->update(array('bookmark' => 1)); + + // Send bookmark to third-party services if enabled + $item_id = Database::get('db') + ->table('items') + ->eq('rowid', $_POST['id']) + ->findOneColumn('id'); + + Service\push($item_id); } else if ($_POST['as'] === 'unsaved') { $query->update(array('bookmark' => 0));