Permalink
Browse files

first commit - freshly created Catalyst app

  • Loading branch information...
vanstyn committed Sep 12, 2013
0 parents commit 3ae1821feffcc0d21ab8559afecde630f8968461
@@ -0,0 +1,4 @@
This file documents the revision history for Perl extension RA::ChinookDemo.

0.01 2013-09-12 15:26:38
- initial revision, generated by Catalyst
@@ -0,0 +1,25 @@
#!/usr/bin/env perl
# IMPORTANT: if you delete this file your app will not work as
# expected. You have been warned.
use inc::Module::Install;
use Module::Install::Catalyst; # Complain loudly if you don't have
# Catalyst::Devel installed or haven't said
# 'make dist' to create a standalone tarball.

name 'RA-ChinookDemo';
all_from 'lib/RA/ChinookDemo.pm';

requires 'Catalyst::Runtime' => '5.90042';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
requires 'Moose';
requires 'namespace::autoclean';
requires 'Config::General'; # This should reflect the config file format you've chosen
# See Catalyst::Plugin::ConfigLoader for supported formats
test_requires 'Test::More' => '0.88';
catalyst;

install_script glob('script/*.pl');
auto_install;
WriteAll;
1 README
@@ -0,0 +1 @@
Run script/ra_chinookdemo_server.pl to test the application.
@@ -0,0 +1,122 @@
# -- RapidApp "Chinook" Video Demo Series --
#
# (www.rapidapp.info/demos/chinook)
#
# Part 1. Intro and Setup
#
# * In this demo we will:
# * Build a new webapp from scratch, using RapidApp
# * Around the "Chinook" sample database
# (http://chinookdatabase.codeplex.com/)
# * Focus on database features using the "RapidDbic" plugin
# (grids, CRUD, query builder, custom views, etc)
# * Record all commands & changes real-time in Git
# (https://github.com/IntelliTree/RA-ChinookDemo)
# * All steps performed live/real-world within this shell
# (SSH session on an ordinary Linux box)
#
# -->
###################################################################
# +++ COMMAND LOG/HISTORY FOR THIS SHELL (to follow along) +++
#
# github.com/IntelliTree/RA-ChinookDemo/blob/master/cmd_history.sh
#
###################################################################
# --
#
# Agenda/Outline:
#
# Part 1 ($self)
# * Intro, agenda, prerequisite knowledge, etc
# * RapidApp installation
# * Create a new skeleton Catalyst app
# * Setup Git and Commit shortcuts
# * Download the chinook database from the web
# * Setup Catalyst DBIC Model for the database
# git tag: 01_prepared_app
#
# Part 2 (RapidDbic Basics)
# * Enable RapidDbic Plugin
# * Demo main out-of-the-box features
# * Schema-based interfaces, grids, searching, reports, etc
# * Relationships
# * Editing (CRUD)
# * Interface options
# * Virtual Columns
# git tag: 02_rapiddbic_basics
#
# Part 3 (User Authentication and Saved Views)
# * AuthCore Plugin
# * Instant user db, sessions, authentication
# * User management
# * NavCore Plugin
# * Saved Views (per-user and public)
# * Manageable navigation tree (drag/drop)
# git tag: 03_auth_and_saved_views
#
# Part 4 and Beyond
# * Extension and Customization
# * Templates
# * Integrating normal Catalyst Controllers/Views
# * Asset management (CSS, JavaScript, Images)
# * Etc...
#
# "Living" Demo
# * New sections added on an ongoing basis
# * Future topics and examples in branches
#
# ----
#
#
# Prerequisite Knowledge:
#
# * You should already know about:
# * Perl
# * Catalyst
# * DBIx::Class (aka "DBIC")
# * Relational database concepts
# * Git
#
# ----
clear
# Install the latest RapidApp (and its dependencies):
cpanm RapidApp
#
# --> (Side note: if you don't have "cpanm")
#
# cpan App::cpanminus # <-- install cpanminus
# (see also http://metacpan.org/module/App::cpanminus)
#
# --
#
clear
# Create new Catalyst app "RA::ChinookDemo":
catalyst.pl RA::ChinookDemo
cd RA-ChinookDemo/ # <-- Enter the new app directory
#
# Initialize git repo and setup remote (on Github)
git init
git remote add origin \
git@github.com:IntelliTree/RA-ChinookDemo.git
#
# Setup 'Commit' alias/shortcut:
alias Commit='\
history -a cmd_history.sh && \
RestoreHistNewlines cmd_history.sh && \
git add --all && \
git commit -m'
#
# Setup 'RestoreHistNewlines' alias (used in 'Commit' above):
alias RestoreHistNewlines='\
sed -i -e \
'"'"'/\\$/,/[^\\]$/{p;d;};/^[a-z]/s/ \( \) *\([^#]\)/ \\\n \1 \2/g'"'"''
#
# ^^ 'sed' command puts newlines back for multi-line commands
# that use backslash (\) to escape newlines. They get stripped
# by the shell when recorded in the history file, and this
# puts them back...
# This is just for readability in cmd_history.sh
#
#
# Now we can record progress & history in a simple one-liner:
Commit 'first commit - freshly created Catalyst app'
@@ -0,0 +1,75 @@
package RA::ChinookDemo;
use Moose;
use namespace::autoclean;

use Catalyst::Runtime 5.80;

# Set flags and add plugins for the application.
#
# Note that ORDERING IS IMPORTANT here as plugins are initialized in order,
# therefore you almost certainly want to keep ConfigLoader at the head of the
# list if you're using it.
#
# -Debug: activates the debug mode for very useful log messages
# ConfigLoader: will load the configuration from a Config::General file in the
# application's home directory
# Static::Simple: will serve static files from the application's root
# directory

use Catalyst qw/
-Debug
ConfigLoader
Static::Simple
/;

extends 'Catalyst';

our $VERSION = '0.01';

# Configure the application.
#
# Note that settings in ra_chinookdemo.conf (or other external
# configuration file that you set up manually) take precedence
# over this when using ConfigLoader. Thus configuration
# details given here can function as a default configuration,
# with an external configuration file acting as an override for
# local deployment.

__PACKAGE__->config(
name => 'RA::ChinookDemo',
# Disable deprecated behavior needed by old applications
disable_component_resolution_regex_fallback => 1,
);

# Start the application
__PACKAGE__->setup();


=head1 NAME
RA::ChinookDemo - Catalyst based application
=head1 SYNOPSIS
script/ra_chinookdemo_server.pl
=head1 DESCRIPTION
[enter your description here]
=head1 SEE ALSO
L<RA::ChinookDemo::Controller::Root>, L<Catalyst>
=head1 AUTHOR
root
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

1;
@@ -0,0 +1,69 @@
package RA::ChinookDemo::Controller::Root;
use Moose;
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
#
__PACKAGE__->config(namespace => '');

=head1 NAME
RA::ChinookDemo::Controller::Root - Root Controller for RA::ChinookDemo
=head1 DESCRIPTION
[enter your description here]
=head1 METHODS
=head2 index
The root page (/)
=cut

sub index :Path :Args(0) {
my ( $self, $c ) = @_;

# Hello World
$c->response->body( $c->welcome_message );
}

=head2 default
Standard 404 error page
=cut

sub default :Path {
my ( $self, $c ) = @_;
$c->response->body( 'Page not found' );
$c->response->status(404);
}

=head2 end
Attempt to render a view, if needed.
=cut

sub end : ActionClass('RenderView') {}

=head1 AUTHOR
root
=head1 LICENSE
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,3 @@
# rename this file to ra::chinookdemo.yml and put a ':' after 'name' if
# you want to use YAML like in old versions of Catalyst
name RA::ChinookDemo
@@ -0,0 +1,8 @@
use strict;
use warnings;

use RA::ChinookDemo;

my $app = RA::ChinookDemo->apply_default_middlewares(RA::ChinookDemo->psgi_app);
$app;

BIN +2.49 KB root/favicon.ico
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,30 @@
#!/usr/bin/env perl

use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('RA::ChinookDemo', 'CGI');

1;

=head1 NAME
ra_chinookdemo_cgi.pl - Catalyst CGI
=head1 SYNOPSIS
See L<Catalyst::Manual>
=head1 DESCRIPTION
Run a Catalyst application as a cgi script.
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

Oops, something went wrong.

0 comments on commit 3ae1821

Please sign in to comment.