Permalink
Browse files

Initial catalyst app

  • Loading branch information...
1 parent 3107d56 commit 24740a898efead5f43334704389768f32d5e7e9a @mattp- mattp- committed Jul 2, 2011
Showing 344 changed files with 479 additions and 41 deletions.
View
@@ -0,0 +1,4 @@
+This file documents the revision history for Perl extension MetaCPAN::Web.
+
+0.01 2011-07-01 20:15:58
+ - initial revision, generated by Catalyst
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env perl
+# IMPORTANT: if you delete this file your app will not work as
+# expected. You have been warned.
+use inc::Module::Install;
+use Module::Install::Catalyst; # Complain loudly if you don't have
+ # Catalyst::Devel installed or haven't said
+ # 'make dist' to create a standalone tarball.
+
+name 'MetaCPAN-Web';
+all_from 'lib/MetaCPAN/Web.pm';
+
+requires 'Catalyst::Runtime' => '5.80032';
+requires 'Catalyst::Plugin::ConfigLoader';
+requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Action::RenderView';
+requires 'Moose';
+requires 'namespace::autoclean';
+requires 'Config::General'; # This should reflect the config file format you've chosen
+ # See Catalyst::Plugin::ConfigLoader for supported formats
+test_requires 'Test::More' => '0.88';
+catalyst;
+
+install_script glob('script/*.pl');
+auto_install;
+WriteAll;
View
1 README
@@ -0,0 +1 @@
+Run script/metacpan_web_server.pl to test the application.
View
@@ -1,3 +0,0 @@
-#!/bin/sh
-twiggy lib/MetaCPAN/Web.pm -p 5001 -R lib -E development
-
View
@@ -1,43 +1,75 @@
package MetaCPAN::Web;
+use Moose;
+use namespace::autoclean;
-# ABSTRACT: Modern front-end for MetaCPAN
-use strict;
-use warnings;
-use FindBin;
-use lib "$FindBin::RealBin/../";
-use Plack::App::URLMap;
-use Plack::App::File;
-use MetaCPAN::Web::View;
-use MetaCPAN::Web::Model;
-use MetaCPAN::Web::Controller;
-use Module::Find qw(findallmod);
-use Plack::Middleware::Assets;
-use Plack::Middleware::Runtime;
-use Plack::Middleware::ReverseProxy;
-use Plack::Middleware::StackTrace;
-
-my $api = 'http://' . ( $ENV{METACPAN_API} || 'api.metacpan.org' );
-
-my $view = MetaCPAN::Web::View->new;
-my $model = MetaCPAN::Web::Model->new( url => $api );
-my $controller =
- MetaCPAN::Web::Controller->new( view => $view, model => $model );
-my $app = Plack::App::URLMap->new;
-$app->map( '/static/' => Plack::App::File->new( root => 'static' ) );
-$app->map( '/favicon.ico' => Plack::App::File->new( file => 'static/icons/favicon.ico' ) );
-$app->map( '/' => $controller->dispatch );
-$app = Plack::Middleware::Runtime->wrap($app);
-$app = Plack::Middleware::Assets->wrap( $app, files => [<static/css/*.css>] );
-$app = Plack::Middleware::Assets->wrap(
- $app,
- files => [
- map { "static/js/$_.js" }
- qw(jquery.min jquery.tablesorter jquery.cookie jquery.relatize_date jquery.ajaxQueue jquery.autocomplete.pack shCore shBrushPerl cpan)
- ],
- minify => 0,
+use Catalyst::Runtime 5.80;
+
+# Set flags and add plugins for the application.
+#
+# Note that ORDERING IS IMPORTANT here as plugins are initialized in order,
+# therefore you almost certainly want to keep ConfigLoader at the head of the
+# list if you're using it.
+#
+# -Debug: activates the debug mode for very useful log messages
+# ConfigLoader: will load the configuration from a Config::General file in the
+# application's home directory
+# Static::Simple: will serve static files from the application's root
+# directory
+
+use Catalyst qw/
+ -Debug
+ ConfigLoader
+ Static::Simple
+/;
+
+extends 'Catalyst';
+
+our $VERSION = '0.01';
+
+# Configure the application.
+#
+# Note that settings in metacpan_web.conf (or other external
+# configuration file that you set up manually) take precedence
+# over this when using ConfigLoader. Thus configuration
+# details given here can function as a default configuration,
+# with an external configuration file acting as an override for
+# local deployment.
+
+__PACKAGE__->config(
+ name => 'MetaCPAN::Web',
+ # Disable deprecated behavior needed by old applications
+ disable_component_resolution_regex_fallback => 1,
);
-Plack::Middleware::StackTrace->wrap($app);
-Plack::Middleware::ReverseProxy->wrap($app);
+# Start the application
+__PACKAGE__->setup();
+
+
+=head1 NAME
+
+MetaCPAN::Web - Catalyst based application
+
+=head1 SYNOPSIS
+
+ script/metacpan_web_server.pl
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 SEE ALSO
+
+L<MetaCPAN::Web::Controller::Root>, L<Catalyst>
+
+=head1 AUTHOR
+
+Matthew,,,
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
-# ABSTRACT: A Front End for MetaCPAN
+1;
@@ -0,0 +1,69 @@
+package MetaCPAN::Web::Controller::Root;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+
+#
+# Sets the actions in this controller to be registered with no prefix
+# so they function identically to actions created in MyApp.pm
+#
+__PACKAGE__->config(namespace => '');
+
+=head1 NAME
+
+MetaCPAN::Web::Controller::Root - Root Controller for MetaCPAN::Web
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 METHODS
+
+=head2 index
+
+The root page (/)
+
+=cut
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+ # Hello World
+ $c->response->body( $c->welcome_message );
+}
+
+=head2 default
+
+Standard 404 error page
+
+=cut
+
+sub default :Path {
+ my ( $self, $c ) = @_;
+ $c->response->body( 'Page not found' );
+ $c->response->status(404);
+}
+
+=head2 end
+
+Attempt to render a view, if needed.
+
+=cut
+
+sub end : ActionClass('RenderView') {}
+
+=head1 AUTHOR
+
+Matthew,,,
+
+=head1 LICENSE
+
+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;
View
@@ -0,0 +1,3 @@
+# rename this file to metacpan::web.yml and put a ':' after 'name' if
+# you want to use YAML like in old versions of Catalyst
+name MetaCPAN::Web
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.

0 comments on commit 24740a8

Please sign in to comment.