Permalink
Browse files

Merge branch 'master' into session-as-object

Conflicts:
	inc/VegGuide/Build.pm
	lib/VegGuide/Config.pm
  • Loading branch information...
2 parents 8828913 + 3c563c9 commit a4db1f256cd26e4bd1b8b598823c6f9f9effe4a2 @autarch autarch committed Oct 19, 2011
Showing with 1,136 additions and 543 deletions.
  1. +2 −1 .hgignore → .gitignore
  2. +44 −13 bin/vg-backup
  3. +20 −0 bin/vg-delete-old-sessions
  4. +35 −44 bin/vg-log-monitor
  5. +2 −2 inc/VegGuide/Build.pm
  6. +40 −0 lib/VegGuide.pm
  7. +52 −68 lib/VegGuide/CachedHierarchy.pm
  8. +3 −2 lib/VegGuide/Config.pm
  9. +9 −0 lib/VegGuide/Controller/Base.pm
  10. +70 −1 lib/VegGuide/Controller/Entry.pm
  11. +20 −4 lib/VegGuide/Controller/Region.pm
  12. +1 −14 lib/VegGuide/Cuisine.pm
  13. +1 −1 lib/VegGuide/Image.pm
  14. +15 −20 lib/VegGuide/Location.pm
  15. +182 −3 lib/VegGuide/Plugin/ErrorHandling.pm
  16. +6 −4 lib/VegGuide/RSSWriter.pm
  17. +5 −4 lib/VegGuide/Role/Controller/Search.pm
  18. +49 −1 lib/VegGuide/User.pm
  19. +73 −50 lib/VegGuide/Vendor.pm
  20. +1 −0 lib/VegGuide/VendorSource.pm
  21. +3 −4 lib/VegGuide/VendorSource/Filter/MFA.pm
  22. +1 −1 lib/VegGuide/View/Mason.pm
  23. +0 −6 script/vegguide_apaches.pl
  24. +4 −0 script/vegguide_apaches.sh
  25. +1 −1 script/vegguide_sync_db.pl
  26. +15 −16 share/css-source/03-vegguide.css
  27. +2 −0 share/feed-templates/vendor-entry-content.mas
  28. BIN share/images/facebook-badge.gif
  29. BIN share/images/mfa-logo.gif
  30. +2 −0 share/js-source/VegGuide/Enhancements.js
  31. +83 −0 share/js-source/VegGuide/FrontPageGeolocation.js
  32. +1 −1 share/js-source/VegGuide/LoginForm.js
  33. +12 −6 share/mason/autohandler
  34. +15 −10 share/mason/entry/autohandler
  35. +2 −11 share/mason/entry/large-map
  36. +4 −3 share/mason/entry/ratings.mas
  37. +1 −0 share/mason/entry/review-form
  38. +3 −2 share/mason/entry/reviews
  39. +3 −2 share/mason/entry/supplementary.mas
  40. +18 −19 share/mason/entry/view
  41. +1 −1 share/mason/error/404
  42. +1 −1 share/mason/error/500
  43. +16 −7 share/mason/footer.mas
  44. +2 −3 share/mason/head.mas
  45. +23 −5 share/mason/lib/comments.mas
  46. +23 −0 share/mason/lib/contact-us.mas
  47. +4 −6 share/mason/lib/entries-table.mas
  48. +1 −2 share/mason/lib/feeds-list.mas
  49. +7 −0 share/mason/lib/filter/remove-last-br.mas
  50. +63 −0 share/mason/lib/format/address.mas
  51. +1 −1 share/mason/lib/front-page/nearby.mas
  52. +1 −9 share/mason/lib/google-map.mas
  53. +5 −1 share/mason/lib/hours-listing.mas
  54. +4 −1 share/mason/lib/link/license.mas
  55. +6 −1 share/mason/lib/link/user.mas
  56. +9 −9 share/mason/lib/search-filter-column.mas
  57. +0 −37 share/mason/page.mas
  58. +7 −7 share/mason/region/autohandler
  59. +0 −4 share/mason/shared/printable-entry-list
  60. +16 −29 share/mason/site/about
  61. +1 −0 share/mason/site/admin/menu
  62. +21 −0 share/mason/site/admin/region-maintainer-list
  63. +2 −2 share/mason/site/copyright
  64. +2 −8 share/mason/site/entry-list
  65. +79 −66 share/mason/site/help
  66. +3 −2 share/mason/site/source
  67. +1 −5 share/mason/user/individual/autohandler
  68. +5 −2 share/mason/user/login-form
  69. +3 −3 share/static/sample.rss
  70. +2 −0 system/etc/apache2-backend/apache2.conf
  71. +2 −0 system/etc/apache2-backend/sites-available/vegguide
  72. +8 −4 system/etc/apache2/apache2.conf
  73. +11 −10 system/etc/apache2/sites-available/vegguide.org
  74. +1 −0 system/etc/cron.d/vegguide
  75. +1 −1 system/etc/logrotate.d/apache2-backend
  76. +4 −2 system/usr/sbin/apache2ctl-backend
View
@@ -1,4 +1,3 @@
-syntax: glob
.\#*
\#*\#
*~
@@ -8,6 +7,8 @@ Build
_build
MANIFEST
META.yml
+MYMETA.yml
+MYMETA.json
README
Debian_CPANTS.txt
Makefile.PL
View
@@ -3,27 +3,58 @@
use strict;
use warnings;
+use Getopt::Long;
use VegGuide::Config;
exit 0
unless VegGuide::Config->IsProduction()
- && ! VegGuide::Config->IsTest();
+ && !VegGuide::Config->IsTest();
+
+my $verbose;
+my @hosts;
+my $dump = 1;
+
+GetOptions(
+ 'verbose' => \$verbose,
+ 'host=s@' => \@hosts,
+ 'dump!' => \$dump,
+);
+
+@hosts = qw( urth.org li205-70.members.linode.com )
+ unless @hosts;
# Should be run as me (autarch) on the vegguide.org box. No need to
# run as root.
+if ($dump) {
+ print "Dumping database\n\n" if $verbose;
-system( qw( mysqldump -u root RegVeg --ignore-table RegVeg.Session -r /home/autarch/RegVeg.sql ) )
- and die 'Cannot execute mysqldump';
+ system(
+ qw( mysqldump -u root RegVeg --ignore-table RegVeg.Session -r /home/autarch/RegVeg.sql )
+ ) and die 'Cannot execute mysqldump';
+}
-for my $source ( qw( /var/lib/vegguide/entry-images
- /var/lib/vegguide/user-images
- /var/lib/vegguide/skin-images
- /home/autarch/RegVeg.sql
- /var/lib/mailman/archives
- /var/lib/mailman/lists ) )
-{
- system( 'rsync', '-e', 'ssh -i /home/autarch/.ssh/id_rsa.backups', '-r',
- $source, 'urth.org:/home/autarch/backup/vegguide.org/' )
- and die "Cannot rsync $source";
+for my $host (@hosts) {
+ print "Rsyncing to $host\n\n";
+
+ for my $source (
+ qw( /var/lib/vegguide/entry-images
+ /var/lib/vegguide/user-images
+ /var/lib/vegguide/skin-images
+ /home/autarch/RegVeg.sql
+ /var/lib/mailman/archives
+ /var/lib/mailman/lists )
+ ) {
+
+ my @v = $verbose ? '-v' : ();
+ system(
+ 'rsync',
+ @v,
+ '-e', 'ssh -i /home/autarch/.ssh/id_rsa.backups',
+ '-r', '--links',
+ $source, $host . ':/home/autarch/backup/vegguide.org/'
+ ) and die "Cannot rsync $source to $host";
+ }
}
+
+print "vg-backup completed successfully\n\n";
View
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use DateTime;
+use Getopt::Long;
+use VegGuide::Schema;
+
+my %opts = ( days => 7 );
+GetOptions(
+ 'days:i' => \$opts{days},
+);
+
+my $dbh = VegGuide::Schema->Connect()->driver()->handle();
+
+$dbh->do(
+ 'DELETE FROM Session WHERE expires < ?', {},
+ DateTime->now( time_zone => 'UTC' )->subtract( days => $opts{days} )->epoch()
+);
View
@@ -14,24 +14,23 @@ use File::Tail;
use VegGuide::Config;
use VegGuide::JSON;
-
my $file = '/var/log/apache2-backend/error.log';
my $interval = 5 * 60;
-my $sleep = 60;
+my $sleep = 60;
-my $hostname = VegGuide::Config->Hostname();
-my $from = 'log-monitor@' . $hostname;
-my $sender = Email::Send->new( { mailer => 'Sendmail' } );
+my $hostname = VegGuide::Config->Hostname();
+my $from = 'log-monitor@' . $hostname;
+my $sender = Email::Send->new( { mailer => 'Sendmail' } );
my $last_sent = 0;
my @messages;
my $local_tz = DateTime::TimeZone->new( name => 'local' );
my $tail = _make_tail();
-while ( defined ( my $line = $tail->read() ) )
-{
+while ( defined( my $line = $tail->read() ) ) {
+
# Process all the messages that are pending if there's something
# in the logs.
next if process_line($line);
@@ -40,42 +39,37 @@ while ( defined ( my $line = $tail->read() ) )
sleep $sleep;
}
-sub process_line
-{
+sub process_line {
my $line = shift;
return if $line eq '';
my %message;
- if ( $line =~ /^([^[].*)/ )
- {
+ if ( $line =~ /^([^[].*)/ ) {
$message{date} = DateTime->now( time_zone => $local_tz );
$message{level} = 'warning';
$message{text} = $1;
}
- elsif ( $line =~ /^\[([^]]+)\] \[(error|warning)] vegguide: (.+)$/ )
- {
- $message{date} = DateTime::Format::HTTP->parse_datetime( $1, $local_tz );
+ elsif ( $line =~ /^\[([^]]+)\] \[(error|warning)] vegguide: (.+)$/ ) {
+ $message{date}
+ = DateTime::Format::HTTP->parse_datetime( $1, $local_tz );
$message{level} = $2;
my $text = $3;
- if ( $text =~ /^{.+}$/ )
- {
+ if ( $text =~ /^{.+}$/ ) {
$text =~ s/(\\.)/eval qq{"$1"}/eg;
my $error = VegGuide::JSON->Decode($text);
- $text = 'URI: ' . $error->{uri};
- if ( $error->{user} )
- {
+ $text = 'URI: ' . $error->{uri};
+ if ( $error->{user} ) {
$text .= "\n";
- $text .= 'User: ' . $error->{user}
+ $text .= 'User: ' . $error->{user};
}
- if ( $error->{referer} )
- {
+ if ( $error->{referer} ) {
$text .= "\n";
$text .= "Referer: $error->{referer}";
}
@@ -97,8 +91,7 @@ sub process_line
return 1;
}
-sub send_if_pending
-{
+sub send_if_pending {
return unless @messages;
my $now = time;
@@ -107,25 +100,24 @@ sub send_if_pending
my $body = '';
- for my $msg (@messages)
- {
+ for my $msg (@messages) {
$body .= "\n\n" if $body;
- $body .= $msg->{date}->strftime( '%Y-%m-%d %H:%M:%S' ) . q{ - } . $msg->{level};
+ $body .= $msg->{date}->strftime('%Y-%m-%d %H:%M:%S') . q{ - }
+ . $msg->{level};
$body .= "\n";
$body .= $msg->{text};
}
- my $email =
- Email::Simple->create
- ( header =>
- [ From => $from,
- To => 'autarch@urth.org',
- Subject => "VegGuide ($hostname) log errors",
- 'Message-ID' => Email::MessageID->new(),
- ],
- body => $body,
- );
+ my $email = Email::Simple->create(
+ header => [
+ From => $from,
+ To => 'autarch@urth.org',
+ Subject => "VegGuide ($hostname) log errors",
+ 'Message-ID' => Email::MessageID->new(),
+ ],
+ body => $body,
+ );
$sender->send($email);
@@ -134,11 +126,10 @@ sub send_if_pending
@messages = ();
}
-sub _make_tail
-{
- return
- File::Tail->new( name => $file,
- resetafter => 3600 * 8,
- nowait => 1,
- );
+sub _make_tail {
+ return File::Tail->new(
+ name => $file,
+ resetafter => 3600 * 8,
+ nowait => 1,
+ );
}
View
@@ -290,7 +290,7 @@ sub _find_things {
my $rule = File::Find::Rule->new();
$rule = $rule->or(
- $rule->new()->directory()->name('.hg')->prune()->discard(),
+ $rule->new()->directory()->name('.git')->prune()->discard(),
$rule->new()->name('*~')->prune()->discard(),
@@ -381,7 +381,7 @@ sub ACTION_write_revision_file {
require VegGuide::Config;
- my ($revision) = `hg tip` =~ /changeset:\s+(\d+)/;
+ my ($revision) = `git log -n 1` =~ /commit\s+(......)/;
return unless $revision;
View
@@ -44,6 +44,46 @@ __PACKAGE__->response_class('VegGuide::Response');
__PACKAGE__->setup();
+{
+
+ # monkey patch to fix Catalyst::Runtime issue
+ use Moose::Util qw/find_meta/;
+
+ sub setup_engine {
+ my ( $class, $requested_engine ) = @_;
+
+ my $engine = $class->engine_class($requested_engine);
+
+ # Don't really setup_engine -- see _setup_psgi_app for explanation.
+ return if $class->loading_psgi_file;
+
+ Class::MOP::load_class($engine);
+
+ if ( $ENV{MOD_PERL} ) {
+ my $apache = $class->engine_loader->auto;
+
+ my $meta = find_meta($class);
+ my $was_immutable = $meta->is_immutable;
+ my %immutable_options = $meta->immutable_options;
+ $meta->make_mutable if $was_immutable;
+
+ $meta->add_method(
+ handler => sub {
+ my $r = shift;
+ my $psgi_app = $class->_finalized_psgi_app;
+ $apache->call_app( $r, $psgi_app );
+ }
+ );
+
+ $meta->make_immutable(%immutable_options) if $was_immutable;
+ }
+
+ $class->engine( $engine->new );
+
+ return;
+ }
+}
+
sub skin {
my $self = shift;
Oops, something went wrong.

0 comments on commit a4db1f2

Please sign in to comment.