add Wobject metadata, passive profiling, generateContent script

This commit is contained in:
Len Kranendonk 2004-07-17 20:20:10 +00:00
parent 3482822e40
commit 50cc94ba43
7 changed files with 648 additions and 0 deletions

View file

@ -0,0 +1,50 @@
package Hourly::SummarizePassiveProfileLog;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::PassiveProfiling;
use WebGUI::DateTime;
#-----------------------------------------
sub process {
my $verbose = shift;
unless ($session{setting}{passiveProfilingEnabled}) {
print "Passive profiling is disabled...\n";
return;
}
my ($firstDate) = WebGUI::SQL->quickArray("select min(dateOfEntry) from passiveProfileLog");
my $interval = $session{config}{passiveProfileInterval} || 86400;
if (WebGUI::DateTime::time()-$firstDate < $interval) {
print " - Recently runned: Skipping...\n" if ($verbose);
return "";
}
my $sessionExpired = WebGUI::DateTime::time() - $session{setting}{sessionTimeout};
# We process entries for registered users and expired visitor sessions
my $sql = "select * from passiveProfileLog";
$sql .= " where userId <> 1 or (userId = 1 and dateOfEntry < ".quote($sessionExpired).")";
my $sth = WebGUI::SQL->read($sql);
while (my $data = $sth->hashRef) {
WebGUI::PassiveProfiling::summarizeAOI($data);
WebGUI::SQL->write("delete from passiveProfileLog where passiveProfileLogId = ".
quote($data->{passiveProfileLogId}));
}
$sth->finish;
}
1;

123
sbin/generateContent.pl Normal file
View file

@ -0,0 +1,123 @@
#!/usr/bin/perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our $webguiRoot;
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use DBI;
use Getopt::Long;
use strict qw(subs vars);
use WebGUI;
use WebGUI::Session;
use WebGUI::HTML;
use WebGUI::Utility;
$|=1;
my ($configFile, $pageId, $userId, $styleId, $toFile, $stripHTML, $help);
$userId = 1;
GetOptions(
'configFile:s'=>\$configFile,
'pageId:i'=>\$pageId,
'userId:i'=>\$userId,
'styleId:i'=>\$styleId,
'toFile:s'=>\$toFile,
'stripHTML'=>\$stripHTML,
'help'=>\$help
);
#if ($help || $configFile eq '' || $pageId eq '' ) {
if ($help || $configFile eq '' ) {
print <<STOP;
Usage: perl $0 --configfile=<webguiConfig> --pageId=<pageNumber>
--configFile WebGUI config file (with no path info).
--pageId Set the page to be generated.
Options:
--help Displays this message.
--userId Set the user that should view the page.
Defaults to "1" (Visitor).
--styleId Set an alternate style for the page.
Defaults to page's default style.
--toFile Set the path and filename to write the
content to instead of standard out.
--stripHTML A flag indicating that WebGUI should
strip all the HTML from the document and
output only text. NOTE: The resulting
text may have formatting problems as a
result.
STOP
exit;
}
# Open output file if necessary
if ($toFile) {
open (TOFILE, ">$toFile") or die "Can't open file $toFile for writing. $!";
}
# Open WebGUI session
WebGUI::Session::open($webguiRoot,$configFile);
WebGUI::Session::refreshUserInfo($userId,$session{dbh});
WebGUI::Session::refreshPageInfo($pageId);
# No HTTP header as we're browserless
$session{page}{noHttpHeader} = 1;
# Alternate style
if (defined $styleId) {
$session{form}{makePrintable}++; # prevent caching
$session{page}{styleId} = $styleId;
}
# Retrieve content
my $content = WebGUI::page(undef, undef, 1);
# stripHTML
if ($stripHTML) {
$content = WebGUI::HTML::html2text($content);
} else {
# Make links absolute
$content = WebGUI::HTML::makeAbsolute($content);
}
# Print result
if ($toFile) {
print TOFILE $content;
} else {
print $content;
}
# Clean-up WebGUI Session
WebGUI::Session::end($session{var}{sessionId});
WebGUI::Session::close();
# Close output file if necessary
close(TOFILE) if ($toFile);
exit;