aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/LinkDB.php3
-rw-r--r--index.php67
-rw-r--r--plugins/markdown/markdown.css29
-rw-r--r--tpl/dailyrss.html4
4 files changed, 59 insertions, 44 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index 9f4d3e3c..9488ac45 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -32,6 +32,9 @@ class LinkDB implements Iterator, Countable, ArrayAccess
32 // Links are stored as a PHP serialized string 32 // Links are stored as a PHP serialized string
33 private $_datastore; 33 private $_datastore;
34 34
35 // Link date storage format
36 const LINK_DATE_FORMAT = 'Ymd_His';
37
35 // Datastore PHP prefix 38 // Datastore PHP prefix
36 protected static $phpPrefix = '<?php /* '; 39 protected static $phpPrefix = '<?php /* ';
37 40
diff --git a/index.php b/index.php
index 231b63f6..a9264cbb 100644
--- a/index.php
+++ b/index.php
@@ -531,33 +531,6 @@ function getMaxFileSize()
531 return $maxsize; 531 return $maxsize;
532} 532}
533 533
534/* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a timestamp (Unix epoch)
535 (used to build the ADD_DATE attribute in Netscape-bookmarks file)
536 PS: I could have used strptime(), but it does not exist on Windows. I'm too kind. */
537function linkdate2timestamp($linkdate)
538{
539 if(strcmp($linkdate, '_000000') !== 0 || !$linkdate){
540 $Y=$M=$D=$h=$m=$s=0;
541 $r = sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s);
542 return mktime($h,$m,$s,$M,$D,$Y);
543 }
544 return time();
545}
546
547/* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a RFC822 date.
548 (used to build the pubDate attribute in RSS feed.) */
549function linkdate2rfc822($linkdate)
550{
551 return date('r',linkdate2timestamp($linkdate)); // 'r' is for RFC822 date format.
552}
553
554/* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a ISO 8601 date.
555 (used to build the updated tags in ATOM feed.) */
556function linkdate2iso8601($linkdate)
557{
558 return date('c',linkdate2timestamp($linkdate)); // 'c' is for ISO 8601 date format.
559}
560
561// ------------------------------------------------------------------------------------------ 534// ------------------------------------------------------------------------------------------
562// Token management for XSRF protection 535// Token management for XSRF protection
563// Token should be used in any form which acts on data (create,update,delete,import...). 536// Token should be used in any form which acts on data (create,update,delete,import...).
@@ -749,14 +722,16 @@ function showRSS()
749 { 722 {
750 $link = $linksToDisplay[$keys[$i]]; 723 $link = $linksToDisplay[$keys[$i]];
751 $guid = $pageaddr.'?'.smallHash($link['linkdate']); 724 $guid = $pageaddr.'?'.smallHash($link['linkdate']);
752 $rfc822date = linkdate2rfc822($link['linkdate']); 725 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
753 $absurl = $link['url']; 726 $absurl = $link['url'];
754 if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute 727 if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute
755 if ($usepermalinks===true) 728 if ($usepermalinks===true)
756 echo '<item><title>'.$link['title'].'</title><guid isPermaLink="true">'.$guid.'</guid><link>'.$guid.'</link>'; 729 echo '<item><title>'.$link['title'].'</title><guid isPermaLink="true">'.$guid.'</guid><link>'.$guid.'</link>';
757 else 730 else
758 echo '<item><title>'.$link['title'].'</title><guid isPermaLink="false">'.$guid.'</guid><link>'.$absurl.'</link>'; 731 echo '<item><title>'.$link['title'].'</title><guid isPermaLink="false">'.$guid.'</guid><link>'.$absurl.'</link>';
759 if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) echo '<pubDate>'.escape($rfc822date)."</pubDate>\n"; 732 if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) {
733 echo '<pubDate>'.escape($date->format(DateTime::RSS))."</pubDate>\n";
734 }
760 if ($link['tags']!='') // Adding tags to each RSS entry (as mentioned in RSS specification) 735 if ($link['tags']!='') // Adding tags to each RSS entry (as mentioned in RSS specification)
761 { 736 {
762 foreach(explode(' ',$link['tags']) as $tag) { echo '<category domain="'.$pageaddr.'">'.$tag.'</category>'."\n"; } 737 foreach(explode(' ',$link['tags']) as $tag) { echo '<category domain="'.$pageaddr.'">'.$tag.'</category>'."\n"; }
@@ -837,8 +812,9 @@ function showATOM()
837 { 812 {
838 $link = $linksToDisplay[$keys[$i]]; 813 $link = $linksToDisplay[$keys[$i]];
839 $guid = $pageaddr.'?'.smallHash($link['linkdate']); 814 $guid = $pageaddr.'?'.smallHash($link['linkdate']);
840 $iso8601date = linkdate2iso8601($link['linkdate']); 815 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
841 $latestDate = max($latestDate,$iso8601date); 816 $iso8601date = $date->format(DateTime::ISO8601);
817 $latestDate = max($latestDate, $iso8601date);
842 $absurl = $link['url']; 818 $absurl = $link['url'];
843 if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute 819 if (startsWith($absurl,'?')) $absurl=$pageaddr.$absurl; // make permalink URL absolute
844 $entries.='<entry><title>'.$link['title'].'</title>'; 820 $entries.='<entry><title>'.$link['title'].'</title>';
@@ -846,7 +822,10 @@ function showATOM()
846 $entries.='<link href="'.$guid.'" /><id>'.$guid.'</id>'; 822 $entries.='<link href="'.$guid.'" /><id>'.$guid.'</id>';
847 else 823 else
848 $entries.='<link href="'.$absurl.'" /><id>'.$guid.'</id>'; 824 $entries.='<link href="'.$absurl.'" /><id>'.$guid.'</id>';
849 if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) $entries.='<updated>'.escape($iso8601date).'</updated>'; 825
826 if (!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()) {
827 $entries.='<updated>'.escape($iso8601date).'</updated>';
828 }
850 829
851 // Add permalink in description 830 // Add permalink in description
852 $descriptionlink = '(<a href="'.$guid.'">Permalink</a>)'; 831 $descriptionlink = '(<a href="'.$guid.'">Permalink</a>)';
@@ -952,8 +931,7 @@ function showDailyRSS() {
952 931
953 // For each day. 932 // For each day.
954 foreach ($days as $day => $linkdates) { 933 foreach ($days as $day => $linkdates) {
955 $daydate = linkdate2timestamp($day.'_000000'); // Full text date 934 $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000');
956 $rfc822date = linkdate2rfc822($day.'_000000');
957 $absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page. 935 $absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page.
958 936
959 // Build the HTML body of this RSS entry. 937 // Build the HTML body of this RSS entry.
@@ -966,7 +944,8 @@ function showDailyRSS() {
966 $l = $LINKSDB[$linkdate]; 944 $l = $LINKSDB[$linkdate];
967 $l['formatedDescription'] = format_description($l['description'], $GLOBALS['redirector']); 945 $l['formatedDescription'] = format_description($l['description'], $GLOBALS['redirector']);
968 $l['thumbnail'] = thumbnail($l['url']); 946 $l['thumbnail'] = thumbnail($l['url']);
969 $l['timestamp'] = linkdate2timestamp($l['linkdate']); 947 $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']);
948 $l['timestamp'] = $l_date->getTimestamp();
970 if (startsWith($l['url'], '?')) { 949 if (startsWith($l['url'], '?')) {
971 $l['url'] = index_url($_SERVER) . $l['url']; // make permalink URL absolute 950 $l['url'] = index_url($_SERVER) . $l['url']; // make permalink URL absolute
972 } 951 }
@@ -976,10 +955,10 @@ function showDailyRSS() {
976 // Then build the HTML for this day: 955 // Then build the HTML for this day:
977 $tpl = new RainTPL; 956 $tpl = new RainTPL;
978 $tpl->assign('title', $GLOBALS['title']); 957 $tpl->assign('title', $GLOBALS['title']);
979 $tpl->assign('daydate', $daydate); 958 $tpl->assign('daydate', $dayDate->getTimestamp());
980 $tpl->assign('absurl', $absurl); 959 $tpl->assign('absurl', $absurl);
981 $tpl->assign('links', $links); 960 $tpl->assign('links', $links);
982 $tpl->assign('rfc822date', escape($rfc822date)); 961 $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS)));
983 $html = $tpl->draw('dailyrss', $return_string=true); 962 $html = $tpl->draw('dailyrss', $return_string=true);
984 963
985 echo $html . PHP_EOL; 964 echo $html . PHP_EOL;
@@ -1035,7 +1014,8 @@ function showDaily($pageBuilder)
1035 $linksToDisplay[$key]['taglist']=$taglist; 1014 $linksToDisplay[$key]['taglist']=$taglist;
1036 $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $GLOBALS['redirector']); 1015 $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $GLOBALS['redirector']);
1037 $linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']); 1016 $linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']);
1038 $linksToDisplay[$key]['timestamp'] = linkdate2timestamp($link['linkdate']); 1017 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
1018 $linksToDisplay[$key]['timestamp'] = $date->getTimestamp();
1039 } 1019 }
1040 1020
1041 /* We need to spread the articles on 3 columns. 1021 /* We need to spread the articles on 3 columns.
@@ -1060,11 +1040,12 @@ function showDaily($pageBuilder)
1060 $fill[$index]+=$length; 1040 $fill[$index]+=$length;
1061 } 1041 }
1062 1042
1043 $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000');
1063 $data = array( 1044 $data = array(
1064 'linksToDisplay' => $linksToDisplay, 1045 'linksToDisplay' => $linksToDisplay,
1065 'linkcount' => count($LINKSDB), 1046 'linkcount' => count($LINKSDB),
1066 'cols' => $columns, 1047 'cols' => $columns,
1067 'day' => linkdate2timestamp($day.'_000000'), 1048 'day' => $dayDate->getTimestamp(),
1068 'previousday' => $previousday, 1049 'previousday' => $previousday,
1069 'nextday' => $nextday, 1050 'nextday' => $nextday,
1070 ); 1051 );
@@ -1569,7 +1550,7 @@ function renderPage()
1569 $link = array( 1550 $link = array(
1570 'title' => trim($_POST['lf_title']), 1551 'title' => trim($_POST['lf_title']),
1571 'url' => $url, 1552 'url' => $url,
1572 'description' => trim($_POST['lf_description']), 1553 'description' => $_POST['lf_description'],
1573 'private' => (isset($_POST['lf_private']) ? 1 : 0), 1554 'private' => (isset($_POST['lf_private']) ? 1 : 0),
1574 'linkdate' => $linkdate, 1555 'linkdate' => $linkdate,
1575 'tags' => str_replace(',', ' ', $tags) 1556 'tags' => str_replace(',', ' ', $tags)
@@ -1780,7 +1761,8 @@ HTML;
1780 ($exportWhat=='private' && $link['private']!=0) || 1761 ($exportWhat=='private' && $link['private']!=0) ||
1781 ($exportWhat=='public' && $link['private']==0)) 1762 ($exportWhat=='public' && $link['private']==0))
1782 { 1763 {
1783 echo '<DT><A HREF="'.$link['url'].'" ADD_DATE="'.linkdate2timestamp($link['linkdate']).'" PRIVATE="'.$link['private'].'"'; 1764 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
1765 echo '<DT><A HREF="'.$link['url'].'" ADD_DATE="'.$date->getTimestamp().'" PRIVATE="'.$link['private'].'"';
1784 if ($link['tags']!='') echo ' TAGS="'.str_replace(' ',',',$link['tags']).'"'; 1766 if ($link['tags']!='') echo ' TAGS="'.str_replace(' ',',',$link['tags']).'"';
1785 echo '>'.$link['title']."</A>\n"; 1767 echo '>'.$link['title']."</A>\n";
1786 if ($link['description']!='') echo '<DD>'.$link['description']."\n"; 1768 if ($link['description']!='') echo '<DD>'.$link['description']."\n";
@@ -2023,7 +2005,8 @@ function buildLinkList($PAGE,$LINKSDB)
2023 $link['description'] = format_description($link['description'], $GLOBALS['redirector']); 2005 $link['description'] = format_description($link['description'], $GLOBALS['redirector']);
2024 $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight'; 2006 $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight';
2025 $link['class'] = $link['private'] == 0 ? $classLi : 'private'; 2007 $link['class'] = $link['private'] == 0 ? $classLi : 'private';
2026 $link['timestamp'] = linkdate2timestamp($link['linkdate']); 2008 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
2009 $link['timestamp'] = $date->getTimestamp();
2027 $taglist = explode(' ', $link['tags']); 2010 $taglist = explode(' ', $link['tags']);
2028 uasort($taglist, 'strcasecmp'); 2011 uasort($taglist, 'strcasecmp');
2029 $link['taglist'] = $taglist; 2012 $link['taglist'] = $taglist;
diff --git a/plugins/markdown/markdown.css b/plugins/markdown/markdown.css
index 6d666dcf..3c1b2aeb 100644
--- a/plugins/markdown/markdown.css
+++ b/plugins/markdown/markdown.css
@@ -114,6 +114,35 @@
114 margin-bottom: 0; 114 margin-bottom: 0;
115} 115}
116 116
117.markdown pre {
118 background-color: #eee;
119 padding: 4px 9px;
120 -webkit-border-radius: 5px;
121 -moz-border-radius: 5px;
122 border-radius: 5px;
123 overflow: auto;
124 box-shadow: 0 -1px 0 #e5e5e5,0 0 1px rgba(0,0,0,0.12),0 1px 2px rgba(0,0,0,0.24);
125}
126
127.markdown pre code {
128 color: black;
129 font-family: 'Consolas', 'Monaco', 'Andale Mono', monospace;
130 direction: ltr;
131 text-align: left;
132 white-space: pre;
133 word-spacing: normal;
134 word-break: normal;
135 line-height: 1.7;
136 font-size: 11.5px;
137 -moz-tab-size: 4;
138 -o-tab-size: 4;
139 tab-size: 4;
140 -webkit-hyphens: none;
141 -moz-hyphens: none;
142 -ms-hyphens: none;
143 hyphens: none;
144}
145
117.md_help { 146.md_help {
118 color: white; 147 color: white;
119} 148}
diff --git a/tpl/dailyrss.html b/tpl/dailyrss.html
index d959d6be..4133ca3e 100644
--- a/tpl/dailyrss.html
+++ b/tpl/dailyrss.html
@@ -2,7 +2,7 @@
2 <title>{$title} - {function="strftime('%A %e %B %Y', $daydate)"}</title> 2 <title>{$title} - {function="strftime('%A %e %B %Y', $daydate)"}</title>
3 <guid>{$absurl}</guid> 3 <guid>{$absurl}</guid>
4 <link>{$absurl}</link> 4 <link>{$absurl}</link>
5 <pubDate>{$rfc822date}</pubDate> 5 <pubDate>{$rssdate}</pubDate>
6 <description><![CDATA[ 6 <description><![CDATA[
7 {loop="links"} 7 {loop="links"}
8 <h3><a href="{$value.url}">{$value.title}</a></h3> 8 <h3><a href="{$value.url}">{$value.title}</a></h3>
@@ -13,4 +13,4 @@
13 <br><br><hr> 13 <br><br><hr>
14 {/loop} 14 {/loop}
15 ]]></description> 15 ]]></description>
16</item> \ No newline at end of file 16</item>