wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / weblog-4.pl
blob55aa06f38350087c35d51f12b7676fb3400ec599
1 # Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/weblog-4.pl">weblog-4.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Blogging_With_Tags">Blogging With Tags</a></p>';
21 push(@MyInitVariables, sub {
22 $SearchFreeTextTagUrl = $ScriptName . '?action=browse;tag=1;id=';
23 });
25 push(@MyAdminCode, \&BlogMenu);
27 sub BlogMenu {
28 my ($id, $menuref, $restref) = @_;
29 push(@$menuref, ScriptLink('action=new', T('New'), 'new'));
32 # Default page content copied from weblog-3.pl.
34 *BlogOldOpenPage = *OpenPage;
35 *OpenPage = *BlogNewOpenPage;
37 sub BlogNewOpenPage {
38 BlogOldOpenPage(@_);
39 if ($Page{revision} == 0) {
40 if ($OpenPageName eq $HomePage) {
41 $Page{text} = '<journal>';
42 } elsif (GetParam('tag','') or $Category{$OpenPageName}) {
43 # if the page is either on the categories page, or the tag=1
44 # parameter was added, show a journal
45 $Page{text} = T('Matching pages:')
46 . "\n\n<journal search tag:$OpenPageName>";
51 # New Action
53 $Action{new} = \&DoCategories;
55 sub DoCategories {
56 if (GetParam('tags', '') and GetParam('id', '')) {
57 DoEdit(GetParam('id', ''), "\n\n\nTags: "
58 . join (' ', map { "[[tag:$_]]" } split(' ', GetParam('tags', ''))),
59 1);
60 } else {
61 print GetHeader('', T('New')), $q->start_div({-class=>'content categories'}),
62 GetFormStart(undef, 'get', 'cat');
63 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime();
64 my $today = sprintf("%d-%02d-%02d", $year + 1900, $mon + 1, $mday);
65 my $go = T('Go!');
66 print $q->p(T('Title: '),
67 qq{<input type="text" name="id" value="$today" tabindex="1" />},
68 GetHiddenValue('action', 'new'));
69 print $q->p(T('Tags: '),
70 qq{<input type="text" name="tags" tabindex="2" />});
71 print $q->p(qq{<input type="submit" value="$go" tabindex="3" />});
72 print $q->end_form, $q->end_div();
73 PrintFooter();