rss now from view/rss.php
[dylansserver.git] / cms.php
diff --git a/cms.php b/cms.php
index bd7ed60..1f455a4 100644 (file)
--- a/cms.php
+++ b/cms.php
@@ -6,7 +6,6 @@ abstract class cms {
   protected $db;
   protected $recaptcha_publickey;
   protected $recaptcha_privatekey;
-  protected  $scripts;
   public $title;
   public $home_link;
 
@@ -70,63 +69,6 @@ abstract class cms {
     }
     $statement->free_result();
     return $return;
-      }
-
-  public function display_head($title = "dylansserver",
-                                  $home_link = "/") {
-    $scripts = $this->scripts;
-    $stylesheets = "<link href='/includes/style.css' rel='stylesheet' type='text/css'>";
-    $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylansserver.com&amp;ucn_task=conformance#";
-    echo <<<END_OF_HEAD
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-"http://www.w3.org/TR/html4/loose.dtd">
-
-<html>
-<head>
-  <meta name="generator" content=
-  "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
-  <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
-
-  <title>$this->title</title>
-  <link rel="icon" href="/favicon.ico" type="image/png">
-  $stylesheets
-  $scripts
-</head>
-
-<body onload="return typeof highlight == 'function' ? highlight() : true;">
-  <div id="structure">
-    <div id="banner">
-      <a href="$this->home_link">
-      <img src="/images/dylansserver.png" alt="dylansserver"
-      border="0"></a>
-    </div>
-
-    <div id="content">
-END_OF_HEAD;
-  }
-
-  public function display_contact() {
-    echo <<<END_OF_CONTACT
-      <div id="contact_me"><h1><a href=
-      "mailto:dylan@psu.edu">dylan</a></h1><a href=
-      "mailto:dylan@psu.edu">@psu.edu</a>
-      </div>
-END_OF_CONTACT;
-  }
-
-  public function display_close($show_contact = true) {
-    if ($show_contact) {
-      $this->display_contact();
-    }
-    echo <<<END_OF_CLOSE
-    </div>
-    <br>
-    <br>
-  </div>
-</body>
-</html>
-END_OF_CLOSE;
-    ob_flush();
   }
 
   public function init() {
@@ -221,24 +163,6 @@ class page extends cms {
   public function __construct() {
     parent::__construct();
     $this->page_offset();
-    $this->scripts = "
-        <script type='text/javascript' src='/includes/syntax/scripts/shCore.js'></script>
-        <script type='text/javascript' src='/includes/syntax/scripts/shAutoloader.js'></script>
-        <link type='text/css' rel='stylesheet' href='/includes/syntax/styles/shCore.css'>
-        <link type='text/css' rel='stylesheet' href='/includes/syntax/styles/shThemeDefault.css'>
-        <script type='text/javascript'>
-          function highlight() {
-            SyntaxHighlighter.autoloader(
-             'js /includes/syntax/scripts/shBrushJScript.js',
-             'bash /includes/syntax/scripts/shBrushBash.js',
-             'sql /includes/syntax/scripts/shBrushSql.js',
-             'cpp /includes/syntax/scripts/shBrushCpp.js');
-            SyntaxHighlighter.defaults['gutter'] = false;
-            SyntaxHighlighter.defaults['toolbar'] = false;
-            SyntaxHighlighter.all();
-          }
-        </script>
-    ";
   }
 
   private function page_offset() {
@@ -309,30 +233,6 @@ class note extends cms {
   public $number_of_comments;
 
   public function __construct() {
-      $this->scripts = "
-        <script type='text/javascript' src='/includes/syntax/scripts/shCore.js'></script>
-        <script type='text/javascript' src='/includes/syntax/scripts/shAutoloader.js'></script>
-        <link type='text/css' rel='stylesheet' href='/includes/syntax/styles/shCore.css'>
-        <link type='text/css' rel='stylesheet' href='/includes/syntax/styles/shThemeDefault.css'>
-        <script type='text/javascript'>
-          function highlight() {
-            SyntaxHighlighter.autoloader(
-             'js /includes/syntax/scripts/shBrushJScript.js',
-             'bash /includes/syntax/scripts/shBrushBash.js',
-             'sql /includes/syntax/scripts/shBrushSql.js',
-             'cpp /includes/syntax/scripts/shBrushCpp.js');
-            SyntaxHighlighter.defaults['gutter'] = false;
-            SyntaxHighlighter.defaults['toolbar'] = false;
-            SyntaxHighlighter.all();
-          }
-        </script>
-      ";
-
-    if (isset($_GET['comments'])) {
-      $this->scripts .= "
-        <script type='text/javascript' src='http://www.google.com/recaptcha/api/js/recaptcha_ajax.js'></script>
-        <script type='text/javascript' src='/includes/comment.js'></script>";
-    }
     parent::__construct();
     if (isset($_GET['comments'])) {
       $this->comments_enabled = true;
@@ -587,18 +487,15 @@ class archive extends cms {
 
 
 class rss extends cms {
+
   public function display() {
+    require_once("view/rss.php");
+  }
+
+  public function display_items() {
     $result = $this->db->query("SELECT date_posted, title, text, url
                                          FROM notes ORDER BY date_posted DESC
                                          LIMIT 5");
-         echo <<<END_OF_ENTRY
-         <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
-      <channel>
-           <title>dylansserver.com/notes/rss</title>
-               <link>http://dylansserver.com/notes</link>
-               <description>dylansserver.com/notes/rss</description>
-               <atom:link href="http://dylansserver.com/notes/rss" rel="self" type="application/rss+xml" />
-END_OF_ENTRY;
        while ($entry = $result->fetch_object()) {
          $title = $entry->title;
          $date_posted = $entry->date_posted;
@@ -614,18 +511,13 @@ END_OF_ENTRY;
                  $description = substr($text, '0', ($end_of_first_sentence + 1));
                }
          }
-         echo <<<END_OF_ENTRY
-           <item>
-                 <title>$title</title>
-                 <link>$url</link>
-                 <guid>$url</guid>
-                 <description>$description</description>
-           </item>
-END_OF_ENTRY;
+      echo "<item>";
+      echo "  <title>$title</title>";
+      echo "  <link>$url</link>";
+      echo "  <guid>$url</guid>";
+      echo "  <description>$description</description>";
+      echo "</item>";
        }
-      echo "</channel>";
-      echo "</rss>";
-    
   }
 }