incorporate user auth functionality
Tara L Andrews [Wed, 11 Jul 2012 19:33:51 +0000 (21:33 +0200)]
1  2 
lib/stemmaweb/Controller/Root.pm
root/src/index.tt

@@@ -41,15 -41,15 +41,15 @@@ sub index :Path :Args(0) 
  
   GET /directory
  
- Serves a snippet of HTML that lists the available texts.  Eventually this will be available texts by user.
+ Serves a snippet of HTML that lists the available texts.  This returns texts belonging to the logged-in user if any, otherwise it returns all public texts.
  
  =cut
  sub directory :Local :Args(0) {
        my( $self, $c ) = @_;
      my $m = $c->model('Directory');
-     # TODO not used yet, will load user texts later
-     my $user = $c->request->param( 'user' ) || 'ALL';
-     my @textlist = $m->traditionlist();
+     my $user = $c->user_exists ? $c->user->get_object : 'public';
+     my @textlist = $m->traditionlist($user);
      $c->stash->{texts} = \@textlist;
        $c->stash->{template} = 'directory.tt';
  }
@@@ -125,7 -125,7 +125,7 @@@ sub stemma :Local :Args(1) 
        }
        
        $c->stash->{'result'} = $tradition->stemma_count
 -              ? $tradition->stemma(0)->as_svg
 +              ? $tradition->stemma(0)->as_svg( { size => [ 500, 375 ] } )
                : '';
        $c->forward('View::SVG');
  }
diff --combined root/src/index.tt
@@@ -14,7 -14,7 +14,7 @@@ $(document).ready(function() 
  
      <div id="topbanner">
        <h1>Stemmaweb - a collection of tools for analysis of collated texts</h1>
-       <span class="mainnav"><a href="[% c.uri_for( 'about.html' ) %]">About<a> | <a href="[% c.uri_for( 'doc.html' ) %]">Help</a></span>
+       <span class="mainnav">[% IF c.user_exists %]Hello! [% c.user.get_object.email %] [% ELSE %]<a href="[% c.uri_for('/login') %]">Login</a> | <a href="[% c.uri_for('/register') %]">Register</a> | [% END %]<a href="[% c.uri_for( 'about.html' ) %]">About<a> | <a href="[% c.uri_for( 'doc.html' ) %]">Help</a></span>
      </div>
      <div id="directory_container">
        <h2>Text directory</h2>
                  <span>Examine variants against this stemma</span>
          </div>
        </form>
 -    </div>
 -    <div id="variant_container">
 -      <div style="float: left"><h2>Variant graph for <span class="texttitle">selected text</span></h2></div>
        <form id="run_relater" action="" method="GET" name="run_relater">
          <div class="button" id="relater_button" onClick="$('#run_relater').submit()">
            <span>Run relationship mapper</span>
          </div>
        </form>
 -      <div id="variant_graph"></div>
 +    </div>
 +    <div id="variant_container">
      </div>
  
  [% PROCESS footer.tt %]