Files
oddmuse/modules/weblog-4.pl

77 lines
2.5 KiB
Perl
Raw Normal View History

# Copyright (C) 20062014 Alex Schroeder <alex@gnu.org>
2006-06-11 15:06:58 +00:00
#
# 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 the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
2006-06-11 15:06:58 +00:00
#
# 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 General Public License for more details.
2006-06-11 15:06:58 +00:00
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
2006-06-11 15:06:58 +00:00
use strict;
use v5.10;
AddModuleDescription('weblog-4.pl', 'Blogging With Tags');
2006-06-11 15:19:53 +00:00
2015-04-10 13:31:28 +03:00
our ($q, %Action, %Page, $OpenPageName, $HomePage, $ScriptName, @MyInitVariables, @MyAdminCode, $SearchFreeTextTagUrl);
push(@MyInitVariables, sub {
$SearchFreeTextTagUrl = $ScriptName . '?action=browse;tag=1;id=';
2006-06-11 15:19:53 +00:00
});
2006-06-11 15:10:50 +00:00
2006-06-11 15:13:30 +00:00
push(@MyAdminCode, \&BlogMenu);
sub BlogMenu {
my ($id, $menuref, $restref) = @_;
2006-08-06 11:56:40 +00:00
push(@$menuref, ScriptLink('action=new', T('New'), 'new'));
2006-06-11 15:13:30 +00:00
}
2006-06-11 15:06:58 +00:00
# Default page content copied from weblog-3.pl.
*BlogOldOpenPage = \&OpenPage;
*OpenPage = \&BlogNewOpenPage;
2006-06-11 15:06:58 +00:00
sub BlogNewOpenPage {
BlogOldOpenPage(@_);
if ($Page{revision} == 0) {
if ($OpenPageName eq $HomePage) {
$Page{text} = '<journal>';
} elsif (GetParam('tag','')) {
2006-06-11 15:06:58 +00:00
# if the page is either on the categories page, or the tag=1
# parameter was added, show a journal
$Page{text} = T('Matching pages:')
. "\n\n<journal search tag:$OpenPageName>";
2006-06-11 15:06:58 +00:00
}
}
}
# New Action
$Action{new} = \&DoNewPage;
2006-06-11 15:06:58 +00:00
sub DoNewPage {
2006-06-11 15:06:58 +00:00
if (GetParam('tags', '') and GetParam('id', '')) {
DoEdit(GetParam('id', ''), "\n\n\nTags: "
. join (' ', map { "[[tag:$_]]" } split(' ', GetParam('tags', ''))),
1);
} else {
print GetHeader('', T('New')), $q->start_div({-class=>'content new'}),
2006-06-11 15:06:58 +00:00
GetFormStart(undef, 'get', 'cat');
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime();
my $today = sprintf("%d-%02d-%02d", $year + 1900, $mon + 1, $mday);
my $go = T('Go!');
print $q->p(T('Title:') . ' '
. qq{<input type="text" name="id" value="$today" tabindex="1" />},
2006-06-11 15:06:58 +00:00
GetHiddenValue('action', 'new'));
print $q->p(T('Tags:') . ' '
. qq{<input type="text" name="tags" tabindex="2" />});
2007-02-20 00:29:37 +00:00
print $q->p(qq{<input type="submit" value="$go" tabindex="3" />});
2006-06-11 15:06:58 +00:00
print $q->end_form, $q->end_div();
PrintFooter();
}
}