Committer: bcoffeltReplaced both ljuser_by_string and userlite_as_string with the new UserLite ljuser() function. The new ljuser() function can access LJ::ljuser either through an existing UserLite object, or through creating a new UserLite object that will be populated with LJ::load_user.
U trunk/bin/upgrading/s2layers/core1.s2
U trunk/cgi-bin/LJ/S2.pm
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2 2006-10-18 19:32:33 UTC (rev 9261)
+++ trunk/bin/upgrading/s2layers/core1.s2 2006-10-19 02:28:55 UTC (rev 9262)
@@ -261,6 +261,7 @@
var string[] link_keyseq "Array of keys which can be passed into the get_link";
function builtin equals(UserLite u) : bool "Returns true if the two user objects refer to the same user. Use this rather than comparing usernames, since usernames aren't globally unique.";
+ function builtin ljuser() : string "UserLite";
function builtin get_link(string key) : Link "Returns a link based on the given key, or null if the link is unavailable";
function base_url () : string "Returns URL of user's journal.";
function tag_manage_url () : string "Returns URL to user's tag management page.";
@@ -841,8 +842,7 @@
function builtin set_handler(string eventname, string[][] commands);
function builtin userlite_base_url(UserLite ul) : string;
-function builtin userlite_as_string(UserLite ul) : string "Access to the LJ::ljuser function";
-function builtin ljuser_by_string(string username) : string "Shortcut to the LJ::ljuser function by username";
+function builtin userlite_as_string(UserLite ul) : string "Deprecated function. Use ljuser() from now on.";
function builtin start_css () "Declare that you're about to start printing out CSS that should be buffered, then later cleaned when you call end_css(). WARNING: this is not re-entrant. You can't call start_css recursively.";
function builtin end_css () "Declare that you're done printing CSS and the output thus buffered should be cleaned and printed.";
@@ -1805,7 +1805,7 @@
}
function UserLite::as_string() [fixed] : string {
- return userlite_as_string($this);
+ return $this->ljuser();
}
function UserLite::print() {
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm 2006-10-18 19:32:33 UTC (rev 9261)
+++ trunk/cgi-bin/LJ/S2.pm 2006-10-19 02:28:55 UTC (rev 9262)
@@ -2021,6 +2021,12 @@
package S2::Builtin::LJ;
use strict;
+sub UserLite {
+ my ($ctx,$username) = @_;
+ my $u = LJ::load_user($username);
+ return LJ::S2::UserLite($u);
+}
+
sub start_css {
my ($ctx) = @_;
my $sc = $ctx->[S2::SCRATCH];
@@ -2913,14 +2919,10 @@
return $$c->($this);
}
-sub ljuser_by_string
+sub UserLite__ljuser
{
- my ($ctx,$username) = @_;
- my $u = LJ::load_user($username);
- return unless $u;
- my $user = LJ::ljuser($u);
- return unless $user;
- return $user;
+ my ($ctx, $UserLite) = @_;
+ return LJ::ljuser($UserLite->{_u});
}
sub UserLite__get_link
@@ -3359,12 +3361,6 @@
return $u->journal_base;
}
-sub userlite_as_string
-{
- my ($ctx, $UserLite) = @_;
- return LJ::ljuser($UserLite->{'_u'});
-}
-
sub PalItem
{
my ($ctx, $idx, $color) = @_;