]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | /** | |
3 | * poche, a read it later open source system | |
4 | * | |
5 | * @category poche | |
6 | * @author Nicolas Lœuillet <nicolas@loeuillet.org> | |
7 | * @copyright 2013 | |
8 | * @license http://www.wtfpl.net/ see COPYING file | |
9 | */ | |
10 | ||
11 | /** | |
12 | * TODO | |
13 | * gestion des erreurs sqlite (duplicate tout ça) | |
14 | * gérer si url vide | |
15 | * traiter les variables passées en get | |
16 | * récupérer le titre de la page pochée (cf readityourself.php) | |
17 | * actions archive, fav et delete à traiter | |
18 | * bookmarklet | |
19 | * améliorer présentation des liens | |
20 | * améliorer présentation d'un article | |
21 | * aligner verticalement les icones d'action | |
22 | * afficher liens mis en favoris et archivés | |
23 | * tri des liens | |
24 | */ | |
25 | ||
26 | try | |
27 | { | |
28 | $db_handle = new PDO('sqlite:poche.sqlite'); | |
29 | $db_handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
30 | } | |
31 | catch (Exception $e) | |
32 | { | |
33 | die('error : '.$e->getMessage()); | |
34 | } | |
35 | ||
36 | $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; | |
37 | ||
38 | switch ($action) { | |
39 | case 'add': | |
40 | $url = (isset ($_GET['url'])) ? htmlspecialchars($_GET['url']) : ''; | |
41 | $title = $url; | |
42 | $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)'); | |
43 | $query->execute(array($url, $title)); | |
44 | break; | |
45 | case 'archive': | |
46 | break; | |
47 | case 'fav' : | |
48 | break; | |
49 | case 'delete': | |
50 | break; | |
51 | default: | |
52 | break; | |
53 | } | |
54 | ||
55 | function url(){ | |
56 | $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http"; | |
57 | return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
58 | } | |
59 | ?> | |
60 | <!DOCTYPE html> | |
61 | <!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]--> | |
62 | <!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]--> | |
63 | <!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]--> | |
64 | <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> | |
65 | <html> | |
66 | <head> | |
67 | <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> | |
68 | <meta charset="utf-8"> | |
69 | <meta http-equiv="X-UA-Compatible" content="IE=10"> | |
70 | <title>poche : queue</title> | |
71 | <link rel="stylesheet" href="css/knacss.css" media="all"> | |
72 | <link rel="stylesheet" href="css/style.css" media="all"> | |
73 | </head> | |
74 | <body> | |
75 | <header> | |
76 | <h1>poche, a read it later open source system</h1> | |
77 | </header> | |
78 | <div id="main" class="w800p"> | |
79 | <ul id="links"> | |
80 | <li><a href="index.php">home</a></li> | |
81 | <li><a href="#">favorites</a></li> | |
82 | <li><a href="#">archive</a></li> | |
83 | <li><a href="javascript:(function(){var%20url%20=%20location.href;var%20title%20=%20document.title%20||%20url;window.open('<? echo url()?>index.php?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></li> | |
84 | </ul> | |
85 | <?php | |
86 | $query = $db_handle->prepare("SELECT * FROM entries WHERE read=?"); | |
87 | $query->execute(array('FALSE')); | |
88 | $entries = $query->fetchAll(); | |
89 | ?> | |
90 | <ul id="entries"> | |
91 | <?php | |
92 | foreach ($entries as $entry) { | |
93 | echo '<li><a href="readityourself.php?url='.urlencode($entry['url']).'">' . $entry['title'] . '</a> <a href="#" title="toggle delete" class="tool">✓</a> <a href="#" title="toggle favorite" class="tool">☆</a> <a href="#" title="toggle mark as read" class="tool">⨯</a></li>'; | |
94 | } | |
95 | ?> | |
96 | </ul> | |
97 | </div> | |
98 | <footer class="mr2 mt3"> | |
99 | <p class="smaller"><a href="http://github.com/nicosomb/poche">poche</a> is a read it later open source system, based on <a href="http://www.memiks.fr/readityourself/">ReadItYourself</a>. poche is developed by <a href="http://nicolas.loeuillet.org">Nicolas Lœuillet</a> under the <a href="http://www.wtfpl.net/">Do What the Fuck You Want to Public License</a></p> | |
100 | </footer> | |
101 | </body> | |
102 | </html> |