Author: kake Date: 2012-04-17 13:50:46 +0100 (Tue, 17 Apr 2012) New Revision: 1348
Added: trunk/t/82_stylesheet.t Modified: trunk/INSTALL trunk/MANIFEST trunk/lib/OpenGuides/Config.pm trunk/templates/header.tt Log: Use the basic OpenGuides stylesheet if they don't supply a URL in their wiki.conf
Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2012-04-17 12:30:02 UTC (rev 1347) +++ trunk/INSTALL 2012-04-17 12:50:46 UTC (rev 1348) @@ -137,11 +137,13 @@ *** USE WITH CAUTION. DELETED PAGES CANNOT BE RECOVERED. ***
- "What's the URL of the site's stylesheet?" + "What's the URL of the site's stylesheet? If you don't enter one here, + the basic OpenGuides stylesheet will be used instead.
-Supplying an answer to this question is optional. There are example -stylesheets in the examples/ directory - note that these will not be -automatically installed. +Supplying an answer to this question is optional. If you do not supply +your own stylesheet, your guide will use the basic OpenGuides stylesheet +instead (this is automatically installed in your static content directory +regardless of your answer to the present question).
"What's the wiki called?"
Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2012-04-17 12:30:02 UTC (rev 1347) +++ trunk/MANIFEST 2012-04-17 12:50:46 UTC (rev 1348) @@ -154,6 +154,7 @@ t/78_about.t t/79_host_blacklist.t t/81_node_moderate_whitelist.t +t/82_stylesheet.t t/83_show_delete_to_admins_only.t t/84_navbar_admin.t t/85_universal_edit_link.t
Modified: trunk/lib/OpenGuides/Config.pm =================================================================== --- trunk/lib/OpenGuides/Config.pm 2012-04-17 12:30:02 UTC (rev 1347) +++ trunk/lib/OpenGuides/Config.pm 2012-04-17 12:50:46 UTC (rev 1348) @@ -167,7 +167,7 @@ enable_page_deletion => "Do you want to enable page deletion?", moderation_requires_password => "Is the admin password required for moderating pages?", admin_pass => "Please specify a password for the site admin.", - stylesheet_url => "What's the URL of the site's stylesheet?", + stylesheet_url => "What's the URL of the site's stylesheet? If you don't enter one here, the basic OpenGuides stylesheet will be used instead.", enable_node_image => "Should nodes be allowed to have an externally hosted image?", enable_common_categories => "Do you want a common list of categories shown on all node pages?", enable_common_locales => "Do you want a common list of locales shown on all node pages?",
Added: trunk/t/82_stylesheet.t =================================================================== --- trunk/t/82_stylesheet.t (rev 0) +++ trunk/t/82_stylesheet.t 2012-04-17 12:50:46 UTC (rev 1348) @@ -0,0 +1,48 @@ +use strict; +use OpenGuides; +use OpenGuides::CGI; +use OpenGuides::Test; +use Test::More; + +eval { require DBD::SQLite; }; +if ( $@ ) { + my ($error) = $@ =~ /^(.*?)\n/; + plan skip_all => + "DBD::SQLite could not be used - no database to test with. ($error)"; +} + +eval { require Test::HTML::Content; }; +if ( $@ ) { + plan skip_all => "Test::HTML::Content not available."; +} + +plan tests => 3; + +my $config = OpenGuides::Test->make_basic_config; +my $guide = OpenGuides->new( config => $config ); +my $wiki = $guide->wiki; + +# Clear out the database from any previous runs. +OpenGuides::Test::refresh_db(); + +# Write a node. +OpenGuides::Test->write_data( guide => $guide, node => "Red Lion", + return_output => 1 ); + +# Display it, and make sure we get the openguides-base.css in there. +$config->static_url( "http://example.org/static/" ); +my $output = $guide->display_node( id => "Red Lion", return_output => 1 ); +Test::HTML::Content::tag_ok( $output, "link", + { rel => "stylesheet", + href => "http://example.org/static/openguides-base.css" }, + "openguides-base stylesheet used when none provided" ); + +# Make sure the guide's own stylesheet overrides this though. +$config->stylesheet_url( "http://example.com/styles.css" ); +$output = $guide->display_node( id => "Red Lion", return_output => 1 ); +Test::HTML::Content::no_tag( $output, "link", + { rel => "stylesheet", href => "openguides-base.css" }, + "...but not when one is provided" ); +Test::HTML::Content::tag_ok( $output, "link", + { rel => "stylesheet", href => "http://example.com/styles.css" }, + "...and the guide's own stylesheet is used instead" );
Modified: trunk/templates/header.tt =================================================================== --- trunk/templates/header.tt 2012-04-17 12:30:02 UTC (rev 1347) +++ trunk/templates/header.tt 2012-04-17 12:50:46 UTC (rev 1348) @@ -29,6 +29,8 @@
[% IF stylesheet %] <link rel="stylesheet" href="[% stylesheet %]" type="text/css" title="Stylesheet for [% site_name %]" /> + [% ELSE %] + <link rel="stylesheet" href="[% config.static_url %]openguides-base.css" type="text/css" title="Basic OpenGuides stylesheet" /> [% END %] [% IF config.use_leaflet %] <link rel="stylesheet" href="http://code.leafletjs.com/leaflet-0.3.1/leaflet.css" />
openguides-commits@lists.openguides.org