Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r19980: LJSUP-9743 (site schemes refactoring)

Committer: ailyin
LJSUP-9743 (site schemes refactoring)
U   trunk/cgi-bin/LJ/HTML/Template.pm
A   trunk/cgi-bin/LJ/SiteScheme/
A   trunk/cgi-bin/LJ/SiteScheme/Lynx.pm
A   trunk/cgi-bin/LJ/SiteScheme.pm
U   trunk/cgi-bin/bml/scheme/global.look
U   trunk/cgi-bin/bml/scheme/lynx.look
U   trunk/cgi-bin/lj-bml-blocks.pl
U   trunk/cgi-bin/lj-bml-init.pl
U   trunk/cgi-bin/weblib.pl
A   trunk/templates/SiteScheme/
A   trunk/templates/SiteScheme/include/
A   trunk/templates/SiteScheme/include/breadcrumbs.tmpl
A   trunk/templates/SiteScheme/lynx.tmpl
Modified: trunk/cgi-bin/LJ/HTML/Template.pm
===================================================================
--- trunk/cgi-bin/LJ/HTML/Template.pm	2011-09-07 07:38:44 UTC (rev 19979)
+++ trunk/cgi-bin/LJ/HTML/Template.pm	2011-09-07 07:58:39 UTC (rev 19980)
@@ -9,13 +9,26 @@
 
     my %common_params = (
         'lj_siteroot'   => $LJ::SITEROOT,
-        'lj_statprefix' => $LJ::STATPREFIX,
-        'lj_imgprefix'  => $LJ::IMGPREFIX,
         'lj_sitename'   => $LJ::SITENAMESHORT,
         'lj_sslroot'    => $LJ::SSLROOT,
-        'lj_jsprefix'   => $LJ::JSPREFIX,
     );
 
+    if ($LJ::IS_SSL) {
+        %common_params = (
+            %common_params,
+            'lj_imgprefix'  => $LJ::SSLIMGPREFIX,
+            'lj_jsprefix'   => $LJ::SSLJSPREFIX,
+            'lj_statprefix' => $LJ::SSLSTATPREFIX,
+        );
+    } else {
+        %common_params = (
+            %common_params,
+            'lj_imgprefix'  => $LJ::IMGPREFIX,
+            'lj_jsprefix'   => $LJ::JSPREFIX,
+            'lj_statprefix' => $LJ::STATPREFIX,
+        );
+    }
+
     if ( LJ::is_web_context() ) {
         %common_params = (
             %common_params,

Added: trunk/cgi-bin/LJ/SiteScheme/Lynx.pm
===================================================================
--- trunk/cgi-bin/LJ/SiteScheme/Lynx.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/SiteScheme/Lynx.pm	2011-09-07 07:58:39 UTC (rev 19980)
@@ -0,0 +1,35 @@
+package LJ::SiteScheme::Lynx;
+use strict;
+use warnings;
+
+use base qw( LJ::SiteScheme );
+
+sub code {'lynx'}
+
+sub need_res {
+    LJ::need_res(qw( stc/lj_base-app.css stc/lynx/layout.css ));
+}
+
+sub template_params {
+    my ( $class, $args ) = @_;
+
+    my $remote = LJ::get_remote();
+
+    my ( $parentcrumb_title, $parentcrumb_link ) = ( '', '' );
+    if ( LJ::get_active_crumb() ne '' ) {
+        my $parentcrumb = LJ::get_parent_crumb();
+        ( $parentcrumb_title, $parentcrumb_link ) = @$parentcrumb;
+    }
+
+    my $body_class = 'scheme-lynx ' . LJ::get_body_class_for_service_pages();
+
+    return {
+        %{ $class->common_template_params($args) },
+
+        'parentcrumb_title' => $parentcrumb_title,
+        'parentcrumb_link'  => $parentcrumb_link,
+        'body_class'        => $body_class,
+    };
+}
+
+1;

Added: trunk/cgi-bin/LJ/SiteScheme.pm
===================================================================
--- trunk/cgi-bin/LJ/SiteScheme.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/SiteScheme.pm	2011-09-07 07:58:39 UTC (rev 19980)
@@ -0,0 +1,433 @@
+package LJ::SiteScheme;
+use strict;
+use warnings;
+
+use LJ::Lang qw( ml );
+
+my %CODE_TO_CLASS_MAP;
+
+### PARENT CLASS FUNCTIONS ###
+sub render_page {
+    my ( $class, $args ) = @_;
+
+    my $handler;
+
+    if ( $class eq __PACKAGE__ ) {
+        $handler = $class->find_handler;
+    } else {
+        $handler = $class;
+    }
+
+    $handler->need_res;
+
+    my $filename = "$ENV{'LJHOME'}/templates/SiteScheme/"
+        . $handler->template_filename . '.tmpl';
+
+    # cast all keys to lowercase because uppercase everywhere is creepy
+    my $args_normalized = {};
+    foreach my $k ( keys %$args ) {
+        $args_normalized->{ lc $k } = $args->{$k};
+    }
+
+    my $params = $handler->template_params($args_normalized);
+
+    my $template = LJ::HTML::Template->new( { 'use_expr' => 1 },
+        'filename' => $filename, );
+
+    $template->param(%$params);
+
+    return $template->output;
+}
+
+sub find_handler {
+    my ($class) = @_;
+
+    my @candidate_codes = (
+        LJ::Request->notes('bml_use_scheme'),
+        LJ::run_hook('force_scheme'),
+        LJ::Request->get_param('usescheme'),
+        LJ::Request->cookie('BMLschemepref'),
+        LJ::run_hook('default_scheme'),
+        'lynx',
+    );
+
+    foreach my $code (@candidate_codes) {
+        next unless defined $code;
+
+        my $handler = $class->handler_from_code($code);
+        next unless defined $handler;
+
+        return $handler;
+    }
+
+    # this shouldn never happen because we always have lynx
+    die 'no scheme found';
+}
+
+sub handler_from_code {
+    my ( $class, $code ) = @_;
+    return $CODE_TO_CLASS_MAP{$code};
+}
+
+### PARENT CLASS UTILITY FUNCTIONS ###
+
+sub template_param_breadcrumbs {
+    my ($class) = @_;
+
+    my @crumbs = LJ::get_crumb_path();
+    return [] unless @crumbs;
+
+    my @ret;
+    my $count = 0;
+    foreach my $crumb (@crumbs) {
+        my ( $name, $link, $parent, $type ) = @$crumb;
+
+        # put crumbs together
+        next unless $type;    # no blank crumbs
+        if ( $type eq 'dynamic' ) {
+            unshift @ret, { 'is_dynamic' => 1, 'name' => $name };
+        } else {
+            unshift @ret, { 'name' => ml("crumb.$type"), 'link' => $link };
+        }
+    }
+
+    return \@ret;
+}
+
+sub show_mobile_link {
+    return 1 if LJ::is_enabled('view_mobile_link_always');
+    return 1 if Apache::WURFL->is_mobile;
+    return 0;
+}
+
+sub common_template_params {
+    my ( $class, $args ) = @_;
+
+    my $remote = LJ::get_remote();
+    my $uri    = LJ::Request->uri;
+
+    my $remote_username = '';
+    if ($remote) {
+        $remote_username = $remote->username;
+    }
+
+    my $favicon = '';
+    if ( my $journal = LJ::get_active_journal() ) {
+        if ( $journal->is_personal ) {
+            $favicon = $journal->userhead;
+            $favicon = $LJ::IMGPREFIX . "/" . $favicon
+                unless $favicon =~ m{^http://};
+        }
+    }
+
+    my $additional_head_content = '';
+    LJ::run_hooks( 'head_content', \$additional_head_content );
+
+    my $error_list = '';
+    if ( my @errors = @BMLCodeBlock::errors ) {
+        $error_list = LJ::error_list(@errors);
+    }
+
+    my $warning_list = '';
+    if ( my @warnings = @BMLCodeBlock::warnings ) {
+        $warning_list = LJ::warning_list(@warnings);
+    }
+
+    my $chalresp_js = '';
+    if (   !LJ::get_remote()
+        && !$LJ::IS_SSL
+        && !$LJ::USE_SSL_LOGIN
+        && !$LJ::REQ_HEAD_HAS{'chalresp_js'}++ )
+    {
+        $chalresp_js = $LJ::COMMON_CODE{'chalresp_js'};
+    }
+
+    my $after_bml_title = LJ::run_hook('insert_after_bml_title') || '';
+
+    my $show_mobile_link = $class->show_mobile_link;
+    my $ml_mobile_link   = '';
+    if ($show_mobile_link) {
+        my $uri = '';
+
+        $uri .= $LJ::IS_SSL ? 'http://' : 'https://';
+        $uri .= LJ::Request->hostname;
+        $uri .= LJ::Request->uri;
+
+        if ( my $args = LJ::Request->args ) {
+            $uri .= '?' . $args;
+        }
+
+        my $mobile_uri =
+            "http://m.$LJ::DOMAIN/redirect?from=" . LJ::eurl($uri);
+
+        $ml_mobile_link =
+            ml( 'link.mobile', { 'href' => "href='$mobile_uri'" }, );
+    }
+
+    my $initial_body_html = LJ::initial_body_html();
+
+    my $site_messages_html = '';
+    if ( LJ::Widget::SiteMessages->should_render ) {
+        $site_messages_html = LJ::Widget::SiteMessages->render;
+    }
+
+    my @navbar = LJ::Nav->navbar($remote);
+
+    # apparently our HTML::Template doesn't support __index__,
+    # let's provide one ourselves; lanzelot requires this for
+    # drop-downs to work
+    $navbar[$_]->{'idx'} = $_ foreach ( 0 .. $#navbar );
+
+    my $expresslane_html_comment =
+        LJ::LJcom::expresslane_html_comment($remote);
+
+    my $remote_logged_in      = $remote ? 1 : 0;
+    my $remote_personal       = 0;
+    my $remote_identity       = 0;
+    my $remote_paid           = 0;
+    my $remote_sees_ads       = 0;
+    my $logout_link           = '';
+    my $remote_sessid         = 0;
+    my $remote_userpic_url    = '';
+    my $remote_ljuser_display = '';
+    my $remote_display_name   = '';
+    my $remote_profile_url    = '';
+    my $remote_recent_url     = '';
+    my $remote_friends_url    = '';
+    my $remote_can_use_esn    = 0;
+    my $remote_unread_count   = 0;
+    my $remote_wallet_link    = 0;
+
+    if ($remote) {
+        my $username = $remote->username;
+
+        if ( my $session = $remote->session ) {
+            $remote_sessid = $session->id;
+            $logout_link =
+                "$LJ::SITEROOT/logout.bml?user=$username&sessid=$remote_sessid";
+        } else {
+            $logout_link = "$LJ::SITEROOT/logout.bml?user=$username";
+        }
+
+        if ( my $upi = $remote->userpic ) {
+            $remote_userpic_url = $upi->url;
+        }
+
+        $remote_personal       = $remote->is_personal;
+        $remote_identity       = $remote->is_identity;
+        $remote_paid           = $remote->get_cap('paid');
+        $remote_sees_ads       = $remote->get_cap('ads');
+        $remote_ljuser_display = $remote->ljuser_display;
+        $remote_display_name   = $remote->display_name;
+        $remote_profile_url    = $remote->profile_url;
+        $remote_recent_url     = $remote->journal_base . '/';
+        $remote_friends_url    = $remote->journal_base . '/friends/';
+        $remote_can_use_esn    = $remote->can_use_esn;
+        $remote_unread_count   = $remote->notification_inbox->unread_count;
+        $remote_wallet_link    = LJ::Pay::Wallet->get_wallet_link($remote);
+    }
+
+    my $need_loginform = 0;
+
+    my $loginform_returnto          = '';
+    my $loginform_root              = '';
+    my $loginform_challenge         = '';
+    my $loginform_need_extra_fields = 0;
+    my $loginform_onclick           = '';
+
+    unless ( $remote || $uri eq '/login.bml' || $uri eq '/logout.bml' ) {
+        $need_loginform = 1;
+    }
+
+    # lanzelot doesn't respect need_loginform; i. e. it renders it on
+    # login.bml and logout.bml as well
+    unless ($remote) {
+        $loginform_returnto = LJ::Request->get_param('returnto') || '';
+
+        if ($LJ::USE_SSL_LOGIN) {
+            $loginform_root = $LJ::SSLROOT;
+        } else {
+            $loginform_root              = $LJ::SITEROOT;
+            $loginform_challenge         = LJ::challenge_generate(300);
+            $loginform_need_extra_fields = 1;
+            $loginform_onclick           = "onclick='return sendForm()'";
+        }
+    }
+
+    my $dev_banner = '';
+    if ($LJ::IS_DEV_SERVER) {
+        $dev_banner = $LJ::DEV_BANNER;
+    }
+
+    my $pagestats_obj  = LJ::pagestats_obj();
+    my $pagestats_html = $pagestats_obj->render;
+
+    my $before_body_close = '';
+    if ( LJ::get_active_journal() ) {
+        LJ::run_hooks( 'insert_html_before_journalctx_body_close',
+            \$before_body_close, );
+    }
+
+    my $final_body_html = LJ::final_body_html();
+
+    # ad stuff
+    my ( $ad_beforecrumbs, $ad_aftertitle, $ad_bottom, $ad_beforetitle ) =
+        ( '', '', '', '' );
+
+    unless ($LJ::IS_SSL) {
+        $ad_beforecrumbs =
+            LJ::get_ads( { 'location' => 'look.top.beforecrumbs' } );
+
+        $ad_aftertitle =
+            LJ::get_ads( { 'location' => 'look.top.aftertitle' } );
+
+        $ad_bottom = LJ::get_ads( { 'location' => 'look.bottom' } );
+
+        $ad_beforetitle =
+            LJ::get_ads( { 'location' => 'look.top.beforetitle' } );
+    }
+
+    # footer stuff
+    my $uri_tos = LJ::run_hook("get_tos_uri")
+        || "$LJ::SITEROOT/legal/tos.bml";
+
+    my $uri_privacy = LJ::run_hook("get_privacy_uri")
+        || "$LJ::SITEROOT/legal/privacy.bml";
+
+    my $uri_advertising = LJ::run_hook("get_advertising_url") || "#";
+
+    my $uri_policy = LJ::run_hook('get_policy_uri')
+        || "$LJ::SITEROOT/abuse/policy.bml";
+
+    my $uri_volunteer = $LJ::HELPURL{'how_to_help'};
+
+    my $uri_developers = do {
+        my $lj_dev = LJ::load_user('lj_dev');
+        $lj_dev ? $lj_dev->url : '';
+    };
+
+    my $uri_merchandise = LJ::run_hook('get_merchandise_link')
+        || 'https://www.zazzle.com/livejournal*';
+
+    my $ml_ljlabs_header = ml(
+        'horizon.footer.ljlabs.header',
+        { 'sitenameabbrev' => $LJ::SITENAMEABBREV },
+    );
+
+    my $ml_ljlabs_aqua =
+        ml( 'horizon.footer.ljlabs.aqua',
+        { 'sitenameabbrev' => $LJ::SITENAMEABBREV },
+        );
+
+    my $ml_ljlabs_dashboard = ml(
+        'horizon.footer.ljlabs.dashboard',
+        { 'sitenameabbrev' => $LJ::SITENAMEABBREV },
+    );
+
+    my $version_html        = LJ::run_hook('current_version_html');
+    my $ml_copyright_header = ml(
+        'horizon.footer.copyright.header_current',
+        { 'current_year' => $LJ::CURRENT_YEAR },
+    );
+
+    return {
+        'pretitle'           => $args->{'pretitle'},
+        'title'              => $args->{'title'},
+        'windowtitle'        => $args->{'windowtitle'} || $args->{'title'},
+        'meta'               => $args->{'meta'},
+        'head'               => $args->{'head'},
+        'bodyopts'           => $args->{'bodyopts'},
+        'body'               => $args->{'body'},
+        'page_is_ssl'        => $LJ::IS_SSL ? 1 : 0,
+        'error_list'         => $error_list,
+        'warning_list'       => $warning_list,
+        'breadcrumbs'        => $class->template_param_breadcrumbs,
+        'chalresp_js'        => $chalresp_js,
+        'after_bml_title'    => $after_bml_title,
+        'show_mobile_link'   => $show_mobile_link,
+        'ml_mobile_link'     => $ml_mobile_link,
+        'initial_body_html'  => $initial_body_html,
+        'site_messages_html' => $site_messages_html,
+        'navbar'             => \@navbar,
+        'navbar_max_idx'     => $#navbar,
+        'server_signature'   => $LJ::SERVER_SIGNATURE_BODY,
+        'dev_banner'         => $dev_banner,
+        'pagestats_html'     => $pagestats_html,
+        'before_body_close'  => $before_body_close,
+        'final_body_html'    => $final_body_html,
+
+        'remote_logged_in'      => $remote_logged_in,
+        'remote_personal'       => $remote_personal,
+        'remote_identity'       => $remote_identity,
+        'remote_paid'           => $remote_paid,
+        'remote_sees_ads'       => $remote_sees_ads,
+        'remote_username'       => $remote_username,
+        'remote_sessid'         => $remote_sessid,
+        'logout_link'           => $logout_link,
+        'remote_userpic_url'    => $remote_userpic_url,
+        'remote_ljuser_display' => $remote_ljuser_display,
+        'remote_display_name'   => $remote_display_name,
+        'remote_profile_url'    => $remote_profile_url,
+        'remote_recent_url'     => $remote_recent_url,
+        'remote_friends_url'    => $remote_friends_url,
+        'remote_can_use_esn'    => $remote_can_use_esn,
+        'remote_unread_count'   => $remote_unread_count,
+        'remote_wallet_link'    => $remote_wallet_link,
+
+        'need_loginform'              => $need_loginform,
+        'loginform_returnto'          => $loginform_returnto,
+        'loginform_root'              => $loginform_root,
+        'loginform_challenge'         => $loginform_challenge,
+        'loginform_need_extra_fields' => $loginform_need_extra_fields,
+        'loginform_onclick'           => $loginform_onclick,
+
+        'additional_head_content'  => $additional_head_content,
+        'expresslane_html_comment' => $expresslane_html_comment,
+        'server_signature_title'   => $LJ::SERVER_SIGNATURE_TITLE || '',
+
+        'ad_beforecrumbs' => $ad_beforecrumbs,
+        'ad_aftertitle'   => $ad_aftertitle,
+        'ad_bottom'       => $ad_bottom,
+        'ad_beforetitle'  => $ad_beforetitle,
+
+        'uri_tos'             => $uri_tos,
+        'uri_privacy'         => $uri_privacy,
+        'uri_advertising'     => $uri_advertising,
+        'uri_policy'          => $uri_policy,
+        'uri_volunteer'       => $uri_volunteer,
+        'uri_developers'      => $uri_developers,
+        'uri_merchandise'     => $uri_merchandise,
+        'ml_ljlabs_header'    => $ml_ljlabs_header,
+        'ml_ljlabs_aqua'      => $ml_ljlabs_aqua,
+        'ml_ljlabs_dashboard' => $ml_ljlabs_dashboard,
+        'version_html'        => $version_html,
+        'ml_copyright_header' => $ml_copyright_header,
+    };
+}
+
+### OVERRIDABLE FUNCTIONS ###
+
+sub template_filename {
+    my ($class) = @_;
+    return $class->code;
+}
+
+sub code            { die 'abstract method'; }
+sub need_res        { die 'abstract method'; }
+sub template_params { die 'abstract method'; }
+
+BEGIN {
+    require LJ::Config;
+    LJ::Config->load;
+
+    foreach my $class (@LJ::SUPPORTED_SCHEMES_LIST) {
+        my $filename = $class;
+        $filename =~ s{::}{/}g;
+        $filename .= '.pm';
+
+        require $filename;
+        $CODE_TO_CLASS_MAP{ $class->code } = $class;
+    }
+}
+
+1;

Modified: trunk/cgi-bin/bml/scheme/global.look
===================================================================
--- trunk/cgi-bin/bml/scheme/global.look	2011-09-07 07:38:44 UTC (rev 19979)
+++ trunk/cgi-bin/bml/scheme/global.look	2011-09-07 07:58:39 UTC (rev 19980)
@@ -24,173 +24,6 @@
 
 REQUIREPOST=><?_ml bml.requirepost _ml?>
 
-FAVICON<=
-<?_code
-    my $ie_userhead = '<link rel="shortcut icon" type="image/x-icon" href="'.$LJ::IMGPREFIX.'/userinfo.ico">';
-    my $u = LJ::get_active_journal();
-    return '' unless $u && $u->is_person;
-    my ($userhead) = $u->userhead;
-    $userhead = $LJ::IMGPREFIX . "/" . $userhead 
-        unless $userhead =~ m|^http://|;
-    return "$ie_userhead\n    " . '<link rel="icon" type="image/gif" href="'.$userhead.'">';
-_code?>
-<=FAVICON
-
-LOAD_PAGE_INFO<=
-<?_code
-#line 3
- @sidebar = ({ 'name' => 'Home',
-	       'uri' => '/',
-	       'match' => "^/(index\\.bml)?(\\?.*)?\$",
-	       'children' => [
-			      { 'name' => 'Create Journal',
-				'uri' => '/create.bml', },
-			      { 'name' => 'Update',
-				'uri' => '/update.bml', 
-#				'children' => [
-#					       { 'name' => 'Full Update',
-#						 'uri' => '/update.bml?mode=full', }
-#					       ],
-			    },
-			      { 'name' => 'Download',
-				'uri' => '/download/', },
-			      ],
-	       },
-	     { 'name' => 'LiveJournal',
-	       'children' => [
-			      { 'name' => 'News',
-				'match' => '^/news\\.bml\$',
-				'uri' => '/news.bml', },
-			      { 'name' => 'Paid Accounts',
-				'uri' => '/paidaccounts/', 
-                                'recursematch' => '^/paidaccounts/',
-				'children' => [ 
-						{ 'name' => 'Is this safe?',
-						  'uri' => '/paidaccounts/whysafe.bml', },
-						{ 'name' => 'Progress',
-						  'uri' => '/paidaccounts/progress.bml', },
-						],
-				},
-#			      { 'name' => 'To-Do list',
-#				'uri' => '/todo.bml', },
-			      { 'name' => 'Contributors',
-				'uri' => '/contributors.bml', },
-			      ],
-	       },
-	     { 'name' => 'Customize',
-	       'children' => [
-			      { 'name' => 'Customize Journal',
-				'uri' => '/customize/', },
-			      { 'name' => 'Create Style',
-				'uri' => '/createstyle.bml', },
-			      { 'name' => 'Edit Style',
-				'uri' => '/editstyle.bml', },
-			      ],
-	   },
-	     { 'name' => 'Find Users',
-	       'children' => [
-       			      { 'name' => 'Random!',
-				'uri' => '/random.bml', },
-       			      { 'name' => 'By Region',
-				'uri' => '/directory.bml', },
-       			      { 'name' => 'By Interest',
-				'uri' => '/interests.bml', },
-                              { 'name' => 'Search',	
-				'uri' => '/directorysearch.bml', }  
-	              ], },
-	     { 'name' => 'Edit ...',
-	       'children' => [
-			      { 'name' => 'Personal Info &',
-				'uri' => '/manage/profile/', },
-			      { 'name' => 'Settings', cont => 1,
-				'uri' => '/manage/', },
-			      { 'name' => 'Your Friends',
-				'uri' => '/editfriends.bml', },
-			      { 'name' => 'Old Entries',
-				'uri' => '/editjournal.bml', },
-			      { 'name' => 'Your Pictures',
-				'uri' => '/editpics.bml', },
-			      { 'name' => 'Your Password',
-				'uri' => '/changepassword.bml', },
-			      ],
-	   },
-	     { 'name' => 'Developer Area',
-	       'uri' => '/developer/',
-	       'match' => "^/developer/\$",
-	       'recursematch' => "^/developer/",
-	       'children' => [
-			      { 'name' => 'Style System',
-				'uri' => '/developer/styles.bml', 
-				'children' => [
-					       { 'name' => 'View Types',
-						 'uri' => '/developer/views.bml', },
-					       { 'name' => 'Variable List',
-						 'uri' => '/developer/varlist.bml', },
-					       ],
-				},
-			      { 'name' => 'Embedding',
-				'uri' => '/developer/embedding.bml', },
-			      { 'name' => 'Protocol',
-				'uri' => '/developer/protocol.bml', 
-				'children' => [
-					       { 'name' => 'Mode List',
-						 'uri' => '/developer/modelist.bml', }
-					       ],
-			    },
-			      ],
-	   },
-	     { 'name' => 'Need Help?',
-	       'children' => [
-			      { 'name' => 'Lost Password?',
-				'uri' => '/lostinfo.bml', },
-			      { 'name' => 'Freq. Asked',
-				'uri' => '/support/faq.bml', },
-			      { 'name' => 'Questions',
-				'uri' => '/support/faq.bml', cont => 1, },
-			      { 'name' => 'Support Area',
-				'uri' => '/support/', },
-			      ],
-	   },
- );
- 
- my $remote = LJ::get_remote();
- my $remuser = $remote ? $remote->{'user'} : "";
- my $uri = BML::get_uri();        
- if ($remuser ne "" && $uri ne "/logout.bml") 
- {
-     my $subdomain = $remuser;
-     $subdomain =~ s/_/-/g;
-     unshift @sidebar, { 'name' => "Hello, $remuser!",
-			 'children' => [
-					{ 'name' => 'Your Journal', 
-					  'children' => [
-							 { 'name' => 'Recent',
-							   'uri' => "/users/$remuser/", },
-							 { 'name' => 'Calendar',
-							   'uri' => "/users/$remuser/calendar", },
-							 { 'name' => 'Friends',
-							   'uri' => "/users/$remuser/friends",
-							   'extra' => "/friendsfilter.bml",
-						       },
-							 ],
-					  },
-					{ 'name' => 'User Info',
-					  'uri' => "/userinfo.bml?user=$remuser", },
-					{ 'name' => 'Memories',
-					  'uri' => "/memories.bml?user=$remuser", },
-					{ 'name' => 'Logout',
-					  'uri' => '/logout.bml', },
-					]
-					};
- } elsif ($uri ne "/login.bml") {
-     unshift @sidebar, { 'name' => "Log In",
-			 'uri' => '/login.bml', }
- }
-
-return "";
-_code?>
-<=LOAD_PAGE_INFO
-
 AL=>{P}<i><a href="%%data1%%">%%data2%%</a></i> <img src="/img/external_link.gif" width='16' height='11' align='absmiddle' />
 AWAYLINK=>{P}<i><a href="%%data1%%">%%data2%%</a></i> <img src="/img/external_link.gif" width='16' height='11' align='absmiddle' />
 
@@ -274,44 +107,11 @@
 <=CHOICES
 
 PAGE<=
-{Fp}<html>
-<head><title>%%title%%</title>
-<?_code LJ::res_includes() _code?>
-<link rel="stylesheet" type="text/css" href="<?statprefix?>/lj_base-app.css" />
-%%head%%
-</head>
-<body %%bodyopts%%>
+{Fp}
 <?_code
-    return @errors && scalar @errors ? LJ::error_list(@errors) : '';
+    my ( $scratch, $elhash ) = @_;
+    return LJ::SiteScheme->render_page($elhash);
 _code?>
-%%body%%
-</body>
-</html>
 <=PAGE
 
-BREADCRUMBS<=
-{Fp}<?_code
-    # where are we
-    my @crumbs = LJ::get_crumb_path();
-    return unless @crumbs;
-    my @ret;
-    my $count = 0;
-    foreach my $crumb (@crumbs) {
-        # put crumbs together
-        next unless $crumb->[3]; # no blank crumbs
-        if ($crumb->[3] eq 'dynamic') {
-            # dynamic
-            unshift @ret, "<b>$crumb->[0]</b>";
-            $count++;
-        } else {
-            # non-dynamic
-            unshift @ret, $count++ == 0 ?
-                "<b>$ML{'crumb.'.$crumb->[3]}</b>" :
-                $crumb->[1] ne '' ?
-                    "<a href=\"$crumb->[1]\">$ML{'crumb.'.$crumb->[3]}</a>" :
-                    "$ML{'crumb.'.$crumb->[3]}";
-        }
-    }
-    return "<div id='ljbreadcrumbs'>" . join(" : ", @ret) . "</div>";
-_code?>
-<=BREADCRUMBS
+

Modified: trunk/cgi-bin/bml/scheme/lynx.look
===================================================================
--- trunk/cgi-bin/bml/scheme/lynx.look	2011-09-07 07:38:44 UTC (rev 19979)
+++ trunk/cgi-bin/bml/scheme/lynx.look	2011-09-07 07:58:39 UTC (rev 19980)
@@ -10,88 +10,3 @@
 loginboxstyle=>{S}
 commloginboxstyle=>{S}
 
-page<=
-{Fps}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />
-<link rel="home" title="<?_ml lynx.nav.home _ml?>" href="<?siteroot?>/" />
-<link rel="contents" title="<?_ml lynx.nav.sitemap _ml?>" href="<?siteroot?>/site/" />
-<link rel="help" title="<?_ml lynx.nav.help _ml?>" href="<?siteroot?>/support/" />
-<?_code
-    use strict;
-    LJ::need_res("stc/lj_base-app.css", "stc/lynx/layout.css");
-
-    my $crumb_up;
-    if (LJ::get_active_crumb() ne '') {
-        my $parentcrumb = LJ::get_parent_crumb();
-        $crumb_up = "<link rel='up' title='$parentcrumb->[0]' href='$parentcrumb->[1]' />";
-    }
-    return $crumb_up;
-_code?>
-<?favicon?>
-<style>
-    #Comments q { padding-left: 2.5em; font-style: italic; }
-</style>
-<title><?_code {
-    my $elhash = $_[1];
-    return $elhash->{'WINDOWTITLE'} || $elhash->{'TITLE'};
-} _code?></title>
-<?_code return LJ::run_hook("insert_after_bml_title"); _code?>
-<?_code LJ::res_includes() _code?>
-%%HEAD%%
-    <?_code
-        my $head = '';
-        LJ::run_hooks('head_content', \$head);
-        return $head;
-    _code?>
-
-</head>
-
-<?_code {
-    my $class = LJ::get_body_class_for_service_pages();
-    return "<body class='scheme-lynx $class' %%bodyopts%%>";
-} _code?>
-<?_code LJ::initial_body_html(); _code?>
-
-<?_code return (LJ::Widget::SiteMessages->should_render) ? LJ::Widget::SiteMessages->render : ''; _code?>
-%%BODY%%
-
-<hr style="clear:both;" />
-
-<p>[ <a href='<?siteroot?>/'><?_ml lynx.nav.home _ml?></a> | <?_code
-   my $remote = LJ::get_remote();
-   return if !$remote || $remote->is_identity;
-   return qq{<a href='<?siteroot?>/update.bml'>$ML{'lynx.nav.update'}</a> | };
-_code?><?_code
-   use strict;
-   my $remote = LJ::get_remote();
-   return unless $remote;
-
-   my $ret;
-   my $baseurl = $remote->journal_base();
-   unless ($remote->is_identity) {
-       $ret .= "<a href='$baseurl/'>$ML{'lynx.nav.recent'}</a> | ";
-   }
-   $ret .= "<a href='$baseurl/friends/'>$ML{'lynx.nav.friends'}</a> | ";
-   return $ret;
-_code?><a href='<?siteroot?>/login.bml'><?_ml lynx.nav.login _ml?></a>/<a href='<?siteroot?>/logout.bml'><?_ml lynx.nav.logout _ml?></a> | <a href='<?siteroot?>/site/search.bml'><?_ml lynx.nav.search _ml?></a> | <a href='<?siteroot?>/manage/settings/index2.bml?cat=account '><?_ml lynx.nav.siteopts _ml?></a> | <a href='<?siteroot?>/site/'><?_ml lynx.nav.sitemap _ml?></a> ]</p>
-<?breadcrumbs?>
-<?_code
-{
-    my $pagestats_obj = LJ::pagestats_obj();
-    $pagestats_obj->render;
-}
-_code?>
-
-<?_code
-{
-    my $before_body_close = "";
-    LJ::run_hooks("insert_html_before_journalctx_body_close", \$before_body_close) if LJ::get_active_journal();
-    return $before_body_close;
-}
-_code?>
-<?_code LJ::final_body_html() _code?>
-</body>
-</html>
-<=page

Modified: trunk/cgi-bin/lj-bml-blocks.pl
===================================================================
--- trunk/cgi-bin/lj-bml-blocks.pl	2011-09-07 07:38:44 UTC (rev 19979)
+++ trunk/cgi-bin/lj-bml-blocks.pl	2011-09-07 07:58:39 UTC (rev 19980)
@@ -6,18 +6,25 @@
 LJ::Config->load;
 
 BML::register_block("DOMAIN", "S", $LJ::DOMAIN);
-BML::register_block("IMGPREFIX", "S", $LJ::IMGPREFIX);
-BML::register_block("SSLIMGPREFIX", "S", $LJ::SSLIMGPREFIX);
-BML::register_block("STATPREFIX", "S", $LJ::STATPREFIX);
-BML::register_block("SSLSTATPREFIX", "S", $LJ::SSLSTATPREFIX);
+
 BML::register_block("SITEROOT", "S", $LJ::SITEROOT);
 BML::register_block("SITENAME", "S", $LJ::SITENAME);
 BML::register_block("ADMIN_EMAIL", "S", $LJ::ADMIN_EMAIL);
 BML::register_block("SUPPORT_EMAIL", "S", $LJ::SUPPORT_EMAIL);
 BML::register_block("CHALRESPJS", "", $LJ::COMMON_CODE{'chalresp_js'});
-BML::register_block("JSPREFIX", "S", $LJ::JSPREFIX);
-BML::register_block("SSLJSPREFIX", "S", $LJ::SSLJSPREFIX);
 
+BML::register_block("IMGPREFIX", "S", sub {
+    return $LJ::IS_SSL ? $LJ::SSLIMGPREFIX : $LJ::IMGPREFIX;
+});
+
+BML::register_block("STATPREFIX", "S", sub {
+    return $LJ::IS_SSL ? $LJ::SSLSTATPREFIX : $LJ::STATPREFIX;
+});
+
+BML::register_block("JSPREFIX", "S", sub {
+    return $LJ::IS_SSL ? $LJ::SSLJSPREFIX : $LJ::JSPREFIX;
+});
+
 # dynamic blocks to implement calling our ljuser function to generate HTML
 #    <?ljuser banana ljuser?>
 #    <?ljcomm banana ljcomm?>

Modified: trunk/cgi-bin/lj-bml-init.pl
===================================================================
--- trunk/cgi-bin/lj-bml-init.pl	2011-09-07 07:38:44 UTC (rev 19979)
+++ trunk/cgi-bin/lj-bml-init.pl	2011-09-07 07:58:39 UTC (rev 19980)
@@ -73,7 +73,10 @@
 # extra perl to insert at the beginning of a code block
 # compilation
 BML::register_hook("codeblock_init_perl", sub {
-    return q{*errors = *BMLCodeBlock::errors;};
+    return q{
+        *errors = *BMLCodeBlock::errors;
+        *warnings = *BMLCodeBlock::warnings;
+    };
 });
 
 # now apply any local behaviors which may be defined

Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2011-09-07 07:38:44 UTC (rev 19979)
+++ trunk/cgi-bin/weblib.pl	2011-09-07 07:58:39 UTC (rev 19980)
@@ -21,6 +21,7 @@
                       LJ::M::FriendsOf
                       );
 use LJ::ControlStrip;
+use LJ::SiteScheme;
 use Apache::WURFL;
 
 # <LJFUNC>

Added: trunk/templates/SiteScheme/include/breadcrumbs.tmpl
===================================================================
--- trunk/templates/SiteScheme/include/breadcrumbs.tmpl	                        (rev 0)
+++ trunk/templates/SiteScheme/include/breadcrumbs.tmpl	2011-09-07 07:58:39 UTC (rev 19980)
@@ -0,0 +1,21 @@
+<TMPL_IF breadcrumbs>
+    <div id='ljbreadcrumbs'>
+        <TMPL_LOOP breadcrumbs>
+            <TMPL_IF is_dynamic>
+                <b><TMPL_VAR name></b>
+            <TMPL_ELSE>
+                <TMPL_IF __last__>
+                    <b><TMPL_VAR name></b>
+                <TMPL_ELSE>
+                    <TMPL_IF link>
+                        <a href="<TMPL_VAR link>"><TMPL_VAR name></a>
+                    <TMPL_ELSE>
+                        <TMPL_VAR name>
+                    </TMPL_IF>
+                </TMPL_IF>
+            </TMPL_IF>
+
+            <TMPL_UNLESS __last__> : </TMPL_UNLESS>
+        </TMPL_LOOP>
+    </div>
+</TMPL_IF>

Added: trunk/templates/SiteScheme/lynx.tmpl
===================================================================
--- trunk/templates/SiteScheme/lynx.tmpl	                        (rev 0)
+++ trunk/templates/SiteScheme/lynx.tmpl	2011-09-07 07:58:39 UTC (rev 19980)
@@ -0,0 +1,69 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />
+<link rel="home" title="<TMPL_VAR expr="ml('lynx.nav.home')">" href="<TMPL_VAR lj_siteroot>/" />
+<link rel="contents" title="<TMPL_VAR expr="ml('lynx.nav.sitemap')">" href="<TMPL_VAR lj_siteroot>/site/" />
+<link rel="help" title="<TMPL_VAR expr="ml('lynx.nav.help')">" href="<TMPL_VAR lj_siteroot>/support/" />
+
+<TMPL_IF parentcrumb_link>
+    <link rel='up' title='<TMPL_VAR parentcrumb_title>' href='<TMPL_VAR parentcrumb_link>' />
+</TMPL_IF>
+
+<TMPL_IF favicon>
+    <link rel="shortcut icon" type="image/x-icon" href="<TMPL_VAR lj_imgprefix>/userinfo.ico">
+    <link rel="icon" type="image/gif" href="<TMPL_VAR favicon>">
+</TMPL_IF>
+
+<style>
+    #Comments q { padding-left: 2.5em; font-style: italic; }
+</style>
+
+<title><TMPL_VAR windowtitle></title>
+<TMPL_VAR after_bml_title>
+<TMPL_VAR lj_res_includes>
+<TMPL_VAR head>
+<TMPL_VAR additional_head_content>
+
+</head>
+
+<body class='<TMPL_VAR body_class>' <TMPL_VAR bodyopts> >
+<TMPL_VAR initial_body_html>
+
+<TMPL_VAR site_messages_html>
+<TMPL_VAR body>
+
+<hr style="clear:both;" />
+
+<p>
+    [
+
+    <a href='<TMPL_VAR lj_siteroot>/'><TMPL_VAR expr="ml('lynx.nav.home')"></a> |
+
+    <TMPL_IF remote_logged_in>
+        <TMPL_IF remote_personal>
+            <a href='<TMPL_VAR lj_siteroot>/update.bml'><TMPL_VAR expr="ml('lynx.nav.update')"></a> |
+            <a href='<TMPL_VAR remote_recent_url>'><TMPL_VAR expr="ml('lynx.nav.recent')"></a> |
+        </TMPL_IF>
+
+        <a href='<TMPL_VAR remote_friends_url>'><TMPL_VAR expr="ml('lynx.nav.friends')"></a> |
+    </TMPL_IF>
+
+    <a href='<TMPL_VAR lj_siteroot>/login.bml'><TMPL_VAR expr="ml('lynx.nav.login')"></a> /
+    <a href='<TMPL_VAR lj_siteroot>/logout.bml'><TMPL_VAR expr="ml('lynx.nav.logout')"></a> |
+
+    <a href='<TMPL_VAR lj_siteroot>/site/search.bml'><TMPL_VAR expr="ml('lynx.nav.search')"></a> |
+    <a href='<TMPL_VAR lj_siteroot>/manage/settings/?cat=account'><TMPL_VAR expr="ml('lynx.nav.siteopts')"></a> |
+    <a href='<TMPL_VAR lj_siteroot>/site/'><TMPL_VAR expr="ml('lynx.nav.sitemap')"></a>
+
+    ]
+</p>
+
+<TMPL_INCLUDE "templates/SiteScheme/include/breadcrumbs.tmpl">
+
+<TMPL_VAR pagestats_html>
+<TMPL_VAR before_body_close>
+<TMPL_VAR final_body_html>
+
+</body>
+</html>

Tags: andy, livejournal, look, pl, pm, tmpl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments