fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-03 07:17 am

[dw-free] convert directory frontend to TT

[commit: http://hg.dwscoalition.org/dw-free/rev/e3f09b49dde7]

http://bugs.dwscoalition.org/show_bug.cgi?id=3961

Remove three BML files: directorysearch.bml (search form), directory.bml
(search results page), community/search.bml (tweaked search form for comms).
Move to using a controller and a .tt file.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/Apache/LiveJournal.pm
  • cgi-bin/DW/Controller/Search/Directory.pm
  • cgi-bin/redirect.dat
  • htdocs/community/search.bml
  • htdocs/community/search.bml.text
  • htdocs/directory.bml
  • htdocs/directory.bml.text
  • htdocs/directorysearch.bml
  • htdocs/directorysearch.bml.text
  • views/directory/index.tt
  • views/directory/index.tt.text
  • views/directory/results.tt
  • views/directory/results.tt.text
  • views/directory/searchdots.tt
  • views/directory/searchdots.tt.text
--------------------------------------------------------------------------------
diff -r 6fc0cc50a979 -r e3f09b49dde7 cgi-bin/Apache/LiveJournal.pm
--- a/cgi-bin/Apache/LiveJournal.pm	Mon Oct 03 14:05:08 2011 +0800
+++ b/cgi-bin/Apache/LiveJournal.pm	Mon Oct 03 15:17:20 2011 +0800
@@ -898,6 +898,34 @@
         return $view if defined $view;
     }
 
+    # custom interface handler
+    if ($uri =~ m!^/interface/([\w\-]+)$!) {
+        my $inthandle = LJ::Hooks::run_hook("interface_handler", {
+            int         => $1,
+            r           => $r,
+            bml_handler => $bml_handler,
+        });
+        return $inthandle if defined $inthandle;
+    }
+
+    # see if there is a modular handler for this URI
+    my $ret = LJ::URI->handle( $uri, $r );
+    $ret = DW::Routing->call unless defined $ret;
+    return $ret if defined $ret;
+
+    # protocol support
+    if ($uri =~ m!^/(?:interface/(\w+))|cgi-bin/log\.cgi!) {
+        my $int = $1;
+        $r->handler("perl-script");
+        if ($int =~ /^xmlrpc|blogger|elsewhere_info$/) {
+            $RQ{'interface'} = $int;
+            $RQ{'is_ssl'} = $is_ssl;
+            $r->push_handlers(PerlResponseHandler => \&interface_content);
+            return OK;
+        }
+        return 404;
+    }
+
     # normal (non-domain) journal view
     if (
         $uri =~ m!
@@ -935,34 +963,6 @@
         return $view if defined $view;
     }
 
-    # custom interface handler
-    if ($uri =~ m!^/interface/([\w\-]+)$!) {
-        my $inthandle = LJ::Hooks::run_hook("interface_handler", {
-            int         => $1,
-            r           => $r,
-            bml_handler => $bml_handler,
-        });
-        return $inthandle if defined $inthandle;
-    }
-
-    # see if there is a modular handler for this URI
-    my $ret = LJ::URI->handle( $uri, $r );
-    $ret = DW::Routing->call unless defined $ret;
-    return $ret if defined $ret;
-
-    # protocol support
-    if ($uri =~ m!^/(?:interface/(\w+))|cgi-bin/log\.cgi!) {
-        my $int = $1;
-        $r->handler("perl-script");
-        if ($int =~ /^xmlrpc|blogger|elsewhere_info$/) {
-            $RQ{'interface'} = $int;
-            $RQ{'is_ssl'} = $is_ssl;
-            $r->push_handlers(PerlResponseHandler => \&interface_content);
-            return OK;
-        }
-        return 404;
-    }
-
     # customview (get an S1 journal by number)
     if ($uri =~ m!^/customview\.cgi!) {
         $r->handler("perl-script");
diff -r 6fc0cc50a979 -r e3f09b49dde7 cgi-bin/DW/Controller/Search/Directory.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Controller/Search/Directory.pm	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,151 @@
+#!/usr/bin/perl
+#
+# DW::Controller::Search::Directory
+#
+# Directory search, based on code from LiveJournal.
+#
+# Authors:
+#      Jen Griffin <kareila@livejournal.com>
+#
+# Copyright (c) 2011 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::Controller::Search::Directory;
+
+use strict;
+
+use DW::Routing;
+use DW::Template;
+use DW::Controller;
+
+use LJ::Directory::Search;  # also loads Results and Constraint
+use LJ::Widget;
+
+DW::Routing->register_string( '/directorysearch', \&directory_handler, app => 1 );
+DW::Routing->register_string( '/community/search', \&directory_handler, app => 1 );
+
+sub directory_handler {
+    my $r = DW::Request->get;
+    my $args = $r->get_args;
+
+    my ( $ok, $rv ) = controller();
+    return $rv unless $ok;
+
+    my $remote = $rv->{remote};
+    return error_ml( 'cprod.directory.text3.v1' )
+        unless $remote->can_use_directory;
+
+    # check for the /community/search path (same form)
+    if ( $r->uri =~ m:^/community/search: ) {
+        $rv->{comm_page} = 1;
+        if ( LJ::Hooks::are_hooks("cprod_redirect_user") ) {
+            return LJ::Hooks::run_hook( "cprod_redirect_user", $remote );
+        }
+    }
+
+    # see if we submitted the form (the directory.bml section)
+    if ( $args->{opt_pagesize} || $args->{s_loc} ) {
+
+        # if the search hasn't started, show the interstitial
+        unless ( $args->{start_search} ) {
+            # do a refresh to the page with the finished results.
+            $rv->{refurl} = LJ::ehtml( LJ::page_change_getargs( start_search => 1 ) );
+            $rv->{dots} = LJ::img( 'searchdots', '' );
+            return DW::Template->render_template( 'directory/searchdots.tt', $rv );
+        }
+
+        my $journaltype = $rv->{journaltype} = uc $args->{journaltype} || '';
+        $rv->{searchurl} = $journaltype eq 'C' ?
+                           "community/search" : "directorysearch";
+
+        $rv->{filter_linkbar} = sub {
+           # create the links to filter by journal type
+            my $filter_url = sub {
+                my $jt = $_[0] || '';
+                my %get = ( start_search => 1, journaltype => $jt, page => '' );
+                return LJ::ehtml( LJ::page_change_getargs( %get ) );
+            };
+            my $linkify = sub {
+                my ( $text, $filter ) = @_;
+                return $text if $journaltype eq $filter;
+                my $url = $filter_url->( $filter );
+                return "<a href='$url'>$text</a>";
+            };
+
+            my $strings = $_[0] or return '';
+            my @links;
+
+            push @links, $linkify->( $strings->{all}, '' );
+            push @links, $linkify->( $strings->{comm},  'C' );
+            push @links, $linkify->( $strings->{user},  'P' );
+            push @links, $linkify->( $strings->{ident}, 'I' );
+
+            return join "&nbsp;|&nbsp;", @links;
+        };
+
+        $rv->{ignore} = LJ::Hooks::run_hook( "interest_search_ignore",
+                                             query => $args->{int_like} );
+        unless ( $rv->{ignore} ) {
+            # manipulate form arguments
+            my %searchargs = ( page => delete $args->{page} || 1,
+                               page_size => $args->{opt_pagesize},
+                               format => $args->{opt_format} );
+
+            # country, state and city fields are generated by
+            # LJ::Widget::GeoSearchLocation widget, hence all
+            # corresponding <input>-tags have widget-specific
+            # prefixed 'name' attribute.
+            # calling post_fields to fix this
+            my $widget_params =
+                    LJ::Widget::GeoSearchLocation->post_fields( $args );
+
+            $args->{loc_cn} ||= $widget_params->{country};
+            $args->{loc_ci} ||= $widget_params->{city};
+            $args->{loc_st} ||= $widget_params->{statedrop}
+                            ||  $widget_params->{stateother};
+
+            # parse GET args into search constraints
+            my @constraints =
+                    LJ::Directory::Constraint->constraints_from_formargs( $args );
+
+            # do the actual search (synchronous)
+            my $dir = LJ::Directory::Search->new( %searchargs,
+                                                  constraints => \@constraints );
+            my LJ::Directory::Results $res = $dir->search;
+            $res = $dir->search while !$res;
+
+            if ( $res ) {
+                my $self_link = { self_link => sub {
+                        LJ::page_change_getargs( page => $_[0],
+                                                 start_search => '' );
+                } };
+
+                $rv->{paging_bar} =
+                    LJ::paging_bar( $searchargs{page}, $res->pages, $self_link );
+
+                my @users = $res->users;
+                $rv->{numusers} = scalar @users;
+                $rv->{results} = $res->render;
+
+            } else {
+                $rv->{search_err} = 1;
+            }
+        }
+
+        return DW::Template->render_template( 'directory/results.tt', $rv );
+    }
+
+    # show the search form
+    my $w = LJ::Widget::GeoSearchLocation->new;
+    $rv->{location_widget} =
+            $w->render( country => '', state => '', city => '' );
+
+    return DW::Template->render_template( 'directory/index.tt', $rv );
+}
+
+
+1;
diff -r 6fc0cc50a979 -r e3f09b49dde7 cgi-bin/redirect.dat
--- a/cgi-bin/redirect.dat	Mon Oct 03 14:05:08 2011 +0800
+++ b/cgi-bin/redirect.dat	Mon Oct 03 15:17:20 2011 +0800
@@ -50,3 +50,5 @@
 /settings/                          /manage/settings
 /settings/index                     /manage/settings
 /settings/index.bml                 /manage/settings
+/directory                          /directorysearch
+/directory.bml                      /directorysearch
diff -r 6fc0cc50a979 -r e3f09b49dde7 htdocs/community/search.bml
--- a/htdocs/community/search.bml	Mon Oct 03 14:05:08 2011 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-<?_c
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-_c?>
-<?_info
-localblocks<=
-
-crit<=
-{FpRs}<tr bgcolor='<?emcolor?>'>
-<td align='left' colspan='2'><b>%%name%%</b>
-</tr>
-<tr align='left'><td>&nbsp;</td><td>%%form%%</td></tr>
-<=crit
-
-bar<=
-{F}
-<tr bgcolor='<?emcolor?>'>
-<td>&nbsp;</td>
-<td><b>%%name%%</b>
-</tr>
-<tr><td>&nbsp;</td><td>%%form%%</td></tr>
-<=bar
-
-<=localblocks
-_info?>
-
-<?page
-title=><?_ml .title _ml?>
-body<=
-
-<?_code
-{
-    my $remote = LJ::get_remote() or return "<?needlogin?>";
-    if (LJ::Hooks::are_hooks("cprod_redirect_user")) {
-        return LJ::Hooks::run_hook("cprod_redirect_user", $remote);
-    }
-    return;
-}
-_code?>
-
-<?h1 <?_ml .label.searchcomm _ml?> h1?>
-<?p <?_ml .label.selecriteria _ml?> p?>
-
-<center>
-
-<form action="/directory">
-
-<table summary='' cellpadding='4' cellspacing='0' border='0'>
-
-<!--- location --->
-<?crit
-name=><?_ml .label.bylocation _ml?>
-code=>s_loc
-form<=
-
-<?_code
-{
-    my $w = LJ::Widget::GeoSearchLocation->new;
-    my $ret = '';
-    $ret .= "<style> .field_class {text-align: right;} </style>\n";
-    $ret .= $w->render(
-        country => '',
-        state => '',
-        city => '',
-    );
-    return $ret;
-}
-_code?>
-
-<=form
-crit?>
-
-<!---- update time ----->
-<?crit
-name=><?_ml .label.bytime _ml?>
-code=>s_ut
-form<=
-<?_ml .label.updated _ml?>
-<select name="ut_days">
-<option value="">-------</option>
-<option value="1"><?_ml .sel.day _ml?></option>
-<option value="7"><?_ml .sel.week _ml?></option>
-<option value="30"><?_ml .sel.month _ml?></option>
-</select>
-<=form
-crit?>
-
-<!---- interest ----->
-<?crit
-name=><?_ml .label.byinterest _ml?>
-code=>s_int
-form<=
-Community interest: <input name="int_like" size='30' />
-<=form
-crit?>
-
-<!---- has member ----->
-<?crit
-name=><?_ml .label.hasmember _ml?>
-code=>s_fr
-form<=
-Contains user <input name="user_is_member" size='15' maxlength='25' /> as a member.
-<=form
-crit?>
-
-<!---- output formatting ----->
-<?bar
-name=><?_ml .label.displayoptions _ml?>
-form<=
-
-<table summary=''>
-<tr>
-<td align='right'>
-<?_ml .label.outputformat _ml?>
-</td><td>
-<select name="opt_format">
-<option value="pics" selected='selected'>Picture</option>
-<option value="simple">Text only</option>
-</select>
-</td></tr>
-
-<tr>
-<td align='right'>
-<?_ml .label.records _ml?>
-</td><td>
-<select name="opt_pagesize">
-<option value="25">25</option>
-<option value="50">50</option>
-<option value="100" selected='selected'>100</option>
-<option value="200">200</option>
-</select>
-</td></tr>
-
-</table>
-<=form
-bar?>
-
-<!--- submit --->
-<input type='hidden' name='journaltype' value='C'>
-<tr bgcolor='<?emcolor?>'><td colspan='2' align='center'>
-  <input type='submit' value="<?_ml .button.search _ml?>" />
-  <input type='reset' value="<?_ml .button.clear _ml?>" />
-</td></tr>
-
-</table>
-</form>
-
-</center>
-
-<=body
-page?>
diff -r 6fc0cc50a979 -r e3f09b49dde7 htdocs/community/search.bml.text
--- a/htdocs/community/search.bml.text	Mon Oct 03 14:05:08 2011 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-;; -*- coding: utf-8 -*-
-.button.clear=Clear Form
-
-.button.search=Search
-
-.checkbox.onlywithpics=Only communities with pictures
-
-.label.byinterest=By Interest
-
-.label.bylocation=By Location
-
-.label.bytime=By Journal Update Time
-
-.label.city=City:
-
-.label.country=Country:
-
-.label.displayoptions=Display Options
-
-.label.hasmember=Has Member
-
-.label.othercriteria=Other Criteria
-
-.label.outputformat=Output Format:
-
-.label.records=Results per page:
-
-.label.searchcomm=Search Communities
-
-.label.selecriteria=You can use this page to search for communities on Dreamwidth. If you fill in more than one search box, the search will return only results that contain all your search words: for example, if you put in "Boston" and "beer", the only communities your search will show are those which have both words somewhere in their Profile.
-
-.label.sortmethod=Sorting Method:
-
-.label.stateprovince=State/Province:
-
-.label.updated=Updated in last 
-
-.sel.bypicture=By Picture
-
-.sel.communityname=Community Name
-
-.sel.commview=Community View
-
-.sel.day=day
-
-.sel.month=month
-
-.sel.simple=Simple
-
-.sel.updatetime=Update Time
-
-.sel.username=User Name
-
-.sel.week=week
-
-.title=Community Search
-
diff -r 6fc0cc50a979 -r e3f09b49dde7 htdocs/directory.bml
--- a/htdocs/directory.bml	Mon Oct 03 14:05:08 2011 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-<?_c
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-_c?>
-<?page
-body<=
-<?_code
-{
-    use strict;
-    use LJ::Directory::Search;
-    use LJ::Widget;
-    use vars qw(%GET %POST %FORM $title $headextra @errors @warnings);
-
-    $title = $ML{'.title'};
-
-    # redirect to directorysearch if we haven't submitted the form
-    return BML::redirect( "/directorysearch" )
-        unless $GET{opt_pagesize} || $GET{s_loc} || $GET{s_fro};
-
-    LJ::need_res(qw(
-                    stc/directory.css
-                    ));
-
-    LJ::set_active_crumb('advsearch');
-
-    my $remote = LJ::get_remote();
-    return "<?needlogin?>" unless $remote;
-
-    return LJ::CProd->inline($remote, inline => 'Directory') || BML::ml('cprod.directory.text3.v1')
-        unless $remote->can_use_directory;
-
-    my $ret = '';
-
-    if (! $GET{start_search}) {
-        # do a refresh to the page with the finished results.
-        # this will display some nice text to the user while they wait
-        # for their results.
-
-        my $refurl = LJ::ehtml( LJ::page_change_getargs( start_search => 1 ) );
-        $headextra = "<meta http-equiv='Refresh' content='1;URL=$refurl' id='refresher' />";
-
-        my $dots = LJ::img( 'searchdots', '' );
-        $ret .= qq {
-            <div id="SearchWaitText" style='text-align: center;'>
-               <b>$ML{'.search.title'}$dots</b>
-               <p>$ML{'.search.monkey'}</p>
-            </div>
-        };
-
-        return $ret;
-    }
-
-    # Do the actual search
-
-    my $url = "$LJ::SITEROOT/";
-    $url .= $GET{journaltype} && $GET{journaltype} eq "C" ? "community/search"
-                                                          : "directorysearch";
-    $ret .= qq {
-        <div id="NewSearch">
-            <a href="$url"><< $ML{'.new_search'}</a>
-        </div>
-    };
-
-    $ret .= qq {
-        <?h1 $ML{'.search_results'} h1?>
-    };
-
-    my $filter_url = LJ::ehtml( LJ::page_change_getargs( start_search => 1,
-                                                         journaltype => '',
-                                                         page => '' ) );
-
-    my $all_search = "$ML{'.new_all_search'}";
-    $all_search = "<a href='$filter_url'>$all_search</a>"
-        if uc( $GET{journaltype} ) =~ /^[CPI]$/;
-
-    my $community_search = "$ML{'.new_community_search'}";
-    $community_search = "<a href='$filter_url&journaltype=C'>$community_search</a>"
-        unless uc( $GET{journaltype} ) eq 'C';
-
-    my $user_search = "$ML{'.new_user_search'}";
-    $user_search = "<a href='$filter_url&journaltype=P'>$user_search</a>"
-        unless uc( $GET{journaltype} ) eq 'P';
-
-    my $identity_search = "$ML{ '.new_identity_search' }";
-    $identity_search = "<a href='$filter_url&journaltype=I'>$identity_search</a>"
-        unless uc( $GET{journaltype} ) eq 'I';
-
-    $ret .= qq {\n<div id="FilterSearch">$ML{'.new_search_show'}&nbsp;$all_search&nbsp;|&nbsp;};
-    $ret .= qq {$community_search&nbsp;|&nbsp;$user_search&nbsp;|&nbsp;$identity_search</div>\n};
-
-    if (LJ::Hooks::run_hook("interest_search_ignore", query => $GET{int_like})) {
-        $ret .= $ML{'.unable_find_users'};
-        return $ret;
-    }
-
-    my $page = delete $GET{page} || 1;
-    my $page_size = $GET{opt_pagesize};
-
-    # country, state and city fields are generated by LJ::Widget::GeoSearchLocation widget,
-    # hence all corresponding <input>-tags have widget-specific prefixed 'name' attribute
-    # calling post_fields to fix this
-    my $widget_params = LJ::Widget::GeoSearchLocation->post_fields(\%GET);
-    $GET{'loc_cn'} ||= $widget_params->{'country'};
-    $GET{'loc_st'} ||= $widget_params->{'statedrop'} || $widget_params->{'stateother'};
-    $GET{'loc_ci'} ||= $widget_params->{'city'};
-
-    # parse GET args into search constraints
-    my @constraints = LJ::Directory::Constraint->constraints_from_formargs(\%GET);
-
-    # do synchronous search
-    my $dir = LJ::Directory::Search->new(page_size => $page_size, page => $page,
-                                         format => $GET{opt_format}, constraints => \@constraints);
-    my LJ::Directory::Results $res = $dir->search;
-    $res = $dir->search while !$res;
-
-    unless ($res) {
-        $ret .= "<?errorbar $ML{'.errar.search_dir'} errorbar?>";
-        return $ret;
-    }
-
-    my $pagecount = $res->pages;
-    my @users     = $res->users;
-
-    unless (@users) {
-        $ret .= "<div class='warning-box'>$ML{'.no_results'}</div>";
-        return $ret;
-    }
-
-    my $querystring = join('&', map { LJ::eurl($_) . '=' . LJ::eurl($GET{$_}) } grep { $_ ne 'start_search' } keys %GET);
-
-    my $pagingbar = LJ::paging_bar($page, $pagecount, {
-        self_link => sub { BML::get_uri() . "?page=$_[0]&" . $querystring },
-    });
-
-    $ret .= $pagingbar;
-    $ret .= $res->render;
-
-    # if more than 20 results (or 4 rows), show paging bar again at bottom
-    $ret .= $pagingbar if @users > 20;
-
-    return $ret;
-}
-_code?>
-<=body
-title=><?_code return $title; _code?>
-head<=
-<?_code return $headextra; _code?>
-<=head
-<=body
-page?>
diff -r 6fc0cc50a979 -r e3f09b49dde7 htdocs/directory.bml.text
--- a/htdocs/directory.bml.text	Mon Oct 03 14:05:08 2011 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-;; -*- coding: utf-8 -*-
-.error.accounttype2<<
-Sorry, your account type doesn't permit usage of the
-directory, or you aren't currently <a [[aopts]]>logged in</a>.  If your account type permits
-directory usage, be sure that you are logged in and then try again.
-.
-
-.error.notloggedin=You must <a [[aopts]]>login</a> to use the directory.
-
-.error.search_dir=There was an error searching the directory. Please try again in a few minutes.
-
-.navcrap.matches=[[count]] matches
-
-.navcrap.xofy=Page [[curpage]] of [[totpages]] shown (records [[reca]]-[[recb]])
-
-.new_all_search=All
-
-.new_community_search=Communities Only
-
-.new_identity_search=OpenIDs Only
-
-.new_search=New search
-
-.new_search_show=Show:
-
-.new_user_search=Users Only
-
-.no_results=No Results Found!
-
-.open=Open
-
-.post=Post
-
-.search.monkey=Hundreds of trained monkeys are currently running about finding your search results.  Please stand by.
-
-.search.new=New Query
-
-.search.overflow=<b>Search results limited to [[count]] results.  Please refine your query.</b>
-
-.search.title=Searching
-
-.search_results=Search Results
-
-.title=Directory Search
-
-.unable_find_users=Sorry, we're unable to help you find users matching the interests you've provided.
-
-.update=Update:
-
-.user=User
diff -r 6fc0cc50a979 -r e3f09b49dde7 htdocs/directorysearch.bml
--- a/htdocs/directorysearch.bml	Mon Oct 03 14:05:08 2011 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-<?_c
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-_c?>
-<?_info
-localblocks<=
-crit<=
-{FpRs}<tr bgcolor='<?emcolor?>'>
-<td align='left' colspan='2'><b>%%name%%</b>
-</tr>
-<tr align='left'><td>&nbsp;</td><td>%%form%%</td></tr>
-<=crit
-bar<=
-{FpRs}<tr bgcolor='<?emcolor?>' align='left'>
-<td>&nbsp;</td>
-<td><b>%%name%%</b></td>
-</tr>
-<tr align='left'><td>&nbsp;</td><td>%%form%%</td></tr>
-<=bar
-<=localblocks
-_info?><?page
-title=><?_ml .title _ml?>
-body<=
-<?_code
-{
-    LJ::set_active_crumb('advsearch');
-    return "";
-}
-_code?>
-
-<?_code
-{
-    my $remote = LJ::get_remote();
-    return "<?needlogin?>" unless $remote;
-
-    return LJ::CProd->inline($remote, inline => 'Directory') || BML::ml('cprod.directory.text3.v1')
-        unless $remote->can_use_directory;
-
-    return "";
-}
-_code?>
-
-<?p 
-<?_code
-    my $ret = BML::ml('.use_this_dir2', { 'aopts' => "href='$LJ::SITEROOT/community/search'", sitename => $LJ::SITENAMESHORT });
-    return $ret;
-_code?>
- p?>
-
-<?hr?>
-
-<center>
-
-<form style='margin-top: 1.5em' action='/directory' method='get'>
-
-<table summary='' cellpadding='4' cellspacing='0' border='0'>
-
-<!--- location --->
-<?crit
-name=><?_ml .by_location _ml?>
-code=>s_loc
-form<=
-<?_code
-{
-    my $w = LJ::Widget::GeoSearchLocation->new;
-    my $ret = '';
-    $ret .= "<style> .field_class {text-align: right;} </style>\n";
-    $ret .= $w->render(
-        country => '',
-        state => '',
-        city => '',
-    );
-    return $ret;
-}
-_code?>
-
-<=form
-crit?>
-
-<!---- update time ----->
-<?crit
-name=><?_ml .recently_updated _ml?>
-code=>s_ut
-form<=
-<?_ml .updated_in_last _ml?> 
-<select name="ut_days">
-<option value="">-------</option>
-<option value="1"><?_ml .day _ml?></option>
-<option value="7"><?_ml .week _ml?></option>
-<option value="30"><?_ml .month _ml?></option>
-</select>
-<=form
-crit?>
-
-<!---- age ----->
-<?crit
-name=><?_ml .by_age _ml?>
-code=>s_age
-form<=
-<?_ml .between _ml?> 
-<input name="age_min" size='3' maxlength='3' /> <?_ml .and _ml?> 
-<input name="age_max" size='3' maxlength='3' /> <?_ml .years_old _ml?>
-<=form
-crit?>
-
-<?_c  DISABLED because of privacy policy.  add later when 'public gender' option
-<!---- gender ----->
-<?crit
-name=><?_ml .by_gender _ml?>
-code=>s_gen
-form<=
-User is: <select name="gen_sel">
-<option></option>
-<option value="F"><?_ml .female _ml?></option>
-<option value="M"><?_ml .male _ml?></option>
-<option value="O">Other</option>
-</select>
-<=form
-crit?>
-_c?>
-
-<!---- interest ----->
-<?crit
-name=><?_ml .by_interest _ml?>
-code=>s_int
-form<=
-<?_ml .user_likes _ml?> <input name="int_like" size='30' />
-<br /><?_ml .int_multiple _ml?>
-<=form
-crit?>
-
-<!---- trust/watch ----->
-<?crit
-name=><?_ml .by_circle _ml?>
-code=>s_fr
-form<=
-<?_code
-    my $ret = BML::ml( '.user_trusts', { input => "<input name=\"user_trusts\" size='15' maxlength='25' />" } ) . "<br />";
-    $ret .= BML::ml( '.user_trusted_by', { input => "<input name=\"user_trusted_by\" size='15' maxlength='25' />" } ) . "<br />";
-    $ret .= BML::ml( '.user_watches', { input => "<input name=\"user_watches\" size='15' maxlength='25' />" } ) . "<br />";
-    $ret .= BML::ml( '.user_watched_by', { input => "<input name=\"user_watched_by\" size='15' maxlength='25' />" } );
-
-    return $ret;
-_code?>
-<=form
-crit?>
-
-<?_c no index on this yet.  need a userprop boolean.
-<!----- other ------>
-<?bar
-name=><?_ml .other_criteria _ml?>
-form<=
-<input type='checkbox' name="s_withpic" value='1' /> Only users with pictures
-<=form
-bar?>
-_c?>
-
-<!---- output formatting ----->
-<?bar
-name=><?_ml .display_results _ml?>
-form<=
-
-<table summary=''>
-<tr>
-<td align='right'>
-<?_ml .display_by _ml?>
-</td><td>
-<select name="opt_format">
-<option value="pics"><?_ml .picture _ml?></option>
-<option value="simple"><?_ml .text_only _ml?></option>
-</select>
-</td></tr>
-
-<tr>
-<td align='right'>
-<?_ml .records_per_page _ml?>
-</td><td>
-<select name="opt_pagesize">
-<option value="25">25</option>
-<option value="50">50</option>
-<option value="100" selected='selected'>100</option>
-<option value="200">200</option>
-</select>
-</td></tr>
-
-</table>
-<=form
-bar?>
-
-<!--- submit --->
-<tr bgcolor='<?emcolor?>'><td colspan='2' align='center'>
-  <input type='submit' value="<?_ml .search _ml?>" />
-  <input type='reset' value="<?_ml .clear_form _ml?>" />
-</td></tr>
-
-</table>
-</form>
-
-</center>
-
-<=body
-page?>
diff -r 6fc0cc50a979 -r e3f09b49dde7 htdocs/directorysearch.bml.text
--- a/htdocs/directorysearch.bml.text	Mon Oct 03 14:05:08 2011 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-;; -*- coding: utf-8 -*-
-.and=and
-
-.between=Between
-
-.by_age=By Age
-
-.by_circle=By Circle
-
-.by_gender=By Gender
-
-.by_interest=By Interest
-
-.by_location=By Location
-
-.clear_form=Clear Form
-
-.country=Country:
-
-.date=Date
-
-.day=day
-
-.display_by=Display by
-
-.display_results=Display Results
-
-.error.notloggedin=You must <a [[aopts]]>log in</a> to use the directory.
-
-.female=Female
-
-.h1=Search Directory
-
-.int_multiple=<i>Note: you may specify multiple interests separated by commas.</i>
-
-.male=Male
-
-.month=month
-
-.other_criteria=Other Criteria
-
-.picture=picture
-
-.recently_updated=Last Update
-
-.records_per_page=Results per page:
-
-.search=Search!
-
-.state_province=State/Province:
-
-.text_only=text only
-
-.title=Directory Search
-
-.updated_in_last=Updated in last
-
-.user_likes=People interested in:
-
-.user_trusted_by=People granted access by: [[input]]
-
-.user_trusts=People who grant access to: [[input]]
-
-.user_watched_by=People subscribed to by: [[input]]
-
-.user_watches=People subscribed to: [[input]]
-
-.use_this_dir2=You can use this directory to search for people on [[sitename]]. If you fill in more than one search box, the search will return only results that contain all your search words; for example, if you put in "Baltimore City" and "cars", the journals your search will show are those which have both words somewhere in their Profile.  If you're looking for a community instead of a person, you can use our <a [[aopts]]>community search page</a> to find them.
-
-.week=week
-
-.years_old=years old.
-
diff -r 6fc0cc50a979 -r e3f09b49dde7 views/directory/index.tt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/directory/index.tt	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,140 @@
+[%# TT conversion of directorysearch.bml & directory.bml
+  # Directory search, as inherited from LiveJournal.
+  #
+  # Authors:
+  #      Jen Griffin <kareila@livejournal.com>
+  #
+  # Copyright (c) 2011 by Dreamwidth Studios, LLC.
+  #
+  # This program is free software; you may redistribute it and/or modify it
+  # under the same terms as Perl itself. For a copy of the license, please
+  # reference 'perldoc perlartistic' or 'perldoc perlgpl'.
+  #
+%]
+
+[%- sections.head = BLOCK %]
+<style type='text/css'>
+    .field_class { text-align: right; }
+</style>
+[% END -%]
+
+[%- usetitle = comm_page ? '.title.comm' : '.title.directory' -%]
+[%- sections.title = usetitle | ml -%]
+
+[%- emcolor='#c0c0c0'; # from global.look
+ %]
+
+[%# building blocks for search table
+ %]
+
+  [%- BLOCK searchcrit %]
+    <tr bgcolor='[% emcolor %]'>
+      <td align='left' colspan='2'><b>[% name | ml %]</b></td>
+    </tr>
+  [% END -%]
+
+  [%- BLOCK searchform_before %]<tr align='left'><td>&nbsp;</td><td>[% END -%]
+  [%- BLOCK searchform_after %]</td></tr>[% END -%]
+
+[%# end blocks
+ %]
+
+
+[%- usethis = comm_page ? '.use.comm' : '.use.dir' -%]
+<p>[% usethis | ml(aopts = "href='$site.root/community/search'",
+                   sitename = site.nameshort) %]</p>
+
+<hr />
+
+<center>
+  <form style='margin-top: 1.5em' action="/directorysearch" method='GET'>
+    <table summary='' cellpadding='4' cellspacing='0' border='0'>
+
+      <!--- location (s_loc) --->
+      [% PROCESS searchcrit name = '.by_location';
+         PROCESS searchform_before; location_widget;
+         PROCESS searchform_after %]
+
+      <!---- update time (s_ut) ----->
+      [% PROCESS searchcrit name = '.by_updated';
+         PROCESS searchform_before;
+         '.updated_in_last' | ml %]
+      <select name="ut_days">
+        <option value="">-------</option>
+        <option value="1">[% '.opt.day' | ml %]</option>
+        <option value="7">[% '.opt.week' | ml %]</option>
+        <option value="30">[% '.opt.month' | ml %]</option>
+      </select>
+      [% PROCESS searchform_after %]
+
+      <!---- age (s_age) ----->
+      [%- UNLESS comm_page -%]
+        [% PROCESS searchcrit name = '.by_age';
+           PROCESS searchform_before;
+           '.between' | ml %]
+        <input name="age_min" size='3' maxlength='3' /> [% '.and' | ml %]
+        <input name="age_max" size='3' maxlength='3' /> [% '.years_old' | ml %]
+        [% PROCESS searchform_after %]
+      [%- END -%]
+
+      <!---- interest (s_int) ----->
+      [% PROCESS searchcrit name = '.by_interest';
+         PROCESS searchform_before %]
+      [% '.user_likes' | ml %] <input name="int_like" size='30' /><br />
+      [% '.int_multiple' | ml %]
+      [% PROCESS searchform_after %]
+
+      <!---- trust/watch (s_fr) ----->
+      [% circle_label = comm_page ? '.by_members' : '.by_circle';
+         PROCESS searchcrit name = circle_label;
+         PROCESS searchform_before;
+         IF comm_page %]
+          [% '.comm.member' | ml %] <input name="user_is_member" size='15' maxlength='25' />
+      [% ELSE -%]
+          [% '.user_trusts'     | ml %] <input name="user_trusts" size='15' maxlength='25' /><br />
+          [% '.user_trusted_by' | ml %] <input name="user_trusted_by" size='15' maxlength='25' /><br />
+          [% '.user_watches'    | ml %] <input name="user_watches" size='15' maxlength='25' /><br />
+          [% '.user_watched_by' | ml %] <input name="user_watched_by" size='15' maxlength='25' />
+      [% END -%]
+      [% PROCESS searchform_after %]
+
+      <!---- output formatting ----->
+      [% PROCESS searchcrit name = '.display_results';
+         PROCESS searchform_before %]
+      <table summary=''>
+        <tr>
+          <td align='right'>[% '.display_by' | ml %]</td>
+          <td>
+            <select name="opt_format">
+              <option value="pics">[% '.show.picture' | ml %]</option>
+              <option value="simple">[% '.show.text_only' | ml %]</option>
+            </select>
+          </td>
+        </tr>
+
+        <tr>
+          <td align='right'>[% '.records_per_page' | ml %]</td>
+          <td>
+            <select name="opt_pagesize">
+              <option value="25">25</option>
+              <option value="50">50</option>
+              <option value="100" selected='selected'>100</option>
+              <option value="200">200</option>
+            </select>
+          </td>
+        </tr>
+      </table>
+      [% PROCESS searchform_after %]
+
+      <!--- submit --->
+      [%- IF comm_page -%]
+        <input type='hidden' name='journaltype' value='C'>
+      [%- END -%]
+      <tr bgcolor='[% emcolor %]'><td colspan='2' align='center'>
+        <input type='submit' value="[% '.button.search' | ml %]" />
+        <input type='reset' value="[% '.button.clear' | ml %]" />
+      </td></tr>
+
+    </table>
+  </form>
+</center>
diff -r 6fc0cc50a979 -r e3f09b49dde7 views/directory/index.tt.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/directory/index.tt.text	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,62 @@
+;; -*- coding: utf-8 -*-
+.and=and
+
+.between=Between
+
+.button.clear=Clear Form
+
+.button.search=Search
+
+.by_age=By Age
+
+.by_circle=By Circle
+
+.by_interest=By Interest
+
+.by_location=By Location
+
+.by_members=By Member
+
+.by_updated=By Journal Update Time
+
+.comm.member=Community membership includes this user:
+
+.display_by=Result format:
+
+.display_results=Display Options
+
+.int_multiple=<i>Note: you may specify multiple interests separated by commas.</i>
+
+.opt.day=day
+
+.opt.month=month
+
+.opt.week=week
+
+.records_per_page=Results per page:
+
+.show.picture=picture
+
+.show.text_only=text only
+
+.title.comm=Community Search
+
+.title.directory=Directory Search
+
+.updated_in_last=Updated in last
+
+.use.comm=You can use this page to search for communities on [[sitename]]. If you fill in more than one search box, the search will return only results that contain all your search words: for example, if you put in "Boston" and "beer", the only communities your search will show are those which have both words somewhere in their Profile.
+
+.use.dir=You can use this directory to search for users on [[sitename]]. If you fill in more than one search box, the search will return only results that contain all your search words; for example, if you put in "Baltimore City" and "cars", the journals your search will show are those which have both words somewhere in their Profile.  If you're looking for a community, you can try our <a [[aopts]]>community search page</a> instead.
+
+.user_likes=Interested in:
+
+.user_trusted_by=Accounts granted access by:
+
+.user_trusts=Accounts who grant access to:
+
+.user_watched_by=Accounts subscribed to by:
+
+.user_watches=Accounts subscribed to:
+
+.years_old=years old.
diff -r 6fc0cc50a979 -r e3f09b49dde7 views/directory/results.tt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/directory/results.tt	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,41 @@
+[%# TT conversion of directorysearch.bml & directory.bml
+  # Directory search, as inherited from LiveJournal.
+  #
+  # Authors:
+  #      Jen Griffin <kareila@livejournal.com>
+  #
+  # Copyright (c) 2011 by Dreamwidth Studios, LLC.
+  #
+  # This program is free software; you may redistribute it and/or modify it
+  # under the same terms as Perl itself. For a copy of the license, please
+  # reference 'perldoc perlartistic' or 'perldoc perlgpl'.
+  #
+%]
+
+[%- dw.need_res( 'stc/directory.css' ) -%]
+
+[%- sections.title='.title' | ml -%]
+
+<div id="NewSearch">
+    <a href='[% "$site.root/$searchurl" %]'>&lt;&lt; [% '.new_search' | ml %]</a>
+</div>
+
+<h1>[% '.search_results' | ml %]</h1>
+
+<div id="FilterSearch">[% '.new_search_show' | ml %]&nbsp;
+[%- search_ml.all   = '.new_all_search' | ml;
+    search_ml.comm  = '.new_community_search' | ml;
+    search_ml.user  = '.new_user_search' | ml;
+    search_ml.ident = '.new_identity_search' | ml;
+    filter_linkbar( search_ml ) %]
+</div>
+
+[%- IF ignore; '.unable_find_users' | ml; ELSIF search_err -%]
+    <div class='error-box'>[% '.error.search_dir' | ml %]</div>
+[%- ELSIF ! numusers -%]
+    <div class='warning-box'>[% '.no_results' | ml %]</div>
+[%- ELSE; paging_bar; results %]
+[%# if more than 20 results (or 4 rows), show paging bar again at bottom
+    %]
+[%- IF numusers > 20; paging_bar; END -%]
+[%- END -%]
diff -r 6fc0cc50a979 -r e3f09b49dde7 views/directory/results.tt.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/directory/results.tt.text	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,22 @@
+;; -*- coding: utf-8 -*-
+.error.search_dir=There was an error searching the directory. Please try again in a few minutes.
+
+.new_all_search=All
+
+.new_community_search=Communities Only
+
+.new_identity_search=OpenIDs Only
+
+.new_search=New search
+
+.new_search_show=Show:
+
+.new_user_search=Accounts Only
+
+.no_results=No Results Found.
+
+.search_results=Search Results
+
+.title=Directory Search
+
+.unable_find_users=We're unable to find anyone matching the interests you've provided.
diff -r 6fc0cc50a979 -r e3f09b49dde7 views/directory/searchdots.tt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/directory/searchdots.tt	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,26 @@
+[%# TT conversion of directorysearch.bml & directory.bml
+  # Directory search, as inherited from LiveJournal.
+  #
+  # Authors:
+  #      Jen Griffin <kareila@livejournal.com>
+  #
+  # Copyright (c) 2011 by Dreamwidth Studios, LLC.
+  #
+  # This program is free software; you may redistribute it and/or modify it
+  # under the same terms as Perl itself. For a copy of the license, please
+  # reference 'perldoc perlartistic' or 'perldoc perlgpl'.
+  #
+%]
+
+[%- sections.head = BLOCK %]
+    <meta http-equiv='Refresh' content='1;URL=[% refurl %]' id='refresher' />
+[% END -%]
+
+[%- dw.need_res( 'stc/directory.css' ) -%]
+
+[%- sections.title='.title' | ml -%]
+
+<div id="SearchWaitText" style='text-align: center;'>
+    <b>[% '.search.title' | ml; dots %]</b>
+    <p>[% '.search.monkey' | ml %]</p>
+</div>
diff -r 6fc0cc50a979 -r e3f09b49dde7 views/directory/searchdots.tt.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/directory/searchdots.tt.text	Mon Oct 03 15:17:20 2011 +0800
@@ -0,0 +1,6 @@
+;; -*- coding: utf-8 -*-
+.search.monkey=Hang in there while we look that up for you.
+
+.search.title=Searching
+
+.title=Directory Search
--------------------------------------------------------------------------------