Permalink
Browse files

Resume!

  • Loading branch information...
0 parents commit 918e6f078d929a90a533dcea4357ad435cb09517 @vti committed Aug 24, 2011
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Perlresume',
+ AUTHOR => q{YOUR NAME <youremail@example.com>},
+ VERSION_FROM => 'lib/Perlresume.pm',
+ ABSTRACT => 'YOUR APPLICATION ABSTRACT',
+ ($ExtUtils::MakeMaker::VERSION >= 6.3002
+ ? ('LICENSE'=> 'perl')
+ : ()),
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'YAML' => 0,
+ 'Dancer' => 1.3030,
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'Perlresume-*' },
+);
@@ -0,0 +1,4 @@
+#!/usr/bin/env perl
+use Dancer;
+use Perlresume;
+dance;
@@ -0,0 +1,7 @@
+appname: "Perlresume"
+
+layout: "main"
+
+charset: "UTF-8"
+
+template: "caml"
@@ -0,0 +1,27 @@
+# configuration file for development environment
+
+# the logger engine to use
+# console: log messages to STDOUT (your console where you started the
+# application server)
+# file: log message to a file in log/
+logger: "console"
+
+# the log level for this environement
+# core is the lowest, it shows Dancer's core log messages as well as yours
+# (debug, warning and error)
+log: "core"
+
+# should Dancer consider warnings as critical errors?
+warnings: 1
+
+# should Dancer show a stacktrace when an error is caught?
+show_errors: 1
+
+# auto_reload is a development and experimental feature
+# you should enable it by yourself if you want it
+# Module::Refresh is needed
+#
+# Be aware it's unstable and may cause a memory leak.
+# DO NOT EVER USE THAT FEATURE IN PRODUCTION
+# OR TINY KITTENS SHALL DIE WITH LOTS OF SUFFERING
+auto_reload: 0
@@ -0,0 +1,17 @@
+# configuration file for production environment
+
+# only log warning and error messsages
+log: "warning"
+
+# log message to a file in logs/
+logger: "file"
+
+# don't consider warnings critical
+warnings: 0
+
+# hide errors
+show_errors: 0
+
+# cache route resolution for maximum performance
+route_cache: 1
+
@@ -0,0 +1,103 @@
+package Perlresume;
+use Dancer ':syntax';
+use MetaCPAN::API;
+use Try::Tiny;
+use Time::Piece;
+
+our $VERSION = '0.1';
+
+get '/' => sub {
+ if (my $author = params->{author}) {
+ redirect '/' . $author;
+ }
+
+ template 'index';
+};
+
+get '/:author' => sub {
+ my $id = uc params->{author};
+
+ my $author = fetch_author($id);
+
+ if (!$author) {
+ status 'not_found';
+ return template 'not_found';
+ }
+
+ $author->{dist_count} = fetch_dist_count($id);
+
+ $author->{email} = $author->{email}->[0] if defined $author->{email};
+ $author->{website} = $author->{website}->[0] if defined $author->{website};
+
+ $author->{contacts} = [];
+ foreach my $profile (@{$author->{profile}}) {
+ push @{$author->{contacts}},
+ { $profile->{name} => 1,
+ id => $profile->{id}
+ };
+ }
+
+ $author->{profiles} = 1 if @{$author->{contacts}};
+
+ $author->{first_release_year} = fetch_first_release_year($id);
+ $author->{favorited_dist_count} = fetch_favorited_dist_count($id);
+
+ template 'resume' => $author;
+};
+
+true;
+
+sub fetch_author {
+ my ($id) = @_;
+
+ my $mcpan = MetaCPAN::API->new;
+
+ return try { $mcpan->author($id) };
+}
+
+sub fetch_dist_count {
+ my ($id) = @_;
+
+ my $mcpan = MetaCPAN::API->new;
+
+ my $result = $mcpan->fetch(
+ 'release/_search',
+ q => "author:$id AND status:latest",
+ size => 0
+ );
+
+ return $result->{hits}->{total};
+}
+
+sub fetch_favorited_dist_count {
+ my ($id) = @_;
+
+ my $mcpan = MetaCPAN::API->new;
+
+ my $result = $mcpan->fetch(
+ 'favorite/_search',
+ q => "author:$id",
+ size => 0
+ );
+
+ return $result->{hits}->{total};
+}
+
+sub fetch_first_release_year {
+ my ($id) = @_;
+
+ my $mcpan = MetaCPAN::API->new;
+
+ my $result = $mcpan->fetch(
+ 'release/_search',
+ q => "author:$id",
+ sort => 'date',
+ size => 1
+ );
+
+ my $date = $result->{hits}->{hits}->[0]->{_source}->{date};
+
+ $date = Time::Piece->strptime($date, '%Y-%m-%dT%H:%M:%S');
+
+ return $date->year;
+}
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title>Error 404</title>
+<link rel="stylesheet" href="/css/error.css" />
+<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
+</head>
+<body>
+<h1>Error 404</h1>
+<div id="content">
+<h2>Page Not Found</h2><p>Sorry, this is the void.</p>
+</div>
+<div id="footer">
+Powered by <a href="http://perldancer.org/">Dancer</a> 1.3030
+</div>
+</body>
+</html>
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title>Error 500</title>
+<link rel="stylesheet" href="/css/error.css" />
+<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
+</head>
+<body>
+<h1>Error 500</h1>
+<div id="content">
+<h2>Internal Server Error</h2><p>Wooops, something went wrong</p>
+</div>
+<div id="footer">
+Powered by <a href="http://perldancer.org/">Dancer</a> 1.3030
+</div>
+</body>
+</html>
@@ -0,0 +1,70 @@
+body {
+ font-family: Lucida,sans-serif;
+}
+
+h1 {
+ color: #AA0000;
+ border-bottom: 1px solid #444;
+}
+
+h2 { color: #444; }
+
+pre {
+ font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace;
+ font-size: 12px;
+ border-left: 2px solid #777;
+ padding-left: 1em;
+}
+
+footer {
+ font-size: 10px;
+}
+
+span.key {
+ color: #449;
+ font-weight: bold;
+ width: 120px;
+ display: inline;
+}
+
+span.value {
+ color: #494;
+}
+
+/* these are for the message boxes */
+
+pre.content {
+ background-color: #eee;
+ color: #000;
+ padding: 1em;
+ margin: 0;
+ border: 1px solid #aaa;
+ border-top: 0;
+ margin-bottom: 1em;
+}
+
+div.title {
+ font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace;
+ font-size: 12px;
+ background-color: #aaa;
+ color: #444;
+ font-weight: bold;
+ padding: 3px;
+ padding-left: 10px;
+}
+
+pre.content span.nu {
+ color: #889;
+ margin-right: 10px;
+}
+
+pre.error {
+ background: #334;
+ color: #ccd;
+ padding: 1em;
+ border-top: 1px solid #000;
+ border-left: 1px solid #000;
+ border-right: 1px solid #eee;
+ border-bottom: 1px solid #eee;
+}
+
@@ -0,0 +1,84 @@
+#main {
+ width:740px;
+ margin:0px auto;
+ padding:2em;
+}
+
+#container {
+}
+
+#footer {
+ border-top:1px solid #ccc;
+ font-size:small;
+ margin-top:2em;
+ padding-top:2em;
+ color:#777;
+}
+
+#resume-banner {
+ padding-top:2em;
+ border-top: 5px solid #ccc;
+}
+
+h1#name {
+ padding-top:0px;
+ margin-top:0px;
+ margin-bottom:0px;
+}
+
+h2#asciiname {
+ padding-top:0px;
+ margin-top:0px;
+ margin-bottom:0px;
+ color:#777;
+}
+
+h3#proud {
+ font-style:italic;
+}
+
+#resume tr {
+ background:#eee;
+}
+
+#resume td {
+ padding:1em;
+ vertical-align:top;
+}
+
+#resume td.title {
+ font-style:italic;
+}
+
+dl {
+ padding:0px;
+ margin:0px;
+}
+
+dt {
+ font-style:italic;
+}
+
+dd {
+ margin-bottom:1em;
+}
+
+#name {
+ padding-top:0px;
+}
+
+#asciiname {
+}
+
+#resume-image {
+ float:left;
+}
+
+.comment {
+ font-size:small;
+ color:#777;
+}
+
+.clear {
+ clear:both;
+}
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use Dancer ':syntax';
+use FindBin '$RealBin';
+use Plack::Runner;
+
+# For some reason Apache SetEnv directives dont propagate
+# correctly to the dispatchers, so forcing PSGI and env here
+# is safer.
+set apphandler => 'PSGI';
+set environment => 'production';
+
+my $psgi = path($RealBin, '..', 'bin', 'app.pl');
+die "Unable to read startup script: $psgi" unless -r $psgi;
+
+Plack::Runner->run($psgi);
Oops, something went wrong.

0 comments on commit 918e6f0

Please sign in to comment.