diff options
-rw-r--r-- | atom-excerpt.php | 27 | ||||
-rw-r--r-- | atom.php | 2 | ||||
-rw-r--r-- | includes/atom.php | 18 | ||||
-rw-r--r-- | includes/header.php | 2 |
4 files changed, 41 insertions, 8 deletions
diff --git a/atom-excerpt.php b/atom-excerpt.php new file mode 100644 index 0000000..27832e3 --- /dev/null +++ b/atom-excerpt.php @@ -0,0 +1,27 @@ +<?php +/* + * Copyright (C) 2009 Nick White + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +include($_SERVER['DOCUMENT_ROOT'] . "/includes/atom.php"); + +atom_header("/text/index.php"); + +create_entries_from_dir("text", false); + +atom_footer(); + +?> @@ -20,7 +20,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/includes/atom.php"); atom_header("/text/index.php"); -create_entries_from_dir("text"); +create_entries_from_dir("text", true); atom_footer(); diff --git a/includes/atom.php b/includes/atom.php index be8d8f8..726c4b6 100644 --- a/includes/atom.php +++ b/includes/atom.php @@ -39,6 +39,8 @@ function atom_header($metadatafile) print("\t<author><name>" . $author . "</name></author>\n"); print("\t<link rel=\"self\" href=\"http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\" />\n"); + if (isset($license_rdf) && !empty($license_rdf)) + print("\t<link rel=\"license\" type=\"application/rdf+xml\" href=\"" . $license_rdf . "\" />\n"); if (isset($copyright) && !empty($copyright)) print("\t<rights>" . $copyright . "</rights>\n"); $description = extract_description($body); @@ -46,9 +48,9 @@ function atom_header($metadatafile) print("\t<description>" . $description . "</description>\n"); } -function create_entry($dir, $file) +function create_entry($dir, $file, $full) { - unset($title, $body, $summary, $author, $language, $category, $updated); + unset($title, $body, $summary, $author, $language, $category, $updated, $license_rdf); include($_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/" . $file); print("\t<entry>\n"); @@ -63,11 +65,15 @@ function create_entry($dir, $file) print("\t\t<author><name>" . $author . "</name></author>\n"); print("\t\t<link rel=\"alternate\" href=\"" . "http://" . $_SERVER['HTTP_HOST'] . "/" . $dir . "/" . $file . "\" />\n"); + if (isset($license_rdf) && !empty($license_rdf)) + print("\t\t<link rel=\"license\" type=\"application/rdf+xml\" href=\"" . $license_rdf . "\" />\n"); + $summary = extract_description($body); if (!empty($summary)) print("\t\t<summary>" . $summary . "</summary>\n"); - print("\t\t<content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">" . $body . "</div></content>\n"); + if ($full) + print("\t\t<content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">" . $body . "</div></content>\n"); $category = ereg_replace("^text", "", $dir); /* dir after text */ if (!empty($category)) @@ -76,17 +82,17 @@ function create_entry($dir, $file) print("\t</entry>\n"); } -function create_entries_from_dir($dir) +function create_entries_from_dir($dir, $full=false) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (!is_dir($file)) { if ($file[0] != "." && ereg(".php$", $file)) - create_entry($dir, $file); + create_entry($dir, $file, $full); } else { if ($file[0] != ".") - create_entries_from_dir($dir . "/" . $file); + create_entries_from_dir($dir . "/" . $file, $full); } } closedir($handle); diff --git a/includes/header.php b/includes/header.php index cb0ef21..e03a7d6 100644 --- a/includes/header.php +++ b/includes/header.php @@ -35,7 +35,7 @@ function xhtml_header($title) <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <title>' . $newtitle . '</title> <link rel="stylesheet" type="text/css" href="/includes/default.css" /> - <link rel="alternate" type="application/rss+xml" href="/rss.php" title="Excerpt feed" /> + <link rel="alternate" type="application/atom+xml" href="/atom-excerpt.php" title="Excerpt feed" /> <link rel="alternate" type="application/atom+xml" href="/atom.php" title="Full feed" /> <link rel="icon" href="/graphics/candles.ico" /> </head> |