Significant update to the SyndicatedContent wobject to allow for better aggregation and scheduled content downloads.

This commit is contained in:
Daniel Collis-Puro 2005-06-15 02:29:12 +00:00
parent c7c968eaf2
commit 2fd3cb57f3
6 changed files with 519 additions and 150 deletions

View file

@ -0,0 +1,34 @@
package Hourly::GetSyndicatedContent;
use strict;
use warnings;
use WebGUI::SQL;
use WebGUI::Asset::Wobject::SyndicatedContent;
=head2 Hourly::GetSyndicatedContent
Loops through all the URLs in the SyndicatedWobjects and puts them into WebGUI::Cache if they haven't been spidered or if they have expired from the cache. This should reduce HTTP traffic a little, and allow for more granular scheduling of feed downloads in the future.
=cut
#-------------------------------------------------------------------
sub process{
#In the new Wobject, "rssURL" actually can refer to more than one URL.
my @syndicatedWobjectURLs = WebGUI::SQL->buildArray("select rssUrl from SyndicatedContent");
foreach my $url(@syndicatedWobjectURLs) {
#Loop through the SyndicatedWobjects and split all the URLs they are syndicating off into
#a separate array.
my @urlsToSyndicate = split(/\s+/,$url);
foreach ((@urlsToSyndicate)) {
WebGUI::Asset::Wobject::SyndicatedContent::_get_rss_data($_);
}
}
}
1;

126
sbin/updateTranslations.pl Executable file
View file

@ -0,0 +1,126 @@
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Long;
our $webguiRoot;
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
my $language='English';
my $namespace;
my $help;
my $test;
GetOptions(
'language=s'=>\$language,
'namespace=s'=>\$namespace,
'help'=>\$help,
'test'=>\$test
);
if ((!$help && !$namespace) or $help){
print <<STOP;
Usage: perl $0
This script helps you add keys and entries to the appropriate
WebGUI/i18n/<Language>/ translation files. It sorts the entries
by key value and takes care of escaping automatically.
Options:
--language The language you're adding an entry for.
Defaults to English
--help Display this help message and exit.
--namespace The name of the file you want to manipulate
in "lib/WebGUI/i18n/<language>" WITHOUT the .pm
extension. So, if you're editing the "Macro_GroupAdd.pm"
file, it's "Macro_GroupAdd".
--test Don't edit the actual file, but create a copy with ".test"
appended to the name.
STOP
exit;
}
die('You need to give us a namespace to edit') if (!$namespace);
my $tranmodule=join('::',('WebGUI','i18n',$language,$namespace));
eval "use $tranmodule;";
if (($@)) {
die('Either that namespace does not exist or you spelled it incorrectly. Please try again');
}
my $variable='$'.$tranmodule.'::I18N';
my $i18n=eval "$variable";
print "\nEnter a new key value to create a new entry.\nCurrent Keys:\n\n";
foreach ((keys %$i18n)) {
print "$_\n";
}
my $key='';
while (lc($key) ne 'quit') {
print "\n\nNew Key, or quit to stop:\n";
$key=<STDIN>;
chomp($key);
next if(!$key);
last if(lc($key) eq 'quit');
if (! defined $i18n->{$key}) {
print "\nNew key. Ok?\n";
my $input=<STDIN>;
chomp($input);
if (lc(substr($input,0,1)) eq 'y') {
get_info($key,$i18n);
}
} else {
print "\nErm. . . That key's already in use. Please try again.\n";
}
}
################################################################################
sub save_file{
open(OUTPUT,">","../lib/WebGUI/i18n/$language/$namespace.pm".(($test) ? '.test' : '')) or die($!);
$Data::Dumper::Varname='I18N';
$Data::Dumper::Sortkeys=1;
print OUTPUT "package $tranmodule;\n\n";
my $output=Dumper($i18n);
$output =~ s/^\$I18N1/\$I18N/i;
print OUTPUT "our ".$output;
print OUTPUT "1;";
close OUTPUT;
print "Saved!!\n";
}
########################################
################################################################################
sub get_info{
my $key=shift;
my $i18n=shift;
print "\nEnter the new information for this key. Press Ctrl-D to save\n";
my @info=<STDIN>;
print "\n\nOk? \n";
my $input=<STDIN>;
chomp($input);
if (lc(substr($input,0,1)) eq 'y') {
my $string=join("",@info);
chomp($string);
$i18n->{$key}->{message}=$string;
$i18n->{$key}->{lastUpdated}=time;
save_file();
}
}
########################################