diff options
83 files changed, 1436 insertions, 846 deletions
diff --git a/perllib/Catalyst/Engine.pm b/perllib/Catalyst/Engine.pm new file mode 100644 index 000000000..236713976 --- /dev/null +++ b/perllib/Catalyst/Engine.pm @@ -0,0 +1,738 @@ +package Catalyst::Engine; + +use Moose; +with 'MooseX::Emulate::Class::Accessor::Fast'; + +use CGI::Simple::Cookie; +use Data::Dump qw/dump/; +use Errno 'EWOULDBLOCK'; +use HTML::Entities; +use HTTP::Body; +use HTTP::Headers; +use URI::QueryParam; +use Plack::Loader; +use Catalyst::EngineLoader; +use Encode (); +use utf8; + +use namespace::clean -except => 'meta'; + +# Amount of data to read from input on each pass +our $CHUNKSIZE = 64 * 1024; + +# XXX - this is only here for compat, do not use! +has env => ( is => 'rw', writer => '_set_env' ); +my $WARN_ABOUT_ENV = 0; +around env => sub { + my ($orig, $self, @args) = @_; + if(@args) { + warn "env as a writer is deprecated, you probably need to upgrade Catalyst::Engine::PSGI" + unless $WARN_ABOUT_ENV++; + return $self->_set_env(@args); + } + return $self->$orig; +}; + +# XXX - Only here for Engine::PSGI compat +sub prepare_connection { + my ($self, $ctx) = @_; + $ctx->request->prepare_connection; +} + +=head1 NAME + +Catalyst::Engine - The Catalyst Engine + +=head1 SYNOPSIS + +See L<Catalyst>. + +=head1 DESCRIPTION + +=head1 METHODS + + +=head2 $self->finalize_body($c) + +Finalize body. Prints the response output. + +=cut + +sub finalize_body { + my ( $self, $c ) = @_; + my $body = $c->response->body; + no warnings 'uninitialized'; + if ( blessed($body) && $body->can('read') or ref($body) eq 'GLOB' ) { + my $got; + do { + $got = read $body, my ($buffer), $CHUNKSIZE; + $got = 0 unless $self->write( $c, $buffer ); + } while $got > 0; + + close $body; + } + else { + $self->write( $c, $body ); + } + + my $res = $c->response; + $res->_writer->close; + $res->_clear_writer; + + return; +} + +=head2 $self->finalize_cookies($c) + +Create CGI::Simple::Cookie objects from $c->res->cookies, and set them as +response headers. + +=cut + +sub finalize_cookies { + my ( $self, $c ) = @_; + + my @cookies; + my $response = $c->response; + + foreach my $name (keys %{ $response->cookies }) { + + my $val = $response->cookies->{$name}; + + my $cookie = ( + blessed($val) + ? $val + : CGI::Simple::Cookie->new( + -name => $name, + -value => $val->{value}, + -expires => $val->{expires}, + -domain => $val->{domain}, + -path => $val->{path}, + -secure => $val->{secure} || 0, + -httponly => $val->{httponly} || 0, + ) + ); + if (!defined $cookie) { + $c->log->warn("undef passed in '$name' cookie value - not setting cookie") + if $c->debug; + next; + } + + push @cookies, $cookie->as_string; + } + + for my $cookie (@cookies) { + $response->headers->push_header( 'Set-Cookie' => $cookie ); + } +} + +=head2 $self->finalize_error($c) + +Output an appropriate error message. Called if there's an error in $c +after the dispatch has finished. Will output debug messages if Catalyst +is in debug mode, or a `please come back later` message otherwise. + +=cut + +sub _dump_error_page_element { + my ($self, $i, $element) = @_; + my ($name, $val) = @{ $element }; + + # This is fugly, but the metaclass is _HUGE_ and demands waaay too much + # scrolling. Suggestions for more pleasant ways to do this welcome. + local $val->{'__MOP__'} = "Stringified: " + . $val->{'__MOP__'} if ref $val eq 'HASH' && exists $val->{'__MOP__'}; + + my $text = encode_entities( dump( $val )); + sprintf <<"EOF", $name, $text; +<h2><a href="#" onclick="toggleDump('dump_$i'); return false">%s</a></h2> +<div id="dump_$i"> + <pre wrap="">%s</pre> +</div> +EOF +} + +sub finalize_error { + my ( $self, $c ) = @_; + + $c->res->content_type('text/html; charset=utf-8'); + my $name = ref($c)->config->{name} || join(' ', split('::', ref $c)); + + # Prevent Catalyst::Plugin::Unicode::Encoding from running. + # This is a little nasty, but it's the best way to be clean whether or + # not the user has an encoding plugin. + + if ($c->can('encoding')) { + $c->{encoding} = ''; + } + + my ( $title, $error, $infos ); + if ( $c->debug ) { + + # For pretty dumps + $error = join '', map { + '<p><code class="error">' + . encode_entities($_) + . '</code></p>' + } @{ $c->error }; + $error ||= 'No output'; + $error = qq{<pre wrap="">$error</pre>}; + $title = $name = "$name on Catalyst $Catalyst::VERSION"; + $name = "<h1>$name</h1>"; + + # Don't show context in the dump + $c->res->_clear_context; + + # Don't show body parser in the dump + $c->req->_clear_body; + + my @infos; + my $i = 0; + for my $dump ( $c->dump_these ) { + push @infos, $self->_dump_error_page_element($i, $dump); + $i++; + } + $infos = join "\n", @infos; + } + else { + $title = $name; + $error = ''; + $infos = <<""; +<pre> +(en) Please come back later +(fr) SVP veuillez revenir plus tard +(de) Bitte versuchen sie es spaeter nocheinmal +(at) Konnten's bitt'schoen spaeter nochmal reinschauen +(no) Vennligst prov igjen senere +(dk) Venligst prov igen senere +(pl) Prosze sprobowac pozniej +(pt) Por favor volte mais tarde +(ru) Попробуйте еще раз позже +(ua) Спробуйте ще раз пізніше +</pre> + + $name = ''; + } + $c->res->body( <<"" ); +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="Content-Language" content="en" /> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>$title</title> + <script type="text/javascript"> + <!-- + function toggleDump (dumpElement) { + var e = document.getElementById( dumpElement ); + if (e.style.display == "none") { + e.style.display = ""; + } + else { + e.style.display = "none"; + } + } + --> + </script> + <style type="text/css"> + body { + font-family: "Bitstream Vera Sans", "Trebuchet MS", Verdana, + Tahoma, Arial, helvetica, sans-serif; + color: #333; + background-color: #eee; + margin: 0px; + padding: 0px; + } + :link, :link:hover, :visited, :visited:hover { + color: #000; + } + div.box { + position: relative; + background-color: #ccc; + border: 1px solid #aaa; + padding: 4px; + margin: 10px; + } + div.error { + background-color: #cce; + border: 1px solid #755; + padding: 8px; + margin: 4px; + margin-bottom: 10px; + } + div.infos { + background-color: #eee; + border: 1px solid #575; + padding: 8px; + margin: 4px; + margin-bottom: 10px; + } + div.name { + background-color: #cce; + border: 1px solid #557; + padding: 8px; + margin: 4px; + } + code.error { + display: block; + margin: 1em 0; + overflow: auto; + } + div.name h1, div.error p { + margin: 0; + } + h2 { + margin-top: 0; + margin-bottom: 10px; + font-size: medium; + font-weight: bold; + text-decoration: underline; + } + h1 { + font-size: medium; + font-weight: normal; + } + /* from http://users.tkk.fi/~tkarvine/linux/doc/pre-wrap/pre-wrap-css3-mozilla-opera-ie.html */ + /* Browser specific (not valid) styles to make preformatted text wrap */ + pre { + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ + } + </style> +</head> +<body> + <div class="box"> + <div class="error">$error</div> + <div class="infos">$infos</div> + <div class="name">$name</div> + </div> +</body> +</html> + + # Trick IE. Old versions of IE would display their own error page instead + # of ours if we'd give it less than 512 bytes. + $c->res->{body} .= ( ' ' x 512 ); + + $c->res->{body} = Encode::encode("UTF-8", $c->res->{body}); + + # Return 500 + $c->res->status(500); +} + +=head2 $self->finalize_headers($c) + +Allows engines to write headers to response + +=cut + +sub finalize_headers { + my ($self, $ctx) = @_; + + $ctx->finalize_headers unless $ctx->response->finalized_headers; + return; +} + +=head2 $self->finalize_uploads($c) + +Clean up after uploads, deleting temp files. + +=cut + +sub finalize_uploads { + my ( $self, $c ) = @_; + + # N.B. This code is theoretically entirely unneeded due to ->cleanup(1) + # on the HTTP::Body object. + my $request = $c->request; + foreach my $key (keys %{ $request->uploads }) { + my $upload = $request->uploads->{$key}; + unlink grep { -e $_ } map { $_->tempname } + (ref $upload eq 'ARRAY' ? @{$upload} : ($upload)); + } + +} + +=head2 $self->prepare_body($c) + +sets up the L<Catalyst::Request> object body using L<HTTP::Body> + +=cut + +sub prepare_body { + my ( $self, $c ) = @_; + + $c->request->prepare_body; +} + +=head2 $self->prepare_body_chunk($c) + +Add a chunk to the request body. + +=cut + +# XXX - Can this be deleted? +sub prepare_body_chunk { + my ( $self, $c, $chunk ) = @_; + + $c->request->prepare_body_chunk($chunk); +} + +=head2 $self->prepare_body_parameters($c) + +Sets up parameters from body. + +=cut + +sub prepare_body_parameters { + my ( $self, $c ) = @_; + + $c->request->prepare_body_parameters; +} + +=head2 $self->prepare_parameters($c) + +Sets up parameters from query and post parameters. +If parameters have already been set up will clear +existing parameters and set up again. + +=cut + +sub prepare_parameters { + my ( $self, $c ) = @_; + + $c->request->_clear_parameters; + return $c->request->parameters; +} + +=head2 $self->prepare_path($c) + +abstract method, implemented by engines. + +=cut + +sub prepare_path { + my ($self, $ctx) = @_; + + my $env = $ctx->request->env; + + my $scheme = $ctx->request->secure ? 'https' : 'http'; + my $host = $env->{HTTP_HOST} || $env->{SERVER_NAME}; + my $port = $env->{SERVER_PORT} || 80; + my $base_path = $env->{SCRIPT_NAME} || "/"; + + # set the request URI + my $path; + if (!$ctx->config->{use_request_uri_for_path}) { + my $path_info = $env->{PATH_INFO}; + if ( exists $env->{REDIRECT_URL} ) { + $base_path = $env->{REDIRECT_URL}; + $base_path =~ s/\Q$path_info\E$//; + } + $path = $base_path . $path_info; + $path =~ s{^/+}{}; + $path =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go; + $path =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE + } + else { + my $req_uri = $env->{REQUEST_URI}; + $req_uri =~ s/\?.*$//; + $path = $req_uri; + $path =~ s{^/+}{}; + } + + # Using URI directly is way too slow, so we construct the URLs manually + my $uri_class = "URI::$scheme"; + + # HTTP_HOST will include the port even if it's 80/443 + $host =~ s/:(?:80|443)$//; + + if ($port !~ /^(?:80|443)$/ && $host !~ /:/) { + $host .= ":$port"; + } + + my $query = $env->{QUERY_STRING} ? '?' . $env->{QUERY_STRING} : ''; + my $uri = $scheme . '://' . $host . '/' . $path . $query; + + $ctx->request->uri( (bless \$uri, $uri_class)->canonical ); + + # set the base URI + # base must end in a slash + $base_path .= '/' unless $base_path =~ m{/$}; + + my $base_uri = $scheme . '://' . $host . $base_path; + + $ctx->request->base( bless \$base_uri, $uri_class ); + + return; +} + +=head2 $self->prepare_request($c) + +=head2 $self->prepare_query_parameters($c) + +process the query string and extract query parameters. + +=cut + +sub prepare_query_parameters { + my ($self, $c) = @_; + + my $env = $c->request->env; + my $query_string = exists $env->{QUERY_STRING} + ? $env->{QUERY_STRING} + : ''; + + # Check for keywords (no = signs) + # (yes, index() is faster than a regex :)) + if ( index( $query_string, '=' ) < 0 ) { + $c->request->query_keywords( $self->unescape_uri($query_string) ); + return; + } + + my %query; + + # replace semi-colons + $query_string =~ s/;/&/g; + + my @params = grep { length $_ } split /&/, $query_string; + + for my $item ( @params ) { + + my ($param, $value) + = map { $self->unescape_uri($_) } + split( /=/, $item, 2 ); + + $param = $self->unescape_uri($item) unless defined $param; + + if ( exists $query{$param} ) { + if ( ref $query{$param} ) { + push @{ $query{$param} }, $value; + } + else { + $query{$param} = [ $query{$param}, $value ]; + } + } + else { + $query{$param} = $value; + } + } + $c->request->query_parameters( \%query ); +} + +=head2 $self->prepare_read($c) + +Prepare to read by initializing the Content-Length from headers. + +=cut + +sub prepare_read { + my ( $self, $c ) = @_; + + # Initialize the amount of data we think we need to read + $c->request->_read_length; +} + +=head2 $self->prepare_request(@arguments) + +Populate the context object from the request object. + +=cut + +sub prepare_request { + my ($self, $ctx, %args) = @_; + $ctx->log->psgienv($args{env}) if $ctx->log->can('psgienv'); + $ctx->request->_set_env($args{env}); + $self->_set_env($args{env}); # Nasty back compat! + $ctx->response->_set_response_cb($args{response_cb}); +} + +=head2 $self->prepare_uploads($c) + +=cut + +sub prepare_uploads { + my ( $self, $c ) = @_; + + my $request = $c->request; + return unless $request->_body; + + my $uploads = $request->_body->upload; + my $parameters = $request->parameters; + foreach my $name (keys %$uploads) { + my $files = $uploads->{$name}; + my @uploads; + for my $upload (ref $files eq 'ARRAY' ? @$files : ($files)) { + my $headers = HTTP::Headers->new( %{ $upload->{headers} } ); + my $u = Catalyst::Request::Upload->new + ( + size => $upload->{size}, + type => scalar $headers->content_type, + headers => $headers, + tempname => $upload->{tempname}, + filename => $upload->{filename}, + ); + push @uploads, $u; + } + $request->uploads->{$name} = @uploads > 1 ? \@uploads : $uploads[0]; + + # support access to the filename as a normal param + my @filenames = map { $_->{filename} } @uploads; + # append, if there's already params with this name + if (exists $parameters->{$name}) { + if (ref $parameters->{$name} eq 'ARRAY') { + push @{ $parameters->{$name} }, @filenames; + } + else { + $parameters->{$name} = [ $parameters->{$name}, @filenames ]; + } + } + else { + $parameters->{$name} = @filenames > 1 ? \@filenames : $filenames[0]; + } + } +} + +=head2 $self->write($c, $buffer) + +Writes the buffer to the client. + +=cut + +sub write { + my ( $self, $c, $buffer ) = @_; + + $c->response->write($buffer); +} + +=head2 $self->read($c, [$maxlength]) + +Reads from the input stream by calling C<< $self->read_chunk >>. + +Maintains the read_length and read_position counters as data is read. + +=cut + +sub read { + my ( $self, $c, $maxlength ) = @_; + + $c->request->read($maxlength); +} + +=head2 $self->read_chunk($c, \$buffer, $length) + +Each engine implements read_chunk as its preferred way of reading a chunk +of data. Returns the number of bytes read. A return of 0 indicates that +there is no more data to be read. + +=cut + +sub read_chunk { + my ($self, $ctx) = (shift, shift); + return $ctx->request->read_chunk(@_); +} + +=head2 $self->run($app, $server) + +Start the engine. Builds a PSGI application and calls the +run method on the server passed in, which then causes the +engine to loop, handling requests.. + +=cut + +sub run { + my ($self, $app, $psgi, @args) = @_; + # @args left here rather than just a $options, $server for back compat with the + # old style scripts which send a few args, then a hashref + + # They should never actually be used in the normal case as the Plack engine is + # passed in got all the 'standard' args via the loader in the script already. + + # FIXME - we should stash the options in an attribute so that custom args + # like Gitalist's --git_dir are possible to get from the app without stupid tricks. + my $server = pop @args if (scalar @args && blessed $args[-1]); + my $options = pop @args if (scalar @args && ref($args[-1]) eq 'HASH'); + # Back compat hack for applications with old (non Catalyst::Script) scripts to work in FCGI. + if (scalar @args && !ref($args[0])) { + if (my $listen = shift @args) { + $options->{listen} ||= [$listen]; + } + } + if (! $server ) { + $server = Catalyst::EngineLoader->new(application_name => ref($self))->auto(%$options); + # We're not being called from a script, so auto detect what backend to + # run on. This should never happen, as mod_perl never calls ->run, + # instead the $app->handle method is called per request. + $app->log->warn("Not supplied a Plack engine, falling back to engine auto-loader (are your scripts ancient?)") + } + $app->run_options($options); + $server->run($psgi, $options); +} + +=head2 build_psgi_app ($app, @args) + +Builds and returns a PSGI application closure. (Raw, not wrapped in middleware) + +=cut + +sub build_psgi_app { + my ($self, $app, @args) = @_; + + return sub { + my ($env) = @_; + + return sub { + my ($respond) = @_; + confess("Did not get a response callback for writer, cannot continiue") unless $respond; + $app->handle_request(env => $env, response_cb => $respond); + }; + }; +} + +=head2 $self->unescape_uri($uri) + +Unescapes a given URI using the most efficient method available. Engines such +as Apache may implement this using Apache's C-based modules, for example. + +=cut + +sub unescape_uri { + my ( $self, $str ) = @_; + + $str =~ s/(?:%([0-9A-Fa-f]{2})|\+)/defined $1 ? chr(hex($1)) : ' '/eg; + + return $str; +} + +=head2 $self->finalize_output + +<obsolete>, see finalize_body + +=head2 $self->env + +Hash containing environment variables including many special variables inserted +by WWW server - like SERVER_*, REMOTE_*, HTTP_* ... + +Before accessing environment variables consider whether the same information is +not directly available via Catalyst objects $c->request, $c->engine ... + +BEWARE: If you really need to access some environment variable from your Catalyst +application you should use $c->engine->env->{VARNAME} instead of $ENV{VARNAME}, +as in some environments the %ENV hash does not contain what you would expect. + +=head1 AUTHORS + +Catalyst Contributors, see Catalyst.pm + +=head1 COPYRIGHT + +This library is free software. You can redistribute it and/or modify it under +the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; diff --git a/perllib/Catalyst/Log.pm b/perllib/Catalyst/Log.pm new file mode 100644 index 000000000..d72ee162f --- /dev/null +++ b/perllib/Catalyst/Log.pm @@ -0,0 +1,329 @@ +package Catalyst::Log; + +use Moose; +with 'MooseX::Emulate::Class::Accessor::Fast'; + +use Data::Dump; +use Class::MOP (); +use Carp qw/ cluck /; + +our %LEVELS = (); # Levels stored as bit field, ergo debug = 1, warn = 2 etc +our %LEVEL_MATCH = (); # Stored as additive, thus debug = 31, warn = 30 etc + +has level => (is => 'rw'); +has _body => (is => 'rw'); +has abort => (is => 'rw'); +has _psgi_logger => (is => 'rw', predicate => '_has_psgi_logger', clearer => '_clear_psgi_logger'); +has _psgi_errors => (is => 'rw', predicate => '_has_psgi_errors', clearer => '_clear_psgi_errors'); + +sub clear_psgi { + my $self = shift; + $self->_clear_psgi_logger; + $self->_clear_psgi_errors; +} + +sub psgienv { + my ($self, $env) = @_; + + $self->_psgi_logger($env->{'psgix.logger'}) if $env->{'psgix.logger'}; + $self->_psgi_errors($env->{'psgi.errors'}) if $env->{'psgi.errors'}; +} + + +{ + my @levels = qw[ debug info warn error fatal ]; + + my $meta = Class::MOP::get_metaclass_by_name(__PACKAGE__); + my $summed_level = 0; + for ( my $i = $#levels ; $i >= 0 ; $i-- ) { + + my $name = $levels[$i]; + + my $level = 1 << $i; + $summed_level |= $level; + + $LEVELS{$name} = $level; + $LEVEL_MATCH{$name} = $summed_level; + + $meta->add_method($name, sub { + my $self = shift; + + if ( $self->level & $level ) { + $self->_log( $name, @_ ); + } + }); + + $meta->add_method("is_$name", sub { + my $self = shift; + return $self->level & $level; + });; + } +} + +around new => sub { + my $orig = shift; + my $class = shift; + my $self = $class->$orig; + + $self->levels( scalar(@_) ? @_ : keys %LEVELS ); + + return $self; +}; + +sub levels { + my ( $self, @levels ) = @_; + $self->level(0); + $self->enable(@levels); +} + +sub enable { + my ( $self, @levels ) = @_; + my $level = $self->level; + for(map { $LEVEL_MATCH{$_} } @levels){ + $level |= $_; + } + $self->level($level); +} + +sub disable { + my ( $self, @levels ) = @_; + my $level = $self->level; + for(map { $LEVELS{$_} } @levels){ + $level &= ~$_; + } + $self->level($level); +} + +our $HAS_DUMPED; +sub _dump { + my $self = shift; + unless ($HAS_DUMPED++) { + cluck("Catalyst::Log::_dump is deprecated and will be removed. Please change to using your own Dumper.\n"); + } + $self->info( Data::Dump::dump(@_) ); +} + +sub _log { + my $self = shift; + my $level = shift; + my $message = join( "\n", @_ ); + if ($self->can('_has_psgi_logger') and $self->_has_psgi_logger) { + $self->_psgi_logger->({ + level => $level, + message => $message, + }); + } else { + $message .= "\n" unless $message =~ /\n$/; + my $body = $self->_body; + $body .= sprintf( "[%s] %s", $level, $message ); + $self->_body($body); + } +} + +sub _flush { + my $self = shift; + if ( $self->abort || !$self->_body ) { + $self->abort(undef); + } + else { + $self->_send_to_log( $self->_body ); + } + $self->_body(undef); +} + +sub _send_to_log { + my $self = shift; + if ($self->can('_has_psgi_errors') and $self->_has_psgi_errors) { + $self->_psgi_errors->print(@_); + } else { + print STDERR @_; + } +} + +# 5.7 compat code. +# Alias _body to body, add a before modifier to warn.. +my $meta = __PACKAGE__->meta; # Calling meta method here fine as we happen at compile time. +$meta->add_method('body', $meta->get_method('_body')); +my %package_hash; # Only warn once per method, per package. + # I haven't provided a way to disable them, patches welcome. +$meta->add_before_method_modifier('body', sub { + my $class = blessed(shift); + $package_hash{$class}++ || do { + warn("Class $class is calling the deprecated method Catalyst::Log->body method,\n" + . "this will be removed in Catalyst 5.81"); + }; +}); +# End 5.70 backwards compatibility hacks. + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); + +1; + +__END__ + +=for stopwords psgienv + +=head1 NAME + +Catalyst::Log - Catalyst Log Class + +=head1 SYNOPSIS + + $log = $c->log; + $log->debug($message); + $log->info($message); + $log->warn($message); + $log->error($message); + $log->fatal($message); + + if ( $log->is_debug ) { + # expensive debugging + } + + +See L<Catalyst>. + +=head1 DESCRIPTION + +This module provides the default, simple logging functionality for Catalyst. +If you want something different set C<< $c->log >> in your application module, +e.g.: + + $c->log( MyLogger->new ); + +Your logging object is expected to provide the interface described here. +Good alternatives to consider are Log::Log4Perl and Log::Dispatch. + +If you want to be able to log arbitrary warnings, you can do something along +the lines of + + $SIG{__WARN__} = sub { MyApp->log->warn(@_); }; + +however this is (a) global, (b) hairy and (c) may have unexpected side effects. +Don't say we didn't warn you. + +=head1 LOG LEVELS + +=head2 debug + + $log->is_debug; + $log->debug($message); + +=head2 info + + $log->is_info; + $log->info($message); + +=head2 warn + + $log->is_warn; + $log->warn($message); + +=head2 error + + $log->is_error; + $log->error($message); + +=head2 fatal + + $log->is_fatal; + $log->fatal($message); + +=head1 METHODS + +=head2 new + +Constructor. Defaults to enable all levels unless levels are provided in +arguments. + + $log = Catalyst::Log->new; + $log = Catalyst::Log->new( 'warn', 'error' ); + +=head2 level + +Contains a bitmask of the currently set log levels. + +=head2 levels + +Set log levels + + $log->levels( 'warn', 'error', 'fatal' ); + +=head2 enable + +Enable log levels + + $log->enable( 'warn', 'error' ); + +=head2 disable + +Disable log levels + + $log->disable( 'warn', 'error' ); + +=head2 is_debug + +=head2 is_error + +=head2 is_fatal + +=head2 is_info + +=head2 is_warn + +Is the log level active? + +=head2 abort + +Should Catalyst emit logs for this request? Will be reset at the end of +each request. + +*NOTE* This method is not compatible with other log apis, so if you plan +to use Log4Perl or another logger, you should call it like this: + + $c->log->abort(1) if $c->log->can('abort'); + +=head2 _send_to_log + + $log->_send_to_log( @messages ); + +This protected method is what actually sends the log information to STDERR. +You may subclass this module and override this method to get finer control +over the log output. + +=head2 psgienv $env + + $log->psgienv($env); + +NOTE: This is not meant for public consumption. + +Set the PSGI environment for this request. This ensures logs will be sent to +the right place. If the environment has a C<psgix.logger>, it will be used. If +not, we will send logs to C<psgi.errors> if that exists. As a last fallback, we +will send to STDERR as before. + +=head2 clear_psgi + +Clears the PSGI environment attributes set by L</psgienv>. + +=head2 meta + +=head1 SEE ALSO + +L<Catalyst>. + +=head1 AUTHORS + +Catalyst Contributors, see Catalyst.pm + +=head1 COPYRIGHT + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 723684793..4aa695ae5 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -28,7 +28,7 @@ If no search redirect back to the homepage. =cut -sub around_index : Path : Args(0) { +sub index : Path : Args(0) { my ( $self, $c ) = @_; # handle old coord systems @@ -302,15 +302,10 @@ sub ajax : Path('/ajax') { 'around/on_map_list_items.html', { on_map => $on_map, around_map => $around_map } ); - my $around_map_list_html = $c->render_fragment( - 'around/around_map_list_items.html', - { on_map => $on_map, around_map => $around_map } - ); # JSON encode the response my $json = { pins => $pins }; $json->{current} = $on_map_list_html if $on_map_list_html; - $json->{current_near} = $around_map_list_html if $around_map_list_html; my $body = JSON->new->utf8(1)->encode($json); $c->res->body($body); } diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index 9db9386f5..3c4ce2cf7 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -31,7 +31,7 @@ sub my : Path : Args(0) { $c->forward( '/reports/stash_report_filter_status' ); my $pins = []; - my $problems = {}; + my $problems = []; my $states = $c->stash->{filter_problem_states}; my $params = { @@ -60,9 +60,7 @@ sub my : Path : Args(0) { id => $problem->id, title => $problem->title, }; - my $state = $problem->is_fixed ? 'fixed' : $problem->is_closed ? 'closed' : 'confirmed'; - push @{ $problems->{$state} }, $problem; - push @{ $problems->{all} }, $problem; + push @$problems, $problem; } $c->stash->{problems_pager} = $rs->pager; $c->stash->{problems} = $problems; diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 3bd7e592b..407fc625e 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -492,6 +492,9 @@ sub stash_report_filter_status : Private { } elsif ( $status eq 'open' ) { $c->stash->{filter_status} = 'open'; $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->open_states(); + } elsif ( $status eq 'closed' ) { + $c->stash->{filter_status} = 'closed'; + $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->closed_states(); } elsif ( $status eq 'fixed' ) { $c->stash->{filter_status} = 'fixed'; $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->fixed_states(); diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index 37a81e444..a92021f0c 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -11,7 +11,7 @@ use Utils; __PACKAGE__->config( TEMPLATE_EXTENSION => '.html', - INCLUDE_PATH => [ # + INCLUDE_PATH => [ FixMyStreet->path_to( 'templates', 'web', 'base' ), ], ENCODING => 'utf8', @@ -38,6 +38,15 @@ TT View for FixMyStreet::App. =cut +# Override parent function so that errors are only logged once. +sub _rendering_error { + my ($self, $c, $err) = @_; + my $error = qq/Couldn't render template "$err"/; + # $c->log->error($error); + $c->error($error); + return 0; +} + =head2 loc [% loc('Some text to localize', 'Optional comment for translator') %] diff --git a/templates/web/fixmystreet/around/around_index.html b/templates/web/base/around/_error_multiple.html index 2cd51da17..15089ba6b 100644 --- a/templates/web/fixmystreet/around/around_index.html +++ b/templates/web/base/around/_error_multiple.html @@ -1,14 +1,3 @@ -[% pre_container_extra = INCLUDE 'around/postcode_form.html' %] -[% INCLUDE 'header.html', title = loc('Reporting a problem'), bodyclass = 'frontpage fullwidthpage' %] - -[% - # NOTE ON PARTIAL REPORTS: - # - # partial reports get a bit of extra text added, the form goes to - # '/report/new' and the partial hidden field is added to the form. -%] - -<div class="tablewrapper"> [% IF location_error %] [% INCLUDE 'around/location_error.html' %] [% END %] @@ -28,6 +17,3 @@ [% loc("Thanks for uploading your photo. We now need to locate your problem, so please enter a nearby street name or postcode in the box above :") %] </p> [% END %] -</div> - -[% INCLUDE 'footer.html' %] diff --git a/templates/web/base/around/_main.html b/templates/web/base/around/_main.html new file mode 100644 index 000000000..1b832cb49 --- /dev/null +++ b/templates/web/base/around/_main.html @@ -0,0 +1,8 @@ +<form action="[% c.uri_for('/around') %]" method="get" name="mapForm" id="mapForm"> + <div id="side-form"> + <div id="report-a-problem-main"> + [% pre_container_extra %] + [% INCLUDE 'around/_error_multiple.html' %] + </div> + </div> +</form> diff --git a/templates/web/base/around/_report_banner.html b/templates/web/base/around/_report_banner.html index 024fe08d9..9fcfe3640 100755 --- a/templates/web/base/around/_report_banner.html +++ b/templates/web/base/around/_report_banner.html @@ -1,10 +1,6 @@ -<p id="text_map" class="banner"> - [% loc( 'To <strong>report a problem</strong>, click on the map at the correct location.' ) %] - [% - tprintf( - loc("<small>If you cannot see the map, <a href='%s' rel='nofollow'>skip this step</a>.</small>"), - url_skip - ) - %] - <span id="text_map_arrow"></span> -</p> +<h1 class="big-green-banner"> + [% loc( 'Click map to report a problem' ) %] +</h1> +<a id="skip-this-step" href="[% url_skip %]" rel="nofollow"> + [% loc("Can't see the map? <em>Skip this step</em>") %] +</a> diff --git a/templates/web/base/around/around_index.html b/templates/web/base/around/around_index.html deleted file mode 100644 index 3b2714643..000000000 --- a/templates/web/base/around/around_index.html +++ /dev/null @@ -1,27 +0,0 @@ -[% - SET bodyclass = 'mappage'; - INCLUDE 'header.html', title => loc('Reporting a problem') -%] - -<form action="[% c.uri_for('/around') %]" method="get" name="mapForm" id="mapForm"> - <div id="side-form"> - <div id="report-a-problem-main"> - [% INCLUDE 'around/postcode_form.html' %] - - [% IF location_error %] - [% INCLUDE 'around/location_error.html' %] - [% END %] - - [% IF possible_location_matches %] - <p>[% loc('We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.') %]</p> - <ul class="pc_alternatives"> - [% FOREACH match IN possible_location_matches %] - <li><a href="/around?latitude=[% match.latitude | uri %];longitude=[% match.longitude | uri %]">[% match.address | html %]</a></li> - [% END %] - </ul> - [% END %] - </div> - </div> -</form> - -[% INCLUDE 'footer.html' %] diff --git a/templates/web/base/around/around_map_list_items.html b/templates/web/base/around/around_map_list_items.html deleted file mode 100644 index da75561b5..000000000 --- a/templates/web/base/around/around_map_list_items.html +++ /dev/null @@ -1,18 +0,0 @@ -[% IF around_map.size %] - [% FOREACH p IN around_map %] - - [% dist = tprintf("%.1f", (p.distance || 0) ) %] - - <li> - <a href="[% c.uri_for('/report', p.problem.id ) %]">[% p.problem.title | html %]</a> - <small>[% prettify_dt( p.problem.confirmed, 1 ) %], [% dist %]km</small> - [% IF p.problem.is_fixed %] - <small>[% loc('(fixed)') %]</small> - [% ELSIF p.problem.is_closed %] - <small>[% loc('(closed)') %]</small> - [% END %] - </li> - [% END %] -[% ELSE %] - <li>[% loc('No problems found.') %]</li> -[% END %] diff --git a/templates/web/base/around/index.html b/templates/web/base/around/index.html new file mode 100644 index 000000000..f2be5575c --- /dev/null +++ b/templates/web/base/around/index.html @@ -0,0 +1,13 @@ +[% pre_container_extra = INCLUDE 'around/postcode_form.html' %] +[% INCLUDE 'header.html', title = loc('Reporting a problem'), bodyclass = 'frontpage fullwidthpage' %] + +[% + # NOTE ON PARTIAL REPORTS: + # + # partial reports get a bit of extra text added, the form goes to + # '/report/new' and the partial hidden field is added to the form. +%] + +[% INCLUDE 'around/_main.html' %] + +[% INCLUDE 'footer.html' %] diff --git a/templates/web/fixmystreet/around/intro.html b/templates/web/base/around/intro.html index d71dad1d5..d71dad1d5 100644 --- a/templates/web/fixmystreet/around/intro.html +++ b/templates/web/base/around/intro.html diff --git a/templates/web/base/around/location_error.html b/templates/web/base/around/location_error.html index 9b907b64b..fc9b2b8ce 100644 --- a/templates/web/base/around/location_error.html +++ b/templates/web/base/around/location_error.html @@ -1 +1 @@ -<p class="error">[% location_error %]</p> +<p class="form-error">[% location_error %]</p> diff --git a/templates/web/base/around/on_map_list_items.html b/templates/web/base/around/on_map_list_items.html index 70a071406..90f836fc8 100644 --- a/templates/web/base/around/on_map_list_items.html +++ b/templates/web/base/around/on_map_list_items.html @@ -1,15 +1,14 @@ -[% IF on_map.size %] - [% FOREACH p IN on_map %] - <li> - <a href="[% c.uri_for('/report', p.id ) %]">[% p.title | html %]</a> - <small>[% prettify_dt( p.confirmed, 1 ) %]</small> - [% IF p.is_fixed %] - <small>[% loc('(fixed)') %]</small> - [% ELSIF p.is_closed %] - <small>[% loc('(closed)') %]</small> - [% END %] - </li> +[% all_reports = on_map.merge(around_map) %] +[% IF all_reports.size %] + [% FOREACH problem IN all_reports %] + [% UNLESS problem.title; + dist = tprintf("%.1f", (problem.distance || 0) ); + problem = problem.problem; + END %] + [% INCLUDE 'reports/_list-entry.html' %] [% END %] [% ELSE %] - <li>[% loc('No problems have been reported yet.') %]</li> + <li class="empty"> + <p>[% loc('There are no reports to show.') %]</p> + </li> [% END %] diff --git a/templates/web/base/around/postcode_form.html b/templates/web/base/around/postcode_form.html index f58d7285d..601f0ee9e 100644 --- a/templates/web/base/around/postcode_form.html +++ b/templates/web/base/around/postcode_form.html @@ -1,13 +1,26 @@ -[% - question = c.cobrand.enter_postcode_text || loc('Enter a nearby street name and area'); -%] - -<form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> - <label for="pc">[% question %]:</label> - <span><input type="text" name="pc" value="[% pc | html %]" id="pc" size="10" maxlength="200"> - <input type="submit" value="[% loc('Go') %]" id="sub"> - </span> - [% IF partial_token %] - <input type="hidden" name="partial" value="[% partial_token.token %]"> - [% END %] -</form> +<div id="front-main"> + <div id="front-main-container"> + [% INCLUDE 'around/intro.html' %] + + [% + question = c.cobrand.enter_postcode_text || loc('Enter a nearby street name and area'); + %] + + [% IF c.cobrand.moniker == 'fixmybarangay' %] + [% INCLUDE '_barangay_buttons.html' %] + [% ELSE %] + <form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> + <label for="pc">[% question %]:</label> + <div> + <input type="text" name="pc" value="[% pc | html %]" id="pc" size="10" maxlength="200" placeholder="[% tprintf(loc('e.g. ‘%s’ or ‘%s’'), c.cobrand.example_places) %]"> + <input type="submit" value="[% loc('Go') %]" id="sub"> + </div> + + [% IF partial_token %] + <input type="hidden" name="partial" value="[% partial_token.token %]"> + [% END %] + + </form> + [% END %] + </div> +</div> diff --git a/templates/web/base/around/tabbed_lists.html b/templates/web/base/around/tabbed_lists.html index 4ad7b35fc..2828027e2 100755 --- a/templates/web/base/around/tabbed_lists.html +++ b/templates/web/base/around/tabbed_lists.html @@ -1,23 +1,5 @@ -<div id="nearby_lists"> - - <h2>[% loc('Reports on and around the map') %]</h2> - - <ul id="current"> - [% INCLUDE "around/on_map_list_items.html" %] - </ul> - - <h2> - [% - tprintf( - loc( 'Closest nearby problems <small>(within %skm)</small>' ), - distance - ) - %] - </h2> - - <ul id="current_near"> - [% INCLUDE "around/around_map_list_items.html" %] - </ul> - -</div> +[% INCLUDE "reports/_list-filters.html" %] +<ul id="current" class="issue-list-a"> + [% INCLUDE "around/on_map_list_items.html" %] +</ul> diff --git a/templates/web/base/footer.html b/templates/web/base/footer.html index 102aacd25..3f4e5b551 100644 --- a/templates/web/base/footer.html +++ b/templates/web/base/footer.html @@ -23,9 +23,7 @@ <p><a href="/contact">[% tprintf(loc("Contact %s", "%s is the site name"), site_name) | replace(' ', ' ') %]</a></p> - <p>[% loc('Are you a <strong>developer</strong>? Would you like to contribute to FixMyStreet?') %] - [% loc('Our code is open source and <a href="http://github.com/mysociety/fixmystreet">available on GitHub</a>.') %] - </p> + [% INCLUDE 'front/footer-marketing.html' %] </div> diff --git a/templates/web/base/front/_list-entry.html b/templates/web/base/front/_list-entry.html new file mode 100755 index 000000000..2fcf5f296 --- /dev/null +++ b/templates/web/base/front/_list-entry.html @@ -0,0 +1 @@ +[% INCLUDE 'report/_item.html' no_fixed = 1 %] diff --git a/templates/web/fixmystreet/front/footer-marketing.html b/templates/web/base/front/footer-marketing.html index c0c9b4168..c0c9b4168 100644 --- a/templates/web/fixmystreet/front/footer-marketing.html +++ b/templates/web/base/front/footer-marketing.html diff --git a/templates/web/fixmystreet/front/javascript.html b/templates/web/base/front/javascript.html index 13aa5216c..13aa5216c 100644 --- a/templates/web/fixmystreet/front/javascript.html +++ b/templates/web/base/front/javascript.html diff --git a/templates/web/base/front/recent.html b/templates/web/base/front/recent.html new file mode 100644 index 000000000..de74f3326 --- /dev/null +++ b/templates/web/base/front/recent.html @@ -0,0 +1,23 @@ +[% + recent_photos = c.cobrand.recent_photos('front', 5); +%] + +[% IF recent_photos.size %] +<div id="front-recently"> + <h2> + [%- IF c.cobrand.moniker == 'hart' %] + Recently reported + [% ELSE %] + [% loc('Recently reported problems') %] + [% END -%] + </h2> + + <section class="full-width"> + <ul class="issue-list-a"> + [% FOREACH problem IN recent_photos %] + [% INCLUDE 'front/_list-entry.html' %] + [% END %] + </ul> + </section> +</div> +[% END %] diff --git a/templates/web/base/header.html b/templates/web/base/header.html index 479a349f3..1d7960661 100644 --- a/templates/web/base/header.html +++ b/templates/web/base/header.html @@ -11,6 +11,8 @@ <meta name="HandHeldFriendly" content="true"> <meta name="mobileoptimized" content="0"> + [% INCLUDE 'header_opengraph.html' %] + <link rel="stylesheet" href="[% version('/css/core.css') %]"> [% INCLUDE 'common_header_tags.html' %] @@ -24,14 +26,16 @@ %][% loc('FixMyStreet') %] [%- IF NOT title AND NOT c.req.path %]</h1>[% ELSE %]</a></div>[% END %] - <ul id="meta"> - [% IF c.user_exists %] - <li>[% tprintf(loc('Signed in as %s'), c.user.name || c.user.email) %] - <li class="last"><a href="/auth/sign_out">[% loc('Sign out') %]</a></li> - [% ELSE %] - <li> </li> - [% END %] - </ul> + [% IF c.user_exists %] + <div id="user-meta"> + <p> + [% tprintf(loc('Hi %s'), c.user.name || c.user.email) %] + <a href="/auth/sign_out">[% loc('sign out') %]</a> + </p> + </div> + [% END %] + + [% pre_container_extra %] <div id="mysociety" class="container" role="main"> diff --git a/templates/web/base/header_opengraph.html b/templates/web/base/header_opengraph.html index e69de29bb..f728d083f 100644 --- a/templates/web/base/header_opengraph.html +++ b/templates/web/base/header_opengraph.html @@ -0,0 +1,6 @@ + <meta property="og:url" content="[% c.cobrand.base_url %][% c.req.uri.path %]"> + <meta property="og:title" content="[% title || site_name %]"> + <meta property="og:site_name" content="[% site_name %]"> + [% IF c.req.uri.path == '/' %]<meta property="og:description" content="Report, view, and discuss local street-related problems.">[% END %] + <meta property="og:type" content="website"> + [% INCLUDE 'header_opengraph_image.html' %] diff --git a/templates/web/fixmystreet/header_opengraph_image.html b/templates/web/base/header_opengraph_image.html index 7ec1aabb0..7ec1aabb0 100644 --- a/templates/web/fixmystreet/header_opengraph_image.html +++ b/templates/web/base/header_opengraph_image.html diff --git a/templates/web/base/index.html b/templates/web/base/index.html index cea0f832a..0441b3efb 100644 --- a/templates/web/base/index.html +++ b/templates/web/base/index.html @@ -1,55 +1,20 @@ -[% INCLUDE 'header.html', title = '' %] +[% map_js = PROCESS 'front/javascript.html' %] + +[% pre_container_extra = PROCESS 'around/postcode_form.html' %] +[% INCLUDE 'header.html', title = '', bodyclass = 'frontpage fullwidthpage' %] [% IF error %] - <p class="error">[% error %]</p> + <p class="form-error">[% error %]</p> [% END %] -<p id="expl"> - [% - subhead = loc('(like graffiti, fly tipping, broken paving slabs, or street lighting)'); - %] - <strong>[% loc('Report, view, or discuss local problems') %]</strong> - [% IF subhead != ' ' %] - <small>[% subhead %]</small> - [% END %] -</p> - -[% PROCESS 'around/postcode_form.html' %] - -<div id="front_intro"> - [% INCLUDE 'index-steps.html' %] -</div> - -[% - recent_photos = c.cobrand.recent_photos('front', 3); - probs = c.cobrand.recent(); -%] +[% TRY %][% PROCESS 'front/pre-steps.html' %][% CATCH file %][% END %] -[% IF probs.size || recent_photos.size %] -<div id="front_recent"> - <h2>[% loc('Recently reported problems') %]</h2> - [% IF recent_photos.size %] - <p id="front_photos"> - [% FOREACH p IN recent_photos; - photo = p.get_photo_params; - %] - <a href="/report/[% p.id %]"><img border="0" height="100" - src="[% photo.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> - [% END %] - </p> - [% END %] +<div class="tablewrapper"> + <div id="front-howto"> + [% INCLUDE 'index-steps.html' %] + </div> - [% IF probs.size %] - <ul id="nearby_lists"> - [% FOREACH p IN probs %] - <li> - <a href="/report/[% p.id %]">[% p.title | html %]</a> - <small>[% prettify_dt( p.confirmed, 1 ) %]</small> - </li> - [% END %] - </ul> - [% END %] + [% INCLUDE 'front/recent.html' %] </div> -[% END %] -[% INCLUDE 'footer.html' %] +[% INCLUDE 'footer.html' pagefooter = 'yes' %] diff --git a/templates/web/greenwich/my/_problem-list.html b/templates/web/base/my/_problem-list.html index 1ff69f9fb..4b5fc73d6 100644 --- a/templates/web/greenwich/my/_problem-list.html +++ b/templates/web/base/my/_problem-list.html @@ -1,7 +1,7 @@ <ul class='issue-list-a full-width'> - [% IF problems.all %] - [% FOREACH p = problems.all %] - [% INCLUDE 'reports/_list-entry.html', problem = p, no_fixed =1 %] + [% IF problems.size %] + [% FOREACH problem = problems %] + [% INCLUDE 'reports/_list-entry.html' no_fixed = 1 %] [% END %] [% ELSE %] <li class="empty"> diff --git a/templates/web/base/my/my.html b/templates/web/base/my/my.html index f3ad3f2fe..91cf40b68 100644 --- a/templates/web/base/my/my.html +++ b/templates/web/base/my/my.html @@ -21,32 +21,20 @@ c.uri_for('/') ) %] [% END %] +[% IF c.cobrand.moniker == 'fixmybarangay' %] + [% INCLUDE '_barangay_buttons.html' %] +[% ELSIF c.cobrand.moniker == 'hart' %] + [% INCLUDE '_hart_hants_note.html' %] +[% END %] + +[% INCLUDE "reports/_list-filters.html", use_section_wrapper = 1 %] + [% INCLUDE 'pagination.html', pager = problems_pager, param = 'p' %] -[% FOREACH p = problems.confirmed %] - [% IF loop.first %]<h2>[% loc('Open reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[% FOREACH p = problems.fixed %] - [% IF loop.first %]<h2>[% loc('Fixed reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[% FOREACH p = problems.closed %] - [% IF loop.first %]<h2>[% loc('Closed reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[%# FOREACH p = problems.unconfirmed; - IF loop.first; - '<h2>' _ loc('Unconfirmed reports') _ '</h2>'; - END; - INCLUDE problem; -END %] +[% INCLUDE 'my/_problem-list.html' %] [% FOREACH u IN updates %] [% IF loop.first %] @@ -60,9 +48,9 @@ END %] <li>“[% u.text | html %]” – <a href="[% c.uri_for( '/report', u.problem_id ) %]#update_[% u.id %]">[% u.problem.title | html %]</a>. - <em class="council_sent_info"> + <p><small class="council_sent_info"> [% tprintf( loc("Added %s"), prettify_dt( u.confirmed, 'date' ) ) %] - </em> + </small></p> </li> [% "</ul>" IF loop.last %] [% END %] @@ -70,20 +58,3 @@ END %] </div> [% INCLUDE 'footer.html' %] - -[% BLOCK problem %] - [% "<ul class='issue-list-a full-width'>" IF loop.first %] - - <li><a href="[% c.uri_for( '/report', p.id ) %]">[% p.title | html %]</a> - <em class="council_sent_info"> – - [% IF p.whensent %] - [% tprintf( loc("Reported %s, to %s"), prettify_dt( p.confirmed, 'date' ), p.body(c) ) %] - [% ELSE %] - [% tprintf( loc("Reported %s"), prettify_dt( p.confirmed, 'date' ) ) %] - [% END %] - </em> - </li> - - [% "</ul>" IF loop.last %] -[% END %] - diff --git a/templates/web/fixmystreet/report/_item.html b/templates/web/base/report/_item.html index 8e2e73a8d..2fcfa9fb8 100644 --- a/templates/web/fixmystreet/report/_item.html +++ b/templates/web/base/report/_item.html @@ -7,16 +7,16 @@ [% END %] <h4>[% problem.title | html %]</h4> <small> - [% IF c.cobrand.moniker != 'fixamingata' %] [%# Default: %] + [%- IF c.cobrand.moniker != 'fixamingata' %] [%# Default: %] [%- prettify_dt( problem.confirmed, 1 ) %] - [% ELSE %] [%# Swedish cobrand fixamingata: %] + [%- ELSE %] [%# Swedish cobrand fixamingata: %] [%- prettify_dt( problem.confirmed) %] - [% END %] + [%- END %] [%- IF dist %], [% dist %]km[% END %] - [%- IF include_lastupdate AND problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %], + [%- IF problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %], [% tprintf(loc('last updated %s'), prettify_dt( problem.lastupdate, 1 ) ) %] [%- END %] - [% IF include_lastupdate %] + [% IF include_sentinfo %] [% IF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %] [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %] [% END %] diff --git a/templates/web/base/reports/_list-entry.html b/templates/web/base/reports/_list-entry.html index 445a5315f..dbf0a576e 100755 --- a/templates/web/base/reports/_list-entry.html +++ b/templates/web/base/reports/_list-entry.html @@ -1,6 +1 @@ -<li><a href="[% c.uri_for('/report/' _ problem.id) %]">[% problem.title | html %]</a> - [% IF problem.bodies_str_ids.size > 1 %] <small>[% loc('(sent to both)') %]</small> [% END %] - [% IF c.cobrand.moniker != 'emptyhomes' %] - [% IF problem.bodies_str_ids.size == 0 %] <small>[% loc('(not sent to council)') %]</small> [% END %] - [% END %] -</li> +[% INCLUDE 'report/_item.html' %] diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html index e69de29bb..4dd270dc6 100644 --- a/templates/web/base/reports/_list-filters.html +++ b/templates/web/base/reports/_list-filters.html @@ -0,0 +1,34 @@ +[% select_status = BLOCK %] + <select name="status" id="statuses"> + <option value="all"[% ' selected' IF filter_status == 'all' %]>[% loc('all reports') %]</option> + <option value="open"[% ' selected' IF filter_status == 'open' %]>[% loc('unfixed reports') %]</option> + <option value="closed"[% ' selected' IF filter_status == 'closed' %]>[% loc('closed reports') %]</option> + <option value="fixed"[% ' selected' IF filter_status == 'fixed' %]>[% loc('fixed reports') %]</option> + </select> +[% END %] + +[% select_category = BLOCK %] + <select name="filter_category" id="filter_categories"> + <option value="">[% loc('Everything') %]</option> + [% FOR category IN filter_categories %] + <option value="[% category | html %]"[% ' selected' IF filter_category == category %]> + [% category | html %] + </option> + [% END %] + </select> +[% END %] + +[% IF use_section_wrapper %] +<section class="full-width"> + <form method="get" action=""> +[% END %] + + <p class="report-list-filters"> + [% tprintf(loc('<label>Show %s</label> <label>about %s</label>', 'The first %s is a dropdown of all/fixed/etc, the second is a dropdown of categories'), select_status, select_category) %] + <input type="submit" value="[% loc('Go') %]"> + </p> + +[% IF use_section_wrapper %] + </form> +</section> +[% END %] diff --git a/templates/web/base/reports/_problem-list.html b/templates/web/base/reports/_problem-list.html index 45746e309..a4c78877a 100644 --- a/templates/web/base/reports/_problem-list.html +++ b/templates/web/base/reports/_problem-list.html @@ -8,7 +8,7 @@ <ul class="issue-list-a"> [% IF problems %] [% FOREACH problem IN problems %] - [% INCLUDE 'reports/_list-entry.html' %] + [% INCLUDE 'reports/_list-entry.html' include_sentinfo = 1 include_lastupdate = 1 %] [% END %] [% ELSE %] <li class="empty"> diff --git a/templates/web/base/reports/body.html b/templates/web/base/reports/body.html index ffb5d8838..dfaa98d6a 100755 --- a/templates/web/base/reports/body.html +++ b/templates/web/base/reports/body.html @@ -43,8 +43,8 @@ [% INCLUDE '_hart_hants_note.html' %] [% END %] -[% IF NOT body.areas.size AND c.cobrand.moniker == 'fixmystreet' %] - [% INCLUDE 'reports/_body_gone.html' %] +[% IF NOT body.areas.size %] + [% TRY %][% INCLUDE 'reports/_body_gone.html' %][% CATCH file %][% END %] [% ELSE %] [% INCLUDE 'reports/_rss.html' %] [% END %] diff --git a/templates/web/bromley/around/around_map_list_items.html b/templates/web/bromley/around/around_map_list_items.html deleted file mode 100644 index e69de29bb..000000000 --- a/templates/web/bromley/around/around_map_list_items.html +++ /dev/null diff --git a/templates/web/bromley/around/on_map_list_items.html b/templates/web/bromley/around/on_map_list_items.html deleted file mode 100644 index 893f5c698..000000000 --- a/templates/web/bromley/around/on_map_list_items.html +++ /dev/null @@ -1,11 +0,0 @@ -[% all_reports = on_map.merge(around_map) %] -[% IF all_reports.size %] - [% FOREACH problem IN all_reports %] - [% UNLESS problem.title; problem = problem.problem; END %] - [% INCLUDE "reports/_list-entry.html" %] - [% END %] -[% ELSE %] - <li class="empty"> - <p>[% loc('There are no reports to show.') %]</p> - </li> -[% END %] diff --git a/templates/web/bromley/around/tabbed_lists.html b/templates/web/bromley/around/tabbed_lists.html deleted file mode 100644 index ab95ec828..000000000 --- a/templates/web/bromley/around/tabbed_lists.html +++ /dev/null @@ -1,5 +0,0 @@ -[% INCLUDE "reports/_list-filters.html" %] - -<ul class="issue-list-a" id="current"> - [% INCLUDE "around/on_map_list_items.html" %] -</ul> diff --git a/templates/web/bromley/report/_item.html b/templates/web/bromley/report/_item.html index cd3fbc18c..6398f698e 100644 --- a/templates/web/bromley/report/_item.html +++ b/templates/web/bromley/report/_item.html @@ -1,5 +1,5 @@ -<li> -<a class="text" href="[% c.uri_for('/report', problem.id ) %]"> +<li class="[% c.cobrand.pin_colour(problem) %]"> +<a class="[% problem.category %] text" href="[% c.uri_for('/report', problem.id ) %]"> [% IF problem.photo; photo = problem.get_photo_params %] @@ -11,7 +11,7 @@ [%- IF include_lastupdate AND problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %], [% tprintf(loc('last updated %s'), prettify_dt( problem.lastupdate, 1 ) ) %] [%- END %] - [% IF include_lastupdate %] + [% IF include_sentinfo %] [% IF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %] [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %] [% END %] diff --git a/templates/web/bromley/reports/_list-entry.html b/templates/web/bromley/reports/_list-entry.html deleted file mode 100644 index 5a4258b2c..000000000 --- a/templates/web/bromley/reports/_list-entry.html +++ /dev/null @@ -1,29 +0,0 @@ -[% include_lastupdate = 1 %] -<li class="[% c.cobrand.pin_colour(problem) %]"> - <a class="[% problem.category %] text" href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.photo; - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> - [% END %] - <span>[% problem.title | html %]</span><br /> - <small>[% prettify_dt( problem.confirmed, 1 ) %] - [%- IF dist %], [% dist %]km[% END %] - [%- IF include_lastupdate AND problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %], - [% tprintf(loc('last updated %s'), prettify_dt( problem.lastupdate, 1 ) ) %] - [%- END %] - [% IF include_lastupdate %] - [% IF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %] - [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %] - [% END %] - [% END %] - [% IF NOT no_fixed AND problem.is_fixed %] - [% loc('(fixed)') %] - [% ELSIF NOT no_fixed AND problem.is_closed %] - [% loc('(closed)') %] - [% END %]</small> - </a> -</li> - - - diff --git a/templates/web/bromley/reports/_list-filters.html b/templates/web/bromley/reports/_list-filters.html deleted file mode 120000 index 0422239b4..000000000 --- a/templates/web/bromley/reports/_list-filters.html +++ /dev/null @@ -1 +0,0 @@ -../../oxfordshire/reports/_list-filters.html
\ No newline at end of file diff --git a/templates/web/fixmybarangay/around/intro.html b/templates/web/fixmybarangay/around/intro.html new file mode 100644 index 000000000..b876de453 --- /dev/null +++ b/templates/web/fixmybarangay/around/intro.html @@ -0,0 +1,2 @@ + <h1>View local problems</h1> + <h2>(potholes or street lighting)</h2> diff --git a/templates/web/fixmystreet-uk-councils/report/_item-with-pin.html b/templates/web/fixmystreet-uk-councils/report/_item-with-pin.html new file mode 100644 index 000000000..cd70410d3 --- /dev/null +++ b/templates/web/fixmystreet-uk-councils/report/_item-with-pin.html @@ -0,0 +1,6 @@ +<li class="[% c.cobrand.pin_colour(problem) %]"> + <a href="[% c.uri_for('/report', problem.id ) %]" class="[% problem.category %]"> + <h3>[% problem.title | html %]</h3> + <p>Reported [%- prettify_dt( problem.confirmed, 1 ) %]</p> + </a> +</li> diff --git a/templates/web/fixmystreet/around/_main.html b/templates/web/fixmystreet/around/_main.html new file mode 100644 index 000000000..900dcb6aa --- /dev/null +++ b/templates/web/fixmystreet/around/_main.html @@ -0,0 +1,3 @@ +<div class="tablewrapper"> + [% INCLUDE 'around/_error_multiple.html' %] +</div> diff --git a/templates/web/fixmystreet/around/_report_banner.html b/templates/web/fixmystreet/around/_report_banner.html deleted file mode 100755 index 9fcfe3640..000000000 --- a/templates/web/fixmystreet/around/_report_banner.html +++ /dev/null @@ -1,6 +0,0 @@ -<h1 class="big-green-banner"> - [% loc( 'Click map to report a problem' ) %] -</h1> -<a id="skip-this-step" href="[% url_skip %]" rel="nofollow"> - [% loc("Can't see the map? <em>Skip this step</em>") %] -</a> diff --git a/templates/web/fixmystreet/around/around_map_list_items.html b/templates/web/fixmystreet/around/around_map_list_items.html deleted file mode 100644 index 612b37d00..000000000 --- a/templates/web/fixmystreet/around/around_map_list_items.html +++ /dev/null @@ -1,9 +0,0 @@ -[% IF around_map.size %] - [% FOREACH p IN around_map %] - [% INCLUDE 'report/_item.html' - problem = p.problem, - dist = tprintf("%.1f", (p.distance || 0) ) %] - [% END %] -[% ELSE %] - <li><p>[% loc('No problems found.') %]</p></li> -[% END %] diff --git a/templates/web/fixmystreet/around/location_error.html b/templates/web/fixmystreet/around/location_error.html deleted file mode 100644 index fc9b2b8ce..000000000 --- a/templates/web/fixmystreet/around/location_error.html +++ /dev/null @@ -1 +0,0 @@ -<p class="form-error">[% location_error %]</p> diff --git a/templates/web/fixmystreet/around/on_map_list_items.html b/templates/web/fixmystreet/around/on_map_list_items.html deleted file mode 100644 index 7b66d4267..000000000 --- a/templates/web/fixmystreet/around/on_map_list_items.html +++ /dev/null @@ -1,7 +0,0 @@ -[% IF on_map.size %] - [% FOREACH problem IN on_map %] - [% INCLUDE 'report/_item.html' %] - [% END %] -[% ELSE %] - <li><p>[% loc('No problems have been reported yet.') %]</p></li> -[% END %] diff --git a/templates/web/fixmystreet/around/postcode_form.html b/templates/web/fixmystreet/around/postcode_form.html deleted file mode 100644 index ed5d700f0..000000000 --- a/templates/web/fixmystreet/around/postcode_form.html +++ /dev/null @@ -1,31 +0,0 @@ -<div id="front-main"> - <div id="front-main-container"> - [% IF c.cobrand.moniker == 'fixmybarangay' %] - <h1>View local problems</h1> - <h2>(potholes or street lighting)</h2> - [% ELSE %] - [% INCLUDE 'around/intro.html' %] - [% END %] - - [% - question = c.cobrand.enter_postcode_text || loc('Enter a nearby street name and area'); - %] - - [% IF c.cobrand.moniker == 'fixmybarangay' %] - [% INCLUDE '_barangay_buttons.html' %] - [% ELSE %] - <form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> - <label for="pc">[% question %]:</label> - <div> - <input type="text" name="pc" value="[% pc | html %]" id="pc" size="10" maxlength="200" placeholder="[% tprintf(loc('e.g. ‘%s’ or ‘%s’'), c.cobrand.example_places) %]"> - <input type="submit" value="[% loc('Go') %]" id="sub"> - </div> - - [% IF partial_token %] - <input type="hidden" name="partial" value="[% partial_token.token %]"> - [% END %] - - </form> - [% END %] - </div> -</div> diff --git a/templates/web/fixmystreet/around/tabbed_lists.html b/templates/web/fixmystreet/around/tabbed_lists.html deleted file mode 100644 index 77c5a521b..000000000 --- a/templates/web/fixmystreet/around/tabbed_lists.html +++ /dev/null @@ -1,14 +0,0 @@ -<menu id="problems-nav" class="tab-nav"> - <ul> - <li><a href="#current">[% loc('Problems on the map') %]</a></li> - <li><a href="#current_near">[% loc( 'Problems nearby' ) %]</a></li> - </ul> -</menu> - -<ul id="current" class="issue-list-a tab"> - [% INCLUDE "around/on_map_list_items.html" %] -</ul> - -<ul id="current_near" class="issue-list-a tab"> - [% INCLUDE "around/around_map_list_items.html" %] -</ul> diff --git a/templates/web/fixmystreet/front/recent.html b/templates/web/fixmystreet/front/recent.html deleted file mode 100644 index 4cb575489..000000000 --- a/templates/web/fixmystreet/front/recent.html +++ /dev/null @@ -1,24 +0,0 @@ - [% - recent_photos = c.cobrand.recent_photos('front', 5); - %] - - [% IF recent_photos.size %] - <div id="front-recently"> - <h2> - [% IF c.cobrand.moniker == 'hart' %] - Recently reported - [% ELSE %] - [% loc('Recently reported problems') %] - [% END %] - </h2> - - <section class="full-width"> - <ul class="issue-list-a"> - [% FOREACH problem IN recent_photos %] - [% INCLUDE 'report/_item.html', no_fixed = 1 %] - [% END %] - </ul> - </section> - - </div> - [% END %] diff --git a/templates/web/fixmystreet/header_opengraph.html b/templates/web/fixmystreet/header_opengraph.html deleted file mode 100644 index f728d083f..000000000 --- a/templates/web/fixmystreet/header_opengraph.html +++ /dev/null @@ -1,6 +0,0 @@ - <meta property="og:url" content="[% c.cobrand.base_url %][% c.req.uri.path %]"> - <meta property="og:title" content="[% title || site_name %]"> - <meta property="og:site_name" content="[% site_name %]"> - [% IF c.req.uri.path == '/' %]<meta property="og:description" content="Report, view, and discuss local street-related problems.">[% END %] - <meta property="og:type" content="website"> - [% INCLUDE 'header_opengraph_image.html' %] diff --git a/templates/web/fixmystreet/index.html b/templates/web/fixmystreet/index.html deleted file mode 100644 index 0441b3efb..000000000 --- a/templates/web/fixmystreet/index.html +++ /dev/null @@ -1,20 +0,0 @@ -[% map_js = PROCESS 'front/javascript.html' %] - -[% pre_container_extra = PROCESS 'around/postcode_form.html' %] -[% INCLUDE 'header.html', title = '', bodyclass = 'frontpage fullwidthpage' %] - -[% IF error %] - <p class="form-error">[% error %]</p> -[% END %] - -[% TRY %][% PROCESS 'front/pre-steps.html' %][% CATCH file %][% END %] - -<div class="tablewrapper"> - <div id="front-howto"> - [% INCLUDE 'index-steps.html' %] - </div> - - [% INCLUDE 'front/recent.html' %] -</div> - -[% INCLUDE 'footer.html' pagefooter = 'yes' %] diff --git a/templates/web/fixmystreet/my/_problem-list.html b/templates/web/fixmystreet/my/_problem-list.html deleted file mode 100644 index 1a891de80..000000000 --- a/templates/web/fixmystreet/my/_problem-list.html +++ /dev/null @@ -1,27 +0,0 @@ -[% FOREACH p = problems.confirmed %] - [% IF loop.first %]<h2>[% loc('Open reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[% FOREACH p = problems.fixed %] - [% IF loop.first %]<h2>[% loc('Fixed reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[% FOREACH p = problems.closed %] - [% IF loop.first %]<h2>[% loc('Closed reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[%# FOREACH p = problems.unconfirmed; - IF loop.first; - '<h2>' _ loc('Unconfirmed reports') _ '</h2>'; - END; - INCLUDE problem; -END %] - -[% BLOCK problem %] - [% "<ul class='issue-list-a full-width'>" IF loop.first %] - [% INCLUDE 'report/_item.html', problem = p, no_fixed =1 %] - [% "</ul>" IF loop.last %] -[% END %] diff --git a/templates/web/fixmystreet/my/my.html b/templates/web/fixmystreet/my/my.html deleted file mode 100644 index 16779e503..000000000 --- a/templates/web/fixmystreet/my/my.html +++ /dev/null @@ -1,60 +0,0 @@ -[% - SET bodyclass = 'mappage'; - PROCESS "maps/${map.type}.html" IF problems.size; - INCLUDE 'header.html', title = loc('Your Reports'); -%] - -[% IF problems.size %] - [% map_html %] - </div> - <div id="side"> -[% ELSE %] - <div id="skipped-map"> -[% END %] - -<h1>[% loc('Your Reports') %]</h1> - -<p><a href="/auth/change_password">[% loc('Change password') %]</a></p> - -[% IF ! has_content %] -[% tprintf( loc('You haven’t created any reports yet. <a href="%s">Report a problem now.</a>'), - c.uri_for('/') ) %] -[% END %] - -[% IF c.cobrand.moniker == 'fixmybarangay' %] - [% INCLUDE '_barangay_buttons.html' %] -[% ELSIF c.cobrand.moniker == 'hart' %] - [% INCLUDE '_hart_hants_note.html' %] -[% END %] - -[% INCLUDE "reports/_list-filters.html", use_section_wrapper = 1 %] - -[% INCLUDE 'pagination.html', - pager = problems_pager, - param = 'p' -%] - -[% INCLUDE 'my/_problem-list.html' %] - -[% FOREACH u IN updates %] - [% IF loop.first %] - <h2>[% loc('Your updates') %]</h2> - [% INCLUDE 'pagination.html', - pager = updates_pager, - param = 'u' - %] - <ul class="issue-list full-width"> - [% END %] - - <li>“[% u.text | html %]” - – <a href="[% c.uri_for( '/report', u.problem_id ) %]#update_[% u.id %]">[% u.problem.title | html %]</a>. - <p><small class="council_sent_info"> - [% tprintf( loc("Added %s"), prettify_dt( u.confirmed, 'date' ) ) %] - </small></p> - </li> - [% "</ul>" IF loop.last %] -[% END %] - -</div> - -[% INCLUDE 'footer.html' %] diff --git a/templates/web/fixmystreet/reports/_list-entry.html b/templates/web/fixmystreet/reports/_list-entry.html deleted file mode 100755 index 8509df376..000000000 --- a/templates/web/fixmystreet/reports/_list-entry.html +++ /dev/null @@ -1 +0,0 @@ -[% INCLUDE 'report/_item.html', include_lastupdate = 1 %] diff --git a/templates/web/greenwich/around/around_map_list_items.html b/templates/web/greenwich/around/around_map_list_items.html deleted file mode 100644 index e69de29bb..000000000 --- a/templates/web/greenwich/around/around_map_list_items.html +++ /dev/null diff --git a/templates/web/greenwich/around/on_map_list_items.html b/templates/web/greenwich/around/on_map_list_items.html deleted file mode 100644 index 893f5c698..000000000 --- a/templates/web/greenwich/around/on_map_list_items.html +++ /dev/null @@ -1,11 +0,0 @@ -[% all_reports = on_map.merge(around_map) %] -[% IF all_reports.size %] - [% FOREACH problem IN all_reports %] - [% UNLESS problem.title; problem = problem.problem; END %] - [% INCLUDE "reports/_list-entry.html" %] - [% END %] -[% ELSE %] - <li class="empty"> - <p>[% loc('There are no reports to show.') %]</p> - </li> -[% END %] diff --git a/templates/web/greenwich/around/tabbed_lists.html b/templates/web/greenwich/around/tabbed_lists.html deleted file mode 100644 index 0d7dfddfc..000000000 --- a/templates/web/greenwich/around/tabbed_lists.html +++ /dev/null @@ -1,5 +0,0 @@ -[% INCLUDE "reports/_list-filters.html" %] - -<ul class="report-list" id="current"> - [% INCLUDE "around/on_map_list_items.html" %] -</ul> diff --git a/templates/web/greenwich/reports/_list-entry.html b/templates/web/greenwich/reports/_list-entry.html index cd70410d3..b24ef2260 100644 --- a/templates/web/greenwich/reports/_list-entry.html +++ b/templates/web/greenwich/reports/_list-entry.html @@ -1,6 +1 @@ -<li class="[% c.cobrand.pin_colour(problem) %]"> - <a href="[% c.uri_for('/report', problem.id ) %]" class="[% problem.category %]"> - <h3>[% problem.title | html %]</h3> - <p>Reported [%- prettify_dt( problem.confirmed, 1 ) %]</p> - </a> -</li> +[% INCLUDE 'report/_item-with-pin.html' %] diff --git a/templates/web/greenwich/reports/_list-filters.html b/templates/web/greenwich/reports/_list-filters.html deleted file mode 120000 index 0422239b4..000000000 --- a/templates/web/greenwich/reports/_list-filters.html +++ /dev/null @@ -1 +0,0 @@ -../../oxfordshire/reports/_list-filters.html
\ No newline at end of file diff --git a/templates/web/hart/footer.html b/templates/web/hart/footer.html index 14adf983d..312f63ff4 100644 --- a/templates/web/hart/footer.html +++ b/templates/web/hart/footer.html @@ -23,7 +23,7 @@ </div> <div class="nav-wrapper-2 clearfix"> <div id="main-nav" class="clearfix" role="navigation"> - <ul> + <ul class="nav-menu"> <li> <a href="http://www.hart.gov.uk/home">Home</a> </li> diff --git a/templates/web/oxfordshire/around/around_map_list_items.html b/templates/web/oxfordshire/around/around_map_list_items.html deleted file mode 100644 index e69de29bb..000000000 --- a/templates/web/oxfordshire/around/around_map_list_items.html +++ /dev/null diff --git a/templates/web/oxfordshire/around/on_map_list_items.html b/templates/web/oxfordshire/around/on_map_list_items.html deleted file mode 100644 index 893f5c698..000000000 --- a/templates/web/oxfordshire/around/on_map_list_items.html +++ /dev/null @@ -1,11 +0,0 @@ -[% all_reports = on_map.merge(around_map) %] -[% IF all_reports.size %] - [% FOREACH problem IN all_reports %] - [% UNLESS problem.title; problem = problem.problem; END %] - [% INCLUDE "reports/_list-entry.html" %] - [% END %] -[% ELSE %] - <li class="empty"> - <p>[% loc('There are no reports to show.') %]</p> - </li> -[% END %] diff --git a/templates/web/oxfordshire/around/tabbed_lists.html b/templates/web/oxfordshire/around/tabbed_lists.html deleted file mode 100644 index 0d7dfddfc..000000000 --- a/templates/web/oxfordshire/around/tabbed_lists.html +++ /dev/null @@ -1,5 +0,0 @@ -[% INCLUDE "reports/_list-filters.html" %] - -<ul class="report-list" id="current"> - [% INCLUDE "around/on_map_list_items.html" %] -</ul> diff --git a/templates/web/oxfordshire/my/_problem-list.html b/templates/web/oxfordshire/my/_problem-list.html deleted file mode 100644 index 1ff69f9fb..000000000 --- a/templates/web/oxfordshire/my/_problem-list.html +++ /dev/null @@ -1,25 +0,0 @@ -<ul class='issue-list-a full-width'> - [% IF problems.all %] - [% FOREACH p = problems.all %] - [% INCLUDE 'reports/_list-entry.html', problem = p, no_fixed =1 %] - [% END %] - [% ELSE %] - <li class="empty"> - <p>[% loc('There are no reports to show.') %]</p> - </li> - [% END %] -</ul> - -[% IF ! problems.size %] -<!-- Preserve behaviour of map filters despite map not being shown --> -<script type="text/javascript"> - (function($) { - $(function() { - $(".report-list-filters [type=submit]").hide(); - $(".report-list-filters select").change(function() { - $(this).closest("form").submit(); - }); - }) - })(window.jQuery); -</script> -[% END %] diff --git a/templates/web/oxfordshire/reports/_list-entry.html b/templates/web/oxfordshire/reports/_list-entry.html index cd70410d3..b24ef2260 100644 --- a/templates/web/oxfordshire/reports/_list-entry.html +++ b/templates/web/oxfordshire/reports/_list-entry.html @@ -1,6 +1 @@ -<li class="[% c.cobrand.pin_colour(problem) %]"> - <a href="[% c.uri_for('/report', problem.id ) %]" class="[% problem.category %]"> - <h3>[% problem.title | html %]</h3> - <p>Reported [%- prettify_dt( problem.confirmed, 1 ) %]</p> - </a> -</li> +[% INCLUDE 'report/_item-with-pin.html' %] diff --git a/templates/web/oxfordshire/reports/_list-filters.html b/templates/web/oxfordshire/reports/_list-filters.html deleted file mode 100644 index 5d610261b..000000000 --- a/templates/web/oxfordshire/reports/_list-filters.html +++ /dev/null @@ -1,32 +0,0 @@ -[% IF use_section_wrapper %] -<section class="full-width"> - <form method="get" action=""> -[% END %] - - <p class="report-list-filters"> - <label> - Show - <select name="status" id="statuses"> - <option value="all"[% ' selected' IF filter_status == 'all' %]>all reports</option> - <option value="open"[% ' selected' IF filter_status == 'open' %]>unfixed reports</option> - <option value="fixed"[% ' selected' IF filter_status == 'fixed' %]>fixed reports</option> - </select> - </label> - <label> - about - <select name="filter_category" id="filter_categories"> - <option value="">Everything</option> - [% FOR category IN filter_categories %] - <option value="[% category | html %]"[% ' selected' IF filter_category == category %]> - [% category | html %] - </option> - [% END %] - </select> - </label> - <input type=submit value="Go" /> - </p> - -[% IF use_section_wrapper %] - </form> -</section> -[% END %] diff --git a/templates/web/seesomething/around/around_index.html b/templates/web/seesomething/around/index.html index a143e90a2..a143e90a2 100644 --- a/templates/web/seesomething/around/around_index.html +++ b/templates/web/seesomething/around/index.html diff --git a/templates/web/zerotb/around/around_map_list_items.html b/templates/web/zerotb/around/around_map_list_items.html deleted file mode 100644 index 225ddde6e..000000000 --- a/templates/web/zerotb/around/around_map_list_items.html +++ /dev/null @@ -1,9 +0,0 @@ -[% IF around_map.size %] - [% FOREACH p IN around_map %] - [% INCLUDE 'report/_item.html' - problem = p.problem, - dist = tprintf("%.1f", (p.distance || 0) ) %] - [% END %] -[% ELSE %] - <li><p>[% loc('No clinics found.') %]</p></li> -[% END %] diff --git a/templates/web/zerotb/around/on_map_list_items.html b/templates/web/zerotb/around/on_map_list_items.html index 838e2e9fa..2cc7251e4 100644 --- a/templates/web/zerotb/around/on_map_list_items.html +++ b/templates/web/zerotb/around/on_map_list_items.html @@ -1,7 +1,14 @@ -[% IF on_map.size %] - [% FOREACH problem IN on_map %] +[% all_reports = on_map.merge(around_map) %] +[% IF all_reports.size %] + [% FOREACH problem IN all_reports %] + [% UNLESS problem.title; + dist = tprintf("%.1f", (problem.distance || 0) ); + problem = problem.problem; + END %] [% INCLUDE 'report/_item.html' %] [% END %] [% ELSE %] - <li><p>[% loc('No clinics found.') %]</p></li> + <li class="empty"> + <p>[% loc('No clinics found.') %]</p> + </li> [% END %] diff --git a/templates/web/zerotb/around/tabbed_lists.html b/templates/web/zerotb/around/tabbed_lists.html index 8b8e8753e..76c0f71f8 100644 --- a/templates/web/zerotb/around/tabbed_lists.html +++ b/templates/web/zerotb/around/tabbed_lists.html @@ -1,14 +1,3 @@ -<menu id="problems-nav" class="tab-nav"> - <ul> - <li><a href="#current">[% loc('Clinics on the map') %]</a></li> - <li><a href="#current_near">[% loc( 'Clinics nearby' ) %]</a></li> - </ul> -</menu> - <ul id="current" class="issue-list-a tab"> [% INCLUDE "around/on_map_list_items.html" %] </ul> - -<ul id="current_near" class="issue-list-a tab"> - [% INCLUDE "around/around_map_list_items.html" %] -</ul> diff --git a/web/cobrands/bromley/layout.scss b/web/cobrands/bromley/layout.scss index 4b61f8ee9..cd6c174db 100644 --- a/web/cobrands/bromley/layout.scss +++ b/web/cobrands/bromley/layout.scss @@ -1,8 +1,6 @@ @import "_colours"; @import "../sass/layout"; - -// Import the new filters/list styling -@import "../sass/_report_list.scss"; +@import "../sass/report_list_pins"; // Alter the logo and the header on every page *but* the map page. On the map // page it stays small like in base.css @@ -71,11 +69,10 @@ body.alertindex form.full-width { body.mappage #user-meta p { background-color: $bromley_blue; border-bottom: 1px solid #444; - left: 2.65em; } // And also override the banner on other pages so that it lines up properly -#user-meta { +#user-meta, body.mappage #user-meta { max-width: 1200px; } #user-meta p, diff --git a/web/cobrands/eastsussex/layout.scss b/web/cobrands/eastsussex/layout.scss index 3ccfb3f6a..d90a617f1 100644 --- a/web/cobrands/eastsussex/layout.scss +++ b/web/cobrands/eastsussex/layout.scss @@ -211,42 +211,6 @@ body.twothirdswidthpage .content aside { margin-top: 3em; /* required to push "Your Reports" visible on Safari/IE */ } -#main-nav { - margin-top: 106px; - ul { - margin-left: 157px; - float: none; - } -} - -#main-nav ul li { - text-align: center; - text-transform: uppercase; - padding: 0 15px; - font-size: 16px; - border-right: solid 1px white; - line-height: 1.5em; -} - -#main-nav ul li a { - padding: 0; - font-size: inherit; -} - -#main-nav ul li:last-child { - border-right: none; -} - -#main-nav ul li a:link, #main-nav ul li a:visited { - color: #fff; -} - -#main-nav ul li:hover, #main-nav ul li:hover a, { - background-color: white; - color: black; - text-decoration: none; -} - .main-menu-wrapper { display: none; } @@ -254,11 +218,6 @@ body.twothirdswidthpage .content aside { @media only screen and (max-width: 61em) { - #main-nav { - padding-left: 0px; - float:none; - } - #site-header { height: auto; } diff --git a/web/cobrands/greenwich/base.scss b/web/cobrands/greenwich/base.scss index 844cf2762..3d8dc29ba 100644 --- a/web/cobrands/greenwich/base.scss +++ b/web/cobrands/greenwich/base.scss @@ -29,7 +29,7 @@ body.frontpage #site-logo, background-size: cover; } -.issue-list-a li, .list-a li, #user-meta p, #front-main #postcodeForm { +.issue-list-a li, #user-meta p, #front-main #postcodeForm { background-color: $greenwich_light_grey; } diff --git a/web/cobrands/greenwich/layout.scss b/web/cobrands/greenwich/layout.scss index df5437968..894b82a33 100644 --- a/web/cobrands/greenwich/layout.scss +++ b/web/cobrands/greenwich/layout.scss @@ -1,7 +1,7 @@ @import "_colours"; @import "_fonts"; @import "../sass/layout"; -@import "../sass/report_list"; +@import "../sass/report_list_pins"; $fixed_page_width: 990px; diff --git a/web/cobrands/hart/hart.scss b/web/cobrands/hart/hart.scss index 0823a4bc5..7cd7306cc 100644 --- a/web/cobrands/hart/hart.scss +++ b/web/cobrands/hart/hart.scss @@ -76,14 +76,13 @@ body.frontpage .nav-wrapper-2 { #main-nav { margin-top: 106px; - - ul { - margin-left: 157px; - float: none; - } + } + .nav-menu { + margin-left: 157px; + float: none; } - #main-nav ul li { + .nav-menu li { text-align: center; text-transform: uppercase; padding: 0 15px; @@ -91,21 +90,16 @@ body.frontpage .nav-wrapper-2 { border-right: solid 1px white; line-height: 1.5em; } - - #main-nav ul li a { - padding: 0; - font-size: inherit; - } - - #main-nav ul li:last-child { + .nav-menu li:last-child { border-right: none; } - #main-nav ul li a:link, #main-nav ul li a:visited { - color: #fff; + .nav-menu a { + padding: 0; + font-size: inherit; } - #main-nav ul li:hover, #main-nav ul li:hover a, { + .nav-menu li:hover, .nav-menu li:hover a, { background-color: white; color: black; text-decoration: none; diff --git a/web/cobrands/oxfordshire/layout.scss b/web/cobrands/oxfordshire/layout.scss index 75a31e461..04890b1aa 100644 --- a/web/cobrands/oxfordshire/layout.scss +++ b/web/cobrands/oxfordshire/layout.scss @@ -1,6 +1,6 @@ @import "_colours"; @import "../sass/layout"; -@import "../sass/report_list"; +@import "../sass/report_list_pins"; body, body a { font-family:"Trebuchet MS",Arial, Helvetica, sans-serif; @@ -266,7 +266,7 @@ body.mappage { } } -.report-list, .issue-list-a { +.issue-list-a { li:after { background-color: $oxfordshire_mid_grey_green; } @@ -287,7 +287,7 @@ h4.static-with-rule { background: transparent; margin-top: 0; // no space between list items - // Replicate .report-list styling, a bit + // Replicate .issue-list-a styling, a bit border-top: 1px solid $oxfordshire_mid_grey_green; padding: 1em 1em 1em 0; margin-left: 1em; diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index 60a70f77e..301f6fdce 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -7,6 +7,7 @@ $image-sprite: '/cobrands/fixmystreet/images/sprite.png' !default; $menu-image: 'menu-white' !default; @import "_mixins"; +@import "_report_list"; body { font-family: $body-font; @@ -865,9 +866,8 @@ input.final-submit { padding: 0; border-bottom: 0.25em solid $primary; li { - list-style: none; - margin:0; - padding:0; + list-style: none; + padding: 0; margin: 0.25em 0 0; /* see note below about this */ display:table; @@ -882,7 +882,7 @@ input.final-submit { a { color:#222222; } - a:hover { + a:hover, a:focus { color:#222222; background-color:#e6e6e6; text-decoration: none; @@ -919,13 +919,7 @@ input.final-submit { } } } -.list-a { - @extend .issue-list-a; - a { - padding:0.5em 1em; - font-weight:bold; - } -} + //display:table fixes .ie6, .ie7 { .issue-list-a { diff --git a/web/cobrands/sass/_layout.scss b/web/cobrands/sass/_layout.scss index 806f1408c..c9cc3610d 100644 --- a/web/cobrands/sass/_layout.scss +++ b/web/cobrands/sass/_layout.scss @@ -1116,7 +1116,7 @@ body.frontpage { // Left padding is to ensure no overlap of the site-logo // Background styling replicates header styling - #main-nav{ + #main-nav { width: auto; float: $right; padding-#{$left}: 180px; diff --git a/web/cobrands/sass/_report_list.scss b/web/cobrands/sass/_report_list.scss index 0ba69fd4b..8d34bfd77 100644 --- a/web/cobrands/sass/_report_list.scss +++ b/web/cobrands/sass/_report_list.scss @@ -1,6 +1,3 @@ -// You should @import this file in a cobrand's layout.scss if it's using -// the new-style combined report list with category/status filters. - .report-list-filters { padding: 1em 1em 0; margin-bottom: 0.5em; @@ -33,129 +30,3 @@ max-width: 13em; } } - -.report-list, .issue-list-a { - margin-#{$left}: 0; - - li { - list-style: none; - position: relative; - margin: 0; - background: none; - - a { - display: block; - padding: 1em; - padding-#{$left}: 4em; - border-#{$left}: solid 1em transparent; - background: transparent url(/i/pin-yellow-small.png) no-repeat $left center; - - &:hover, &:focus { - text-decoration: none; - } - } - - &.yellow a { - background-image: url(/i/pin-yellow-small.png); - } - &.green a { - background-image: url(/i/pin-green-small.png); - } - &.red a { - background-image: url(/i/pin-red-small.png); - } - &.grey a { - background-image: url(/i/pin-grey-small.png); - } - - &.empty p { - display: block; - padding: 1em; - font-size: 1em; - text-align: center; - } - - &:after { - content: ""; - display: block; - height: 1px; - position: absolute; - #{$left}: 4em; - #{$right}: 0; - bottom: 0; - background-color: #e5e5e5; - } - - &.empty:after { - #{$left}: 0; - } - } - - h3, p { - margin: 0; - } - - h3 { - color: $primary; - margin-bottom: 0.2em; - } - - p { - font-size: 0.8em; - color: #777; - } -} - -// On the /my page, we use a .issue-list with an extra full-width modifier -// which removes the left padding. However, our new reports list still needs -// it: -.issue-list-a.full-width { - margin-#{$left}: -1em; -} - -.big-green-banner { - display: none; // hide the empty banner by default - - &.mobile-map-banner { - display: block; // show it again once the mobile javascript adds this class - } -} - -.click-the-map { - color: #000; - margin: -10px -1em 0; // overlap padding on parents - padding: 18px; - border-bottom: 1px solid #e5e5e5; - // TODO This is not right-to-left enabled yet - background: #fff url('/i/click-map-chevron-big.gif') 90% 12px no-repeat; - - h2 { - font-family: inherit; - margin: 0 0 5px; - } - - p { - margin: 0; - font-size: 18px; - line-height: 20px; - color: $primary; - padding-#{$right}: 20px; - // TODO This is not right-to-left enabled yet, image wise - background: transparent url('/i/click-map-chevron-small.gif') $right center no-repeat; - display: inline-block; - } - - img { - // the little chevron icon - vertical-align: -1px; - margin-#{$left}: 0.2em; - } -} - -body.frontpage { - .issue-list-a, .list-a { - li .text { - padding-#{$left}: 3em; - } - } -} diff --git a/web/cobrands/sass/_report_list_pins.scss b/web/cobrands/sass/_report_list_pins.scss new file mode 100644 index 000000000..f1948775b --- /dev/null +++ b/web/cobrands/sass/_report_list_pins.scss @@ -0,0 +1,111 @@ +.issue-list-a { + li { + position: relative; + margin: 0; + background: none; + + a { + display: block; + padding: 1em; + padding-#{$left}: 4em; + border-#{$left}: solid 1em transparent; + background: transparent url(/i/pin-yellow-small.png) no-repeat $left center; + } + + &.yellow a { + background-image: url(/i/pin-yellow-small.png); + } + &.green a { + background-image: url(/i/pin-green-small.png); + } + &.red a { + background-image: url(/i/pin-red-small.png); + } + &.grey a { + background-image: url(/i/pin-grey-small.png); + } + + &.empty p { + display: block; + padding: 1em; + font-size: 1em; + text-align: center; + } + + &:after { + content: ""; + display: block; + height: 1px; + position: absolute; + #{$left}: 4em; + #{$right}: 0; + bottom: 0; + background-color: #e5e5e5; + } + + &.empty:after { + #{$left}: 0; + } + } + + h3, p { + margin: 0; + } + + h3 { + color: $primary; + margin-bottom: 0.2em; + } + + p { + font-size: 0.8em; + color: #777; + } +} + +.big-green-banner { + display: none; // hide the empty banner by default + + &.mobile-map-banner { + display: block; // show it again once the mobile javascript adds this class + } +} + +.click-the-map { + color: #000; + margin: -10px -1em 0; // overlap padding on parents + padding: 18px; + border-bottom: 1px solid #e5e5e5; + // TODO This is not right-to-left enabled yet + background: #fff url('/i/click-map-chevron-big.gif') 90% 12px no-repeat; + + h2 { + font-family: inherit; + margin: 0 0 5px; + } + + p { + margin: 0; + font-size: 18px; + line-height: 20px; + color: $primary; + padding-#{$right}: 20px; + // TODO This is not right-to-left enabled yet, image wise + background: transparent url('/i/click-map-chevron-small.gif') $right center no-repeat; + display: inline-block; + } + + img { + // the little chevron icon + vertical-align: -1px; + margin-#{$left}: 0.2em; + } +} + +body.frontpage { + .issue-list-a { + li .text { + padding-#{$left}: 3em; + } + } +} diff --git a/web/cobrands/stevenage/layout.scss b/web/cobrands/stevenage/layout.scss index 49529dd49..17ef6a4c3 100644 --- a/web/cobrands/stevenage/layout.scss +++ b/web/cobrands/stevenage/layout.scss @@ -37,10 +37,8 @@ } // d523b431 -#main-nav { - ul { - float: none; - } +.nav-menu { + float: none; } .nav-menu a, .nav-menu span { margin: 0; @@ -224,7 +222,9 @@ body.frontpage { // d523b431 #main-nav { float: left; + padding-left: 0; } + .nav-wrapper { .nav-wrapper-2 { @include background(linear-gradient(#222, #555 30%, #555 60%, #222)); diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 63ef7324d..3cd54bc23 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -552,13 +552,10 @@ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { } else { obj = json; } - var current, current_near; + var current; if (typeof(obj.current) != 'undefined' && (current = document.getElementById('current'))) { current.innerHTML = obj.current; } - if (typeof(obj.current_near) != 'undefined' && (current_near = document.getElementById('current_near'))) { - current_near.innerHTML = obj.current_near; - } return fms_markers_list( obj.pins, false ); }, CLASS_NAME: "OpenLayers.Format.FixMyStreet" diff --git a/web/js/moderate.js b/web/js/moderate.js index 075766d0b..dd366df3f 100644 --- a/web/js/moderate.js +++ b/web/js/moderate.js @@ -1,12 +1,7 @@ -$(function () { - setup_moderation( $('.problem-header'), 'problem' ); - setup_moderation( $('.issue-list .issue'), 'update' ); -}); - function setup_moderation (elem, word) { elem.each( function () { - var $elem = $(this) + var $elem = $(this); $elem.find('.moderate').click( function () { $elem.find('.moderate-display').hide(); $elem.find('.moderate-edit').show(); @@ -40,3 +35,8 @@ function setup_moderation (elem, word) { }); }); } + +$(function () { + setup_moderation( $('.problem-header'), 'problem' ); + setup_moderation( $('.issue-list .issue'), 'update' ); +}); |