[Cpan-forum-commit] rev 102 - in trunk: . lib/CPAN templates
svn at pti.co.il
svn at pti.co.il
Sun Feb 6 22:36:17 IST 2005
Author: gabor
Date: 2005-02-06 22:36:17 +0200 (Sun, 06 Feb 2005)
New Revision: 102
Added:
trunk/templates/site_is_closed.tmpl
Modified:
trunk/MANIFEST
trunk/lib/CPAN/Forum.pm
trunk/templates/admin.tmpl
Log:
enable "site is closed" display
Modified: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST 2005-02-06 18:53:29 UTC (rev 101)
+++ trunk/MANIFEST 2005-02-06 20:36:17 UTC (rev 102)
@@ -67,3 +67,4 @@
www/robots.txt
www/style.css
+templates/site_is_closed.tmpl
Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm 2005-02-06 18:53:29 UTC (rev 101)
+++ trunk/lib/CPAN/Forum.pm 2005-02-06 20:36:17 UTC (rev 102)
@@ -18,6 +18,7 @@
my $cookiename = "cpanforum";
my $SUBJECT = qr{[\w .:~!@#\$%^&*\()+?><,'";=-]+};
+my $STATUS_FILE;
my %errors = (
"ERR no_less_sign" => "No < sign in text",
@@ -184,7 +185,11 @@
Make CPAN::Forum::Configure an easy interface to the configuration table
Give "no result" on no result
Trim off leading and trailing spaces from the query.
+ Hide distname from the listing when resticted to one distribution (the same with users)
+ Setup a "status" variable for the site that allows the administrator to lock the whole site.
+ Currently it does not let the admin outlock, s/he has to remove the db/status file for this.
+
v0.11
Search for users
Unite the serch methods
@@ -571,6 +576,7 @@
my $dbh = CPAN::Forum::DBI::db_Main();
my $log = $self->param("ROOT") . "/db/messages.log";
+ $STATUS_FILE = $self->param("ROOT") . "/db/status";
$self->log_config(
LOG_DISPATCH_MODULES => [
@@ -630,6 +636,7 @@
about faq
posts threads dist users
search all
+ site_is_closed
help
rss );
my @restricted_modes = qw(
@@ -684,6 +691,13 @@
$self->log->debug("Current runmode: $rm");
+ my $status = $self->status();
+ if ($status ne "open" and not $self->session->param("admin")) {
+ $self->prerun_mode('site_is_closed');
+ return;
+ }
+ $self->log->debug("Status: $status");
+
$self->param(path_parameters => []);
if (not $rm or $rm eq "home") {
@@ -967,6 +981,11 @@
my $session = $self->session;
$session->param(loggedin => 0);
$session->param(username => '');
+ $session->param(uid => '');
+ $session->param(fname => '');
+ $session->param(lname => '');
+ $session->param(email => '');
+ $session->param(admin => '');
$self->redirect_home;
}
@@ -1947,6 +1966,9 @@
}
}
+ $self->status($q->param('status'));
+
+
my $t = $self->load_tmpl("admin.tmpl");
$t->param(updated => 1);
$t->output;
@@ -1963,6 +1985,7 @@
$data{$c->field} = $c->value;
}
my $t = $self->load_tmpl("admin.tmpl");
+ $t->param("status_" . $self->status() => 1);
$t->param(%data);
$t->output;
}
@@ -2096,6 +2119,34 @@
}
}
+sub status {
+ my ($self, $value) = @_;
+ if ($value) {
+ if ($value eq "open") {
+ if (-e $STATUS_FILE) {
+ unlink $STATUS_FILE;
+ # TODO check if the file does not exist any more after this action?
+ }
+ return "open";
+ }
+
+ open my $fh, ">", $STATUS_FILE;
+ if (not $fh) {
+ warn "Could not open status file '$STATUS_FILE' $!\n";
+ return;
+ }
+ print $fh $value;
+ return $value;
+ } else {
+ return "open" if not -e $STATUS_FILE;
+ open my $fh, "<", $STATUS_FILE;
+ my $value = <$fh>;
+ chomp $value;
+ return $value;
+ }
+}
+
+
=head2 _text2mail
replace the markup used in the posting by things we can use in
@@ -2112,6 +2163,9 @@
$_[0]->load_tmpl("help.tmpl")->output;
}
+sub site_is_closed {
+ $_[0]->load_tmpl("site_is_closed.tmpl")->output;
+}
1;
Modified: trunk/templates/admin.tmpl
===================================================================
--- trunk/templates/admin.tmpl 2005-02-06 18:53:29 UTC (rev 101)
+++ trunk/templates/admin.tmpl 2005-02-06 20:36:17 UTC (rev 102)
@@ -17,6 +17,11 @@
<tr><td>From address:</td><td><input name="from" value="<TMPL_VAR from>" size="50"></td></tr>
<tr><td>Page size:</td><td><input name="per_page" value="<TMPL_VAR per_page>" size="5"></td></tr>
<tr><td>RSS size:</td><td><input name="rss_size" value="<TMPL_VAR rss_size>" size="5"></td></tr>
+<tr><td>Status:</td><td><select name="status">
+ <option value="open" <TMPL_IF status_open>SELECTED</TMPL_IF>>Open</option>
+ <option value="readonly" <TMPL_IF status_readonly>SELECTED</TMPL_IF>>Read only</option>
+ <option value="closed" <TMPL_IF status_closed>SELECTED</TMPL_IF>>Closed</option>
+ </select></td></tr>
</table>
<p>
<input type="submit" value="Update" />
Added: trunk/templates/site_is_closed.tmpl
===================================================================
--- trunk/templates/site_is_closed.tmpl 2005-02-06 18:53:29 UTC (rev 101)
+++ trunk/templates/site_is_closed.tmpl 2005-02-06 20:36:17 UTC (rev 102)
@@ -0,0 +1,8 @@
+<TMPL_INCLUDE NAME="head.tmpl">
+<p id="pageTitle">Site is closed</p>
+
+<p>
+Temporarily the site is closed for upgrade. Please check back in a few minutes.
+</p>
+
+<TMPL_INCLUDE NAME="footer.tmpl">
More information about the Cpan-forum-commit
mailing list