aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/config.php10
-rwxr-xr-xinc/functions.php28
-rwxr-xr-xindex.php88
-rwxr-xr-xtpl/footer.html4
-rw-r--r--tpl/head.html18
-rw-r--r--tpl/home.html33
-rw-r--r--tpl/js.html22
-rwxr-xr-xtpl/view.html29
-rwxr-xr-xview.php13
9 files changed, 132 insertions, 113 deletions
diff --git a/inc/config.php b/inc/config.php
index f9a4701e..6d8be9ee 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -13,4 +13,14 @@ include 'db.php';
13include 'functions.php'; 13include 'functions.php';
14require_once 'Readability.php'; 14require_once 'Readability.php';
15require_once 'Encoding.php'; 15require_once 'Encoding.php';
16require_once 'rain.tpl.class.php';
17
18$db = new db(DB_PATH);
19
20raintpl::$tpl_dir = './tpl/';
21raintpl::$cache_dir = './cache/';
22raintpl::$base_url = get_poche_url();
23raintpl::configure('path_replace', false);
24raintpl::configure('debug', false);
25$tpl = new raintpl();
16?> \ No newline at end of file 26?> \ No newline at end of file
diff --git a/inc/functions.php b/inc/functions.php
index 0b9eb936..ffd400ef 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -3,7 +3,7 @@
3/** 3/**
4 * Permet de générer l'URL de poche pour le bookmarklet 4 * Permet de générer l'URL de poche pour le bookmarklet
5 */ 5 */
6function url() 6function get_poche_url()
7{ 7{
8 $protocol = "http"; 8 $protocol = "http";
9 if(isset($_SERVER['HTTPS'])) { 9 if(isset($_SERVER['HTTPS'])) {
@@ -15,29 +15,6 @@ function url()
15 return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 15 return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
16} 16}
17 17
18/**
19 * Génération de la page "vue d'un article"
20 */
21function generate_page($entry)
22{
23 raintpl::$tpl_dir = './tpl/';
24 raintpl::$cache_dir = "./cache/";
25 raintpl::$base_url = url();
26 raintpl::configure( 'path_replace', false );
27 raintpl::configure('debug', false);
28
29 $tpl = new raintpl();
30
31 $tpl->assign("id", $entry['id']);
32 $tpl->assign("url", $entry['url']);
33 $tpl->assign("title", $entry['title']);
34 $tpl->assign("content", $entry['content']);
35 $tpl->assign("is_fav", $entry['is_fav']);
36 $tpl->assign("is_read", $entry['is_read']);
37
38 $tpl->draw( "index");
39}
40
41// function define to retrieve url content 18// function define to retrieve url content
42function get_external_file($url, $timeout) 19function get_external_file($url, $timeout)
43{ 20{
@@ -111,6 +88,9 @@ function get_external_file($url, $timeout)
111 } 88 }
112} 89}
113 90
91/**
92 * Préparation de l'URL avec récupération du contenu avant insertion en base
93 */
114function prepare_url($url) 94function prepare_url($url)
115{ 95{
116 $parametres = array(); 96 $parametres = array();
diff --git a/index.php b/index.php
index 8c695cd3..ef18254a 100755
--- a/index.php
+++ b/index.php
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11include dirname(__FILE__).'/inc/config.php'; 11include dirname(__FILE__).'/inc/config.php';
12$db = new db(DB_PATH);
13 12
14$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; 13$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
15$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; 14$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : '';
@@ -19,15 +18,12 @@ $url = (isset ($_GET['url'])) ? $_GET['url'] : '';
19switch ($action) 18switch ($action)
20{ 19{
21 case 'add': 20 case 'add':
22
23 if ($url == '') 21 if ($url == '')
24 continue; 22 continue;
25 23
26 $parametres_url = prepare_url($url); 24 $parametres_url = prepare_url($url);
27 25 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
28 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
29 $params_action = array($url, $parametres_url['title'], $parametres_url['content']); 26 $params_action = array($url, $parametres_url['title'], $parametres_url['content']);
30
31 break; 27 break;
32 case 'delete': 28 case 'delete':
33 $sql_action = "DELETE FROM entries WHERE id=?"; 29 $sql_action = "DELETE FROM entries WHERE id=?";
@@ -80,79 +76,9 @@ catch (Exception $e)
80 die('view query error : '.$e->getMessage()); 76 die('view query error : '.$e->getMessage());
81} 77}
82 78
83?> 79$tpl->assign('title', 'poche, a read it later open source system');
84<!DOCTYPE html> 80$tpl->assign('view', $view);
85<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]--> 81$tpl->assign('poche_url', get_poche_url());
86<!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]--> 82$tpl->assign('entries', $entries);
87<!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]--> 83$tpl->assign('load_all_js', 1);
88<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> 84$tpl->draw('home'); \ No newline at end of file
89<html>
90 <head>
91 <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
92 <meta charset="utf-8">
93 <meta http-equiv="X-UA-Compatible" content="IE=10">
94 <title>poche, a read it later open source system</title>
95 <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
96 <link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144x144-precomposed.png">
97 <link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
98 <link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-precomposed.png">
99 <link rel="stylesheet" href="css/knacss.css" media="all">
100 <link rel="stylesheet" href="css/style.css" media="all">
101 </head>
102 <body>
103 <header>
104 <h1><img src="img/logo.png" alt="logo poche" />poche</h1>
105 </header>
106 <div id="main">
107 <ul id="links">
108 <li><a href="index.php" <?php echo (($view == 'index') ? 'class="current"' : ''); ?>>home</a></li>
109 <li><a href="?view=fav" <?php echo (($view == 'fav') ? 'class="current"' : ''); ?>>favorites</a></li>
110 <li><a href="?view=archive" <?php echo (($view == 'archive') ? 'class="current"' : ''); ?>>archive</a></li>
111 <li><a style="cursor: move" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href;var%20title%20=%20document.title%20||%20url;window.open('<?php echo url()?>?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></li>
112 </ul>
113 <div id="content">
114 <?php
115 foreach ($entries as $entry)
116 {
117 ?>
118 <div id="entry-<?php echo $entry['id']; ?>" class="entrie mb2">
119 <span class="content">
120 <h2 class="h6-like">
121 <a href="view.php?id=<?php echo $entry['id']; ?>"><?php echo $entry['title']; ?>
122 </h2>
123 <div class="tools">
124 <a title="toggle mark as read" class="tool archive <?php echo ( ($entry['is_read'] == '0') ? 'archive-off' : '' ); ?>" onclick="toggle_archive(this, <?php echo $entry['id']; ?>)"><span></span></a>
125 <a title="toggle favorite" class="tool fav <?php echo ( ($entry['is_fav'] == '0') ? 'fav-off' : '' ); ?>" onclick="toggle_favorite(this, <?php echo $entry['id']; ?>)"><span></span></a>
126 <a href="?action=delete&id=<?php echo $entry['id']; ?>" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
127 </div>
128 </span>
129 </div>
130 <?php
131 }
132 ?>
133 </div>
134 </div>
135 <footer class="mr2 mt3 smaller">
136 <p>powered by <a href="http://inthepoche.com">poche</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p>
137 </footer>
138 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
139 <script type="text/javascript" src="js/jquery.masonry.min.js"></script>
140 <script type="text/javascript" src="js/poche.js"></script>
141 <script type="text/javascript">
142 $( window ).load( function()
143 {
144 var columns = 3,
145 setColumns = function() { columns = $( window ).width() > 640 ? 3 : $( window ).width() > 320 ? 2 : 1; };
146
147 setColumns();
148 $( window ).resize( setColumns );
149
150 $( '#content' ).masonry(
151 {
152 itemSelector: '.entrie',
153 columnWidth: function( containerWidth ) { return containerWidth / columns; }
154 });
155 });
156 </script>
157 </body>
158</html>
diff --git a/tpl/footer.html b/tpl/footer.html
index 3328a8a4..d225acbe 100755
--- a/tpl/footer.html
+++ b/tpl/footer.html
@@ -1,5 +1,3 @@
1 <footer class="mr2 mt3 smaller"> 1 <footer class="mr2 mt3 smaller">
2 <p>powered by <a href="http://inthepoche.com">poche</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p> 2 <p>powered by <a href="http://inthepoche.com">poche</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p>
3 </footer> 3 </footer> \ No newline at end of file
4 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
5 <script type="text/javascript" src="js/poche.js"></script> \ No newline at end of file
diff --git a/tpl/head.html b/tpl/head.html
new file mode 100644
index 00000000..66150d8f
--- /dev/null
+++ b/tpl/head.html
@@ -0,0 +1,18 @@
1<!DOCTYPE html>
2<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
3<!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]-->
4<!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]-->
5<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6<html>
7 <head>
8 <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
9 <meta charset="utf-8">
10 <meta http-equiv="X-UA-Compatible" content="IE=10">
11 <title>{$title}</title>
12 <link rel="shortcut icon" type="image/x-icon" href="./img/favicon.ico" />
13 <link rel="apple-touch-icon-precomposed" sizes="144x144" href="./img/apple-touch-icon-144x144-precomposed.png">
14 <link rel="apple-touch-icon-precomposed" sizes="72x72" href="./img/apple-touch-icon-72x72-precomposed.png">
15 <link rel="apple-touch-icon-precomposed" href="./img/apple-touch-icon-precomposed.png">
16 <link rel="stylesheet" href="./css/knacss.css" media="all">
17 <link rel="stylesheet" href="./css/style.css" media="all">
18 </head> \ No newline at end of file
diff --git a/tpl/home.html b/tpl/home.html
new file mode 100644
index 00000000..70a35a7f
--- /dev/null
+++ b/tpl/home.html
@@ -0,0 +1,33 @@
1{include="head"}
2 <body>
3 <header>
4 <h1><img src="./img/logo.png" alt="logo poche" />poche</h1>
5 </header>
6 <div id="main">
7 <ul id="links">
8 <li><a href="index.php" {if="$view == 'index'"}class="current"{/if}>home</a></li>
9 <li><a href="?view=fav" {if="$view == 'fav'"}class="current"{/if}>favorites</a></li>
10 <li><a href="?view=archive" {if="$view == 'archive'"}class="current"{/if}>archive</a></li>
11 <li><a style="cursor: move" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href;var%20title%20=%20document.title%20||%20url;window.open('{$poche_url}?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></li>
12 </ul>
13 <div id="content">
14 {loop="entries"}
15 <div id="entry-{$value.id}" class="entrie mb2">
16 <span class="content">
17 <h2 class="h6-like">
18 <a href="view.php?id={$value.id}">{$value.title}</a>
19 </h2>
20 <div class="tools">
21 <a title="toggle mark as read" class="tool archive {if="$value.is_read == '0'"}archive-off{/if}" onclick="toggle_archive(this, {$value.id})"><span></span></a>
22 <a title="toggle favorite" class="tool fav {if="$value.is_fav == '0'"}fav-off{/if}" onclick="toggle_favorite(this, {$value.id})"><span></span></a>
23 <a href="?action=delete&id={$value.id}" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
24 </div>
25 </span>
26 </div>
27 {/loop}
28 </div>
29 </div>
30 {include="footer"}
31 {include="js"}
32 </body>
33</html>
diff --git a/tpl/js.html b/tpl/js.html
new file mode 100644
index 00000000..a02212b0
--- /dev/null
+++ b/tpl/js.html
@@ -0,0 +1,22 @@
1 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
2 <script type="text/javascript" src="js/poche.js"></script>
3
4 {if="$load_all_js == '1'"}
5 <script type="text/javascript" src="js/jquery.masonry.min.js"></script>
6 <script type="text/javascript">
7 $( window ).load( function()
8 {
9 var columns = 3,
10 setColumns = function() { columns = $( window ).width() > 640 ? 3 : $( window ).width() > 320 ? 2 : 1; };
11
12 setColumns();
13 $( window ).resize( setColumns );
14
15 $( '#content' ).masonry(
16 {
17 itemSelector: '.entrie',
18 columnWidth: function( containerWidth ) { return containerWidth / columns; }
19 });
20 });
21 </script>
22 {/if} \ No newline at end of file
diff --git a/tpl/view.html b/tpl/view.html
new file mode 100755
index 00000000..1e057889
--- /dev/null
+++ b/tpl/view.html
@@ -0,0 +1,29 @@
1{include="head"}
2 <body class="article">
3 <div id="article" class="w600p">
4 <div class="backhome">
5 <a href="index.php" title="back to home">&larr;</a>
6 </div>
7 <div class="tools">
8 <a title="toggle mark as read" class="tool archive {if="$is_read == 0"}archive-off{/if}" onclick="toggle_archive(this, {$id}, 1)"><span></span></a>
9 <a title="toggle favorite" class="tool fav {if="$is_fav == 0"}fav-off{/if}" onclick="toggle_favorite(this, {$id})"><span></span></a>
10 <a href="index.php?action=delete&id={$id}" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
11 </div>
12 <header class="mbm">
13 <h1><a href="{$url}">{$title}</a></h1>
14 <div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>
15 </header>
16 <article>
17 <div id="readityourselfcontent">
18 {$content}
19 </div>
20 </article>
21 <div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>
22 <div class="backhome">
23 <a href="index.php" title="back to home">&larr;</a>
24 </div>
25 </div>
26 {include="footer"}
27 {include="js"}
28 </body>
29</html>
diff --git a/view.php b/view.php
index 75e6c3a9..0ee8957b 100755
--- a/view.php
+++ b/view.php
@@ -8,11 +8,7 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11header('Content-type:text/html; charset=utf-8');
12
13include dirname(__FILE__).'/inc/config.php'; 11include dirname(__FILE__).'/inc/config.php';
14require_once dirname(__FILE__).'/inc/rain.tpl.class.php';
15$db = new db(DB_PATH);
16 12
17if(isset($_GET['id']) && $_GET['id'] != '') { 13if(isset($_GET['id']) && $_GET['id'] != '') {
18 14
@@ -32,7 +28,14 @@ if(isset($_GET['id']) && $_GET['id'] != '') {
32 } 28 }
33 29
34 if ($entry != NULL) { 30 if ($entry != NULL) {
35 generate_page($entry[0]); 31 $tpl->assign('id', $entry[0]['id']);
32 $tpl->assign('url', $entry[0]['url']);
33 $tpl->assign('title', $entry[0]['title']);
34 $tpl->assign('content', $entry[0]['content']);
35 $tpl->assign('is_fav', $entry[0]['is_fav']);
36 $tpl->assign('is_read', $entry[0]['is_read']);
37 $tpl->assign('load_all_js', 0);
38 $tpl->draw('view');
36 } 39 }
37 else { 40 else {
38 die('error in view call'); 41 die('error in view call');