the title of the post rather than older/newer.
}
}
+// basic ascii text to html, not complete. ideally utf8
+static void print_ascii(const char *p) {
+ int c;
+
+ while ((c = *p++)) {
+ switch (c) {
+ case '&':
+ send("&");
+ break;
+ case '<':
+ send("<");
+ break;
+ case '>':
+ send(">");
+ break;
+ case '"':
+ send(""");
+ break;
+ default:
+ sendc(c);
+ }
+ }
+}
+
/*( ********************************************************************** )*/
/* Blog code proper */
// TODO: Once I have a proper index this should output the post name
if (newer || older) {
send("<div>\n");
- if (newer)
- sendf("<a href='" POST_SCRIPT "/%012lx'>Newer Post</a>", newer);
+ if (newer) {
+ const char *title = blog_title(newer);
+
+ sendf("<a href='" POST_SCRIPT "/%012lx'>", newer);
+ if (title)
+ print_ascii(title);
+ else
+ send("Newer Post");
+ send("</a>");
+ }
if (older) {
+ const char *title = blog_title(older);
+
if (newer)
send(" | ");
- sendf("<a href='" POST_SCRIPT "/%012lx'>Older Post</a>", older);
+
+ sendf("<a href='" POST_SCRIPT "/%012lx'>", older);
+ if (title)
+ print_ascii(title);
+ else
+ send("Older Post");
+ send("</a>");
}
send("</div>\n");
}
@allids = ();
@allfiles = ();
+@alltitles = ();
open IN,"ls -1 ${db} | grep -v meta | grep -v '~' | sort|" || die "Unable to find posts";
while (<IN>) {
+ my $title = "";
chop;
$id = $_;
$name = $db."/".$id.".meta";
if (m@^original=http.*\.com/(\d{4}/\d{2})/(.*)@) {
$part = $1;
$file = $2;
+ } elsif (m@^title=(.*)@) {
+ $title = $1;
+ # remove java property file escape
+ $title =~ s@\\(.)@\1@g;
}
}
$byid{$id} = $file;
push @allfiles, $file;
push @allids, $id;
+ push @alltitles, $title;
$index += 1;
}
}
print "\n};\n";
+print "static const char *post_title[] = {\n";
+foreach $k (@alltitles) {
+ $k =~ s/"/\\"/g;
+ print "\"$k\",\n";
+}
+print "\n};\n";
+
print "static const struct post_index post_index[] = {\n";
foreach $k (sort keys %bymonth) {
return id / 1000;
}
+const char *blog_title(postid_t id) {
+ int i = blog_postid(id);
+
+ return i >= 0 ? post_title[i] : NULL;
+}
+
static int cmp_month(const void *ap, const void *bp) {
const char *a = ap;
const struct post_index *b = bp;
postid_t blog_latest(void);
postid_t blog_latest_tag(int tagid);
time_t blog_time(postid_t id);
+const char *blog_title(postid_t id);
int blog_tag_list(const struct post_tag **tags);
const char *blog_tag_name(unsigned int tagid);