From: Dylan Lloyd Date: Sun, 10 Apr 2011 06:48:45 +0000 (-0400) Subject: Merge branch 'rss' into dev X-Git-Url: https://disinclined.org/git/?a=commitdiff_plain;h=951500cf5077761f65c451d14e30b506c20444a1;hp=95d3834c8e04a10ac84ab6f3c956ae80de81f750;p=dylansserver.git Merge branch 'rss' into dev Conflicts: .htaccess index.php --- diff --git a/.htaccess b/.htaccess index fb00ba6..9bd010b 100644 --- a/.htaccess +++ b/.htaccess @@ -3,6 +3,8 @@ ErrorDocument 404 /404.php RewriteEngine on +RewriteRule ^notes/rss/?$ /index.php?rss=true [L] + RewriteRule ^git/?$ /git/gitweb.cgi%{REQUESTURI} [L] RewriteRule ^captcha/?$ /index.php [L] diff --git a/index.php b/index.php index de27473..f985f67 100644 --- a/index.php +++ b/index.php @@ -40,7 +40,9 @@ abstract class cms { return 'index'; } else if (isset($_GET['project'])) { return 'project'; - } else if (isset($_GET['challenge'])) { + } else if (isset($_GET['rss'])) { + return 'rss'; + } else if (isset($_GET['challenge'])) { return 'captcha'; } } @@ -168,7 +170,7 @@ class index extends cms {
  • here
  • + "/notes/">here [rss]
  • @@ -619,6 +621,50 @@ class archive extends cms { } +class rss extends cms { + public function display() { + $result = $this->db->query("SELECT date_posted, title, text, url + FROM notes ORDER BY date_posted DESC + LIMIT 5"); + echo << + + dylanstestserver.com/notes/rss + http://dylanstestserver.com/notes + dylanstestserver.com/notes/rss + +END_OF_ENTRY; + while ($entry = $result->fetch_object()) { + $title = $entry->title; + $date_posted = $entry->date_posted; + $url = "http://dylanstestserver.com/note/" . $entry->url; + $text = $entry->text; + $text = strip_tags($text); + $end_of_first_sentence = strpos($text, '.'); + if ($end_of_first_sentence) { + $end_of_second_sentence = strpos($text, '.', ($end_of_first_sentence + 1)); + if ($end_of_second_sentence) { + $description = substr($text, '0', ($end_of_second_sentence + 1)); + } else { + $description = substr($text, '0', ($end_of_first_sentence + 1)); + } + } + echo << + $title + $url + $url + $description + +END_OF_ENTRY; + } + echo ""; + echo ""; + + } +} + + class notFound extends Exception { public function __construct() { @@ -665,10 +711,13 @@ switch (cms::determine_type()) { $page = new page; $page->display(); break; + case "rss": + $rss = new rss(); + $rss->display(); case 'archive': $archive = new archive; - $archive->display(); - break; + $archive->display(); + break; case "captcha": $captcha = new captcha; $captcha->display();