Author: kake Date: 2008-06-26 23:12:09 +0100 (Thu, 26 Jun 2008) New Revision: 1178
Added: trunk/t/85_universal_edit_link.t Modified: trunk/Changes trunk/MANIFEST trunk/templates/header.tt Log: Added a Universal Edit Link + test (ta Bob).
Modified: trunk/Changes =================================================================== --- trunk/Changes 2008-06-22 23:53:31 UTC (rev 1177) +++ trunk/Changes 2008-06-26 22:12:09 UTC (rev 1178) @@ -19,6 +19,7 @@ * Replace unnecessary instances of rdf:ID with rdf:nodeID. * Model relationship of neighborhood to parent city. * Reduce acres of whitespace in output and clean up indenting. + Added a Universal Edit Link (http://universaleditbutton.org/)
0.62 8 June 2008 Allow wiki page links (simple: [[Foo]], title: [[Foo|bar]]) in
Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2008-06-22 23:53:31 UTC (rev 1177) +++ trunk/MANIFEST 2008-06-26 22:12:09 UTC (rev 1178) @@ -144,5 +144,6 @@ t/77_send_email.t t/78_about.t t/79_host_blacklist.t +t/85_universal_edit_link.t t/templates/15_test.tt wiki.cgi
Added: trunk/t/85_universal_edit_link.t =================================================================== --- trunk/t/85_universal_edit_link.t (rev 0) +++ trunk/t/85_universal_edit_link.t 2008-06-26 22:12:09 UTC (rev 1178) @@ -0,0 +1,45 @@ +use strict; +use OpenGuides; +use OpenGuides::Test; +use Test::More; +use Wiki::Toolkit::Setup::SQLite; + +eval { require DBD::SQLite; }; +if ( $@ ) { + plan skip_all => "DBD::SQLite not installed - no database to test with"; +} + +plan tests => 2; + +# An editable page should get the universal edit <link>; a non-editable one +# shouldn't. + +my ( $config, $guide, $wiki, $cookie, $output ); + +# Clear out the database from any previous runs. +unlink "t/node.db"; +unlink <t/indexes/*>; +Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); + +# Make a guide. +$config = OpenGuides::Test->make_basic_config; +$guide = OpenGuides->new( config => $config ); +$wiki = $guide->wiki; + +# Write a node. +OpenGuides::Test->write_data( + guide => $guide, + node => "Red Lion", + return_output => 1, + ); + +# Check an editable node. +$output = $guide->display_node( + id => "Red Lion", + return_output => 1, + ); +like( $output, qr|<link rel="alternate" type="application/wiki" title="Edit this page!"|ms, "universal edit link present on editable page" ); + +# Check a non-editable node. +$output = $guide->display_recent_changes( return_output => 1 ); +unlike( $output, qr|<link rel="alternate" type="application/wiki" title="Edit this page!"|ms, "universal edit link not present on non-editable page" );
Modified: trunk/templates/header.tt =================================================================== --- trunk/templates/header.tt 2008-06-22 23:53:31 UTC (rev 1177) +++ trunk/templates/header.tt 2008-06-26 22:12:09 UTC (rev 1178) @@ -55,6 +55,10 @@ [% IF deter_robots %] <meta name="robots" content="noindex,nofollow" /> [% END %] + [% UNLESS not_editable %] + <link rel="alternate" type="application/wiki" title="Edit this page!" + href="[% source_site or full_cgi_url %]?id=[% node_param %];action=edit"> + [% END %] [% IF enable_gmaps AND display_google_maps AND gmaps_api_key %] <script src="http://maps.google.com/maps?file=api&v=2&key=[% gmaps_api_key %]" type="text/javascript"></script> [% END %]