diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-05-07 16:50:20 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-05-07 17:11:22 +0200 |
commit | 813849e5216cb87121e0f778a734575be6a36052 (patch) | |
tree | 45605ad43e3f751eba51d19f8c6955c3824e8d32 /index.php | |
parent | a4af59f47103a3f9c903eeddb1e30ab9cb7344f0 (diff) | |
download | Shaarli-813849e5216cb87121e0f778a734575be6a36052.tar.gz Shaarli-813849e5216cb87121e0f778a734575be6a36052.tar.zst Shaarli-813849e5216cb87121e0f778a734575be6a36052.zip |
Add history entries for API endpoint
CHANGED: datetime is now store as an object in history store file
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -707,7 +707,7 @@ function showLinkList($PAGE, $LINKSDB, $conf, $pluginManager) { | |||
707 | * @param PluginManager $pluginManager Plugin Manager instance, | 707 | * @param PluginManager $pluginManager Plugin Manager instance, |
708 | * @param LinkDB $LINKSDB | 708 | * @param LinkDB $LINKSDB |
709 | */ | 709 | */ |
710 | function renderPage($conf, $pluginManager, $LINKSDB) | 710 | function renderPage($conf, $pluginManager, $LINKSDB, $history) |
711 | { | 711 | { |
712 | $updater = new Updater( | 712 | $updater = new Updater( |
713 | read_updates_file($conf->get('resource.updates')), | 713 | read_updates_file($conf->get('resource.updates')), |
@@ -728,12 +728,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
728 | die($e->getMessage()); | 728 | die($e->getMessage()); |
729 | } | 729 | } |
730 | 730 | ||
731 | try { | ||
732 | $history = new History($conf->get('resource.history')); | ||
733 | } catch(Exception $e) { | ||
734 | die($e->getMessage()); | ||
735 | } | ||
736 | |||
737 | $PAGE = new PageBuilder($conf); | 731 | $PAGE = new PageBuilder($conf); |
738 | $PAGE->assign('linkcount', count($LINKSDB)); | 732 | $PAGE->assign('linkcount', count($LINKSDB)); |
739 | $PAGE->assign('privateLinkcount', count_private($LINKSDB)); | 733 | $PAGE->assign('privateLinkcount', count_private($LINKSDB)); |
@@ -2240,9 +2234,16 @@ $linkDb = new LinkDB( | |||
2240 | $conf->get('redirector.encode_url') | 2234 | $conf->get('redirector.encode_url') |
2241 | ); | 2235 | ); |
2242 | 2236 | ||
2237 | try { | ||
2238 | $history = new History($conf->get('resource.history')); | ||
2239 | } catch(Exception $e) { | ||
2240 | die($e->getMessage()); | ||
2241 | } | ||
2242 | |||
2243 | $container = new \Slim\Container(); | 2243 | $container = new \Slim\Container(); |
2244 | $container['conf'] = $conf; | 2244 | $container['conf'] = $conf; |
2245 | $container['plugins'] = $pluginManager; | 2245 | $container['plugins'] = $pluginManager; |
2246 | $container['history'] = $history; | ||
2246 | $app = new \Slim\App($container); | 2247 | $app = new \Slim\App($container); |
2247 | 2248 | ||
2248 | // REST API routes | 2249 | // REST API routes |
@@ -2262,7 +2263,7 @@ $response = $app->run(true); | |||
2262 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { | 2263 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { |
2263 | // We use UTF-8 for proper international characters handling. | 2264 | // We use UTF-8 for proper international characters handling. |
2264 | header('Content-Type: text/html; charset=utf-8'); | 2265 | header('Content-Type: text/html; charset=utf-8'); |
2265 | renderPage($conf, $pluginManager, $linkDb); | 2266 | renderPage($conf, $pluginManager, $linkDb, $history); |
2266 | } else { | 2267 | } else { |
2267 | $app->respond($response); | 2268 | $app->respond($response); |
2268 | } | 2269 | } |