Ticket #254: universaleditandtest.diff

File universaleditandtest.diff, 2.5 kB (added by bob, 6 months ago)

a diff to add universal editsuport

  • templates/header.tt

     
    5555  [% IF deter_robots %] 
    5656    <meta name="robots" content="noindex,nofollow" /> 
    5757  [% END %] 
     58  [% UNLESS not_editable %] 
     59        <link rel="alternate" type="application/wiki" title="Edit this page!" href="[% source_site or full_cgi_url %]?id=[% node_param %];action=edit"> 
     60[% END %] 
    5861  [% IF enable_gmaps AND display_google_maps AND gmaps_api_key %] 
    5962    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=[% gmaps_api_key %]" type="text/javascript"></script> 
    6063  [% END %] 
  • t/85_universal_edit.t

     
     1use strict; 
     2use OpenGuides; 
     3use OpenGuides::Test; 
     4use Test::More; 
     5use Wiki::Toolkit::Setup::SQLite; 
     6 
     7eval { require DBD::SQLite; }; 
     8if ( $@ ) { 
     9    plan skip_all => "DBD::SQLite not installed - no database to test with"; 
     10    exit 0; 
     11} 
     12 
     13 
     14plan tests => 2; 
     15 
     16# test that an editable page gets the universal edit <link> and that a non-editable one doesnt. 
     17 
     18my ( $config, $guide, $wiki, $cookie, $output ); 
     19 
     20# Clear out the database from any previous runs. 
     21unlink "t/node.db"; 
     22unlink <t/indexes/*>; 
     23Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
     24 
     25# Make a guide. 
     26$config = OpenGuides::Test->make_basic_config; 
     27$guide = OpenGuides->new( config => $config ); 
     28my $wiki = $guide->wiki; 
     29 
     30# Write a node. 
     31OpenGuides::Test->write_data( 
     32                              guide => $guide, 
     33                              node  => "Red Lion", 
     34                            ); 
     35 
     36$output = $guide->display_node( 
     37                                 id => "Red Lion", 
     38                                return_output => 1, 
     39                              ); 
     40like( $output, qr|<link rel="alternate" type="application/wiki" title="Edit this page!"|ms, 
     41        "universal edit link present"); 
     42 
     43 
     44unlike ( get_output($wiki, $config), qr|<link rel="alternate" type="application/wiki" title="Edit this page!"|ms, 
     45        "universal edit link not present"); 
     46 
     47 
     48sub get_output { 
     49    my ($wiki, $config) = @_; 
     50 
     51    return OpenGuides::Template->output( 
     52        wiki         => $wiki, 
     53        config       => $config, 
     54        template     => "preferences.tt", 
     55        noheaders    => 1, 
     56        vars         => { 
     57                          not_editable => 1, 
     58                          show_form    => 1 
     59                        }, 
     60    ); 
     61}