Permalink
Browse files

Clean up menus. Use "|" for separator. When zoom in on a contact or a…

…sset

type, don't put the name of the contact or asset type in the navigation menu
at top.  Instead put the word "Refresh".  That avoids the menu wrapping in an
ugly way when you click on a long name.

I also fixed the problem in Contact Invite where if you un-checked the
"include 100 usage tokens" flag it would still include the tokens anyway.
  • Loading branch information...
1 parent a6d150a commit 956bbef5f3f88f04a93b06e23fc2ec62b5265efb Patrick Chkoreff committed Mar 26, 2010
View
1 code/Loom/Context.pm
@@ -108,6 +108,7 @@ sub read_kv
{
my $s = shift;
my $text = shift;
+ $text = "" if !defined $text;
$s = $s->new if ref($s) eq "";
View
4 code/Loom/Crypt.pm
@@ -89,6 +89,8 @@ sub pad
my $s = shift;
my $text = shift;
+ die if !defined $text;
+
my $blocksize = $s->{cipher}->blocksize;
my $len = length($text) + 1; # allow for pad count byte at end
@@ -116,6 +118,8 @@ sub unpad
my $s = shift;
my $text = shift;
+ die if !defined $text;
+
my $num_pad_bytes = ord(substr($text,-1,1));
my $result_length = length($text) - 1 - $num_pad_bytes;
View
6 code/Loom/DB/File.pm
@@ -13,6 +13,10 @@ Converts the Loom::File directory interface into the get/update interface used
by the transaction layer Loom::DB::Trans. Also provides a put routine so you
have simple put/get access as well.
+WARNING: This module makes *no* assumptions about file names whatsoever. It
+assumes that the caller knows what it is doing and is only passing in valid
+file names.
+
=cut
sub new
@@ -46,7 +50,7 @@ sub put
my $key = shift;
my $val = shift;
- $s->{dir}->update({$key => $val}, {});
+ $s->update({$key => $val}, {});
return;
}
View
5 code/Loom/Object/Loom/API_Archive.pm
@@ -56,6 +56,11 @@ sub respond
return;
}
+# LATER 0318 keep the usage tokens in a separate secret grid location for each
+# archive location, instead of moving them back and forth to the usaget token
+# issuer location. That will make Archive a completely decoupled API which
+# requires no privileged operations, i.e. calling charge_usage.
+
sub do_buy
{
my $s = shift;
View
39 code/Loom/Object/Loom/Main.pm
@@ -14,6 +14,18 @@ use Loom::Object::Loom::Login; # LATER need this here, or move down into Folde
use Loom::Random;
use Loom::Sloop::HTTP::Parse;
+# LATER 0325 Let's do a local install of all the prerequisite Perl modules.
+
+# LATER 0325 Let's not "use" all the modules right away here. That way if some
+# some modules are missing the self-test will get a chance to run and report
+# them cleanly. As it stands the code just dies if something like
+# Crypt::Rijndael is missing.
+
+# LATER 0318 object system, including dynamic asset type descriptor, "pay me"
+# site, shopping carts, digital vending machines, and even a code browser
+# for Loom itself. (I have already written that code browser on another site
+# so I'll just port it here.)
+
sub new
{
my $class = shift;
@@ -26,6 +38,16 @@ sub new
$s->{TOP} = $arena->{top}->full_path;
+ if (!defined $arena->{client})
+ {
+ # The Sloop::Listen module will call us without a client object first
+ # upon starting the server. That gives us a chance to do special
+ # processing including self-test.
+
+ $s->startup;
+ return $s;
+ }
+
$s->{id} = Loom::ID->new;
$s->{html} = Loom::HTML->new;
@@ -54,13 +76,21 @@ sub new
return $s;
}
-# This is called if you include the -t option when starting sloop.
+# We call this right before the server starts up or when running the test.
-sub qualify
+sub startup
{
my $s = shift;
- Loom::Load->new->require("Loom::Test::Sloop")->new($s->{arena})->run;
+ if ($s->{arena}->{test})
+ {
+ # We saw the -t option. Run the self-test.
+
+ print "Running self-test.\n";
+ Loom::Load->new->require("Loom::Test::Sloop")->new($s->{arena})->run;
+ print "Test succeeded.\n";
+ }
+
return;
}
@@ -449,8 +479,7 @@ sub top_navigation_bar
my $top_links = $s->{top_links};
for my $link (@$top_links)
{
- $link = "/" if !defined $link || $link eq "";
-
+ $link = "|" if !defined $link || $link eq "";
$dsp_links .= qq{<span style='padding-right:15px'>$link</span>\n};
}
View
3 code/Loom/Object/Loom/Page_Asset.pm
@@ -87,8 +87,7 @@ sub top_links
push @{$site->{top_links}},
$site->highlight_link(
$site->url($op->slice("function","name","session")),
- $q_name,
- $s->{menu} eq "zoom");
+ "Refresh",1) if $s->{menu} eq "zoom";
push @{$site->{top_links}}, "" if $s->{menu} eq "zoom";
View
7 code/Loom/Object/Loom/Page_Contact.pm
@@ -78,8 +78,7 @@ sub top_links
push @{$site->{top_links}},
$site->highlight_link(
$site->url($op->slice("function","name","session")),
- $q_name,
- $s->{menu} eq "zoom");
+ "Refresh",1) if $s->{menu} eq "zoom";
push @{$site->{top_links}}, "" if $s->{menu} eq "zoom";
@@ -152,7 +151,7 @@ sub top_links
$site->highlight_link(
$site->url($op->slice("function"),
action => "invite",
- include_usage_tokens => "on",
+ default_include_usage_tokens => "1",
$op->slice("session")),
"Invite",
$s->{menu} eq "invite",
@@ -1184,7 +1183,7 @@ EOM
if ($action eq "invite")
{
- my $checked = $op->get("include_usage_tokens") ne "" ? " checked" : "";
+ my $checked = $op->get("default_include_usage_tokens") ne "" ? " checked" : "";
$table .= <<EOM;
<tr>
<td align=right>
View
9 code/Loom/Object/Loom/Page_Folder.pm
@@ -40,6 +40,15 @@ sub respond
$s->{archive} = Loom::Object::Loom::EZ_Archive->new($site->{loom});
$s->{grid} = Loom::Object::Loom::EZ_Grid->new($site->{loom});
+ # LATER 0318 The next goal is the atomic API, with parallel update, commit,
+ # loop, all that. That way we can do a series of individual operations
+ # and they'll all be committed at once, with no effect if any one of them
+ # fails. For example, updating the session id in the archive requires two
+ # writes. Those should be atomic.
+
+ # LATER 0318 make the entire server completely self-configuring upon
+ # installation.
+
my $op = $site->{op};
# If we got here by default then set function to "folder".
View
38 code/Loom/Sloop/Listen.pm
@@ -85,54 +85,38 @@ sub respond
$s->{signal}->put_child(0);
$s->{signal}->put_interrupt(0);
- if ($s->{arena}->{test} && !$s->{arena}->{start})
- {
- # Qualify only.
- $s->qualify;
- return;
- }
+ return if !$s->stop_server; # Stop the server if already running.
- # Stop the server if already running.
- my $ok = $s->stop_server;
- if (!$ok)
- {
- # We failed to stop the server! Give up.
- return;
- }
+ $s->init_server if $s->{arena}->{start} || $s->{arena}->{test};
+ # Initialize server if starting or testing.
- # Now start the server if desired.
- if ($s->{arena}->{start})
- {
- $s->start_server;
- }
+ $s->start_server if $s->{arena}->{start}; # Start the server if desired.
return;
}
-# Qualify the handler module before starting the server.
+# When the user starts the server with -y, or runs the self-test with -t, we
+# create an instance of the handler module without a client. That gives it a
+# chance to initialize, run tests, etc. We don't do anything with the handler,
+# we just create it and let it go.
-sub qualify
+sub init_server
{
my $s = shift;
my $opt = $s->{config}->options;
my $module = Loom::Load->new->require($opt->{module});
- $module->new( { top => $s->{top} } )->qualify;
+ my $handler = $module->new($s->{arena});
return;
}
-# Start the server and loop until terminated.
+# Start the server running in the background and loop until terminated.
sub start_server
{
my $s = shift;
- $s->qualify if $s->{arena}->{test};
-
- # OK now we've passed the test so let's start the server running in the
- # background.
-
my $child = fork;
if (!defined $child)
View
11 code/Loom/Test/File.pm
@@ -88,7 +88,15 @@ sub run
my $TOP = $s->{arena}->{TOP};
die if !defined $TOP;
- $s->{data} = Loom::File->new("$TOP/data/test_3e1fc2ef");
+
+ $s->{testdir} = Loom::File->new("$TOP/test");
+
+ my $prog_name = $0;
+ $prog_name =~ s#.*/##;
+
+ $s->{data} = $s->{testdir}->child($prog_name);
+ $s->{data}->create_path;
+
$s->{data}->remove_tree;
$s->{data}->create_dir;
@@ -155,6 +163,7 @@ EOM
{
# Success!
$s->{data}->remove_tree;
+ $s->{testdir}->remove_dir; # remove empty test dir if possible
return 0;
}
else
View
7 code/Loom/Test/Sloop.pm
@@ -29,11 +29,16 @@ sub run
Loom::Test::Grid->new({embedded => 1})->run;
# Test concurrent file operations with many processes.
+
+ # LATER 0318 After we actually port the current GNU DB over to individual
+ # files, I'll write a massively parallel test suite for API operations
+ # themselves, in addition to this raw file test.
+
{
my $arena =
{
embedded => 1,
- count => 30,
+ count => 128,
verbose => 0,
TOP => $s->{arena}->{top}->full_path,
};

0 comments on commit 956bbef

Please sign in to comment.