Compare commits

...

15 Commits

Author SHA1 Message Date
Knah Tsaeb dd91b924c6 Merge branch 'master' of git://github.com/sebsauvage/Shaarli into via 2014-04-04 14:30:00 +02:00
Knah Tsaeb 289ce8f457 Merge branch 'master' into via 2014-02-12 10:50:46 +01:00
Knah Tsaeb 020df22d1e Merge branch 'master' of git://github.com/sebsauvage/Shaarli 2014-02-12 10:49:50 +01:00
Knah Tsaeb f1a8ca9cc8 [fix] warning in search form when empty via field 2014-01-03 09:39:02 +01:00
Knah Tsaeb 4123658eae [upd] change via message (@via to Origine ⇒)
[fix] via field for atom
[fix] warning when add new link
2013-12-19 09:53:12 +01:00
Knah Tsaeb 5f9bf1b96e Merge branch 'master' into via 2013-12-19 09:30:20 +01:00
Knah Tsaeb a9821c6fcd Merge branch 'master' of git://github.com/sebsauvage/Shaarli 2013-12-19 09:25:58 +01:00
Knah Tsaeb f80a51a9bf Merge branch 'master' of git://github.com/sebsauvage/Shaarli 2013-10-11 15:24:33 +02:00
Knah Tsaeb 3c49d5a29a Merge branch 'master' of git://github.com/sebsauvage/Shaarli into via 2013-10-11 15:23:24 +02:00
Knah Tsaeb 040eb18ec8 Add source of link (via imput) 2013-10-11 15:18:37 +02:00
Knah Tsaeb 6f5933d23f Sync with SebSauvage repo 2013-09-27 09:38:01 +02:00
Knah Tsaeb bd5d37d0ba Merge branch 'master' of git://github.com/sebsauvage/Shaarli 2013-09-24 13:49:24 +02:00
Knah Tsaeb 256545b392 Merge branch 'master' of git://github.com/sebsauvage/Shaarli 2013-08-07 10:09:53 +02:00
Knah Tsaeb 9550bfe181 Move inline CSS style to shaarli.css 2013-03-29 15:37:44 +01:00
Knah Tsaeb dc420191df Move inline CSS style to shaarli.css 2013-03-29 15:21:32 +01:00
3 changed files with 33 additions and 10 deletions

View File

@ -445,6 +445,12 @@ if (isset($_POST['login']))
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
// Misc utility functions: // Misc utility functions:
// Try to get just domain for @via
function getJustDomain($url){
$parts = parse_url($url);
return trim($parts['host']);
}
// Returns the server URL (including port and http/https), without path. // Returns the server URL (including port and http/https), without path.
// eg. "http://myserver.com:8080" // eg. "http://myserver.com:8080"
// You can append $_SERVER['SCRIPT_NAME'] to get the current script URL. // You can append $_SERVER['SCRIPT_NAME'] to get the current script URL.
@ -807,7 +813,8 @@ class linkdb implements Iterator, Countable, ArrayAccess
$found= (strpos(strtolower($l['title']),$s)!==false) $found= (strpos(strtolower($l['title']),$s)!==false)
|| (strpos(strtolower($l['description']),$s)!==false) || (strpos(strtolower($l['description']),$s)!==false)
|| (strpos(strtolower($l['url']),$s)!==false) || (strpos(strtolower($l['url']),$s)!==false)
|| (strpos(strtolower($l['tags']),$s)!==false); || (strpos(strtolower($l['tags']),$s)!==false)
|| (!empty($l['via']) && (strpos(strtolower($l['via']),$s)!==false));
if ($found) $filtered[$l['linkdate']] = $l; if ($found) $filtered[$l['linkdate']] = $l;
} }
krsort($filtered); krsort($filtered);
@ -913,7 +920,7 @@ function showRSS()
else $linksToDisplay = $LINKSDB; else $linksToDisplay = $LINKSDB;
$nblinksToDisplay = 50; // Number of links to display. $nblinksToDisplay = 50; // Number of links to display.
if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
{ {
$nblinksToDisplay = $_GET['nb']=='all' ? count($linksToDisplay) : max($_GET['nb']+0,1) ; $nblinksToDisplay = $_GET['nb']=='all' ? count($linksToDisplay) : max($_GET['nb']+0,1) ;
} }
@ -952,7 +959,12 @@ function showRSS()
// If user wants permalinks first, put the final link in description // If user wants permalinks first, put the final link in description
if ($usepermalinks===true) $descriptionlink = '(<a href="'.$absurl.'">Link</a>)'; if ($usepermalinks===true) $descriptionlink = '(<a href="'.$absurl.'">Link</a>)';
if (strlen($link['description'])>0) $descriptionlink = '<br>'.$descriptionlink; if (strlen($link['description'])>0) $descriptionlink = '<br>'.$descriptionlink;
echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$descriptionlink.']]></description>'."\n</item>\n"; if(!empty($link['via'])){
$via = '<br>Origine => <a href="'.htmlspecialchars($link['via']).'">'.htmlspecialchars(getJustDomain($link['via'])).'</a>';
} else {
$via = '';
}
echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$via.$descriptionlink.']]></description>'."\n</item>\n";
$i++; $i++;
} }
echo '</channel></rss><!-- Cached version of '.htmlspecialchars(pageUrl()).' -->'; echo '</channel></rss><!-- Cached version of '.htmlspecialchars(pageUrl()).' -->';
@ -988,7 +1000,7 @@ function showATOM()
else $linksToDisplay = $LINKSDB; else $linksToDisplay = $LINKSDB;
$nblinksToDisplay = 50; // Number of links to display. $nblinksToDisplay = 50; // Number of links to display.
if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
{ {
$nblinksToDisplay = $_GET['nb']=='all' ? count($linksToDisplay) : max($_GET['nb']+0,1) ; $nblinksToDisplay = $_GET['nb']=='all' ? count($linksToDisplay) : max($_GET['nb']+0,1) ;
} }
@ -1014,11 +1026,16 @@ function showATOM()
// Add permalink in description // Add permalink in description
$descriptionlink = htmlspecialchars('(<a href="'.$guid.'">Permalink</a>)'); $descriptionlink = htmlspecialchars('(<a href="'.$guid.'">Permalink</a>)');
if(isset($link['via']) && !empty($link['via'])){
$via = htmlspecialchars('</br> Origine => <a href="'.$link['via'].'">'.getJustDomain($link['via']).'</a>');
} else {
$via = '';
}
// If user wants permalinks first, put the final link in description // If user wants permalinks first, put the final link in description
if ($usepermalinks===true) $descriptionlink = htmlspecialchars('(<a href="'.$absurl.'">Link</a>)'); if ($usepermalinks===true) $descriptionlink = htmlspecialchars('(<a href="'.$absurl.'">Link</a>)');
if (strlen($link['description'])>0) $descriptionlink = '&lt;br&gt;'.$descriptionlink; if (strlen($link['description'])>0) $descriptionlink = '&lt;br&gt;'.$descriptionlink;
$entries.='<content type="html">'.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink."</content>\n"; $entries.='<content type="html">'.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink.$via."</content>\n";
if ($link['tags']!='') // Adding tags to each ATOM entry (as mentioned in ATOM specification) if ($link['tags']!='') // Adding tags to each ATOM entry (as mentioned in ATOM specification)
{ {
foreach(explode(' ',$link['tags']) as $tag) foreach(explode(' ',$link['tags']) as $tag)
@ -1485,7 +1502,7 @@ function renderPage()
if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?')) if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?'))
$url = 'http://'.$url; $url = 'http://'.$url;
$link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0), $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags)); 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags), 'via'=>trim($_POST['lf_via']));
if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title. if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
$LINKSDB[$linkdate] = $link; $LINKSDB[$linkdate] = $link;
$LINKSDB->savedb(); // save to disk $LINKSDB->savedb(); // save to disk
@ -1563,7 +1580,8 @@ function renderPage()
$title = (empty($_GET['title']) ? '' : $_GET['title'] ); // Get title if it was provided in URL (by the bookmarklet). $title = (empty($_GET['title']) ? '' : $_GET['title'] ); // Get title if it was provided in URL (by the bookmarklet).
$description = (empty($_GET['description']) ? '' : $_GET['description']); // Get description if it was provided in URL (by the bookmarklet). [Bronco added that] $description = (empty($_GET['description']) ? '' : $_GET['description']); // Get description if it was provided in URL (by the bookmarklet). [Bronco added that]
$tags = (empty($_GET['tags']) ? '' : $_GET['tags'] ); // Get tags if it was provided in URL $tags = (empty($_GET['tags']) ? '' : $_GET['tags'] ); // Get tags if it was provided in URL
$private = (!empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0); // Get private if it was provided in URL $via = (empty($_GET['via']) ? '' : $_GET['via'] );
$private = (!empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0); // Get private if it was provided in URL
if (($url!='') && parse_url($url,PHP_URL_SCHEME)=='') $url = 'http://'.$url; if (($url!='') && parse_url($url,PHP_URL_SCHEME)=='') $url = 'http://'.$url;
// If this is an HTTP link, we try go get the page to extact the title (otherwise we will to straight to the edit form.) // If this is an HTTP link, we try go get the page to extact the title (otherwise we will to straight to the edit form.)
if (empty($title) && parse_url($url,PHP_URL_SCHEME)=='http') if (empty($title) && parse_url($url,PHP_URL_SCHEME)=='http')
@ -1574,7 +1592,7 @@ function renderPage()
{ {
// Look for charset in html header. // Look for charset in html header.
preg_match('#<meta .*charset=.*>#Usi', $data, $meta); preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
// If found, extract encoding. // If found, extract encoding.
if (!empty($meta[0])) if (!empty($meta[0]))
{ {
@ -1584,7 +1602,7 @@ function renderPage()
$html_charset = (!empty($enc[1])) ? strtolower($enc[1]) : 'utf-8'; $html_charset = (!empty($enc[1])) ? strtolower($enc[1]) : 'utf-8';
} }
else { $html_charset = 'utf-8'; } else { $html_charset = 'utf-8'; }
// Extract title // Extract title
$title = html_extract_title($data); $title = html_extract_title($data);
if (!empty($title)) if (!empty($title))
@ -1595,7 +1613,7 @@ function renderPage()
} }
} }
if ($url=='') $url='?'.smallHash($linkdate); // In case of empty URL, this is just a text (with a link that point to itself) if ($url=='') $url='?'.smallHash($linkdate); // In case of empty URL, this is just a text (with a link that point to itself)
$link = array('linkdate'=>$linkdate,'title'=>$title,'url'=>$url,'description'=>$description,'tags'=>$tags,'private'=>$private); $link = array('linkdate'=>$linkdate,'title'=>$title,'url'=>$url,'description'=>$description,'tags'=>$tags,'via' => $via,'private'=>$private);
} }
$PAGE = new pageBuilder; $PAGE = new pageBuilder;
@ -1845,6 +1863,9 @@ function buildLinkList($PAGE,$LINKSDB)
$taglist = explode(' ',$link['tags']); $taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp'); uasort($taglist, 'strcasecmp');
$link['taglist']=$taglist; $link['taglist']=$taglist;
if(!empty($link['via'])){
$link['via']=htmlspecialchars($link['via']);
}
$linkDisp[$keys[$i]] = $link; $linkDisp[$keys[$i]] = $link;
$i++; $i++;
} }

View File

@ -16,6 +16,7 @@
<i>Title</i><br><input type="text" name="lf_title" value="{$link.title|htmlspecialchars}" style="width:100%"><br> <i>Title</i><br><input type="text" name="lf_title" value="{$link.title|htmlspecialchars}" style="width:100%"><br>
<i>Description</i><br><textarea name="lf_description" rows="4" cols="25" style="width:100%">{$link.description|htmlspecialchars}</textarea><br> <i>Description</i><br><textarea name="lf_description" rows="4" cols="25" style="width:100%">{$link.description|htmlspecialchars}</textarea><br>
<i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br> <i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br>
<i>Origine</i><br><input type="text" name="lf_via" value="{$link.via|htmlspecialchars}" style="width:100%"><br>
{if condition="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"} {if condition="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}
<input type="checkbox" checked="checked" name="lf_private" id="lf_private"> <input type="checkbox" checked="checked" name="lf_private" id="lf_private">
&nbsp;<label for="lf_private"><i>Private</i></label><br> &nbsp;<label for="lf_private"><i>Private</i></label><br>

View File

@ -43,6 +43,7 @@
<span class="linktitle"><a href="{$redirector}{$value.url|htmlspecialchars}">{$value.title|htmlspecialchars}</a></span> <span class="linktitle"><a href="{$redirector}{$value.url|htmlspecialchars}">{$value.title|htmlspecialchars}</a></span>
<br> <br>
{if="$value.description"}<div class="linkdescription"{if condition="$search_type=='permalink'"} style="max-height:none !important;"{/if}>{$value.description}</div>{/if} {if="$value.description"}<div class="linkdescription"{if condition="$search_type=='permalink'"} style="max-height:none !important;"{/if}>{$value.description}</div>{/if}
{if condition="isset($value.via) && !empty($value.via)"}<div><a href="{$value.via}">Origine => {$value.via|getJustDomain}</a></div>{/if}
{if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"} {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"}
<span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{$value.localdate|htmlspecialchars} - permalink</a> - </span> <span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{$value.localdate|htmlspecialchars} - permalink</a> - </span>
{else} {else}