From: Seb Sauvage Date: Thu, 24 Nov 2011 15:10:00 +0000 (+0100) Subject: Version 0.0.31 beta: X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=5112a433897d4d6507982b64bb07333b774ddb3a Version 0.0.31 beta: - Added: Support for TED Talks (ted.com/talks) thumbnails (patch by Emilien K.) [r26] - Corrected: Better error handling in thumbnail generation (patch by Emilien K.) [r27] - Added: partial patch by Idleman: Better design consistency, icon on private links. In-page popup was not included because it causes problem on some websites. - Corrected: The top menu is no longer displayed in bookmarklet popup. - Corrected: Bookmark which have the exact same date/time are now correctly imported. Most remaining import problem should be solved now. - Added: Support for bookmark files without ADD_DATE attributes. - Corrected: Comment in Shaarli export moved to beginning of file to prevent clash with last link description. - Added: Logo is clickable. - Added: user.css can be added to overload Shaarli base CSS.(patch by Jerrywham) Just put user.css in the same directory as shaarli.css. Example: #pageheader { background: blue; } Please note that Shaarli CSS are not stable and may completely change on each version. - Changed: Edit and Delete buttons in link list were replaced with icons. (patch by Jerrywham) --- diff --git a/images/delete_icon.png b/images/delete_icon.png new file mode 100644 index 00000000..55e388b4 Binary files /dev/null and b/images/delete_icon.png differ diff --git a/images/edit_icon.png b/images/edit_icon.png new file mode 100644 index 00000000..5cff5743 Binary files /dev/null and b/images/edit_icon.png differ diff --git a/images/private.png b/images/private.png new file mode 100644 index 00000000..5cea272a Binary files /dev/null and b/images/private.png differ diff --git a/index.php b/index.php index 3b2ab74c..7aec94da 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ Change password - Change your password.

' ); + $changepwd = ($GLOBALS['config']['OPEN_SHAARLI'] ? '' : 'Change password : Change your password.

' ); $toolbar= <<
+
{$changepwd} - Configure your Shaarli - Change Title, timezone...

- Rename/delete tags - Rename or delete a tag in all links.

- Import - Import Netscape html bookmarks (as exported from Firefox, Chrome, Opera, delicious...)

- Export - Export Netscape html bookmarks (which can be imported in Firefox, Chrome, Opera, delicious...)

- Shaare link - Drag this link to your bookmarks toolbar (or right-click it and choose Bookmark This Link....). Then click "Shaare link" button in any page you want to share.

-
+ Configure your Shaarli : Change Title, timezone...

+ Rename/delete tags : Rename or delete a tag in all links

+ Import : Import Netscape html bookmarks (as exported from Firefox, Chrome, Opera, delicious...)

+ Export : Export Netscape html bookmarks (which can be imported in Firefox, Chrome, Opera, delicious...)

+Shaare link ⇐ Drag this link to your bookmarks toolbar (or right-click it and choose Bookmark This Link....). Then click "Shaare link" button in any page you want to share.

+
+ HTML; $data = array('pageheader'=>$toolbar,'body'=>'','onload'=>''); templatePage($data); @@ -1161,9 +1162,9 @@ HTML; { $toolbar= << - Export all - Export all links

- Export public - Export public links only

- Export private - Export private links only

+ Export all : Export all links

+ Export public : Export public links only

+ Export private : Export private links only

HTML; $data = array('pageheader'=>$toolbar,'body'=>'','onload'=>''); @@ -1175,11 +1176,13 @@ HTML; header('Content-Type: text/html; charset=utf-8'); header('Content-disposition: attachment; filename=bookmarks_'.$exportWhat.'_'.strval(date('Ymd_His')).'.html'); + $currentdate=date('Y/m/d H:i:s'); echo << + Bookmarks

Bookmarks

@@ -1196,8 +1199,7 @@ HTML; if ($link['description']!='') echo '
'.htmlspecialchars($link['description'])."\n"; } } - echo '\n"; - exit; + exit; } // -------- User is uploading a file for import @@ -1272,7 +1274,6 @@ function importFile() { // This is a standard Netscape-style bookmark file. // This format is supported by all browsers (except IE, of course), also delicious, diigo and others. - // I didn't want to use DOM... anyway, this is FAST (less than 1 second to import 7200 links (2.1 Mb html file)). foreach(explode('
',$data) as $html) // explode is very fast { $link = array('linkdate'=>'','title'=>'','url'=>'','description'=>'','tags'=>'','private'=>0); @@ -1283,19 +1284,42 @@ function importFile() preg_match('!(.*?)!i',$d[0],$matches); $link['title'] = (isset($matches[1]) ? trim($matches[1]) : ''); // Get title $link['title'] = html_entity_decode($link['title'],ENT_QUOTES,'UTF-8'); preg_match_all('! ([A-Z_]+)=\"(.*?)"!i',$html,$matches,PREG_SET_ORDER); // Get all other attributes + $raw_add_date=0; foreach($matches as $m) { $attr=$m[1]; $value=$m[2]; if ($attr=='HREF') $link['url']=html_entity_decode($value,ENT_QUOTES,'UTF-8'); - elseif ($attr=='ADD_DATE') $link['linkdate']=date('Ymd_His',intval($value)); + elseif ($attr=='ADD_DATE') $raw_add_date=intval($value); elseif ($attr=='PRIVATE') $link['private']=($value=='0'?0:1); elseif ($attr=='TAGS') $link['tags']=html_entity_decode(str_replace(',',' ',$value),ENT_QUOTES,'UTF-8'); } - if ($link['linkdate']!='' && $link['url']!='' && ($overwrite || empty($LINKSDB[$link['linkdate']]))) + if ($link['url']!='') { if ($private==1) $link['private']=1; - $LINKSDB[$link['linkdate']] = $link; - $import_count++; + $dblink = $LINKSDB->getLinkFromUrl($link['url']); // See if the link is already in database. + if ($dblink==false) + { // Link not in database, let's import it... + if (empty($raw_add_date)) $raw_add_date=time(); // In case of shitty bookmark file with no ADD_DATE + + // Make sure date/time is not already used by another link. + // (Some bookmark files have several different links with the same ADD_DATE) + // We increment date by 1 second until we find a date which is not used in db. + // (so that links that have the same date/time are more or less kept grouped by date, but do not conflict.) + while (!empty($LINKSDB[date('Ymd_His',$raw_add_date)])) { $raw_add_date++; }// Yes, I know it's ugly. + $link['linkdate']=date('Ymd_His',$raw_add_date); + $LINKSDB[$link['linkdate']] = $link; + $import_count++; + } + else // link already present in database. + { + if ($overwrite) + { // If overwrite is required, we import link data, except date/time. + $link['linkdate']=$dblink['linkdate']; + $LINKSDB[$link['linkdate']] = $link; + $import_count++; + } + } + } } } @@ -1417,9 +1441,9 @@ function templateLinkList() $classprivate = ($link['private']==0 ? $classLi : 'class="private"'); if (isLoggedIn()) { - $actions='
'; + $actions='
'; $actions.='
'; - $actions.='
'; + $actions.=''; } $tags=''; if ($link['tags']!='') @@ -1520,16 +1544,16 @@ function thumbnail($url,$href=false) || $domain=='ted.com' || endsWith($domain,'.ted.com') ) { - if ($domain=='vimeo.com') - { // Make sure this vimeo url points to a video (/xxx... where xxx is numeric) - $path = parse_url($url,PHP_URL_PATH); - if (!preg_match('!/\d+.+?!',$path)) return ''; // This is not a single video URL. - } - if ($domain=='ted.com' || endsWith($domain,'.ted.com')) - { // Make sure this TED url points to a video (/talks/...) - $path = parse_url($url,PHP_URL_PATH); - if ("/talks/" !== substr($path,0,7)) return ''; // This is not a single video URL. - } + if ($domain=='vimeo.com') + { // Make sure this vimeo url points to a video (/xxx... where xxx is numeric) + $path = parse_url($url,PHP_URL_PATH); + if (!preg_match('!/\d+.+?!',$path)) return ''; // This is not a single video URL. + } + if ($domain=='ted.com' || endsWith($domain,'.ted.com')) + { // Make sure this TED url points to a video (/talks/...) + $path = parse_url($url,PHP_URL_PATH); + if ("/talks/" !== substr($path,0,7)) return ''; // This is not a single video URL. + } $sign = hash_hmac('sha256', $url, $GLOBALS['salt']); // We use the salt to sign data (it's random, secret, and specific to each installation) return ''; } @@ -1563,15 +1587,25 @@ function templatePage($data) $newversion=checkUpdate(); if ($newversion!='') $newversion='
Shaarli '.htmlspecialchars($newversion).' is available.
'; $linkcount = count($LINKSDB); + + $feedurl=htmlspecialchars(serverUrl().$_SERVER['SCRIPT_NAME']); + $searchcrits=''; // Search criteria + if (!empty($_GET['searchtags'])) $searchcrits.='&searchtags='.$_GET['searchtags']; + elseif (!empty($_GET['searchterm'])) $searchcrits.='&searchterm='.$_GET['searchterm']; + $filtered_feed= ($searchcrits=='' ? '' : 'Filtered '); + $open=''; if ($GLOBALS['config']['OPEN_SHAARLI']) { - $menu=' Tools  Add link'; + $menu='ToolsAdd link'; $open='Open '; } else - $menu=(isLoggedIn() ? ' Logout  Tools  Add link' : ' Login'); - + $menu=(isLoggedIn() ? 'LogoutToolsAdd link' : ' Login'); + $menu='Home'.$menu.'RSS FeedATOM FeedTag cloudPicture wall'; + # If we are in the bookmarklet popup, do not display menu. + if (!empty($_GET['source']) && $_GET['source']=='bookmarklet') $menu=''; + foreach(array('pageheader','body','onload') as $k) // make sure all required fields exist (put an empty string if not). { if (!array_key_exists($k,$data)) $data[$k]=''; @@ -1592,15 +1626,12 @@ $(document).ready(function() JS; } - $feedurl=htmlspecialchars(serverUrl().$_SERVER['SCRIPT_NAME']); - $searchcrits=''; // Search criteria - if (!empty($_GET['searchtags'])) $searchcrits.='&searchtags='.$_GET['searchtags']; - elseif (!empty($_GET['searchterm'])) $searchcrits.='&searchterm='.$_GET['searchterm']; - $filtered_feed= ($searchcrits=='' ? '' : 'Filtered '); + $version=shaarli_version; $title = htmlspecialchars( $GLOBALS['title'] ); $pagetitle = htmlspecialchars( empty($GLOBALS['pagetitle']) ? $title : $GLOBALS['pagetitle'] ); + echo << @@ -1609,19 +1640,19 @@ JS; + {$jsincludes} {$newversion} -