dragoness_e: (Default)
[personal profile] dragoness_e
Future_dayz displays entries from the most-recent $past_days to the present, to the next $future_days, instead of the normal $num_entries posts. (However, $num_entries still sets the limit on how many posts from the most-recent $num_days days will be displayed.)  'start time' ($origin) is always Right Now; this plug-in was designed so I could run a calendar of future events using blosxom.
# Blosxom Plugin: future_dayz
# Author:Cynthia Higginbotham <mailto:dragoness77@republicofnewhome.org>
#   (based on Stu Mackenzie's num_dayz plugin)
# Version: v0.1
# License: GPL2
# future_dayz home: My hard drive
# 
# Documentation at the bottom of this file or type: perldoc future_dayz

# Blosxom normally displays the most recent $num_entries posts (5, 10,
# 100); future_dayz displays posts from the more recent $past_days
# posts, and on into $future_days into the future.The maximum number of
# posts that will be displayed is still set by $num_entries.

# 'start time' ($origin) is always Right Now; this plug-in was
# designed so I could run a calendar of future events using
# blosxom. It will detect whether the entries are sorted ascending or
# descending by date, and filter accordingly.

package future_dayz;

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
#  Configuration Section
#
# = = = = = = = = = = = = = = = =
#
# Use this plugin?
$future_dayz_on = 0
    unless defined $future_dayz_on;

# How many days' posts should be displayed?
$past_days = 2;
  
$future_days = 365;


# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

use vars qw($future_dayz_on $past_days $future_days);

use strict;

sub start {
  1;
}

sub filter {
  $future_dayz_on or return 0;               # only run when requested

  my($pkg, $files_ref) = @_;

  my ($origin, $future_secs, $past_secs, $leftover_secs, $SECS_PER_DAY);
  my ($earliest_valid_mtime, $latest_valid_mtime);

  $SECS_PER_DAY = (60 * 60 * 24);

  # $num_secs = $num_days in seconds
  $future_secs = $future_days * $SECS_PER_DAY;
  $past_secs = $past_days * $SECS_PER_DAY;
  $origin = time();
  $leftover_secs = $origin % $SECS_PER_DAY;

  # How many seconds ago/ahead is cut-off time from beginning of today?
  $earliest_valid_mtime = $origin - ($past_secs + $leftover_secs);
  $latest_valid_mtime = $origin + ($future_secs - $leftover_secs);

  foreach my $key ( keys %$files_ref ) {
      (($$files_ref{$key} > $earliest_valid_mtime) and
       ($$files_ref{$key} < $latest_valid_mtime))  
	  or delete $$files_ref{$key};

  }

  1;
}


1;

__END__


=head1 NAME

Blosxom Plug-in: future_dayz


=head1 SYNOPSIS

* Entries from the most-recent $past_days to the present, to the next
  $future_days are displayed, instead of the normal $num_entries
  posts. (However, $num_entries still sets the limit on how many posts
  from the most-recent $num_days days will be displayed.)

* can be turned off/on on a per-config file basis.

=head1 INSTALLATION

Locate the future_dayz plugin you downloaded; open the file and enter 
the three CONFIGURATION values; save the file with unix line ends. 
Upload or drop the future_dayz file into your blosxom plugins folder. 
Blog on.


=head1 CONFIGURATION

With any luck, the instructions in the "Configuration Section" 
at the top of this file are sufficient;

=head1 USAGE NOTES

=head1 BUGS


=head1 VERSION

2005-02-28 (v0.1): Made it live

=head1 LICENSE

this Blosxom Plug-in
Copyright 2005, Cynthia Higginbotham

See the Gnu Public License, 2.0
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

dragoness_e: (Default)
Dragoness Eclectic

November 2025

S M T W T F S
      1
2345678
9101112131415
16171819202122
23 242526272829
30      

Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 28th, 2025 07:28 pm
Powered by Dreamwidth Studios