]> git.etc.gen.nz Git - etcx-sounds.git/commitdiff
Save boilerplate.
authorAndrew Ruthven <andrew@etc.gen.nz>
Tue, 14 May 2013 10:19:05 +0000 (22:19 +1200)
committerAndrew Ruthven <andrew@sounds.agr.etc.gen.nz>
Tue, 14 May 2013 10:19:33 +0000 (22:19 +1200)
19 files changed:
MANIFEST [new file with mode: 0644]
MANIFEST.SKIP [new file with mode: 0644]
Makefile.PL [new file with mode: 0644]
bin/app.pl [new file with mode: 0755]
config.yml [new file with mode: 0644]
environments/development.yml [new file with mode: 0644]
environments/production.yml [new file with mode: 0644]
lib/EtcX/Sounds.pm [new file with mode: 0644]
public/404.html [new file with mode: 0644]
public/500.html [new file with mode: 0644]
public/css/error.css [new file with mode: 0644]
public/css/style.css [new file with mode: 0644]
public/dispatch.cgi [new file with mode: 0755]
public/dispatch.fcgi [new file with mode: 0755]
public/javascripts/jquery.js [new symlink]
t/001_base.t [new file with mode: 0644]
t/002_index_route.t [new file with mode: 0644]
views/index.tt [new file with mode: 0644]
views/layouts/main.tt [new file with mode: 0644]

diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..9636ad7
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,19 @@
+MANIFEST
+bin/app.pl
+config.yml
+environments/development.yml
+environments/production.yml
+views/index.tt
+views/layouts/main.tt
+MANIFEST.SKIP
+lib/EtcX/Sounds.pm
+public/css/style.css
+public/css/error.css
+public/404.html
+public/dispatch.fcgi
+public/javascripts/jquery.js
+public/dispatch.cgi
+public/500.html
+t/002_index_route.t
+t/001_base.t
+Makefile.PL
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
new file mode 100644 (file)
index 0000000..8fd3d29
--- /dev/null
@@ -0,0 +1,13 @@
+^\.git\/
+maint
+^tags$
+.last_cover_stats
+Makefile$
+^blib
+^pm_to_blib
+^.*.bak
+^.*.old
+^t.*sessions
+^cover_db
+^.*\.log
+^.*\.swp$
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..41752d6
--- /dev/null
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME                => 'EtcX::Sounds',
+    AUTHOR              => q{Andrew Ruthven <andrew@etc.gen.nz>},
+    VERSION_FROM        => 'lib/EtcX/Sounds.pm',
+    ABSTRACT            => 'Simple playlist and album selector for MPD',
+    ($ExtUtils::MakeMaker::VERSION >= 6.3002
+      ? ('LICENSE'=> 'perl')
+      : ()),
+    PL_FILES            => {},
+    PREREQ_PM => {
+        'Test::More' => 0,
+        'YAML'       => 0,
+        'Dancer'     => 1.3095,
+    },
+    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean               => { FILES => 'EtcX-Sounds-*' },
+);
diff --git a/bin/app.pl b/bin/app.pl
new file mode 100755 (executable)
index 0000000..286c2cb
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/env perl
+use Dancer;
+use EtcX::Sounds;
+dance;
diff --git a/config.yml b/config.yml
new file mode 100644 (file)
index 0000000..c02a571
--- /dev/null
@@ -0,0 +1,29 @@
+# This is the main configuration file of your Dancer app
+# env-related settings should go to environments/$env.yml
+# all the settings in this file will be loaded at Dancer's startup.
+
+# Your application's name
+appname: "EtcX::Sounds"
+
+# The default layout to use for your application (located in
+# views/layouts/main.tt)
+layout: "main"
+
+# when the charset is set to UTF-8 Dancer will handle for you
+# all the magic of encoding and decoding. You should not care
+# about unicode within your app when this setting is set (recommended).
+charset: "UTF-8"
+
+# template engine
+# simple: default and very basic template engine
+# template_toolkit: TT
+
+template: "simple"
+
+# template: "template_toolkit"
+# engines:
+#   template_toolkit:
+#     encoding:  'utf8'
+#     start_tag: '[%'
+#     end_tag:   '%]'
+
diff --git a/environments/development.yml b/environments/development.yml
new file mode 100644 (file)
index 0000000..2d3eaa7
--- /dev/null
@@ -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 environment
+# core is the lowest, it shows Dancer's core log messages as well as yours
+# (debug, info, 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
diff --git a/environments/production.yml b/environments/production.yml
new file mode 100644 (file)
index 0000000..86801b4
--- /dev/null
@@ -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
+
diff --git a/lib/EtcX/Sounds.pm b/lib/EtcX/Sounds.pm
new file mode 100644 (file)
index 0000000..6d8e78b
--- /dev/null
@@ -0,0 +1,10 @@
+package EtcX::Sounds;
+use Dancer ':syntax';
+
+our $VERSION = '0.1';
+
+get '/' => sub {
+    template 'index';
+};
+
+true;
diff --git a/public/404.html b/public/404.html
new file mode 100644 (file)
index 0000000..fc3e1c4
--- /dev/null
@@ -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>.
+</div>
+</body>
+</html>
diff --git a/public/500.html b/public/500.html
new file mode 100644 (file)
index 0000000..232dde9
--- /dev/null
@@ -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>.
+</div>
+</body>
+</html>
diff --git a/public/css/error.css b/public/css/error.css
new file mode 100644 (file)
index 0000000..003ee2a
--- /dev/null
@@ -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;
+}
+
diff --git a/public/css/style.css b/public/css/style.css
new file mode 100644 (file)
index 0000000..706c3e5
--- /dev/null
@@ -0,0 +1,189 @@
+
+body {
+margin: 0;
+margin-bottom: 25px;
+padding: 0;
+background-color: #ddd;
+background-image: url("/images/perldancer-bg.jpg");
+background-repeat: no-repeat;
+background-position: top left;
+
+font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
+font-size: 13px;
+color: #333;
+}
+
+h1 {
+font-size: 28px;
+color: #000;
+}
+
+a  {color: #03c}
+a:hover {
+background-color: #03c;
+color: white;
+text-decoration: none;
+}
+
+#page {
+background-color: #ddd;
+width: 750px;
+margin: auto;
+margin-left: auto;
+padding-left: 0px;
+margin-right: auto;
+}
+
+#content {
+background-color: white;
+border: 3px solid #aaa;
+border-top: none;
+padding: 25px;
+width: 500px;
+}
+
+#sidebar {
+float: right;
+width: 175px;
+}
+
+#header, #about, #getting-started {
+padding-left: 75px;
+padding-right: 30px;
+}
+
+
+#header {
+background-image: url("/images/perldancer.jpg");
+background-repeat: no-repeat;
+background-position: top left;
+height: 64px;
+}
+#header h1, #header h2 {margin: 0}
+#header h2 {
+color: #888;
+font-weight: normal;
+font-size: 16px;
+}
+
+#about h3 {
+margin: 0;
+margin-bottom: 10px;
+font-size: 14px;
+}
+
+#about-content {
+background-color: #ffd;
+border: 1px solid #fc0;
+margin-left: -11px;
+}
+#about-content table {
+margin-top: 10px;
+margin-bottom: 10px;
+font-size: 11px;
+border-collapse: collapse;
+}
+#about-content td {
+padding: 10px;
+padding-top: 3px;
+padding-bottom: 3px;
+}
+#about-content td.name  {color: #555}
+#about-content td.value {color: #000}
+
+#about-content.failure {
+background-color: #fcc;
+border: 1px solid #f00;
+}
+#about-content.failure p {
+margin: 0;
+padding: 10px;
+}
+
+#getting-started {
+border-top: 1px solid #ccc;
+margin-top: 25px;
+padding-top: 15px;
+}
+#getting-started h1 {
+margin: 0;
+font-size: 20px;
+}
+#getting-started h2 {
+margin: 0;
+font-size: 14px;
+font-weight: normal;
+color: #333;
+margin-bottom: 25px;
+}
+#getting-started ol {
+margin-left: 0;
+padding-left: 0;
+}
+#getting-started li {
+font-size: 18px;
+color: #888;
+margin-bottom: 25px;
+}
+#getting-started li h2 {
+margin: 0;
+font-weight: normal;
+font-size: 18px;
+color: #333;
+}
+#getting-started li p {
+color: #555;
+font-size: 13px;
+}
+
+#search {
+margin: 0;
+padding-top: 10px;
+padding-bottom: 10px;
+font-size: 11px;
+}
+#search input {
+font-size: 11px;
+margin: 2px;
+}
+#search-text {width: 170px}
+
+#sidebar ul {
+margin-left: 0;
+padding-left: 0;
+}
+#sidebar ul h3 {
+margin-top: 25px;
+font-size: 16px;
+padding-bottom: 10px;
+border-bottom: 1px solid #ccc;
+}
+#sidebar li {
+list-style-type: none;
+}
+#sidebar ul.links li {
+margin-bottom: 5px;
+}
+
+h1, h2, h3, h4, h5 {
+font-family: sans-serif;
+margin: 1.2em 0 0.6em 0;
+}
+
+p {
+line-height: 1.5em;
+margin: 1.6em 0;
+}
+
+code, tt {
+    font-family: 'Andale Mono', Monaco, 'Liberation Mono', 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', monospace;
+}
+
+#footer {
+clear: both;
+padding-top: 2em;
+text-align: center;
+padding-right: 160px;
+font-family: sans-serif;
+font-size: 10px;
+}
diff --git a/public/dispatch.cgi b/public/dispatch.cgi
new file mode 100755 (executable)
index 0000000..3bb7f2a
--- /dev/null
@@ -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);
diff --git a/public/dispatch.fcgi b/public/dispatch.fcgi
new file mode 100755 (executable)
index 0000000..8c42e3a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+use Dancer ':syntax';
+use FindBin '$RealBin';
+use Plack::Handler::FCGI;
+
+# 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');
+my $app = do($psgi);
+die "Unable to read startup script: $@" if $@;
+my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
+
+$server->run($app);
diff --git a/public/javascripts/jquery.js b/public/javascripts/jquery.js
new file mode 120000 (symlink)
index 0000000..b77fd86
--- /dev/null
@@ -0,0 +1 @@
+/usr/share/javascript/jquery/jquery.js
\ No newline at end of file
diff --git a/t/001_base.t b/t/001_base.t
new file mode 100644 (file)
index 0000000..4ffb91c
--- /dev/null
@@ -0,0 +1,5 @@
+use Test::More tests => 1;
+use strict;
+use warnings;
+
+use_ok 'EtcX::Sounds';
diff --git a/t/002_index_route.t b/t/002_index_route.t
new file mode 100644 (file)
index 0000000..e88eb5b
--- /dev/null
@@ -0,0 +1,10 @@
+use Test::More tests => 2;
+use strict;
+use warnings;
+
+# the order is important
+use EtcX::Sounds;
+use Dancer::Test;
+
+route_exists [GET => '/'], 'a route handler is defined for /';
+response_status_is ['GET' => '/'], 200, 'response status is 200 for /';
diff --git a/views/index.tt b/views/index.tt
new file mode 100644 (file)
index 0000000..cf4382e
--- /dev/null
@@ -0,0 +1,148 @@
+  
+<!-- 
+    Credit goes to the Ruby on Rails team for this page 
+    has been heavily based on the default Rails page that is 
+    built with a scaffolded application.
+
+    Thanks a lot to them for their work.
+
+    See Ruby on Rails if you want a kickass framework in Ruby:
+    http://www.rubyonrails.org/
+-->
+
+<div id="page">
+      <div id="sidebar">
+        <ul id="sidebar-items">
+          <li>
+            <h3>Join the community</h3>
+            <ul class="links">
+
+              <li><a href="http://perldancer.org/">PerlDancer</a></li>
+              <li><a href="http://twitter.com/PerlDancer/">Official Twitter</a></li>
+              <li><a href="http://github.com/sukria/Dancer/">GitHub Community</a></li>
+            </ul>
+          </li>
+          
+          <li>
+            <h3>Browse the documentation</h3>
+
+            <ul class="links">
+              <li><a
+              href="http://search.cpan.org/dist/Dancer/lib/Dancer/Introduction.pod">Introduction</a></li>
+              <li><a href="http://search.cpan.org/dist/Dancer/lib/Dancer/Cookbook.pod">Cookbook</a></li>
+              <li><a href="http://search.cpan.org/dist/Dancer/lib/Dancer/Deployment.pod">Deployment Guide</a></li>
+              <li><a
+              href="http://search.cpan.org/dist/Dancer/lib/Dancer/Tutorial.pod"
+              title="a tutorial to build a small blog engine with Dancer">Tutorial</a></li>
+            </ul>
+          </li>
+
+          <li>
+            <h3>Your application's environment</h3>
+
+            <ul>
+                <li>Location: <code>/home/andrew/EtcX-Sounds</code></li>
+                <li>Template engine: <code><% settings.template %></code></li>
+                <li>Logger: <code><% settings.logger %></code></li>
+                <li>Environment: <code><% settings.environment %></code></li>
+            </ul>
+
+          </li>
+        </ul>
+
+      </div>
+
+      <div id="content">
+        <div id="header">
+          <h1>Perl is dancing</h1>
+          <h2>You&rsquo;ve joined the dance floor!</h2>
+        </div>
+
+        <div id="getting-started">
+          <h1>Getting started</h1>
+          <h2>Here&rsquo;s how to get dancing:</h2>
+                    
+          <h3><a href="#" id="about_env_link">About your application's environment</a></h3>
+
+          <div id="about-content" style="display: none;">
+            <table>
+                <tbody>
+                <tr>
+                    <td>Perl version</td>
+                    <td><tt><% perl_version %></tt></td>
+                </tr>
+                <tr>
+                    <td>Dancer version</td>
+                    <td><tt><% dancer_version %></tt></td>
+                </tr>
+                <tr>
+                    <td>Backend</td>
+                    <td><tt><% settings.apphandler %></tt></td>
+                </tr>
+                <tr>
+                    <td>Appdir</td>
+                    <td><tt>/home/andrew/EtcX-Sounds</tt></td>
+                </tr>
+                <tr>
+                    <td>Template engine</td>
+                    <td><tt><% settings.template %></tt></td>
+                </tr>
+                <tr>
+                    <td>Logger engine</td>
+                    <td><tt><% settings.logger %></tt></td>
+                </tr>
+                <tr>
+                    <td>Running environment</td>
+                    <td><tt><% settings.environment %></tt></td>
+                </tr>
+                </tbody>
+            </table>
+          </div>
+
+    <script type="text/javascript">
+    $('#about_env_link').click(function() {
+        $('#about-content').slideToggle('fast', function() {
+            // ok
+        });
+        return( false );
+    });
+    </script>
+
+
+          <ol>          
+            <li>
+              <h2>Tune your application</h2>
+
+              <p>
+              Your application is configured via a global configuration file,
+              <tt>config.yml</tt> and an "environment" configuration file,
+              <tt>environments/development.yml</tt>. Edit those files if you
+              want to change the settings of your application.
+              </p>
+            </li>
+
+            <li>
+              <h2>Add your own routes</h2>
+
+              <p>
+              The default route that displays this page can be removed,
+              it's just here to help you get started. The template used to
+              generate this content is located in 
+              <code>views/index.tt</code>.
+              You can add some routes to <tt>lib/EtcX/Sounds.pm</tt>. 
+              </p>
+            </li>
+
+            <li>
+                <h2>Enjoy web development again</h2>
+
+                <p>
+                Once you've made your changes, restart your standalone server
+                (bin/app.pl) and you're ready to test your web application.
+                </p>
+            </li>
+
+          </ol>
+        </div>
+      </div>
+    </div>
diff --git a/views/layouts/main.tt b/views/layouts/main.tt
new file mode 100644 (file)
index 0000000..a7ef88d
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=<% settings.charset %>" />
+<title>EtcX::Sounds</title>
+<link rel="stylesheet" href="<% request.uri_base %>/css/style.css" />
+
+<script type="text/javascript">/* <![CDATA[ */
+    !window.jQuery && document.write('<script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.js"><\/script>')
+/* ]]> */</script>
+
+</head>
+<body>
+<% content %>
+<div id="footer">
+Powered by <a href="http://perldancer.org/">Dancer</a> <% dancer_version %>
+</div>
+</body>
+</html>