Permalink
Browse files

initial impoort

  • Loading branch information...
0 parents commit 2afdf4b3237f85927df3d2a2d0b9ab489ff12644 @tokuhirom committed Jul 20, 2011
@@ -0,0 +1,9 @@
+Makefile
+inc/
+MANIFEST
+*.bak
+*.old
+nytprof.out
+nytprof/
+development.db
+test.db
@@ -0,0 +1,22 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'MetaCPANExplorer',
+ AUTHOR => 'Some Person <person@example.com>',
+ VERSION_FROM => 'lib/MetaCPANExplorer.pm',
+ PREREQ_PM => {
+ 'Amon2' => '2.45',
+ 'Text::Xslate' => '1.1005',
+ 'Text::Xslate::Bridge::TT2Like' => '0.00008',
+ 'Plack::Middleware::ReverseProxy' => '0.09',
+ 'HTML::FillInForm::Lite' => '1.09',
+ 'Time::Piece' => '1.20',
+ 'JSON' => 2,
+ },
+ MIN_PERL_VERSION => '5.008001',
+ (-d 'xt' and $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING}) ? (
+ test => {
+ TESTS => 't/*.t xt/*.t',
+ },
+ ) : (),
+);
@@ -0,0 +1,14 @@
+use File::Spec;
+use File::Basename;
+use lib File::Spec->catdir(dirname(__FILE__), 'extlib', 'lib', 'perl5');
+use lib File::Spec->catdir(dirname(__FILE__), 'lib');
+use MetaCPANExplorer::Web;
+use Plack::Builder;
+
+builder {
+ enable 'Plack::Middleware::Static',
+ path => qr{^(?:/static/|/robot\.txt$|/favicon.ico$)},
+ root => File::Spec->catdir(dirname(__FILE__));
+ enable 'Plack::Middleware::ReverseProxy';
+ MetaCPANExplorer::Web->to_app();
+};
@@ -0,0 +1,10 @@
++{
+ 'DBI' => [
+ 'dbi:SQLite:dbname=deployment.db',
+ '',
+ '',
+ +{
+ sqlite_unicode => 1,
+ }
+ ],
+};
@@ -0,0 +1,10 @@
++{
+ 'DBI' => [
+ 'dbi:SQLite:dbname=development.db',
+ '',
+ '',
+ +{
+ sqlite_unicode => 1,
+ }
+ ],
+};
@@ -0,0 +1,10 @@
++{
+ 'DBI' => [
+ 'dbi:SQLite:dbname=test.db',
+ '',
+ '',
+ +{
+ sqlite_unicode => 1,
+ }
+ ],
+};
@@ -0,0 +1,10 @@
+package MetaCPANExplorer;
+use strict;
+use warnings;
+use parent qw/Amon2/;
+our $VERSION='0.01';
+use 5.008001;
+
+# __PACKAGE__->load_plugin(qw/DBI/);
+
+1;
@@ -0,0 +1,57 @@
+package MetaCPANExplorer::Web;
+use strict;
+use warnings;
+use parent qw/MetaCPANExplorer Amon2::Web/;
+use 5.10.0;
+use File::Spec;
+
+# load all controller classes
+use Module::Find ();
+Module::Find::useall("MetaCPANExplorer::Web::C");
+
+# dispatcher
+use MetaCPANExplorer::Web::Dispatcher;
+sub dispatch {
+ return MetaCPANExplorer::Web::Dispatcher->dispatch($_[0]) or die "response is not generated";
+}
+
+# setup view class
+use Text::Xslate;
+{
+ my $view_conf = __PACKAGE__->config->{'Text::Xslate'} || +{};
+ unless (exists $view_conf->{path}) {
+ $view_conf->{path} = [ File::Spec->catdir(__PACKAGE__->base_dir(), 'tmpl') ];
+ }
+ my $view = Text::Xslate->new(+{
+ 'syntax' => 'TTerse',
+ 'module' => [ 'Text::Xslate::Bridge::TT2Like', 'JSON' ],
+ 'function' => {
+ c => sub { Amon2->context() },
+ uri_with => sub { Amon2->context()->req->uri_with(@_) },
+ uri_for => sub { Amon2->context()->uri_for(@_) },
+ prettify => sub {
+ state $json = JSON->new->pretty;
+ $json->encode(@_);
+ }
+ },
+ %$view_conf
+ });
+ sub create_view { $view }
+}
+
+# load plugins
+use HTTP::Session::Store::File;
+__PACKAGE__->load_plugins(
+ 'Web::FillInFormLite',
+ 'Web::NoCache', # do not cache the dynamic content by default
+);
+
+# for your security
+__PACKAGE__->add_trigger(
+ AFTER_DISPATCH => sub {
+ my ( $c, $res ) = @_;
+ $res->header( 'X-Content-Type-Options' => 'nosniff' );
+ },
+);
+
+1;
@@ -0,0 +1,32 @@
+package MetaCPANExplorer::Web::Dispatcher;
+use strict;
+use warnings;
+use Amon2::Web::Dispatcher::Lite;
+use LWP::UserAgent;
+
+my $ua = LWP::UserAgent->new;
+
+any '/' => sub {
+ my ($c) = @_;
+
+ my %stash;
+
+ if (my $url = $c->req->param('url')) {
+ if ($url =~ m{^/}) {
+ my $content = $c->req->param('content');
+ my $res = do {
+ if (length $content) {
+ $ua->post("http://api.metacpan.org$url", Content => $content);
+ } else {
+ $ua->get("http://api.metacpan.org$url");
+ }
+ };
+ $stash{res} = $res;
+ }
+ }
+
+ $c->fillin_form($c->req);
+ $c->render('index.tt', \%stash);
+};
+
+1;
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8 />
+ <style type="text/css">
+ body {
+ text-align: center;
+ font-family: 'Menlo', 'Monaco', Courier, monospace;
+ background-color: whitesmoke;
+ padding-top: 10%;
+ }
+ .number {
+ font-size: 800%;
+ font-weight: bold;
+ margin-bottom: 40px;
+ }
+ .message {
+ font-size: 400%;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="number">404</div>
+ <div class="message">Not Found</div>
+ </body>
+</html>
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8 />
+ <style type="text/css">
+ body {
+ text-align: center;
+ font-family: 'Menlo', 'Monaco', Courier, monospace;
+ background-color: whitesmoke;
+ padding-top: 10%;
+ }
+ .number {
+ font-size: 800%;
+ font-weight: bold;
+ margin-bottom: 40px;
+ }
+ .message {
+ font-size: 400%;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="number">500</div>
+ <div class="message">Internal Server Error</div>
+ </body>
+</html>
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8 />
+ <style type="text/css">
+ body {
+ text-align: center;
+ font-family: 'Menlo', 'Monaco', Courier, monospace;
+ background-color: whitesmoke;
+ padding-top: 10%;
+ }
+ .number {
+ font-size: 800%;
+ font-weight: bold;
+ margin-bottom: 40px;
+ }
+ .message {
+ font-size: 400%;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="number">502</div>
+ <div class="message">Bad Gateway</div>
+ </body>
+</html>
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8 />
+ <style type="text/css">
+ body {
+ text-align: center;
+ font-family: 'Menlo', 'Monaco', Courier, monospace;
+ background-color: whitesmoke;
+ padding-top: 10%;
+ }
+ .number {
+ font-size: 800%;
+ font-weight: bold;
+ margin-bottom: 40px;
+ }
+ .message {
+ font-size: 400%;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="number">503</div>
+ <div class="message">Service Unavailable</div>
+ </body>
+</html>
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8 />
+ <style type="text/css">
+ body {
+ text-align: center;
+ font-family: 'Menlo', 'Monaco', Courier, monospace;
+ background-color: whitesmoke;
+ padding-top: 10%;
+ }
+ .number {
+ font-size: 800%;
+ font-weight: bold;
+ margin-bottom: 40px;
+ }
+ .message {
+ font-size: 400%;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="number">504</div>
+ <div class="message">Gateway Timeout</div>
+ </body>
+</html>
@@ -0,0 +1,36 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 1.0
+ http://blueprintcss.org
+
+ * Copyright (c) 2007-Present. See LICENSE for more info.
+ * See README for instructions on how to use Blueprint.
+ * For credits and origins, see AUTHORS.
+ * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* ie.css */
+body {text-align:center;}
+.container {text-align:left;}
+* html .column, * html .span-1, * html .span-2, * html .span-3, * html .span-4, * html .span-5, * html .span-6, * html .span-7, * html .span-8, * html .span-9, * html .span-10, * html .span-11, * html .span-12, * html .span-13, * html .span-14, * html .span-15, * html .span-16, * html .span-17, * html .span-18, * html .span-19, * html .span-20, * html .span-21, * html .span-22, * html .span-23, * html .span-24 {display:inline;overflow-x:hidden;}
+* html legend {margin:0px -8px 16px 0;padding:0;}
+sup {vertical-align:text-top;}
+sub {vertical-align:text-bottom;}
+html>body p code {*white-space:normal;}
+hr {margin:-8px auto 11px;}
+img {-ms-interpolation-mode:bicubic;}
+.clearfix, .container {display:inline-block;}
+* html .clearfix, * html .container {height:1%;}
+fieldset {padding-top:0;}
+legend {margin-top:-0.2em;margin-bottom:1em;margin-left:-0.5em;}
+textarea {overflow:auto;}
+label {vertical-align:middle;position:relative;top:-0.25em;}
+input.text, input.title, textarea {background-color:#fff;border:1px solid #bbb;}
+input.text:focus, input.title:focus {border-color:#666;}
+input.text, input.title, textarea, select {margin:0.5em 0;}
+input.checkbox, input.radio {position:relative;top:.25em;}
+form.inline div, form.inline p {vertical-align:middle;}
+form.inline input.checkbox, form.inline input.radio, form.inline input.button, form.inline button {margin:0.5em 0;}
+button, input.button {position:relative;top:0.25em;}
@@ -0,0 +1,29 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 1.0
+ http://blueprintcss.org
+
+ * Copyright (c) 2007-Present. See LICENSE for more info.
+ * See README for instructions on how to use Blueprint.
+ * For credits and origins, see AUTHORS.
+ * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* print.css */
+body {line-height:1.5;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;color:#000;background:none;font-size:10pt;}
+.container {background:none;}
+hr {background:#ccc;color:#ccc;width:100%;height:2px;margin:2em 0;padding:0;border:none;}
+hr.space {background:#fff;color:#fff;visibility:hidden;}
+h1, h2, h3, h4, h5, h6 {font-family:"Helvetica Neue", Arial, "Lucida Grande", sans-serif;}
+code {font:.9em "Courier New", Monaco, Courier, monospace;}
+a img {border:none;}
+p img.top {margin-top:0;}
+blockquote {margin:1.5em;padding:1em;font-style:italic;font-size:.9em;}
+.small {font-size:.9em;}
+.large {font-size:1.1em;}
+.quiet {color:#999;}
+.hide {display:none;}
+a:link, a:visited {background:transparent;font-weight:700;text-decoration:underline;}
+a:link:after, a:visited:after {content:" (" attr(href) ")";font-size:90%;}
Oops, something went wrong.

0 comments on commit 2afdf4b

Please sign in to comment.