Author: dom
Date: 2010-02-28 15:28:05 +0000 (Sun, 28 Feb 2010)
New Revision: 1279
Added:
trunk/templates/read_only.tt
Modified:
trunk/Build.PL
trunk/Changes
trunk/MANIFEST
trunk/lib/OpenGuides.pm
trunk/lib/OpenGuides/Config.pm
trunk/newpage.cgi
trunk/templates/edit_form.tt
trunk/templates/footer.tt
trunk/templates/home_node.tt
trunk/templates/navbar_this_page.tt
trunk/templates/newpage.tt
trunk/templates/node.tt
Log:
Add read_only config option to turn off edits on a guide completely (fixes #276)
Modified: trunk/Build.PL
===================================================================
--- trunk/Build.PL 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/Build.PL 2010-02-28 15:28:05 UTC (rev 1279)
@@ -49,7 +49,7 @@
enable_common_locales recent_changes_on_home_page
random_page_omits_locales random_page_omits_categories
content_above_navbar_in_html show_gmap_in_node_display force_wgs84
- send_moderation_notifications);
+ send_moderation_notifications read_only);
my $skip_config = $force ? 'y' : Module::Build->y_n("Skip OpenGuides configuration?", "n");
if ( $skip_config ) {
@@ -112,7 +112,7 @@
licence_name licence_url licence_info_url moderation_requires_password
enable_node_image enable_common_categories enable_common_locales
spam_detector_module host_checker_module static_path static_url
- send_moderation_notifications
+ send_moderation_notifications read_only
) ) {
my $q_method = $var . "__qu";
my $qu = $existing_config->$q_method;
@@ -388,6 +388,7 @@
"preferences.tt",
"random_page_failure.tt",
"rdf_index.tt",
+ "read_only.tt",
"recent_changes.tt",
"search_results.tt",
"site_index.tt",
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/Changes 2010-02-28 15:28:05 UTC (rev 1279)
@@ -9,6 +9,8 @@
Return HTTP 404 status when displaying a node that doesn't exist (#102)
Add Recent Changes tests (refers to #270)
Some test cleanups (#271)
+ Add read_only config option to turn off edits on a guide
+ completely (#276)
0.64 23 February 2009
Correctly specify all build_requires (#245)
Modified: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/MANIFEST 2010-02-28 15:28:05 UTC (rev 1279)
@@ -70,6 +70,7 @@
templates/preferences.tt
templates/random_page_failure.tt
templates/rdf_index.tt
+templates/read_only.tt
templates/recent_changes.tt
templates/search_results.tt
templates/site_index.tt
Modified: trunk/lib/OpenGuides/Config.pm
===================================================================
--- trunk/lib/OpenGuides/Config.pm 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/lib/OpenGuides/Config.pm 2010-02-28 15:28:05 UTC (rev 1279)
@@ -26,7 +26,7 @@
moderation_requires_password moderate_whitelist
enable_node_image enable_common_categories enable_common_locales
spam_detector_module host_checker_module static_path static_url
- send_moderation_notifications website_link_max_chars
+ send_moderation_notifications website_link_max_chars read_only
);
my @questions = map { $_ . "__qu" } @variables;
OpenGuides::Config->mk_accessors( @variables );
@@ -118,6 +118,7 @@
static_path => "/usr/local/share/openguides/static",
send_moderation_notifications => 1,
website_link_max_chars => 20,
+ read_only => 0,
);
# See if we already have some config variables set.
@@ -205,6 +206,7 @@
send_moderation_notifications => "Should we send email notifications when a moderated node is edited?",
website_link_max_chars => "How many characters of the URL of node websites should be displayed?",
moderate_whitelist => "Enter a comma-separated list of IP addresses able to make changes to moderated nodes and have them show up immediately",
+ read_only => "Should the guide be read-only (no edits permitted)?",
);
foreach my $var ( keys %questions ) {
@@ -343,6 +345,8 @@
=item * website_link_max_chars (default: C<20>)
+=item * read_only
+
=back
=head1 AUTHOR
@@ -351,7 +355,7 @@
=head1 COPYRIGHT
- Copyright (C) 2004-2008 The OpenGuides Project. All Rights Reserved.
+ Copyright (C) 2004-2010 The OpenGuides Project. All Rights Reserved.
The OpenGuides distribution is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
Modified: trunk/lib/OpenGuides.pm
===================================================================
--- trunk/lib/OpenGuides.pm 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/lib/OpenGuides.pm 2010-02-28 15:28:05 UTC (rev 1279)
@@ -288,7 +288,8 @@
enable_gmaps => 1,
wgs84_long => $wgs84_long,
wgs84_lat => $wgs84_lat,
- empty_node => !$node_exists
+ empty_node => !$node_exists,
+ read_only => $config->read_only,
);
# Hide from search engines if showing a specific version.
@@ -543,6 +544,7 @@
edit_type => $edit_type,
moderate => $moderate,
deter_robots => 1,
+ read_only => $config->read_only,
);
# Override some things if we were supplied with them
@@ -615,7 +617,8 @@
preview_above_edit_box => $self->get_cookie(
"preview_above_edit_box" ),
checksum => $q->escapeHTML($checksum),
- moderate => $moderate
+ moderate => $moderate,
+ read_only => $config->read_only,
);
my $output = $self->process_template(
id => $node,
@@ -1511,7 +1514,7 @@
cgi_obj => $q
);
- if ( scalar @{$fails} ) {
+ if ( scalar @{$fails} or $config->read_only ) {
my %vars = (
validate_failed => $fails
);
@@ -1522,7 +1525,8 @@
metadata => \%new_metadata,
vars => \%vars,
checksum => CGI->escapeHTML($checksum),
- return_output => 1
+ return_output => 1,
+ read_only => $config->read_only,
);
return $output if $return_output;
@@ -2333,7 +2337,7 @@
=head1 COPYRIGHT
- Copyright (C) 2003-2009 The OpenGuides Project. All Rights Reserved.
+ Copyright (C) 2003-2010 The OpenGuides Project. All Rights Reserved.
The OpenGuides distribution is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
Modified: trunk/newpage.cgi
===================================================================
--- trunk/newpage.cgi 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/newpage.cgi 2010-02-28 15:28:05 UTC (rev 1279)
@@ -39,7 +39,9 @@
not_deletable => 1,
deter_robots => 1,
disallowed_chars => \@badchars,
- pagename => $pagename }
+ pagename => $pagename,
+ read_only => $config->read_only,
+ }
);
}
Modified: trunk/templates/edit_form.tt
===================================================================
--- trunk/templates/edit_form.tt 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/templates/edit_form.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -1,7 +1,9 @@
[% USE CGI %]
[% INCLUDE header.tt page_title = "Edit $node_name - $site_name" %]
<div id="content">
-
+[% IF read_only %]
+[% INCLUDE read_only.tt %]
+[% ELSE %]
<h1 class="edit_form_title">Edit "[% node_name %]"</h1>
[% IF conflict %]
@@ -419,5 +421,5 @@
</div>
<br clear="all" />
[% END %]
-
+[% END %]
[% INCLUDE footer.tt omit_footer_search_form = 1 %]
Modified: trunk/templates/footer.tt
===================================================================
--- trunk/templates/footer.tt 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/templates/footer.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -24,6 +24,9 @@
[% INCLUDE delete_link %]
<p>
Powered by <a href="[% full_cgi_url%]?action=about">OpenGuides [% openguides_version %]</a>.
+[% IF read_only %]
+This guide is in read-only mode.
+[% END %]
</p>
[% IF licence_name %]
<p>
Modified: trunk/templates/home_node.tt
===================================================================
--- trunk/templates/home_node.tt 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/templates/home_node.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -8,7 +8,7 @@
[% INCLUDE navbar.tt %]
[% END %]
-[% IF !navbar_on_home_page AND !config.recent_changes_on_home_page %]
+[% IF !navbar_on_home_page AND !config.recent_changes_on_home_page AND !read_only %]
<div id="home_page_edit_link">
<a href="[% cgi_url %]?action=edit;id=[% node_param %]">Edit this page</a>
</div>
@@ -39,8 +39,10 @@
[% END %]
</dl>
+[% UNLESS read_only %]
<p><b><a href="[% cgi_url %]?action=edit;id=[% node_param %]">Edit
this page</a></b></p>
+[% END %]
</div>
[% END %]
Modified: trunk/templates/navbar_this_page.tt
===================================================================
--- trunk/templates/navbar_this_page.tt 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/templates/navbar_this_page.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -2,7 +2,9 @@
<div id="navbar_this_page">
<div class="navbar_group_title">This page:</div>
<ul>
+[% UNLESS read_only %]
<li><a class="edit_page_link" href="[% source_site or full_cgi_url %]?id=[% node_param %];action=edit">Edit this page</a></li>
+[% END %]
<li><a href="[% full_cgi_url %]?action=show_backlinks;id=[% node_param %]">Show pages linking here</a></li>
[% IF version AND version > 1 %]
<li><a href="[% full_cgi_url %]?action=list_all_versions;id=[% node_param %]">List all revisions</a></li>
Modified: trunk/templates/newpage.tt
===================================================================
--- trunk/templates/newpage.tt 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/templates/newpage.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -7,6 +7,9 @@
<div id="maincontent">
<div id="create_new_page">
+[% IF read_only %]
+[% INCLUDE read_only.tt %]
+[% ELSE %]
<form action="newpage.cgi" id="new_page_form" method="POST">
<label for="pagename">Enter the name of the page to make:</label>
<input type="text" size="50" name="pagename" id="pagename"
@@ -26,6 +29,7 @@
[% END %]
</div>
</div>
+[% END %]
</div>
</div>
Modified: trunk/templates/node.tt
===================================================================
--- trunk/templates/node.tt 2010-01-22 23:41:00 UTC (rev 1278)
+++ trunk/templates/node.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -70,10 +70,16 @@
[% END %]
[% IF empty_node %]
</div>
-<div id="nonexistent_node_message">We don't have a node called "[% node_name %]". Would you like to <a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">create it</a>?</div>
+<div id="nonexistent_node_message">We don't have a node called "[% node_name %]".
+[% UNLESS read_only %]
+Would you like to <a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">create it</a>?
+[% END %]
+</div>
[% ELSE %]
<div id="title_edit_link">
+[% UNLESS read_only %]
<a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">Edit this page</a>
+[% END %]
</div>
</div>
[% INCLUDE display_metadata.tt %]
Added: trunk/templates/read_only.tt
===================================================================
--- trunk/templates/read_only.tt (rev 0)
+++ trunk/templates/read_only.tt 2010-02-28 15:28:05 UTC (rev 1279)
@@ -0,0 +1 @@
+This guide has been set to read-only; no edits are possible.