summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-24 05:03:16 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-24 05:03:16 +0000
commit49524c429e8dec4e18a81dfcfbbc93cbd1da32c3 (patch)
treed07c9fd97d7ff19a9cdd4e0e7f8e426f01168fc4
parent5e7a3e74289248f464eb004b4e2176b27abe062e (diff)
add blog post template
-rw-r--r--IkiWiki/CGI.pm19
-rw-r--r--IkiWiki/Render.pm12
-rw-r--r--doc/blog.mdwn6
-rw-r--r--doc/sandbox.mdwn4
-rw-r--r--doc/todo/blogging.mdwn4
-rw-r--r--doc/todo/upgradehooks.mdwn6
-rwxr-xr-xikiwiki4
-rw-r--r--templates/inlinepage.tmpl4
8 files changed, 47 insertions, 12 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 29f3ecc89..b540a7b37 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -467,11 +467,28 @@ sub cgi () { #{{{
error("\"do\" parameter missing");
}
- # This does not need a session.
+ # Things that do not need a session.
if ($do eq 'recentchanges') {
cgi_recentchanges($q);
return;
}
+ elsif ($do eq 'blog') {
+ # munge page name to be valid, no matter what freeform text
+ # is entered
+ my $page=$q->param('title');
+ $page=~y/ /_/;
+ $page=~s/([^-A-Za-z0-9_.:+])/"__".ord($1)."__"/eg;
+ # if the page already exist, munge it to be unique
+ my $from=$q->param('from');
+ my $add="";
+ while (exists $pagectime{"$from/$page$add"}) {
+ $add=1 unless length $add;
+ $add++;
+ }
+ $q->param('page', $page.$add);
+ $q->param('do', 'create');
+ # now it behaves same as create does
+ }
CGI::Session->name("ikiwiki_session");
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 3fdbc6f4a..4e2caa6ce 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -160,12 +160,22 @@ sub postprocess_html_inline { #{{{
}
$inlinepages{$parentpage}=$params{pages};
+ my $ret="";
+
+ if (exists $params{rootpage}) {
+ my $formtemplate=HTML::Template->new(blind_cache => 1,
+ filename => "$config{templatedir}/blogpost.tmpl");
+ $formtemplate->param(cgiurl => $config{cgiurl});
+ $formtemplate->param(rootpage => $params{rootpage});
+ my $form=$formtemplate->output;
+ $ret.=$form;
+ }
+
my $template=HTML::Template->new(blind_cache => 1,
filename => (($params{archive} eq "no")
? "$config{templatedir}/inlinepage.tmpl"
: "$config{templatedir}/inlinepagetitle.tmpl"));
- my $ret="";
foreach my $page (blog_list($params{pages}, $params{show})) {
next if $page eq $parentpage;
$template->param(pagelink => htmllink($parentpage, $page));
diff --git a/doc/blog.mdwn b/doc/blog.mdwn
index 598ad98d5..0d67619da 100644
--- a/doc/blog.mdwn
+++ b/doc/blog.mdwn
@@ -1,12 +1,16 @@
You can turn any page on this wiki into a weblog by inserting a
[[PostProcessorDirective]]. Like this:
-\\[[inline pages="blog/* !*/Discussion" show="10"]]
+\\[[inline pages="blog/* !*/Discussion" show="10" rootpage="blog"]]
Any pages that match the specified [[GlobList]] (in the exaple, any
[[SubPages]] of "blog") will be part of the blog, and the newest 10
of them will appear in the page.
+The optional `rootpage` setting tells the wiki that new posts to this blog
+should default to being [[SubPages]] of "blog", and enables a form at the
+top of the blog that can be used to add new items.
+
If you want your blog to have an archive page listing every post ever made
to it, you can accomplish that like this:
diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn
index 69876d26d..a4e01b7c2 100644
--- a/doc/sandbox.mdwn
+++ b/doc/sandbox.mdwn
@@ -40,6 +40,4 @@ Bulleted list
This sandbox is also a [[blog]]! Any [[SubPage]] of this page is automatically
added to the blog below.
-----
-
-[[inline pages="sandbox/*" show="5"]]
+[[inline pages="sandbox/*" rootpage="sandbox" show="5"]]
diff --git a/doc/todo/blogging.mdwn b/doc/todo/blogging.mdwn
index 9ae6cf4a6..55bb24689 100644
--- a/doc/todo/blogging.mdwn
+++ b/doc/todo/blogging.mdwn
@@ -1,6 +1,4 @@
-- Add a small form at top and bottom of a blog to allow entering
- a title for a new item, that goes to a template to create the new page.
- Should probably add params to control various rss fields like the blog
title, its author email, its copyright info, etc.
- The [[TODO]] page would work better if the first N were shown in full,
- and then all open items were shown in summary. Maybe add this mode. \ No newline at end of file
+ and then all open items were shown in summary. Maybe add this mode.
diff --git a/doc/todo/upgradehooks.mdwn b/doc/todo/upgradehooks.mdwn
new file mode 100644
index 000000000..90ef725ae
--- /dev/null
+++ b/doc/todo/upgradehooks.mdwn
@@ -0,0 +1,6 @@
+It's annoying to have to manually run --setup, especially for multiple
+blogs, on upgrade. Is the deb is used, there could be a postinst hook to do
+this.
+
+Let there be an /etc/ikiwiki/wikis, which just lists setup files and the
+user who owns them. postinst loops through, su's, and runs --setup. Voila!
diff --git a/ikiwiki b/ikiwiki
index f8b43d720..1451cb8aa 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -21,7 +21,7 @@ sub getconfig () { #{{{
wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
- wiki_file_regexp => qr/(^[-A-Za-z0-9_.\&;:\/+]+$)/,
+ wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
verbose => 0,
wikiname => "wiki",
default_pageext => ".mdwn",
@@ -32,7 +32,7 @@ sub getconfig () { #{{{
historyurl => '',
diffurl => '',
anonok => 0,
- rss => 1,
+ rss => 0,
rebuild => 0,
wrapper => undef,
wrappermode => undef,
diff --git a/templates/inlinepage.tmpl b/templates/inlinepage.tmpl
index bca3ff55d..4999c3248 100644
--- a/templates/inlinepage.tmpl
+++ b/templates/inlinepage.tmpl
@@ -1,3 +1,6 @@
+
+<hr>
+
<h1><TMPL_VAR PAGELINK></h1>
<TMPL_VAR CONTENT>
@@ -5,4 +8,3 @@
<p>
<i>(posted <TMPL_VAR CTIME>)</i>
</p>
-<hr>