Author: dom
Date: 2008-10-19 16:24:04 +0100 (Sun, 19 Oct 2008)
New Revision: 1236
Added:
trunk/templates/navbar_admin.tt
Modified:
trunk/Build.PL
trunk/Changes
trunk/MANIFEST
trunk/lib/OpenGuides/CGI.pm
trunk/lib/OpenGuides/Template.pm
trunk/preferences.cgi
trunk/t/13_cookies.t
trunk/templates/navbar.tt
trunk/templates/preferences.tt
Log:
Add an admin navbar, to be displayed if the user requests (fixes #261)
Modified: trunk/Build.PL
===================================================================
--- trunk/Build.PL 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/Build.PL 2008-10-19 15:24:04 UTC (rev 1236)
@@ -362,6 +362,7 @@
"navbar_categories.tt",
"navbar_locales.tt",
"navbar_help.tt",
+ "navbar_admin.tt",
"navbar_home_link.tt",
"navbar_options.tt",
"navbar_revision_info.tt",
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/Changes 2008-10-19 15:24:04 UTC (rev 1236)
@@ -13,6 +13,7 @@
Change default database type to sqlite (#241)
Set content charset correctly in RDF (#260)
Display geodata ellipsoid to user in edit from (#230)
+ Add an admin navbar, to be displayed if the user requests (#261)
0.63 16 August 2008
Major overhaul of RDF output.
Modified: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/MANIFEST 2008-10-19 15:24:04 UTC (rev 1236)
@@ -47,6 +47,7 @@
templates/moderate_confirm.tt
templates/moderate_password_wrong.tt
templates/navbar.tt
+templates/navbar_admin.tt
templates/navbar_categories.tt
templates/navbar_help.tt
templates/navbar_home_link.tt
Modified: trunk/lib/OpenGuides/CGI.pm
===================================================================
--- trunk/lib/OpenGuides/CGI.pm 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/lib/OpenGuides/CGI.pm 2008-10-19 15:24:04 UTC (rev 1236)
@@ -38,7 +38,8 @@
default_edit_type => "tidying",
cookie_expires => "never",
track_recent_changes_views => 1,
- display_google_maps => 1
+ display_google_maps => 1,
+ is_admin => 1
);
my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
@@ -83,7 +84,8 @@
default_edit_type => "tidying",
cookie_expires => "never",
track_recent_changes_views => 1,
- display_google_maps => 1
+ display_google_maps => 1,
+ is_admin => 1
);
Croaks unless an L<OpenGuides::Config> object is supplied as C<config>.
@@ -126,7 +128,8 @@
defedit => $args{default_edit_type} || "normal",
exp => $args{cookie_expires},
trackrc => $args{track_recent_changes_views} || 0,
- gmaps => $args{display_google_maps} || 0
+ gmaps => $args{display_google_maps} || 0,
+ admin => $args{is_admin} || 0
},
-expires => $expires,
);
@@ -180,6 +183,7 @@
exp => "cookie_expires",
trackrc => "track_recent_changes_views",
gmaps => "display_google_maps",
+ admin => "is_admin",
);
my %long_data = map { $long_forms{$_} => $data{$_} } keys %long_forms;
@@ -199,6 +203,7 @@
cookie_expires => "month",
track_recent_changes_views => 0,
display_google_maps => 1,
+ is_admin => 0,
);
my %return;
foreach my $key ( keys %data ) {
Modified: trunk/lib/OpenGuides/Template.pm
===================================================================
--- trunk/lib/OpenGuides/Template.pm 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/lib/OpenGuides/Template.pm 2008-10-19 15:24:04 UTC (rev 1236)
@@ -155,6 +155,10 @@
) {
$enable_page_deletion = 1;
}
+ my $is_admin = 0;
+ if ( $cookie_data{is_admin} ) {
+ $is_admin = 1;
+ }
my $tt_vars = {
config => $config,
@@ -169,6 +173,7 @@
home_name => $config->home_name,
navbar_on_home_page => $config->navbar_on_home_page,
omit_help_links => $omit_help_links,
+ is_admin => $is_admin,
formatting_rules_link => $formatting_rules_link,
formatting_rules_node => $formatting_rules_node,
openguides_version => $OpenGuides::VERSION,
Modified: trunk/preferences.cgi
===================================================================
--- trunk/preferences.cgi 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/preferences.cgi 2008-10-19 15:24:04 UTC (rev 1236)
@@ -45,6 +45,7 @@
cookies => \@cookies,
vars => {
not_editable => 1,
+ not_deletable => 1,
}
);
}
@@ -55,8 +56,9 @@
config => $config,
template => "preferences.tt",
vars => {
- not_editable => 1,
- show_form => 1
+ not_editable => 1,
+ show_form => 1,
+ not_deletable => 1,
}
);
}
Modified: trunk/t/13_cookies.t
===================================================================
--- trunk/t/13_cookies.t 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/t/13_cookies.t 2008-10-19 15:24:04 UTC (rev 1236)
@@ -3,7 +3,7 @@
use OpenGuides::CGI;
use Time::Piece;
use Time::Seconds;
-use Test::More tests => 27;
+use Test::More tests => 29;
eval { OpenGuides::CGI->make_prefs_cookie; };
ok( $@, "->make_prefs_cookie dies if no config object supplied" );
@@ -30,6 +30,7 @@
cookie_expires => "never",
track_recent_changes_views => "rc_pref",
display_google_maps => "gm_pref",
+ is_admin => "admin_pref",
);
isa_ok( $cookie, "CGI::Cookie", "->make_prefs_cookie returns a cookie" );
@@ -68,7 +69,8 @@
"...and recent changes tracking" );
is( $prefs{display_google_maps}, "gm_pref",
"...and Google Maps display preference" );
-
+is( $prefs{is_admin}, "admin_pref",
+ "...and admin preference" );
# Now make sure that true/false preferences are taken account of when
# they're false.
$cookie = OpenGuides::CGI->make_prefs_cookie(
@@ -80,6 +82,7 @@
show_minor_edits_in_rc => 0,
track_recent_changes_views => 0,
display_google_maps => 0,
+ is_admin => 0,
);
$ENV{HTTP_COOKIE} = $cookie;
@@ -92,9 +95,10 @@
ok( !$prefs{show_minor_edits_in_rc}, "...and minor edits prefs" );
ok( !$prefs{track_recent_changes_views}, "...and recent changes prefs" );
ok( !$prefs{display_google_maps}, "...and Google Maps prefs" );
+ok( !$prefs{is_admin}, "...and admin prefs" );
# Check that cookie parsing fails nicely if no cookie set.
delete $ENV{HTTP_COOKIE};
%prefs = eval { OpenGuides::CGI->get_prefs_from_cookie( config => $config ); };
is( $@, "", "->get_prefs_from_cookie doesn't die if no cookie set" );
-is( keys %prefs, 10, "...and returns ten default values" );
+is( keys %prefs, 11, "...and returns ten default values" );
Modified: trunk/templates/navbar.tt
===================================================================
--- trunk/templates/navbar.tt 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/templates/navbar.tt 2008-10-19 15:24:04 UTC (rev 1236)
@@ -4,6 +4,7 @@
[% INCLUDE navbar_home_link.tt %]
[% INCLUDE navbar_tools.tt %]
[% INCLUDE navbar_help.tt %]
+ [% INCLUDE navbar_admin.tt %]
[% INCLUDE navbar_options.tt %]
[% INCLUDE navbar_search.tt %]
[% INCLUDE navbar_this_page.tt %]
Added: trunk/templates/navbar_admin.tt
===================================================================
--- trunk/templates/navbar_admin.tt (rev 0)
+++ trunk/templates/navbar_admin.tt 2008-10-19 15:24:04 UTC (rev 1236)
@@ -0,0 +1,12 @@
+[% IF is_admin %]
+ <div id="navbar_admin">
+ <div class="navbar_group_title">Admin:</div>
+ <ul>
+ <li><a href="[% full_cgi_url %]?action=admin">Site Administration</a></li>
+ <li><a href="[% full_cgi_url %]?action=show_needing_moderation">Pages needing moderation</a></li>
+[% IF enable_page_deletion AND NOT not_deletable %]
+ <li><a href="[% full_cgi_url %]?id=[% node_param %];action=delete">Delete page</a></li>[% END %]
+ </ul>
+</div>
+[% END %]
+
Modified: trunk/templates/preferences.tt
===================================================================
--- trunk/templates/preferences.tt 2008-10-19 14:58:02 UTC (rev 1235)
+++ trunk/templates/preferences.tt 2008-10-19 15:24:04 UTC (rev 1236)
@@ -58,6 +58,15 @@
</p>
<p>
+ [% IF prefs.is_admin %]
+ <input type="checkbox" id="is_admin" name="is_admin" value="1" checked />
+ [% ELSE %]
+ <input type="checkbox" id="is_admin" name="is_admin" value="1" />
+ [% END %]
+ <label for="show_minor">Show admin related links</label>
+ </p>
+
+ <p>
[% IF prefs.track_recent_changes_views %]
<input type="checkbox" id="track_recent_changes_views" name="track_recent_changes_views" value="1" checked="1" />
[% ELSE %]
@@ -144,6 +153,10 @@
be included in navbar.
</p>
+ <p>Admin links will
+ [% UNLESS prefs.is_admin %] not [% END %]
+ be included in navbar.
+ </p>
<p>Minor edits
[% UNLESS show_minor_edits_in_rc %] not [% END %]
included in Recent Changes.</p>