Permalink
Browse files

fixed Sky to not rely on cookies; fixed Pilot BX; added ability to cr…

…eate new init file versions; does NOT update init file version
  • Loading branch information...
1 parent 1fb5384 commit 7f36cffca30edeb36cba2feea0f4516f4bbbae29 @windley windley committed Dec 28, 2011
View
@@ -118,52 +118,54 @@ sub calculate_rid_list {
my $r = {};
- my $ken = Kynetx::Persistence::get_ken($session, "", "web"); # empty rid
+ if (is_eventtree_stashed($req_info)) {
+ $logger->debug("Using stashed eventtree");
+ $r = grab_eventtree($req_info);
+ } else {
+ my $ken = Kynetx::Persistence::get_ken($session, "", "web"); # empty rid
- my $memd = get_memd();
- my $rid_list_key = mk_ridlist_key($ken);
+ my $memd = get_memd();
+ my $rid_list_key = mk_ridlist_key($ken);
- my $rid_list = $memd->get($rid_list_key);
+ my $rid_list = $memd->get($rid_list_key);
- if ($rid_list) {
- $logger->debug("Using cached rid_list ", rid_info_string($rid_list));
+ if ($rid_list) {
+ $logger->debug("Using cached rid_list ", rid_info_string($rid_list));
- } else {
- # get accout info
- my $user_rids_info = Kynetx::Configure::get_config('USER_RIDS_URL');
- my ($app_url,$username,$passwd) = split(/\|/, $user_rids_info);
- my $acct_url = $app_url."/".$req_info->{'id_token'};
- my $req = HTTP::Request->new(GET => $acct_url);
- $req->authorization_basic($username, $passwd);
- my $ua = LWP::UserAgent->new;
- $rid_list = decode_json($ua->request($req)->{'_content'})->{'rids'};
+ } else {
+ # get accout info
+ my $user_rids_info = Kynetx::Configure::get_config('USER_RIDS_URL');
+ my ($app_url,$username,$passwd) = split(/\|/, $user_rids_info);
+ my $acct_url = $app_url."/".$req_info->{'id_token'};
+ my $req = HTTP::Request->new(GET => $acct_url);
+ $req->authorization_basic($username, $passwd);
+ my $ua = LWP::UserAgent->new;
+ $rid_list = decode_json($ua->request($req)->{'_content'})->{'rids'};
- $logger->debug("Retrieved rid_list ", print_rids($rid_list));
+ $logger->debug("Retrieved rid_list ", print_rids($rid_list));
- # cache this...
- $memd->set($rid_list_key, $rid_list);
+ # cache this...
+ $memd->set($rid_list_key, $rid_list);
- }
+ }
- my $eventtree_key = mk_eventtree_key($rid_list);
+ my $eventtree_key = mk_eventtree_key($rid_list);
- $r = $memd->get($eventtree_key);
+ # $r = $memd->get($eventtree_key);
- if (defined $r) {
- $logger->debug("Using cached eventtree");
- } else {
foreach my $rid_info (@{$rid_list}) {
my $rid = get_rid($rid_info);
my $ruleset = Kynetx::Repository::get_rules_from_repository($rid_info, $req_info, $rid_info->{'kinetic_app_version'});
- $r->{$rid} = process_dispatch_list($rid, $ruleset);
-
- foreach my $d ( @{$r->{$rid}->{'domains'} }) {
- $r->{$rid}->{'domain'}->{$d} = 1;
+
+ my $dispatch_info = process_dispatch_list($rid, $ruleset);
+# $logger->debug("Domain ", sub{ Dumper $dispatch_info } );
+ foreach my $d ( @{ $dispatch_info->{'domains'} }) {
+ $r->{'ridlist'}->{$rid}->{'domains'}->{$d} = 1;
}
@@ -173,13 +175,15 @@ sub calculate_rid_list {
}
}
}
- $logger->debug("Calculating the event tree");
+ $logger->debug("Calculating and stashing the event tree");
-# $logger->debug("Caching the Event Tree: ", sub { Dumper $r });
+# $logger->debug("Event Tree: ", sub { Dumper $r });
# cache this...
# $memd->set($eventtree_key, $r);
+ stash_eventtree($req_info, $r);
+
}
return $r;
@@ -261,7 +265,7 @@ sub deep_member {
sub process_dispatch_list {
my($rid,$ruleset) = @_;
my $logger = get_logger();
- $logger->debug("Processing dispatch informaion for $rid");
+ # $logger->debug("Processing dispatch information for $rid");
my $r = {};
if( defined $ruleset && $ruleset->{'dispatch'} ) {
@@ -341,4 +345,21 @@ sub mk_eventtree_key {
return Digest::MD5::md5_hex(rid_info_string($rid_list));
}
+sub stash_eventtree {
+ my ( $req_info, $eventtree ) = @_;
+ $req_info->{"KOBJ.eventtree"} = $eventtree;
+}
+
+sub grab_eventtree {
+ my ( $req_info ) = @_;
+ return $req_info->{"KOBJ.eventtree"};
+}
+
+sub is_eventtree_stashed {
+ my ( $req_info ) = @_;
+ return defined $req_info->{"KOBJ.eventtree"};
+}
+
+
+
1;
View
@@ -88,6 +88,7 @@ sub handler {
# $logger->debug("RIDs -> $rids");
my $js_version = Kynetx::Configure::get_config('JS_VERSION');
+ $logger->debug("Using JS version $js_version");
my $js_root = Kynetx::Configure::get_config('DEFAULT_JS_ROOT');
my $not_secure = ! (($r->headers_in->{'X-Secure'} || '') eq 'Yes');
View
@@ -394,6 +394,7 @@ sub eval_raise_statement {
$req_info->{'api'} eq 'blue') # this is what we do for blue
) {
+ $logger->debug("Processing postlude with BLUE api");
# rid list can be an expression
my $rids = Kynetx::Expressions::den_to_exp(
eval_expr_with_default(
@@ -428,6 +429,7 @@ sub eval_raise_statement {
# }
} else {
+ $logger->debug("Processing postlude with SKY api");
my $unfiltered_rid_list = Kynetx::Dispatch::calculate_rid_list($req_info);
$rid_info_list = $unfiltered_rid_list->{$domain}->{$eventtype} || [];
my $found = 0;
View
@@ -116,7 +116,8 @@ sub handler {
# get a session
$logger->debug("KBX cookie? ",$req_info->{'kntx_token'});
- my $session = Kynetx::Session::process_session($r, $req_info->{'kntx_token'});
+# my $session = Kynetx::Session::process_session($r, $req_info->{'kntx_token'});
+ my $session = Kynetx::Session::process_session($r, undef, $req_info->{'id_token'});
# just show the version and exit if that's what's called for
@@ -183,15 +184,17 @@ sub handler {
# $logger->error("Rids for $id_token: ", sub {Dumper ($unfiltered_rid_list)});
# filter $unfiltered_rid_list for saliant rulesets
+
$rid_list = $unfiltered_rid_list->{$domain}->{$eventtype} || [];
- $domain_test = $unfiltered_rid_list;
+ $domain_test = $unfiltered_rid_list->{'ridlist'};
+# $logger->error("Domain test for $id_token: ", sub {Dumper ($domain_test)});
$req_info->{'rids'} = $rid_list;
}
- $logger->info("Rids for $domain/$eventtype: ", sub {Kynetx::Rids::print_rids($rid_list)});
+# $logger->info("Rids for $domain/$eventtype: ", sub {Kynetx::Rids::print_rids($rid_list)});
Kynetx::Request::log_request_env( $logger, $req_info );
@@ -212,11 +215,11 @@ sub handler {
# check dispatch if domain is web and rids weren't specified
my $rid = $rid_info->{'rid'};
- if ($domain eq 'web'&&
+ if ($domain eq 'web'&& $eventtype eq 'pageview' &&
! $req_info->{'explicit_rids'} &&
- ! $domain_test->{$rid}->{'domain'}->{$hostname}
+ ! $domain_test->{$rid}->{'domains'}->{$hostname}
) {
- $logger->debug("Skipping $rid due to domain mismatch");
+ $logger->debug("Skipping $rid due to domain mismatch for $hostname");
next;
}
@@ -35,73 +35,78 @@
use DateTime;
use Data::Dumper;
-# global options
-use vars qw/ %opt /;
-my $opt_string = 'hv:r:au';
-getopts( "$opt_string", \%opt ); # or &usage();
-&usage() if $opt{'h'};
-
use Kynetx::Configure qw/:all/;
# FIXME: don't hardcode this...
use constant DEFAULT_JS_ROOT => '/web/lib/perl/etc/js';
use constant DEFAULT_JS_VERSION => '0.9';
+use constant DEFAULT_JQUERY_VERSION => '1.4.2';
+
+
+# global options
+use vars qw/ %opt /;
+my $opt_string = '?hv:r:auj:';
+getopts( "$opt_string", \%opt ); # or &usage();
+&usage() if $opt{'h'} || $opt{'?'};
+
# configure KNS
Kynetx::Configure::configure();
# use production mode to generate the file if sending to Amazon
Kynetx::Configure::set_run_mode('production') if $opt{'a'};
+my $js_version = $opt{'v'} || DEFAULT_JS_VERSION;
+my $js_root = $opt{'r'} || DEFAULT_JS_ROOT;
+my $jquery_version = $opt{'j'} || DEFAULT_JQUERY_VERSION;
+my $minify = !$opt{'u'};
+
+
my $dt = DateTime->now;
my $dstamp = $dt->ymd('');
my $hstamp = $dt->hms('');
my $kobj_file = "kobj-static-".$dstamp.$hstamp.".js";
-
-my @js_files = qw(
-krl-external-resource.js
-krl-data-set.js
-krl-application.js
-krl-runtime-header.js
-frameworks/jquery/1.4.2/jquery.js
-jquery_noconflict.js
-frameworks/jquery_sprintf/1.0.3/jquery_sprintf.js
-frameworks/json/1.2/jquery.json-1.2.js
-frameworks/bg_iframe/1.0/jquery.bgiframe.js
-frameworks/kgrowl/1.0/kgrowl-1.0.js
-frameworks/snowfall/1.0/snowfall.jquery.js
-krl-setup.js
-krl-runtime.js.tmpl
-krl-actions.js
-krl-functions.js
-frameworks/dom_watch/1.0/krl-domwatch.js
-frameworks/dom_watch/2.0/krl-domwatch.js
-frameworks/perc_and_annotate/1.0/krl-annotate.js
-frameworks/perc_and_annotate/1.0/krl-percolation.js
-frameworks/sidetab/1.0/krl-sidetab.js
-formfill.js
-krl-runtime.js
-krl-eventmanager.js
-frameworks/log4js/1.4/log4javascript_uncompressed.js
-krl-logging.js
-krl-snoop.js
-krl-runtime-footer.js
+my @js_files = (
+"krl-external-resource.js",
+"krl-data-set.js",
+"krl-application.js",
+"krl-runtime-header.js",
+"frameworks/jquery/$jquery_version/jquery.js",
+"jquery_noconflict.js",
+"frameworks/jquery_sprintf/1.0.3/jquery_sprintf.js",
+"frameworks/json/1.2/jquery.json-1.2.js",
+"frameworks/bg_iframe/1.0/jquery.bgiframe.js",
+"frameworks/kgrowl/1.0/kgrowl-1.0.js",
+"frameworks/snowfall/1.0/snowfall.jquery.js",
+"krl-setup.js",
+"krl-runtime.js.tmpl",
+"krl-actions.js",
+"krl-functions.js",
+"frameworks/dom_watch/1.0/krl-domwatch.js",
+"frameworks/dom_watch/2.0/krl-domwatch.js",
+"frameworks/perc_and_annotate/1.0/krl-annotate.js",
+"frameworks/perc_and_annotate/1.0/krl-percolation.js",
+"frameworks/sidetab/1.0/krl-sidetab.js",
+"formfill.js",
+"krl-runtime.js",
+"krl-eventmanager.js",
+"frameworks/log4js/1.4/log4javascript_uncompressed.js",
+"krl-logging.js",
+"krl-snoop.js",
+"krl-runtime-footer.js",
);
my $foo = <<_krl_;
_krl_
-my $js_version = $opt{'v'} || DEFAULT_JS_VERSION;
-my $js_root = $opt{'r'} || DEFAULT_JS_ROOT;
-my $minify = !$opt{'u'};
my $js = "";
$js .= "window['kobj_ts'] = '$dstamp$hstamp';";
@@ -264,7 +269,8 @@ sub usage {
-a : store to S3 only in production mode
-u : don't minify the file during publish
-r DIR : use DIR as the root directory for JS files
- -v V : use V as the verion number
+ -v V : use V as the runtime version number
+ -j V : use V as the jquery version number
EOF
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Deleted file not rendered
Oops, something went wrong.

0 comments on commit 7f36cff

Please sign in to comment.