possibilité de mettre en fav ou en archive un article depuis la page article

This commit is contained in:
nicosomb 2013-04-12 13:13:21 +02:00
parent 67e7910439
commit c8bbe19b3f
8 changed files with 107 additions and 100 deletions

View file

@ -100,7 +100,15 @@ footer {
margin-left: -20px;
}
#main .entrie .tools a.tool span {
#article .tools {
display: inline;
}
#article .tools a.tool {
cursor: pointer;
}
#main .entrie .tools a.tool span, #article .tools a.tool span {
display: inline-block;
width: 16px;
height: 16px;
@ -110,18 +118,34 @@ a.fav span {
background: url('../img/fav-on.png') no-repeat;
}
a.fav span:hover {
background: url('../img/fav-off.png') no-repeat;
}
a.fav-off span {
background: url('../img/fav-off.png') no-repeat;
}
a.fav-off span:hover {
background: url('../img/fav-on.png') no-repeat;
}
a.archive span {
background: url('../img/archive-on.png') no-repeat;
}
a.archive span:hover {
background: url('../img/archive-off.png') no-repeat;
}
a.archive-off span {
background: url('../img/archive-off.png') no-repeat;
}
a.archive-off span:hover {
background: url('../img/archive-on.png') no-repeat;
}
a.delete span {
background: url('../img/delete.png') no-repeat;
}
@ -153,6 +177,10 @@ body.article {
text-decoration: none;
}
.backhome {
display: inline;
}
/*** ***/
#main
{

View file

@ -1,32 +1,46 @@
<?php
function url() {
/**
* Permet de générer l'URL de poche pour le bookmarklet
*/
function url()
{
$protocol = "http";
if(isset($_SERVER['HTTPS']))
if($_SERVER['HTTPS'] != "off")
if(isset($_SERVER['HTTPS'])) {
if($_SERVER['HTTPS'] != "off") {
$protocol = "https";
}
}
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
function generate_page($url,$title,$content) {
raintpl::$tpl_dir = './tpl/'; // template directory
raintpl::$cache_dir = "./cache/"; // cache directory
raintpl::$base_url = url(); // base URL of blog
/**
* 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(); //include Rain TPL
$tpl = new raintpl();
$tpl->assign( "url", $url);
$tpl->assign( "title", $title);
$tpl->assign( "content", $content);
$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"); // draw the template
$tpl->draw( "index");
}
// function define to retrieve url content
function get_external_file($url, $timeout) {
function get_external_file($url, $timeout)
{
// spoofing FireFox 18.0
$useragent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0";
@ -96,56 +110,3 @@ function get_external_file($url, $timeout) {
return FALSE;
}
}
function rel2abs($rel, $base)
{
/* return if already absolute URL */
if (parse_url($rel, PHP_URL_SCHEME) != '') return $rel;
/* queries and anchors */
if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel;
/* parse base URL and convert to local variables:
$scheme, $host, $path */
extract(parse_url($base));
/* remove non-directory element from path */
$path = preg_replace('#/[^/]*$#', '', $path);
/* destroy path if relative url points to root */
if ($rel[0] == '/') $path = '';
/* dirty absolute URL */
$abs = "$host$path/$rel";
/* replace '//' or '/./' or '/foo/../' with '/' */
$re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#');
for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {}
/* absolute URL is ready! */
return $scheme.'://'.$abs;
}
// $str=preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#','$1="http://wintermute.com.au/$2$3',$str);
function absolutes_links($data, $base) {
// cherche les balises 'a' qui contiennent un href
$matches = array();
preg_match_all('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#Si', $data, $matches, PREG_SET_ORDER);
// ne conserve que les liens ne commençant pas par un protocole « protocole:// » ni par une ancre « # »
foreach($matches as $i => $link) {
$link[1] = trim($link[1]);
if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1]) ) {
$absolutePath=rel2abs($link[2],$base);
$data = str_replace($matches[$i][2], $absolutePath, $data);
}
}
return $data;
}
?>

View file

@ -148,7 +148,7 @@ catch (Exception $e)
<a href="view.php?id=<?php echo $entry['id']; ?>"><?php echo $entry['title']; ?>
</h2>
<div class="tools">
<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>
<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>
<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>
<a href="?action=delete&id=<?php echo $entry['id']; ?>" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
</div>

View file

@ -6,15 +6,18 @@ function toggle_favorite(element,id) {
});
}
function toggle_archive(id) {
/*$('#entry-'+id).toggle();*/
function toggle_archive(element, id, view_article) {
$(element).toggleClass('archive-off');
$.ajax ({
url: "process.php?action=toggle_archive",
data:{id:id}
});
var obj = $('#entry-'+id);
$('#content').masonry('remove',obj);
// on vient de la vue de l'article, donc pas de gestion de grille
if (view_article != 1) {
$('#content').masonry('remove',obj);
$('#content').masonry('reloadItems');
$('#content').masonry('reload');
}
}

View file

@ -1,3 +1,5 @@
<footer class="mr2 mt3 smaller">
<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>
</footer>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/poche.js"></script>

View file

@ -17,6 +17,11 @@
<div class="backhome">
<a href="index.php" title="back to home">&larr;</a>
</div>
<div class="tools">
<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>
<a title="toggle favorite" class="tool fav {if="$is_fav == 0"}fav-off{/if}" onclick="toggle_favorite(this, {$id})"><span></span></a>
<a href="index.php?action=delete&id={$id}" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
</div>
<header class="mbm">
<h1><a href="{$url}">{$title}</a></h1>
<div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>

View file

@ -31,5 +31,13 @@ if(isset($_GET['id']) && $_GET['id'] != '') {
die('query error : '.$e->getMessage());
}
generate_page($entry[0]['url'], $entry[0]['title'], $entry[0]['content']);
if ($entry != NULL) {
generate_page($entry[0]);
}
else {
die('error in view call');
}
}
else {
die('error in view call');
}