diff --git a/inc/config.php b/inc/config.php index f9a4701ee..6d8be9ee9 100644 --- a/inc/config.php +++ b/inc/config.php @@ -13,4 +13,14 @@ include 'db.php'; include 'functions.php'; require_once 'Readability.php'; require_once 'Encoding.php'; +require_once 'rain.tpl.class.php'; + +$db = new db(DB_PATH); + +raintpl::$tpl_dir = './tpl/'; +raintpl::$cache_dir = './cache/'; +raintpl::$base_url = get_poche_url(); +raintpl::configure('path_replace', false); +raintpl::configure('debug', false); +$tpl = new raintpl(); ?> \ No newline at end of file diff --git a/inc/functions.php b/inc/functions.php index 0b9eb9369..ffd400ef3 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -3,7 +3,7 @@ /** * Permet de générer l'URL de poche pour le bookmarklet */ -function url() +function get_poche_url() { $protocol = "http"; if(isset($_SERVER['HTTPS'])) { @@ -15,29 +15,6 @@ function url() return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } -/** - * Génération de la page "vue d'un article" - */ -function generate_page($entry) -{ - raintpl::$tpl_dir = './tpl/'; - raintpl::$cache_dir = "./cache/"; - raintpl::$base_url = url(); - raintpl::configure( 'path_replace', false ); - raintpl::configure('debug', false); - - $tpl = new raintpl(); - - $tpl->assign("id", $entry['id']); - $tpl->assign("url", $entry['url']); - $tpl->assign("title", $entry['title']); - $tpl->assign("content", $entry['content']); - $tpl->assign("is_fav", $entry['is_fav']); - $tpl->assign("is_read", $entry['is_read']); - - $tpl->draw( "index"); -} - // function define to retrieve url content function get_external_file($url, $timeout) { @@ -111,6 +88,9 @@ function get_external_file($url, $timeout) } } +/** + * Préparation de l'URL avec récupération du contenu avant insertion en base + */ function prepare_url($url) { $parametres = array(); diff --git a/index.php b/index.php index 8c695cd33..ef18254a4 100755 --- a/index.php +++ b/index.php @@ -9,7 +9,6 @@ */ include dirname(__FILE__).'/inc/config.php'; -$db = new db(DB_PATH); $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; $view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; @@ -19,15 +18,12 @@ $url = (isset ($_GET['url'])) ? $_GET['url'] : ''; switch ($action) { case 'add': - if ($url == '') continue; $parametres_url = prepare_url($url); - - $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; + $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; $params_action = array($url, $parametres_url['title'], $parametres_url['content']); - break; case 'delete': $sql_action = "DELETE FROM entries WHERE id=?"; @@ -80,79 +76,9 @@ catch (Exception $e) die('view query error : '.$e->getMessage()); } -?> - - - - - - - - - - - poche, a read it later open source system - - - - - - - - -
-

logo pochepoche

-
-
- -
- -
- -

- -

-
- - - -
-
-
- -
-
- - - - - - - +$tpl->assign('title', 'poche, a read it later open source system'); +$tpl->assign('view', $view); +$tpl->assign('poche_url', get_poche_url()); +$tpl->assign('entries', $entries); +$tpl->assign('load_all_js', 1); +$tpl->draw('home'); \ No newline at end of file diff --git a/tpl/footer.html b/tpl/footer.html index 3328a8a4e..d225acbe3 100755 --- a/tpl/footer.html +++ b/tpl/footer.html @@ -1,5 +1,3 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/tpl/head.html b/tpl/head.html new file mode 100644 index 000000000..66150d8f8 --- /dev/null +++ b/tpl/head.html @@ -0,0 +1,18 @@ + + + + + + + + + + + {$title} + + + + + + + \ No newline at end of file diff --git a/tpl/home.html b/tpl/home.html new file mode 100644 index 000000000..70a35a7fc --- /dev/null +++ b/tpl/home.html @@ -0,0 +1,33 @@ +{include="head"} + +
+

logo pochepoche

+
+
+ +
+ {loop="entries"} +
+ +

+ {$value.title} +

+
+ + + +
+
+
+ {/loop} +
+
+ {include="footer"} + {include="js"} + + diff --git a/tpl/js.html b/tpl/js.html new file mode 100644 index 000000000..a02212b01 --- /dev/null +++ b/tpl/js.html @@ -0,0 +1,22 @@ + + + + {if="$load_all_js == '1'"} + + + {/if} \ No newline at end of file diff --git a/tpl/view.html b/tpl/view.html new file mode 100755 index 000000000..1e0578899 --- /dev/null +++ b/tpl/view.html @@ -0,0 +1,29 @@ +{include="head"} + +
+
+ +
+
+ + + +
+
+

{$title}

+ +
+
+
+ {$content} +
+
+
view original
+
+ +
+
+ {include="footer"} + {include="js"} + + diff --git a/view.php b/view.php index 75e6c3a9e..0ee8957b9 100755 --- a/view.php +++ b/view.php @@ -8,11 +8,7 @@ * @license http://www.wtfpl.net/ see COPYING file */ -header('Content-type:text/html; charset=utf-8'); - include dirname(__FILE__).'/inc/config.php'; -require_once dirname(__FILE__).'/inc/rain.tpl.class.php'; -$db = new db(DB_PATH); if(isset($_GET['id']) && $_GET['id'] != '') { @@ -32,7 +28,14 @@ if(isset($_GET['id']) && $_GET['id'] != '') { } if ($entry != NULL) { - generate_page($entry[0]); + $tpl->assign('id', $entry[0]['id']); + $tpl->assign('url', $entry[0]['url']); + $tpl->assign('title', $entry[0]['title']); + $tpl->assign('content', $entry[0]['content']); + $tpl->assign('is_fav', $entry[0]['is_fav']); + $tpl->assign('is_read', $entry[0]['is_read']); + $tpl->assign('load_all_js', 0); + $tpl->draw('view'); } else { die('error in view call');