ShittyScript

Last edit

Summary: Shitty arvhice.pl upgrade

Added:

> # Copyright (C) 2007 Alex Schroeder <alex@emacswiki.org>
> #
> # 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 2 of the License, or
> # (at your option) any later version.
> #
> # 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.
> #
> # You should have received a copy of the GNU General Public License

Changed:

< *OldArchiveGetHeader = *GetHeader;
< *GetHeader = *NewArchiveGetHeader;
< # this assumes that *all* calls to GetHeader will print!

< sub NewArchiveGetHeader {
< my ($id) = @_;
< print OldArchiveGetHeader(@_);
< my %years = ();
< my %months = ();
< my $year_now = (localtime($Now))[5]+1900;
< for (AllPagesList()) {
< $months{$1}++ if /^$year_now-(\d\d)-\d\d/;
< $years{$1}++ if /^(\d\d\d\d)-\d\d-\d\d/;
< }
< print $q->div({-class=>'archive'},
< $q->p($q->span(T('Archive:')),
< $q->ul(
< map {
< $year = $_;
< $q->li(ScriptLink('action=collect;match=' . UrlEncode("^$year"), $year));
< if ($year == $year_now) {
< $q->ul(
< map {
< $month = $_;
< if (defined(&month_name)) {
< $q->li(ScriptLink('action=collect;match=' . UrlEncode("^$year-$month"),
< month_name($month)));
< } else {
< $q->li(ScriptLink('action=index;match=' . UrlEncode("^$year-$month"),
< "$month"));
< }
< } sort keys %months);
< }
< } sort keys %years)));
< return '';

to

> push(@MyRules, \&;ArchiveRule);
> sub ArchiveRule {
> if ($bol && m/\G(\&lt;archive&gt;)/cgi) {
> my ($id) = @_;
> my %years = ();
> my %months = ();
> my $year_now = (localtime($Now))[5]+1900;
> for (AllPagesList()) {
> $months{$1}++ if /^$year_now-(\d\d)-\d\d/;
> $years{$1}++ if /^(\d\d\d\d)-\d\d-\d\d/;
> }
> print $q->div({-class=>'archive'},
> $q->p($q->span(T('Archive:')),
> $q->ul(
> map {
> $year = $_;
> $html = "";
> $html .= $
q->li(ScriptLink('action=calendar;year=' . UrlEncode("$year"), $year));
> if ($year == $year_now) {
> $html .= $q->ul(
> map {
> $month = $_;
> if (defined(&month_name)) {
> $q->li(ScriptLink('action=collect;match=' . UrlEncode("^$year-$month"),
> month_name($month)));
> } else {
> $q->li(ScriptLink('action=index;match=' . UrlEncode("^$year-$month"),
> "$month"));
> }
> } reverse sort keys %months);
> }
> $html;
> } reverse sort keys %years)));
> }


# Copyright (C) 2007  Alex Schroeder <alex@emacswiki.org>
#
# 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 2 of the License, or
# (at your option) any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
#    Free Software Foundation, Inc.
#    59 Temple Place, Suite 330
#    Boston, MA 02111-1307 USA

$ModulesDescription .= '<p>$Id: archive.pl,v 1.3 2007/07/04 14:52:44 as Exp $</p>';

push(@MyRules, \&ArchiveRule);

sub ArchiveRule {
	if ($bol && m/\G(\&lt;archive&gt;)/cgi) {
		my ($id) = @_;
		my %years = ();
		my %months = ();
		my $year_now = (localtime($Now))[5]+1900;
		for (AllPagesList()) {
			$months{$1}++  if /^$year_now-(\d\d)-\d\d/;
			$years{$1}++ if /^(\d\d\d\d)-\d\d-\d\d/;
		}

		print $q->div({-class=>'archive'},
			$q->p($q->span(T('Archive:')),
				$q->ul(
					map {
						$year = $_;
						$html = "";
						$html .= $q->li(ScriptLink('action=calendar;year=' . UrlEncode("$year"), $year));
						if ($year == $year_now) {
							$html .= $q->ul(
								map {
									$month = $_;
									if (defined(&month_name)) {
										$q->li(ScriptLink('action=collect;match=' . UrlEncode("^$year-$month"),
												month_name($month)));
									} else {
										$q->li(ScriptLink('action=index;match=' . UrlEncode("^$year-$month"),
												"$month"));
									}

								} reverse sort keys %months);
						}
						$html;
					} reverse sort keys %years)));
	}
}