aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--css/style.css30
-rwxr-xr-xinc/Encoding.php42
-rwxr-xr-xinc/functions.php101
-rwxr-xr-xindex.php2
-rw-r--r--js/poche.js15
-rwxr-xr-xtpl/footer.html2
-rwxr-xr-xtpl/index.html5
-rwxr-xr-xview.php10
8 files changed, 107 insertions, 100 deletions
diff --git a/css/style.css b/css/style.css
index d53060ec..959a411a 100644
--- a/css/style.css
+++ b/css/style.css
@@ -100,7 +100,15 @@ footer {
100 margin-left: -20px; 100 margin-left: -20px;
101} 101}
102 102
103#main .entrie .tools a.tool span { 103#article .tools {
104 display: inline;
105}
106
107#article .tools a.tool {
108 cursor: pointer;
109}
110
111#main .entrie .tools a.tool span, #article .tools a.tool span {
104 display: inline-block; 112 display: inline-block;
105 width: 16px; 113 width: 16px;
106 height: 16px; 114 height: 16px;
@@ -110,18 +118,34 @@ a.fav span {
110 background: url('../img/fav-on.png') no-repeat; 118 background: url('../img/fav-on.png') no-repeat;
111} 119}
112 120
121a.fav span:hover {
122 background: url('../img/fav-off.png') no-repeat;
123}
124
113a.fav-off span { 125a.fav-off span {
114 background: url('../img/fav-off.png') no-repeat; 126 background: url('../img/fav-off.png') no-repeat;
115} 127}
116 128
129a.fav-off span:hover {
130 background: url('../img/fav-on.png') no-repeat;
131}
132
117a.archive span { 133a.archive span {
118 background: url('../img/archive-on.png') no-repeat; 134 background: url('../img/archive-on.png') no-repeat;
119} 135}
120 136
137a.archive span:hover {
138 background: url('../img/archive-off.png') no-repeat;
139}
140
121a.archive-off span { 141a.archive-off span {
122 background: url('../img/archive-off.png') no-repeat; 142 background: url('../img/archive-off.png') no-repeat;
123} 143}
124 144
145a.archive-off span:hover {
146 background: url('../img/archive-on.png') no-repeat;
147}
148
125a.delete span { 149a.delete span {
126 background: url('../img/delete.png') no-repeat; 150 background: url('../img/delete.png') no-repeat;
127} 151}
@@ -153,6 +177,10 @@ body.article {
153 text-decoration: none; 177 text-decoration: none;
154} 178}
155 179
180.backhome {
181 display: inline;
182}
183
156/*** ***/ 184/*** ***/
157#main 185#main
158{ 186{
diff --git a/inc/Encoding.php b/inc/Encoding.php
index ac107af9..577763b4 100755
--- a/inc/Encoding.php
+++ b/inc/Encoding.php
@@ -1,4 +1,4 @@
1<?php 1<?php
2/** 2/**
3 * @author "Sebastián Grignoli" <grignoli@framework2.com.ar> 3 * @author "Sebastián Grignoli" <grignoli@framework2.com.ar>
4 * @package Encoding 4 * @package Encoding
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10class Encoding { 10class Encoding {
11 11
12 protected static $win1252ToUtf8 = array( 12 protected static $win1252ToUtf8 = array(
13 128 => "\xe2\x82\xac", 13 128 => "\xe2\x82\xac",
14 14
@@ -43,10 +43,10 @@ class Encoding {
43 158 => "\xc5\xbe", 43 158 => "\xc5\xbe",
44 159 => "\xc5\xb8" 44 159 => "\xc5\xb8"
45 ); 45 );
46 46
47 protected static $brokenUtf8ToUtf8 = array( 47 protected static $brokenUtf8ToUtf8 = array(
48 "\xc2\x80" => "\xe2\x82\xac", 48 "\xc2\x80" => "\xe2\x82\xac",
49 49
50 "\xc2\x82" => "\xe2\x80\x9a", 50 "\xc2\x82" => "\xe2\x80\x9a",
51 "\xc2\x83" => "\xc6\x92", 51 "\xc2\x83" => "\xc6\x92",
52 "\xc2\x84" => "\xe2\x80\x9e", 52 "\xc2\x84" => "\xe2\x80\x9e",
@@ -58,10 +58,10 @@ class Encoding {
58 "\xc2\x8a" => "\xc5\xa0", 58 "\xc2\x8a" => "\xc5\xa0",
59 "\xc2\x8b" => "\xe2\x80\xb9", 59 "\xc2\x8b" => "\xe2\x80\xb9",
60 "\xc2\x8c" => "\xc5\x92", 60 "\xc2\x8c" => "\xc5\x92",
61 61
62 "\xc2\x8e" => "\xc5\xbd", 62 "\xc2\x8e" => "\xc5\xbd",
63 63
64 64
65 "\xc2\x91" => "\xe2\x80\x98", 65 "\xc2\x91" => "\xe2\x80\x98",
66 "\xc2\x92" => "\xe2\x80\x99", 66 "\xc2\x92" => "\xe2\x80\x99",
67 "\xc2\x93" => "\xe2\x80\x9c", 67 "\xc2\x93" => "\xe2\x80\x9c",
@@ -74,14 +74,14 @@ class Encoding {
74 "\xc2\x9a" => "\xc5\xa1", 74 "\xc2\x9a" => "\xc5\xa1",
75 "\xc2\x9b" => "\xe2\x80\xba", 75 "\xc2\x9b" => "\xe2\x80\xba",
76 "\xc2\x9c" => "\xc5\x93", 76 "\xc2\x9c" => "\xc5\x93",
77 77
78 "\xc2\x9e" => "\xc5\xbe", 78 "\xc2\x9e" => "\xc5\xbe",
79 "\xc2\x9f" => "\xc5\xb8" 79 "\xc2\x9f" => "\xc5\xb8"
80 ); 80 );
81 81
82 protected static $utf8ToWin1252 = array( 82 protected static $utf8ToWin1252 = array(
83 "\xe2\x82\xac" => "\x80", 83 "\xe2\x82\xac" => "\x80",
84 84
85 "\xe2\x80\x9a" => "\x82", 85 "\xe2\x80\x9a" => "\x82",
86 "\xc6\x92" => "\x83", 86 "\xc6\x92" => "\x83",
87 "\xe2\x80\x9e" => "\x84", 87 "\xe2\x80\x9e" => "\x84",
@@ -93,10 +93,10 @@ class Encoding {
93 "\xc5\xa0" => "\x8a", 93 "\xc5\xa0" => "\x8a",
94 "\xe2\x80\xb9" => "\x8b", 94 "\xe2\x80\xb9" => "\x8b",
95 "\xc5\x92" => "\x8c", 95 "\xc5\x92" => "\x8c",
96 96
97 "\xc5\xbd" => "\x8e", 97 "\xc5\xbd" => "\x8e",
98 98
99 99
100 "\xe2\x80\x98" => "\x91", 100 "\xe2\x80\x98" => "\x91",
101 "\xe2\x80\x99" => "\x92", 101 "\xe2\x80\x99" => "\x92",
102 "\xe2\x80\x9c" => "\x93", 102 "\xe2\x80\x9c" => "\x93",
@@ -109,7 +109,7 @@ class Encoding {
109 "\xc5\xa1" => "\x9a", 109 "\xc5\xa1" => "\x9a",
110 "\xe2\x80\xba" => "\x9b", 110 "\xe2\x80\xba" => "\x9b",
111 "\xc5\x93" => "\x9c", 111 "\xc5\x93" => "\x9c",
112 112
113 "\xc5\xbe" => "\x9e", 113 "\xc5\xbe" => "\x9e",
114 "\xc5\xb8" => "\x9f" 114 "\xc5\xb8" => "\x9f"
115 ); 115 );
@@ -119,7 +119,7 @@ class Encoding {
119 * Function Encoding::toUTF8 119 * Function Encoding::toUTF8
120 * 120 *
121 * This function leaves UTF8 characters alone, while converting almost all non-UTF8 to UTF8. 121 * This function leaves UTF8 characters alone, while converting almost all non-UTF8 to UTF8.
122 * 122 *
123 * It assumes that the encoding of the original string is either Windows-1252 or ISO 8859-1. 123 * It assumes that the encoding of the original string is either Windows-1252 or ISO 8859-1.
124 * 124 *
125 * It may fail to convert characters to UTF-8 if they fall into one of these scenarios: 125 * It may fail to convert characters to UTF-8 if they fall into one of these scenarios:
@@ -128,7 +128,7 @@ class Encoding {
128 * are followed by any of these: ("group B") 128 * are followed by any of these: ("group B")
129 * ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶•¸¹º»¼½¾¿ 129 * ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶•¸¹º»¼½¾¿
130 * For example: %ABREPRESENT%C9%BB. «REPRESENTÉ» 130 * For example: %ABREPRESENT%C9%BB. «REPRESENTÉ»
131 * The "«" (%AB) character will be converted, but the "É" followed by "»" (%C9%BB) 131 * The "«" (%AB) character will be converted, but the "É" followed by "»" (%C9%BB)
132 * is also a valid unicode character, and will be left unchanged. 132 * is also a valid unicode character, and will be left unchanged.
133 * 133 *
134 * 2) when any of these: àáâãäåæçèéêëìíîï are followed by TWO chars from group B, 134 * 2) when any of these: àáâãäåæçèéêëìíîï are followed by TWO chars from group B,
@@ -148,7 +148,7 @@ class Encoding {
148 } 148 }
149 return $text; 149 return $text;
150 } elseif(is_string($text)) { 150 } elseif(is_string($text)) {
151 151
152 $max = strlen($text); 152 $max = strlen($text);
153 $buf = ""; 153 $buf = "";
154 for($i = 0; $i < $max; $i++){ 154 for($i = 0; $i < $max; $i++){
@@ -244,15 +244,15 @@ class Encoding {
244 $text = self::toUTF8(utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), $text))); 244 $text = self::toUTF8(utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), $text)));
245 return $text; 245 return $text;
246 } 246 }
247 247
248 static function UTF8FixWin1252Chars($text){ 248 static function UTF8FixWin1252Chars($text){
249 // If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1 249 // If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1
250 // (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it. 250 // (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it.
251 // See: http://en.wikipedia.org/wiki/Windows-1252 251 // See: http://en.wikipedia.org/wiki/Windows-1252
252 252
253 return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text); 253 return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text);
254 } 254 }
255 255
256 static function removeBOM($str=""){ 256 static function removeBOM($str=""){
257 if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { 257 if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
258 $str=substr($str, 3); 258 $str=substr($str, 3);
diff --git a/inc/functions.php b/inc/functions.php
index 6fa5a17a..37a56038 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -1,32 +1,46 @@
1<?php 1<?php
2 2
3function url() { 3/**
4 $protocol = "http"; 4 * Permet de générer l'URL de poche pour le bookmarklet
5 if(isset($_SERVER['HTTPS'])) 5 */
6 if($_SERVER['HTTPS'] != "off") 6function url()
7 $protocol = "https"; 7{
8 $protocol = "http";
9 if(isset($_SERVER['HTTPS'])) {
10 if($_SERVER['HTTPS'] != "off") {
11 $protocol = "https";
12 }
13 }
8 14
9 return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 15 return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
10} 16}
11 17
12function generate_page($url,$title,$content) { 18/**
13 raintpl::$tpl_dir = './tpl/'; // template directory 19 * Génération de la page "vue d'un article"
14 raintpl::$cache_dir = "./cache/"; // cache directory 20 */
15 raintpl::$base_url = url(); // base URL of blog 21function generate_page($entry)
22{
23 raintpl::$tpl_dir = './tpl/';
24 raintpl::$cache_dir = "./cache/";
25 raintpl::$base_url = url();
16 raintpl::configure( 'path_replace', false ); 26 raintpl::configure( 'path_replace', false );
17 raintpl::configure('debug', false); 27 raintpl::configure('debug', false);
18 28
19 $tpl = new raintpl(); //include Rain TPL 29 $tpl = new raintpl();
20 30
21 $tpl->assign( "url", $url); 31 $tpl->assign("id", $entry['id']);
22 $tpl->assign( "title", $title); 32 $tpl->assign("url", $entry['url']);
23 $tpl->assign( "content", $content); 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']);
24 37
25 $tpl->draw( "index"); // draw the template 38 $tpl->draw( "index");
26} 39}
27 40
28// function define to retrieve url content 41// function define to retrieve url content
29function get_external_file($url, $timeout) { 42function get_external_file($url, $timeout)
43{
30 // spoofing FireFox 18.0 44 // spoofing FireFox 18.0
31 $useragent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"; 45 $useragent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0";
32 46
@@ -95,57 +109,4 @@ function get_external_file($url, $timeout) {
95 else { 109 else {
96 return FALSE; 110 return FALSE;
97 } 111 }
98} 112} \ No newline at end of file
99
100function rel2abs($rel, $base)
101{
102 /* return if already absolute URL */
103 if (parse_url($rel, PHP_URL_SCHEME) != '') return $rel;
104
105 /* queries and anchors */
106 if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel;
107
108 /* parse base URL and convert to local variables:
109 $scheme, $host, $path */
110 extract(parse_url($base));
111
112 /* remove non-directory element from path */
113 $path = preg_replace('#/[^/]*$#', '', $path);
114
115 /* destroy path if relative url points to root */
116 if ($rel[0] == '/') $path = '';
117
118 /* dirty absolute URL */
119 $abs = "$host$path/$rel";
120
121 /* replace '//' or '/./' or '/foo/../' with '/' */
122 $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#');
123 for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {}
124
125 /* absolute URL is ready! */
126 return $scheme.'://'.$abs;
127}
128
129// $str=preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#','$1="http://wintermute.com.au/$2$3',$str);
130
131function absolutes_links($data, $base) {
132 // cherche les balises 'a' qui contiennent un href
133 $matches = array();
134 preg_match_all('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#Si', $data, $matches, PREG_SET_ORDER);
135
136 // ne conserve que les liens ne commençant pas par un protocole « protocole:// » ni par une ancre « # »
137 foreach($matches as $i => $link) {
138 $link[1] = trim($link[1]);
139
140 if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1]) ) {
141
142 $absolutePath=rel2abs($link[2],$base);
143
144 $data = str_replace($matches[$i][2], $absolutePath, $data);
145 }
146
147 }
148 return $data;
149}
150
151?> \ No newline at end of file
diff --git a/index.php b/index.php
index 7ae2fb6f..6f7c5fc0 100755
--- a/index.php
+++ b/index.php
@@ -148,7 +148,7 @@ catch (Exception $e)
148 <a href="view.php?id=<?php echo $entry['id']; ?>"><?php echo $entry['title']; ?> 148 <a href="view.php?id=<?php echo $entry['id']; ?>"><?php echo $entry['title']; ?>
149 </h2> 149 </h2>
150 <div class="tools"> 150 <div class="tools">
151 <a title="toggle mark as read" class="tool archive <?php echo ( ($entry['is_read'] == '0') ? 'archive-off' : '' ); ?>" onclick="toggle_archive(<?php echo $entry['id']; ?>)"><span></span></a> 151 <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>
152 <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> 152 <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>
153 <a href="?action=delete&id=<?php echo $entry['id']; ?>" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a> 153 <a href="?action=delete&id=<?php echo $entry['id']; ?>" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
154 </div> 154 </div>
diff --git a/js/poche.js b/js/poche.js
index 42958e83..64df553c 100644
--- a/js/poche.js
+++ b/js/poche.js
@@ -1,4 +1,4 @@
1function toggle_favorite(element,id) { 1function toggle_favorite(element, id) {
2 $(element).toggleClass('fav-off'); 2 $(element).toggleClass('fav-off');
3 $.ajax ({ 3 $.ajax ({
4 url: "process.php?action=toggle_fav", 4 url: "process.php?action=toggle_fav",
@@ -6,15 +6,18 @@ function toggle_favorite(element,id) {
6 }); 6 });
7} 7}
8 8
9function toggle_archive(id) { 9function toggle_archive(element, id, view_article) {
10 /*$('#entry-'+id).toggle();*/ 10 $(element).toggleClass('archive-off');
11 $.ajax ({ 11 $.ajax ({
12 url: "process.php?action=toggle_archive", 12 url: "process.php?action=toggle_archive",
13 data:{id:id} 13 data:{id:id}
14 }); 14 });
15 var obj = $('#entry-'+id); 15 var obj = $('#entry-'+id);
16 $('#content').masonry('remove',obj);
17 16
18 $('#content').masonry('reloadItems'); 17 // on vient de la vue de l'article, donc pas de gestion de grille
19 $('#content').masonry('reload'); 18 if (view_article != 1) {
19 $('#content').masonry('remove',obj);
20 $('#content').masonry('reloadItems');
21 $('#content').masonry('reload');
22 }
20} \ No newline at end of file 23} \ No newline at end of file
diff --git a/tpl/footer.html b/tpl/footer.html
index 8cdda21c..ffe4e0d3 100755
--- a/tpl/footer.html
+++ b/tpl/footer.html
@@ -1,3 +1,5 @@
1 <footer class="mr2 mt3 smaller"> 1 <footer class="mr2 mt3 smaller">
2 <p>download poche on <a href="http://github.com/nicosomb/github">github</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p> 2 <p>download poche on <a href="http://github.com/nicosomb/github">github</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p>
3 </footer> 3 </footer>
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/index.html b/tpl/index.html
index c8b54c84..1c6c83b9 100755
--- a/tpl/index.html
+++ b/tpl/index.html
@@ -17,6 +17,11 @@
17 <div class="backhome"> 17 <div class="backhome">
18 <a href="index.php" title="back to home">&larr;</a> 18 <a href="index.php" title="back to home">&larr;</a>
19 </div> 19 </div>
20 <div class="tools">
21 <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>
22 <a title="toggle favorite" class="tool fav {if="$is_fav == 0"}fav-off{/if}" onclick="toggle_favorite(this, {$id})"><span></span></a>
23 <a href="index.php?action=delete&id={$id}" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
24 </div>
20 <header class="mbm"> 25 <header class="mbm">
21 <h1><a href="{$url}">{$title}</a></h1> 26 <h1><a href="{$url}">{$title}</a></h1>
22 <div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div> 27 <div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>
diff --git a/view.php b/view.php
index aba1b7ec..75e6c3a9 100755
--- a/view.php
+++ b/view.php
@@ -31,5 +31,13 @@ if(isset($_GET['id']) && $_GET['id'] != '') {
31 die('query error : '.$e->getMessage()); 31 die('query error : '.$e->getMessage());
32 } 32 }
33 33
34 generate_page($entry[0]['url'], $entry[0]['title'], $entry[0]['content']); 34 if ($entry != NULL) {
35 generate_page($entry[0]);
36 }
37 else {
38 die('error in view call');
39 }
40}
41else {
42 die('error in view call');
35} \ No newline at end of file 43} \ No newline at end of file