Permalink
Browse files

initial work

  • Loading branch information...
1 parent 2c21363 commit 7f94f2136043923914a73f522722a1cfcedf7d93 @bricas bricas committed May 8, 2012
Showing with 16,178 additions and 27 deletions.
  1. +72 −27 lib/SixteenColors/Paste/Controller/Root.pm
  2. +36 −0 lib/SixteenColors/Paste/View/HTML.pm
  3. BIN root/favicon.ico
  4. +9 −0 root/index.tt
  5. +808 −0 root/static/css/bootstrap-responsive.css
  6. +4,961 −0 root/static/css/bootstrap.css
  7. +239 −0 root/static/css/font-awesome.css
  8. BIN root/static/font/8x16.eot
  9. +252 −0 root/static/font/8x16.svg
  10. BIN root/static/font/8x16.ttf
  11. BIN root/static/font/8x16.woff
  12. BIN root/static/font/fontawesome-webfont.eot
  13. +175 −0 root/static/font/fontawesome-webfont.svg
  14. BIN root/static/font/fontawesome-webfont.svgz
  15. BIN root/static/font/fontawesome-webfont.ttf
  16. BIN root/static/font/fontawesome-webfont.woff
  17. BIN root/static/images/btn_120x50_built.png
  18. BIN root/static/images/btn_120x50_built_shadow.png
  19. BIN root/static/images/btn_120x50_powered.png
  20. BIN root/static/images/btn_120x50_powered_shadow.png
  21. BIN root/static/images/btn_88x31_built.png
  22. BIN root/static/images/btn_88x31_built_shadow.png
  23. BIN root/static/images/btn_88x31_powered.png
  24. BIN root/static/images/btn_88x31_powered_shadow.png
  25. BIN root/static/images/catalyst_logo.png
  26. BIN root/static/img/body-bg-1.png
  27. BIN root/static/img/body-bg-2.png
  28. BIN root/static/img/body-bg-3.png
  29. BIN root/static/img/footer-bg.png
  30. BIN root/static/img/glyphicons-halflings-white.png
  31. BIN root/static/img/glyphicons-halflings.png
  32. BIN root/static/img/logo.png
  33. +6 −0 root/static/js/bootstrap.min.js
  34. +6 −0 root/static/js/jquery.backgroundPosition.js
  35. +9,252 −0 root/static/js/jquery.js
  36. +2 −0 root/uploaded.tt
  37. +3 −0 root/view.tt
  38. +349 −0 root/wrapper.tt
  39. +8 −0 t/view_HTML.t
@@ -4,54 +4,103 @@ 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
-#
+use Data::UUID::Base64URLSafe ();
+use Image::TextMode::Loader;
+use Image::TextMode::Renderer::GD;
+
__PACKAGE__->config(namespace => '');
-=head1 NAME
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
-SixteenColors::Paste::Controller::Root - Root Controller for SixteenColors::Paste
+ if( lc( $c->req->method ) eq 'post' && $c->req->params->{ file } ) {
+ my $ug = Data::UUID::Base64URLSafe->new;
+ my $id = $ug->create_b64_urlsafe;
-=head1 DESCRIPTION
+ my $upload = $c->req->upload( 'file' );
+ my( $ext ) = $upload->basename =~ m{\.([^.]+)$};
+ $ext = lc( $ext );
-[enter your description here]
+ $upload->copy_to( $c->path_to( "root/static/paste/${id}.${ext}" ) );
-=head1 METHODS
+ $c->stash(
+ id => $id,
+ template => 'uploaded.tt',
+ url => $c->uri_for( '/', $id ),
+ );
+ return;
+ }
+}
-=head2 index
+sub instance :Chained('/') PathPart('') CaptureArgs(1) {
+ my ( $self, $c, $id ) = @_;
-The root page (/)
+ my $dir = Path::Class::Dir->new( $c->path_to( "root/static/paste/" ) );
+ my $file;
-=cut
+ while( $file = $dir->next ) {
+ last if $file->basename =~ m{^$id\.};
+ }
-sub index :Path :Args(0) {
- my ( $self, $c ) = @_;
+ if( !$file ) {
+ $c->response->body( 'Page not found' );
+ $c->response->status(404);
+ return;
+ }
- # Hello World
- $c->response->body( $c->welcome_message );
+ $c->stash( id => $id, file => $file );
}
-=head2 default
+sub view :Chained('instance') PathPart('') Args(0) {
+ my ( $self, $c) = @_;
+}
-Standard 404 error page
+sub render :Chained('instance') PathPart('render') Args(0) {
+ my ( $self, $c ) = @_;
-=cut
+ my $file = $c->stash->{ file };
+ my $img = Image::TextMode::Loader->load( "$file" );
+ my $render = Image::TextMode::Renderer::GD->new;
+
+ $c->res->body( $render->fullscale( $img ) );
+ $c->res->content_type( 'image/png' );
+}
sub default :Path {
my ( $self, $c ) = @_;
$c->response->body( 'Page not found' );
$c->response->status(404);
}
-=head2 end
+sub end : ActionClass('RenderView') {}
-Attempt to render a view, if needed.
+__PACKAGE__->meta->make_immutable;
-=cut
+1;
-sub end : ActionClass('RenderView') {}
+__END__
+
+=head1 NAME
+
+SixteenColors::Paste::Controller::Root - Root Controller for SixteenColors::Paste
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 METHODS
+
+=head2 index
+
+The root page (/)
+
+=head2 default
+
+Standard 404 error page
+
+=head2 end
+
+Attempt to render a view, if needed.
=head1 AUTHOR
@@ -63,7 +112,3 @@ 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;
@@ -0,0 +1,36 @@
+package SixteenColors::Paste::View::HTML;
+use Moose;
+use namespace::autoclean;
+
+extends 'Catalyst::View::TT';
+
+__PACKAGE__->config(
+ TEMPLATE_EXTENSION => '.tt',
+ render_die => 1,
+ WRAPPER => 'wrapper.tt',
+);
+
+=head1 NAME
+
+SixteenColors::Paste::View::HTML - TT View for SixteenColors::Paste
+
+=head1 DESCRIPTION
+
+TT View for SixteenColors::Paste.
+
+=head1 SEE ALSO
+
+L<SixteenColors::Paste>
+
+=head1 AUTHOR
+
+Brian Cassidy,,,
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
View
Binary file not shown.
View
@@ -0,0 +1,9 @@
+<form class="form-vertical" method="post" enctype="multipart/form-data">
+ <div class="control-group">
+ <label class="control-label" for="file">Upload a file</label>
+ <div class="controls">
+ <input type="file" name=file id="file">
+ </div>
+ </div>
+ <button type="submit" class="btn">Submit</button>
+</form>
Oops, something went wrong.

0 comments on commit 7f94f21

Please sign in to comment.