Skip to content
This repository
Browse code

Added (empty) Dancer app.

  • Loading branch information...
commit f750bc6accc248fa68cb112944841df243d9ec4c 1 parent 1aa3b91
Dave Cross authored January 31, 2014
2  Build.PL
@@ -7,6 +7,8 @@ my $build = Module::Build->new(
7 7
         DBIx::Class => 0,
8 8
         DBD::mysql  => 0,
9 9
         Moose       => 0,
  10
+        YAML        => 0,
  11
+        Dancer      => 1,
10 12
         MooseX::MarkAsMethods      => 0,
11 13
         MooseX::NonMoose           => 0,
12 14
         DBIx::Class::EncodedColumn => 0,
4  bin/app.pl
... ...
@@ -0,0 +1,4 @@
  1
+#!/usr/bin/env perl
  2
+use Dancer;
  3
+use Lystyng;
  4
+dance;
28  config.yml
... ...
@@ -0,0 +1,28 @@
  1
+# This is the main configuration file of your Dancer app
  2
+# env-related settings should go to environments/$env.yml
  3
+# all the settings in this file will be loaded at Dancer's startup.
  4
+
  5
+# Your application's name
  6
+appname: "Lystyng"
  7
+
  8
+# The default layout to use for your application (located in
  9
+# views/layouts/main.tt)
  10
+layout: "main"
  11
+
  12
+# when the charset is set to UTF-8 Dancer will handle for you
  13
+# all the magic of encoding and decoding. You should not care
  14
+# about unicode within your app when this setting is set (recommended).
  15
+charset: "UTF-8"
  16
+
  17
+# template engine
  18
+# simple: default and very basic template engine
  19
+# template_toolkit: TT
  20
+
  21
+template: "simple"
  22
+
  23
+# template: "template_toolkit"
  24
+# engines:
  25
+#   template_toolkit:
  26
+#     start_tag: '[%'
  27
+#     end_tag:   '%]'
  28
+
27  environments/development.yml
... ...
@@ -0,0 +1,27 @@
  1
+# configuration file for development environment
  2
+
  3
+# the logger engine to use
  4
+# console: log messages to STDOUT (your console where you started the
  5
+#          application server)
  6
+# file:    log message to a file in log/
  7
+logger: "console"
  8
+
  9
+# the log level for this environment
  10
+# core is the lowest, it shows Dancer's core log messages as well as yours
  11
+# (debug, info, warning and error)
  12
+log: "core"
  13
+
  14
+# should Dancer consider warnings as critical errors?
  15
+warnings: 1
  16
+
  17
+# should Dancer show a stacktrace when an error is caught?
  18
+show_errors: 1
  19
+
  20
+# auto_reload is a development and experimental feature
  21
+# you should enable it by yourself if you want it
  22
+# Module::Refresh is needed 
  23
+# 
  24
+# Be aware it's unstable and may cause a memory leak.
  25
+# DO NOT EVER USE THIS FEATURE IN PRODUCTION 
  26
+# OR TINY KITTENS SHALL DIE WITH LOTS OF SUFFERING
  27
+auto_reload: 0
17  environments/production.yml
... ...
@@ -0,0 +1,17 @@
  1
+# configuration file for production environment
  2
+
  3
+# only log warning and error messsages
  4
+log: "warning"
  5
+
  6
+# log message to a file in logs/
  7
+logger: "file"
  8
+
  9
+# don't consider warnings critical
  10
+warnings: 0
  11
+
  12
+# hide errors 
  13
+show_errors: 0
  14
+
  15
+# cache route resolution for maximum performance
  16
+route_cache: 1
  17
+
8  lib/Lystyng.pm
@@ -6,6 +6,12 @@ Lystyng - Code for listing things
6 6
 
7 7
 package Lystyng;
8 8
 
  9
+use Dancer ':syntax';
9 10
 our $VERSION = '0.0.1';
10 11
 
11  
-1;
  12
+get '/' => sub {
  13
+    template 'index';
  14
+};
  15
+
  16
+true;
  17
+
18  public/404.html
... ...
@@ -0,0 +1,18 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3
+<html>
  4
+<head>
  5
+<title>Error 404</title>
  6
+<link rel="stylesheet" href="/css/error.css" />
  7
+<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
  8
+</head>
  9
+<body>
  10
+<h1>Error 404</h1>
  11
+<div id="content">
  12
+<h2>Page Not Found</h2><p>Sorry, this is the void.</p>
  13
+</div>
  14
+<div id="footer">
  15
+Powered by <a href="http://perldancer.org/">Dancer</a>.
  16
+</div>
  17
+</body>
  18
+</html>
18  public/500.html
... ...
@@ -0,0 +1,18 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3
+<html>
  4
+<head>
  5
+<title>Error 500</title>
  6
+<link rel="stylesheet" href="/css/error.css" />
  7
+<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
  8
+</head>
  9
+<body>
  10
+<h1>Error 500</h1>
  11
+<div id="content">
  12
+<h2>Internal Server Error</h2><p>Wooops, something went wrong</p>
  13
+</div>
  14
+<div id="footer">
  15
+Powered by <a href="http://perldancer.org/">Dancer</a>.
  16
+</div>
  17
+</body>
  18
+</html>
70  public/css/error.css
... ...
@@ -0,0 +1,70 @@
  1
+body {
  2
+    font-family: Lucida,sans-serif;
  3
+}
  4
+
  5
+h1 {
  6
+    color: #AA0000;
  7
+    border-bottom: 1px solid #444;
  8
+}
  9
+
  10
+h2 { color: #444; }
  11
+
  12
+pre {
  13
+    font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace;
  14
+    font-size: 12px;
  15
+    border-left: 2px solid #777;
  16
+    padding-left: 1em;
  17
+}
  18
+
  19
+footer {
  20
+    font-size: 10px;
  21
+}
  22
+
  23
+span.key {
  24
+    color: #449;
  25
+    font-weight: bold;
  26
+    width: 120px;
  27
+    display: inline;
  28
+}
  29
+
  30
+span.value {
  31
+    color: #494;
  32
+}
  33
+
  34
+/* these are for the message boxes */
  35
+
  36
+pre.content {
  37
+    background-color: #eee;
  38
+    color: #000;
  39
+    padding: 1em;
  40
+    margin: 0;
  41
+    border: 1px solid #aaa;
  42
+    border-top: 0;
  43
+    margin-bottom: 1em;
  44
+}
  45
+
  46
+div.title {
  47
+    font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace;
  48
+    font-size: 12px;
  49
+    background-color: #aaa;
  50
+    color: #444;
  51
+    font-weight: bold;
  52
+    padding: 3px;
  53
+    padding-left: 10px;
  54
+}
  55
+
  56
+pre.content span.nu {
  57
+    color: #889;
  58
+    margin-right: 10px;
  59
+}
  60
+
  61
+pre.error {
  62
+    background: #334;
  63
+    color: #ccd;
  64
+    padding: 1em;
  65
+    border-top: 1px solid #000;
  66
+    border-left: 1px solid #000;
  67
+    border-right: 1px solid #eee;
  68
+    border-bottom: 1px solid #eee;
  69
+}
  70
+
189  public/css/style.css
... ...
@@ -0,0 +1,189 @@
  1
+
  2
+body {
  3
+margin: 0;
  4
+margin-bottom: 25px;
  5
+padding: 0;
  6
+background-color: #ddd;
  7
+background-image: url("/images/perldancer-bg.jpg");
  8
+background-repeat: no-repeat;
  9
+background-position: top left;
  10
+
  11
+font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
  12
+font-size: 13px;
  13
+color: #333;
  14
+}
  15
+
  16
+h1 {
  17
+font-size: 28px;
  18
+color: #000;
  19
+}
  20
+
  21
+a  {color: #03c}
  22
+a:hover {
  23
+background-color: #03c;
  24
+color: white;
  25
+text-decoration: none;
  26
+}
  27
+
  28
+#page {
  29
+background-color: #ddd;
  30
+width: 750px;
  31
+margin: auto;
  32
+margin-left: auto;
  33
+padding-left: 0px;
  34
+margin-right: auto;
  35
+}
  36
+
  37
+#content {
  38
+background-color: white;
  39
+border: 3px solid #aaa;
  40
+border-top: none;
  41
+padding: 25px;
  42
+width: 500px;
  43
+}
  44
+
  45
+#sidebar {
  46
+float: right;
  47
+width: 175px;
  48
+}
  49
+
  50
+#header, #about, #getting-started {
  51
+padding-left: 75px;
  52
+padding-right: 30px;
  53
+}
  54
+
  55
+
  56
+#header {
  57
+background-image: url("/images/perldancer.jpg");
  58
+background-repeat: no-repeat;
  59
+background-position: top left;
  60
+height: 64px;
  61
+}
  62
+#header h1, #header h2 {margin: 0}
  63
+#header h2 {
  64
+color: #888;
  65
+font-weight: normal;
  66
+font-size: 16px;
  67
+}
  68
+
  69
+#about h3 {
  70
+margin: 0;
  71
+margin-bottom: 10px;
  72
+font-size: 14px;
  73
+}
  74
+
  75
+#about-content {
  76
+background-color: #ffd;
  77
+border: 1px solid #fc0;
  78
+margin-left: -11px;
  79
+}
  80
+#about-content table {
  81
+margin-top: 10px;
  82
+margin-bottom: 10px;
  83
+font-size: 11px;
  84
+border-collapse: collapse;
  85
+}
  86
+#about-content td {
  87
+padding: 10px;
  88
+padding-top: 3px;
  89
+padding-bottom: 3px;
  90
+}
  91
+#about-content td.name  {color: #555}
  92
+#about-content td.value {color: #000}
  93
+
  94
+#about-content.failure {
  95
+background-color: #fcc;
  96
+border: 1px solid #f00;
  97
+}
  98
+#about-content.failure p {
  99
+margin: 0;
  100
+padding: 10px;
  101
+}
  102
+
  103
+#getting-started {
  104
+border-top: 1px solid #ccc;
  105
+margin-top: 25px;
  106
+padding-top: 15px;
  107
+}
  108
+#getting-started h1 {
  109
+margin: 0;
  110
+font-size: 20px;
  111
+}
  112
+#getting-started h2 {
  113
+margin: 0;
  114
+font-size: 14px;
  115
+font-weight: normal;
  116
+color: #333;
  117
+margin-bottom: 25px;
  118
+}
  119
+#getting-started ol {
  120
+margin-left: 0;
  121
+padding-left: 0;
  122
+}
  123
+#getting-started li {
  124
+font-size: 18px;
  125
+color: #888;
  126
+margin-bottom: 25px;
  127
+}
  128
+#getting-started li h2 {
  129
+margin: 0;
  130
+font-weight: normal;
  131
+font-size: 18px;
  132
+color: #333;
  133
+}
  134
+#getting-started li p {
  135
+color: #555;
  136
+font-size: 13px;
  137
+}
  138
+
  139
+#search {
  140
+margin: 0;
  141
+padding-top: 10px;
  142
+padding-bottom: 10px;
  143
+font-size: 11px;
  144
+}
  145
+#search input {
  146
+font-size: 11px;
  147
+margin: 2px;
  148
+}
  149
+#search-text {width: 170px}
  150
+
  151
+#sidebar ul {
  152
+margin-left: 0;
  153
+padding-left: 0;
  154
+}
  155
+#sidebar ul h3 {
  156
+margin-top: 25px;
  157
+font-size: 16px;
  158
+padding-bottom: 10px;
  159
+border-bottom: 1px solid #ccc;
  160
+}
  161
+#sidebar li {
  162
+list-style-type: none;
  163
+}
  164
+#sidebar ul.links li {
  165
+margin-bottom: 5px;
  166
+}
  167
+
  168
+h1, h2, h3, h4, h5 {
  169
+font-family: sans-serif;
  170
+margin: 1.2em 0 0.6em 0;
  171
+}
  172
+
  173
+p {
  174
+line-height: 1.5em;
  175
+margin: 1.6em 0;
  176
+}
  177
+
  178
+code, tt {
  179
+    font-family: 'Andale Mono', Monaco, 'Liberation Mono', 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', monospace;
  180
+}
  181
+
  182
+#footer {
  183
+clear: both;
  184
+padding-top: 2em;
  185
+text-align: center;
  186
+padding-right: 160px;
  187
+font-family: sans-serif;
  188
+font-size: 10px;
  189
+}
15  public/dispatch.cgi
... ...
@@ -0,0 +1,15 @@
  1
+#!/usr/bin/env perl
  2
+use Dancer ':syntax';
  3
+use FindBin '$RealBin';
  4
+use Plack::Runner;
  5
+
  6
+# For some reason Apache SetEnv directives dont propagate
  7
+# correctly to the dispatchers, so forcing PSGI and env here 
  8
+# is safer.
  9
+set apphandler => 'PSGI';
  10
+set environment => 'production';
  11
+
  12
+my $psgi = path($RealBin, '..', 'bin', 'app.pl');
  13
+die "Unable to read startup script: $psgi" unless -r $psgi;
  14
+
  15
+Plack::Runner->run($psgi);
17  public/dispatch.fcgi
... ...
@@ -0,0 +1,17 @@
  1
+#!/usr/bin/env perl
  2
+use Dancer ':syntax';
  3
+use FindBin '$RealBin';
  4
+use Plack::Handler::FCGI;
  5
+
  6
+# For some reason Apache SetEnv directives dont propagate
  7
+# correctly to the dispatchers, so forcing PSGI and env here 
  8
+# is safer.
  9
+set apphandler => 'PSGI';
  10
+set environment => 'production';
  11
+
  12
+my $psgi = path($RealBin, '..', 'bin', 'app.pl');
  13
+my $app = do($psgi);
  14
+die "Unable to read startup script: $@" if $@;
  15
+my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
  16
+
  17
+$server->run($app);
1  public/javascripts/jquery.js
7  t/001_base.t
... ...
@@ -0,0 +1,7 @@
  1
+use Test::More tests => 1;
  2
+use strict;
  3
+use warnings;
  4
+
  5
+use lib 'lib';
  6
+
  7
+use_ok 'Lystyng';
12  t/002_index_route.t
... ...
@@ -0,0 +1,12 @@
  1
+use Test::More tests => 2;
  2
+use strict;
  3
+use warnings;
  4
+
  5
+use lib 'lib';
  6
+
  7
+# the order is important
  8
+use Lystyng;
  9
+use Dancer::Test;
  10
+
  11
+route_exists [GET => '/'], 'a route handler is defined for /';
  12
+response_status_is ['GET' => '/'], 200, 'response status is 200 for /';
148  views/index.tt
... ...
@@ -0,0 +1,148 @@
  1
+  
  2
+<!-- 
  3
+    Credit goes to the Ruby on Rails team for this page 
  4
+    has been heavily based on the default Rails page that is 
  5
+    built with a scaffolded application.
  6
+
  7
+    Thanks a lot to them for their work.
  8
+
  9
+    See Ruby on Rails if you want a kickass framework in Ruby:
  10
+    http://www.rubyonrails.org/
  11
+-->
  12
+
  13
+<div id="page">
  14
+      <div id="sidebar">
  15
+        <ul id="sidebar-items">
  16
+          <li>
  17
+            <h3>Join the community</h3>
  18
+            <ul class="links">
  19
+
  20
+              <li><a href="http://perldancer.org/">PerlDancer</a></li>
  21
+              <li><a href="http://twitter.com/PerlDancer/">Official Twitter</a></li>
  22
+              <li><a href="https://github.com/PerlDancer/Dancer/">GitHub Community</a></li>
  23
+            </ul>
  24
+          </li>
  25
+          
  26
+          <li>
  27
+            <h3>Browse the documentation</h3>
  28
+
  29
+            <ul class="links">
  30
+              <li><a
  31
+              href="http://search.cpan.org/dist/Dancer/lib/Dancer/Introduction.pod">Introduction</a></li>
  32
+              <li><a href="http://search.cpan.org/dist/Dancer/lib/Dancer/Cookbook.pod">Cookbook</a></li>
  33
+              <li><a href="http://search.cpan.org/dist/Dancer/lib/Dancer/Deployment.pod">Deployment Guide</a></li>
  34
+              <li><a
  35
+              href="http://search.cpan.org/dist/Dancer/lib/Dancer/Tutorial.pod"
  36
+              title="a tutorial to build a small blog engine with Dancer">Tutorial</a></li>
  37
+            </ul>
  38
+          </li>
  39
+
  40
+          <li>
  41
+            <h3>Your application's environment</h3>
  42
+
  43
+            <ul>
  44
+                <li>Location: <code>/home/dcross/dev/github/lystyng/Lystyng</code></li>
  45
+                <li>Template engine: <code><% settings.template %></code></li>
  46
+                <li>Logger: <code><% settings.logger %></code></li>
  47
+                <li>Environment: <code><% settings.environment %></code></li>
  48
+            </ul>
  49
+
  50
+          </li>
  51
+        </ul>
  52
+
  53
+      </div>
  54
+
  55
+      <div id="content">
  56
+        <div id="header">
  57
+          <h1>Perl is dancing</h1>
  58
+          <h2>You&rsquo;ve joined the dance floor!</h2>
  59
+        </div>
  60
+
  61
+        <div id="getting-started">
  62
+          <h1>Getting started</h1>
  63
+          <h2>Here&rsquo;s how to get dancing:</h2>
  64
+                    
  65
+          <h3><a href="#" id="about_env_link">About your application's environment</a></h3>
  66
+
  67
+          <div id="about-content" style="display: none;">
  68
+            <table>
  69
+                <tbody>
  70
+                <tr>
  71
+                    <td>Perl version</td>
  72
+                    <td><tt><% perl_version %></tt></td>
  73
+                </tr>
  74
+                <tr>
  75
+                    <td>Dancer version</td>
  76
+                    <td><tt><% dancer_version %></tt></td>
  77
+                </tr>
  78
+                <tr>
  79
+                    <td>Backend</td>
  80
+                    <td><tt><% settings.apphandler %></tt></td>
  81
+                </tr>
  82
+                <tr>
  83
+                    <td>Appdir</td>
  84
+                    <td><tt>/home/dcross/dev/github/lystyng/Lystyng</tt></td>
  85
+                </tr>
  86
+                <tr>
  87
+                    <td>Template engine</td>
  88
+                    <td><tt><% settings.template %></tt></td>
  89
+                </tr>
  90
+                <tr>
  91
+                    <td>Logger engine</td>
  92
+                    <td><tt><% settings.logger %></tt></td>
  93
+                </tr>
  94
+                <tr>
  95
+                    <td>Running environment</td>
  96
+                    <td><tt><% settings.environment %></tt></td>
  97
+                </tr>
  98
+                </tbody>
  99
+            </table>
  100
+          </div>
  101
+
  102
+    <script type="text/javascript">
  103
+    $('#about_env_link').click(function() {
  104
+        $('#about-content').slideToggle('fast', function() {
  105
+            // ok
  106
+        });
  107
+        return( false );
  108
+    });
  109
+    </script>
  110
+
  111
+
  112
+          <ol>          
  113
+            <li>
  114
+              <h2>Tune your application</h2>
  115
+
  116
+              <p>
  117
+              Your application is configured via a global configuration file,
  118
+              <tt>config.yml</tt> and an "environment" configuration file,
  119
+              <tt>environments/development.yml</tt>. Edit those files if you
  120
+              want to change the settings of your application.
  121
+              </p>
  122
+            </li>
  123
+
  124
+            <li>
  125
+              <h2>Add your own routes</h2>
  126
+
  127
+              <p>
  128
+              The default route that displays this page can be removed,
  129
+              it's just here to help you get started. The template used to
  130
+              generate this content is located in 
  131
+              <code>views/index.tt</code>.
  132
+              You can add some routes to <tt>lib/Lystyng.pm</tt>. 
  133
+              </p>
  134
+            </li>
  135
+
  136
+            <li>
  137
+                <h2>Enjoy web development again</h2>
  138
+
  139
+                <p>
  140
+                Once you've made your changes, restart your standalone server
  141
+                (bin/app.pl) and you're ready to test your web application.
  142
+                </p>
  143
+            </li>
  144
+
  145
+          </ol>
  146
+        </div>
  147
+      </div>
  148
+    </div>
20  views/layouts/main.tt
... ...
@@ -0,0 +1,20 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3
+<html xmlns="http://www.w3.org/1999/xhtml">
  4
+<head>
  5
+<meta http-equiv="Content-type" content="text/html; charset=<% settings.charset %>" />
  6
+<title>Lystyng</title>
  7
+<link rel="stylesheet" href="<% request.uri_base %>/css/style.css" />
  8
+
  9
+<script type="text/javascript">/* <![CDATA[ */
  10
+    !window.jQuery && document.write('<script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.js"><\/script>')
  11
+/* ]]> */</script>
  12
+
  13
+</head>
  14
+<body>
  15
+<% content %>
  16
+<div id="footer">
  17
+Powered by <a href="http://perldancer.org/">Dancer</a> <% dancer_version %>
  18
+</div>
  19
+</body>
  20
+</html>

0 notes on commit f750bc6

Please sign in to comment.
Something went wrong with that request. Please try again.