forked from bentglasstube/blosxom-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlastvisited-v20030618
109 lines (79 loc) · 2.46 KB
/
lastvisited-v20030618
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Blosxom Plugin: lastvisited
# Author: Bob Schumaker <[email protected]>
# Version: 20030618
# http://www.cobblers.net/blog/
# License: Public Domain
package lastvisited;
use strict;
use warnings;
use Data::Dumper;
# --- Plug-in package variables -----
my $cookie;
my $lastvisited;
my $newvisited;
# --- Output variables -----
# --- Configurable variables -----
my $cookie_name;
my $new_class = "new";
my $new_marker = " <b>NEW!</b> ";
# --------------------------------
sub start {
1;
}
sub head {
my($pkg, $currentdir, $head_ref) = @_;
if(defined($cookies::domain)) {
$cookie_name ||= "$blosxom::blog_title Last Visit";
$cookie_name =~ s/ /_/g;
$cookie = &cookies::get($cookie_name);
if(defined($cookie)) {
my @v = keys %$cookie;
$lastvisited = $v[0];
}
else {
$lastvisited = $lastmodified::latest_iso8601;
}
$newvisited = $lastmodified::now_iso8601;
$new_marker = "<span class=\"$new_class\">$new_marker</span>";
return 1;
}
}
sub story {
my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) =@_;
if( defined($lastvisited) && $lastvisited lt $lastmodified::story_iso8601 ) {
$$story_ref = $new_marker . $$story_ref;
}
return 1;
}
sub foot {
if( defined($cookies::domain) ) {
&cookies::add(
&CGI::cookie(
-name=>$cookie_name,
-value=>$newvisited,
-path=>$cookies::path,
-domain=>$cookies::domain
)
);
}
}
1;
__END__
=head1 NAME
Blosxom Plug-in: lastvisited
=head1 DESCRIPTION
In cooperation with the cookie plugin and the lastmodified plugin, the lastvisited plugin
marks 'new' stories. A 'new' story is defined as "a story that a previous visitor hasn't read yet.;"
Brand-new visitors (and visitors who don't save cookies) won't have stories marked, since by
definition they're all new stories...
There are a couple of configurable variables:
$lastvisited::new_class: the new marker is enclosed in a <span> of this class
$lastvisited::new_marker: the marker to prefix the story with (it will end up at the end of the title of the post)
=head1 AUTHOR
Bob Schumaker <[email protected]> http://www.cobblers.net/blog
=head1 LICENSE
This source is submitted to the public domain. Feel free to use and modify it.
If you like, a comment in your modified source attributing credit to myself for
my work would be appreciated.
THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND. USE AT
YOUR OWN RISK!