aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2005-03-01 21:17:51 +0000
committerWojciech Polak <polak@gnu.org>2005-03-01 21:17:51 +0000
commit4bd3a7e16ad0f921ccfb655bdaeebe92f090fa04 (patch)
tree474129094893a8a8b49d6b183865f23559892516
parent0e708947ae02c011561cafa1fd76b132c4f66476 (diff)
downloadblogright-4bd3a7e16ad0f921ccfb655bdaeebe92f090fa04.tar.gz
blogright-4bd3a7e16ad0f921ccfb655bdaeebe92f090fa04.tar.bz2
new beta
-rw-r--r--beta.php233
1 files changed, 136 insertions, 97 deletions
diff --git a/beta.php b/beta.php
index 1f9569e..2cc68dd 100644
--- a/beta.php
+++ b/beta.php
@@ -1,7 +1,7 @@
<?php
-// blogRight! version 1.4 (experimental branch)
-// Copyright (C) 2004 Wojciech Polak.
+// blogRight! version 1.6
+// Copyright (C) 2004, 2005 Wojciech Polak.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -19,6 +19,12 @@
require 'config.php';
+if (!isset ($header_file))
+ $header_file = "inc/header.html";
+
+if (!isset ($footer_file))
+ $footer_file = "inc/footer.html";
+
/////////////////////////////
$start_time = microtime ();
@@ -120,7 +126,7 @@ foreach ($searchdirs as $dir)
}
closedir ($dp);
- if ($sortby == "timestamp")
+ if ($sortby == 'timestamp')
ksort ($dirlist);
else // sort by name
sort ($dirlist);
@@ -183,18 +189,18 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
$pubDate = date ("D, d M Y H:i:s O", filemtime ($include_files[0]));
- print '<?xml version="1.0"?>'."\n";
- print '<rss version="2.0">'."\n";
- print " <channel>\n";
- print " <title>$rssTitle</title>\n";
- print " <description>$rssDescription</description>\n";
- print " <link>$site/$weblogdir/</link>\n";
- print " <copyright>$rssCopyright</copyright>\n";
- print " <language>$rssLanguage</language>\n";
- print " <pubDate>$pubDate</pubDate>\n";
- print " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
- print " <generator>blogRight!</generator>\n";
- print " <managingEditor>$rssEditor</managingEditor>\n";
+ echo '<?xml version="1.0"?>'."\n";
+ echo '<rss version="2.0">'."\n";
+ echo " <channel>\n";
+ echo " <title>$rssTitle</title>\n";
+ echo " <description>$rssDescription</description>\n";
+ echo " <link>$site/$weblogdir/</link>\n";
+ echo " <copyright>$rssCopyright</copyright>\n";
+ echo " <language>$rssLanguage</language>\n";
+ echo " <pubDate>$pubDate</pubDate>\n";
+ echo " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
+ echo " <generator>blogRight!</generator>\n";
+ echo " <managingEditor>$rssEditor</managingEditor>\n";
foreach ($include_files as $inc)
{
@@ -222,25 +228,26 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
$itemTitle = date ('d M Y', $fmtime);
$permaLink = date ('Ymd', $fmtime);
- print " <item>\n";
- print " <title>$itemTitle</title>\n";
- print " <link>$site/$weblogdir/?q=$permaLink</link>\n";
- print " <description>\n";
+ echo " <item>\n";
+ echo " <title>$itemTitle</title>\n";
+ echo " <link>$site/$weblogdir/?q=$permaLink</link>\n";
+ echo " <description>\n";
indent_include (9, $inc);
- print " </description>\n";
- print " <guid isPermaLink=\"true\">$site/$weblogdir/?q=$permaLink</guid>\n";
- print " <pubDate>$pubDate</pubDate>\n";
- print " </item>\n";
+ echo " </description>\n";
+ echo " <guid isPermaLink=\"true\">$site/$weblogdir/?q=$permaLink</guid>\n";
+ echo " <pubDate>$pubDate</pubDate>\n";
+ echo " </item>\n";
}
}
- print " </channel>\n";
- print '</rss>'."\n";
+ echo " </channel>\n";
+ echo '</rss>'."\n";
}
else // HTML
{
+ echo '<?xml version="1.0" encoding="US-ASCII"?>'."\n";
@include ($datadir.$header_file);
foreach ($include_files as $inc)
@@ -262,25 +269,38 @@ else // HTML
include_file ($inc);
}
- @include ($datadir.$footer_file);
+ @include ($datadir.'inc/calendar.html');
+
+ // Generate a copyright footnote.
+ $copyright = '';
+ $year_array = array_unique ($year_array);
+ sort ($year_array);
+ echo '<p class="copyright">Copyright (C) ';
+ foreach ($year_array as $y)
+ $copyright .= "$y, ";
+ $copyright = substr ($copyright, 0, -2);
+ echo "$copyright $rssCopyright</p>\n";
+
$duration = microtime_diff ($start_time, microtime ());
$duration = sprintf ("%0.6f", $duration);
- print "\n<!-- processing took $duration seconds -->";
- print "\n<!-- powered by blogRight! -->\n";
+ echo "\n<!-- processing took $duration seconds -->";
+ echo "\n<!-- powered by blogRight! -->\n";
+
+ @include ($datadir.$footer_file);
}
/////////////////////////////
$footnotes = array(); // Array of footnote texts. Indexed by $local_fn
-$local_fn = 0; // Local (within the entry) number of the next footnote.
+$local_fn = 0; // Local (within the entry) number of the next footnote.
$global_fn = 0; // Global number of the next footnote. This is unique
// within a html page and is used for creating unique
// anchors.
// Return full url of the script
-function script_url()
+function script_url ()
{
- global $site,$weblogdir;
+ global $site, $weblogdir;
if (isset($_REQUEST['q']))
return $site.'/'.$weblogdir.'?q='.$_REQUEST['q'];
return $site.'/'.$weblogdir.'/';
@@ -307,40 +327,55 @@ function process_line ($line)
global $local_fn, $global_fn, $footnotes;
global $collect;
- if (isset($collect))
- {
- $collect = $collect . ' ' . rtrim ($line);
+ if (isset ($collect))
+ {
+ $collect = $collect . ' ' . rtrim ($line);
- if (!preg_match('^</footnote>^', $line))
- return false;
- $line = $collect . "\n";
- unset($GLOBALS['collect']);
- }
+ if (!preg_match ('^</footnote>^', $line))
+ return false;
+ $line = $collect . "\n";
+ unset ($GLOBALS['collect']);
+ }
- $line = preg_replace_callback('^<footnote>(.*)</footnote>^',
- "footnote_handler",
- $line);
+ $line = preg_replace_callback ('^<footnote>(.*)</footnote>^',
+ "footnote_handler",
+ $line);
if (preg_match ('^<footnote>^', $line))
- {
- $collect = rtrim ($line);
- return false;
- }
+ {
+ $collect = rtrim ($line);
+ return false;
+ }
- if (!preg_match ('/="(https?|ftp|mailto):\/\/.*?"/i', $line))
- // is a local path
- {
- $line = preg_replace ('/<img src="(.*?)"(.*?)>/i',
- '<img src="'.$site.'/'.$imagedir.'/$1" border="0" alt="[image]"$2>',
- $line);
+ if (!preg_match ('/="(https?|ftp|mailto):\/\/.*?"/i', $line)) // a local path
+ {
+ $line = preg_replace ('/<img src="(.*?)"(.*?)>/i',
+ '<img src="'.$site.'/'.$imagedir.'/$1" alt="[image]"$2 />',
+ $line);
- $line = preg_replace ('/<photo src="(.*?)"(.*?)>/i',
- '<a href="'.$photodir.'/photo.php?q=$1"><span class="photo"><img src="'
- .$site.'/'.$photodir.'/small/small-$1" alt="[photo]"$2></span></a>',
- $line);
+ $line = preg_replace ('/<photo src="(.*?)"(.*?)>/i',
+ '<div class="photo"><a href="'.$photodir.'/photo.php?q=$1"><img src="'
+ .$site.'/'.$photodir.'/small/small-$1" alt="[photo]"$2 /></a></div>',
+ $line);
- $line = preg_replace ('/<a href="(.*?)">/i', '<a href="'.$site.'/$1">', $line);
+ $res = array ();
+ if (preg_match ('/<gallery album="(.*?)" img="(.*?)"(.*?)>/i', $line, $res))
+ {
+ $pdir = dirname (trim ($res[2]));
+ if ($pdir[0] == '.')
+ $pdir = '';
+ $pbase = basename (trim ($res[2]));
+
+ $line = '<div class="gallery"><a href="'.$photodir.'/gallery.php?q='.$res[1].'">'
+ .'<img src="'.$site.'/'.$photodir;
+ if ($pdir)
+ $line .= '/'.$pdir;
+ $line .= '/small/small-'.$pbase.'" alt="[gallery]"'
+ .$res[3]." /><br />&raquo;</a></div>\n";
}
+
+ $line = preg_replace ('/<a href="(.*?)">/i', '<a href="'.$site.'/$1">', $line);
+ }
return $line;
}
@@ -355,31 +390,35 @@ function process_footnotes ($out, $data)
global $local_fn, $global_fn, $footnotes;
if ($local_fn > 0)
+ {
+ $out ($data, '<div class="footnote">');
+ for ($i = 0; $i < $local_fn; $i++)
{
- $out ($data, '<div class="footnote">');
- for ($i = 0; $i < $local_fn; $i++)
- {
- $n = $global_fn-$local_fn+$i+1;
- $out ($data, '<p><a href="'.script_url().'#FNRET'.$n.'" name="footnote'.$n.'"><sup>'.($i+1).')</sup></a> ');
- $out ($data, $footnotes[$i]);
- $out ($data, '</p>');
- }
- $out ($data, '</div>');
+ $n = $global_fn-$local_fn+$i+1;
+ $out ($data, '<p><a href="'.script_url().'#FNRET'.$n.'" name="footnote'.$n.'"><sup>'.($i+1).')</sup></a> ');
+ $out ($data, $footnotes[$i]);
+ $out ($data, '</p>');
}
+ $out ($data, '</div>');
+ }
}
// Simple printer (alias for print, to be used with process_footnotes)
function printer ($data, $string)
{
- print ($string);
+ echo $string;
}
+/////////////////////////////
+
+$year_array = array (); // Array of years for copyright purposes
+
// HTML output
function include_file ($file)
{
global $site, $photodir, $imagedir, $search_d;
global $local_fn;
-
+ global $year_array;
$res = array ();
$cdd = basename (dirname ($file)); // current data dir
@@ -389,6 +428,8 @@ function include_file ($file)
ereg ('^(.*)-(.*)\.', basename ($file), $res);
$year = $cdd; // assume that...
+ $year_array[] = intval ($cdd);
+
if (isset ($res[1]) && isset ($res[2]))
{
$month = $res[1];
@@ -408,58 +449,56 @@ function include_file ($file)
$fd = file ($file);
if ($fd)
{
- print '<p><div class="entryTitle">'.$entryDate;
+ echo '<div class="entryTitle">'.$entryDate;
if (!isset ($search_d))
- print ' (<a href="?q='.$permaLink.'">permalink</a>)';
+ echo ' (<a href="?q='.$permaLink.'">permalink</a>)';
- print '</div>'."\n";
- print '<div class="entryBody">'."\n";
+ echo '</div>'."\n";
+ echo '<div class="entryBody">'."\n";
- unset($GLOBALS['collect']);
+ unset ($GLOBALS['collect']);
foreach ($fd as $line)
- {
- $line = process_line($line);
- if ($line)
- print ($line);
- }
-
+ {
+ $line = process_line($line);
+ if ($line)
+ echo ($line);
+ }
process_footnotes ('printer', 0);
-
- print '</div>'."\n\n";
+ echo '</div>'."\n\n";
}
}
function printer_html ($level, $string)
{
for ($i = 0; $i < $level; $i++)
- print ' ';
- print (htmlentities ($string) . "\n");
+ echo ' ';
+ echo (htmlentities ($string) . "\n");
}
-
// RSS 2.0 output
function indent_include ($level, $file)
{
- global $site, $imagedir, $photodir, $weblogdir;
- global $local_fn;
-
- $cdd = basename (dirname ($file)); // current data dir
-
+ global $site, $imagedir, $photodir, $weblogdir, $local_fn;
$local_fn = 0;
- $fd = file ($file);
+ $cdd = basename (dirname ($file)); // current data dir
+ $fd = file ($file);
if ($fd)
{
- unset($GLOBALS['collect']);
foreach ($fd as $line)
{
- $line = process_line($line);
+ unset ($GLOBALS['collect']);
+ $line = process_line ($line);
if ($line)
- {
- for ($i = 0; $i < $level; $i++)
- print ' ';
- print (htmlentities2 ($line));
- }
+ {
+ for ($i = 0; $i < $level; $i++)
+ echo ' ';
+ $line = htmlentities2 ($line);
+ $patterns[0] = "/&raquo;/"; $replacements[0] = "&amp;raquo;";
+ $patterns[1] = "/&nbsp;/"; $replacements[1] = "&amp;nbsp;";
+ $line = preg_replace ($patterns, $replacements, $line);
+ echo $line;
+ }
}
process_footnotes ('printer_html', $level);

Return to:

Send suggestions and report system problems to the System administrator.