Changeset 935


Ignore:
Timestamp:
Mar 14, 2007, 11:22:38 AM (15 years ago)
Author:
kake
Message:

Make the summary show up in the edit preview, and add a test to make damn sure it does. Closes ticket #182.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/Test.pm

    r928 r935  
    8888                              );
    8989
    90 You can supply values for the following keys: C<content>,
    91 C<categories>, C<locales>, C<os_x>, C<os_y>, C<osie_x>, C<osie_y>,
    92 C<latitude>, C<longitude>.  You should supply them exactly as they
    93 would come from a CGI form, eg lines in a textarea are separated by C<\r\n>.
     90This method calls the C<make_cgi_object> method to make its CGI
     91object; you can supply values for any key mentioned there.  You should
     92supply them exactly as they would come from a CGI form, eg lines in a
     93textarea are separated by C<\r\n>.
    9494
    9595This method will automatically grab the checksum from the database, so
     
    125125sub write_data {
    126126    my ($class, %args) = @_;
     127
     128    my $guide = delete $args{guide};
     129    my $node  = delete $args{node};
     130
     131    my $q = $class->make_cgi_object( %args );
     132   
     133    # Get the checksum of the current contents if necessary.
     134    unless ( $args{omit_checksum} ) {
     135        my $wiki = $guide->wiki;
     136        if ( $wiki->node_exists( $node ) ) {
     137            my %data = $wiki->retrieve_node( $node );
     138            $q->param( -name => "checksum", -value => $data{checksum} );
     139        }
     140    }
     141 
     142    if ( $args{return_output} ) {
     143        return $guide->commit_node(
     144                                          return_output => 1,
     145                                          id => $node,
     146                                          cgi_obj => $q,
     147                                        );
     148    } elsif ( $args{return_tt_vars} ) {
     149        return $guide->commit_node(
     150                                          return_tt_vars => 1,
     151                                          id => $node,
     152                                          cgi_obj => $q,
     153                                        );
     154    } else {
     155        $guide->commit_node(
     156                                   id => $node,
     157                                   cgi_obj => $q,
     158                                 );
     159    }
     160}
     161
     162=over 4
     163
     164=item B<make_cgi_object>
     165
     166  my $q = OpenGuides::Test->make_cgi_object;
     167
     168You can supply values for the following keys: C<content>,
     169C<categories>, C<locales>, C<os_x>, C<os_y>, C<osie_x>, C<osie_y>,
     170C<latitude>, C<longitude>, C<summary>.  You should supply them exactly as they
     171would come from a CGI form, eg lines in a textarea are separated by C<\r\n>.
     172
     173=cut
     174
     175sub make_cgi_object {
     176    my ( $class, %args ) = @_;
    127177
    128178    # Set up CGI parameters ready for a node write.
     
    145195    $q->param( -name => "latitude", -value => $args{latitude} || "" );
    146196    $q->param( -name => "longitude", -value => $args{longitude} || "" );
     197    $q->param( -name => "summary", -value => $args{summary} || "" );
    147198    $q->param( -name => "username", -value => "Kake" );
    148199    $q->param( -name => "comment", -value => "foo" );
    149200    $q->param( -name => "edit_type", -value => "Normal edit" );
    150201    $ENV{REMOTE_ADDR} = "127.0.0.1";
    151    
    152     # Get the checksum of the current contents if necessary.
    153     unless ( $args{omit_checksum} ) {
    154         my $wiki = $args{guide}->wiki;
    155         if ( $wiki->node_exists( $args{node} ) ) {
    156             my %data = $wiki->retrieve_node( $args{node} );
    157             $q->param( -name => "checksum", -value => $data{checksum} );
    158         }
    159     }
    160  
    161     if ( $args{return_output} ) {
    162         return $args{guide}->commit_node(
    163                                           return_output => 1,
    164                                           id => $args{node},
    165                                           cgi_obj => $q,
    166                                         );
    167     } elsif ( $args{return_tt_vars} ) {
    168         return $args{guide}->commit_node(
    169                                           return_tt_vars => 1,
    170                                           id => $args{node},
    171                                           cgi_obj => $q,
    172                                         );
    173     } else {
    174         $args{guide}->commit_node(
    175                                    id => $args{node},
    176                                    cgi_obj => $q,
    177                                  );
    178     }
     202
     203    return $q;
    179204}
    180205
  • trunk/templates/edit_form.tt

    r928 r935  
    1515[% IF preview_html AND preview_above_edit_box %]
    1616  <h2>Preview</h2>
     17  [% IF summary %]
     18    <div id="summary">[% summary %]</div>
     19  [% END %]
    1720  [% INCLUDE display_metadata.tt %]
    1821  [% preview_html %]
     
    186189[% IF preview_html AND NOT preview_above_edit_box %]
    187190  <h2>Preview</h2>
     191  [% IF summary %]
     192    <div id="summary">[% summary %]</div>
     193  [% END %]
    188194  [% INCLUDE display_metadata.tt %]
    189195  [% preview_html %]
Note: See TracChangeset for help on using the changeset viewer.