catalyst.pl Hastu cd Hastu/ # this is important mv hastu.psgi app.psgi # need to edit app.psgi here git add . git init && git add . git commit -m "first commit" git remote add origin https://github.com/simonecesano/Hastu.git cpanm --installdeps . heroku apps:create hastu --stack cedar --buildpack https://github.com/miyagawa/heroku-buildpack-perl.git git push -u origin master git push heroku master
Saturday, September 27, 2014
Deploying Catalyst apps to Heroku
Saturday, May 31, 2014
Setting up a Postgres database
First you create the directory the database resides in:
Change to "unload" to stop the system from starting postgres automatically.
sudo mkdir /Volumes/Data/Postgresql/perfido
Then you make sure that it's owned by the user postgressudo chown -R postgres:postgres /Volumes/Data/Postgresql
and finally you create the databasesudo su postgres -c "initdb -D /Volumes/Data/Postgresql/perfido"
and you're ready to go.
If things don't work (you get a "could not connect to server" message) it's very likely a path issue (see this), and therefore fix your path:export PATH=/opt/local/lib/postgresql93/bin:$PATHTo start postgres automatically use:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql93-server.plist
Change to "unload" to stop the system from starting postgres automatically.
Sunday, March 20, 2011
Serving the right file suffix
Sometimes if you use applications other than the browser to open up links (i.e.: Excel), they behave better if the file served has the neat, correct suffix at the end.
This messes up all internal paths in Catalyst though. So I figured out that if I could clean up the suffix at the end of the URI, and keep it as the format parameter, I'd solved the problem. So here's the code:
This messes up all internal paths in Catalyst though. So I figured out that if I could clean up the suffix at the end of the URI, and keep it as the format parameter, I'd solved the problem. So here's the code:
# inside My::Catalyst::App
after 'prepare_path' => sub {
my ($c) = @_;
local $_ = $c->request->path;
s/\.([a-z]+)$//i;
$c->stash->{format} = lc $1 || 'html';
$c->request->path($_);
};
Cleaning up parameters
I decided that one-letter parameters would be only for internal application use, so that all other can be directly used for querying data. That way I can separate them out before every action, by using a private action in the root controller like this:
Now I have a set of separate parameters that I can use
sub begin : Private {
my ( $self, $c) = @_;
my ($p, $i);
$p = $c->req->params;
for (grep { /^\w$/ } keys %{$p}) {
$i->{$_} = $p->{$_};
delete $p->{$_}
}
$c->stash->{params} = $p;
$c->stash->{int_params} = $i;
}
Now I have a set of separate parameters that I can use
- v = view
- f = format
- q = query
- p = page
- n = number per page
- s = sort
- c = columns
- l = language
Tuesday, July 28, 2009
Serving static files with Catalyst
Serving static javascript files from Catalyst can be a hassle. URLs don't match etc.
If instead you change your MyApp.pm file as follows
Even better, if you don't have application specific files, you can symlink the directory to the one where you keep the same files to be served by Lighttpd.
If instead you change your MyApp.pm file as follows
and you place your javascript files in the MyApp/root/js directory, the hassle's gone.
__PACKAGE__->config->{static}->{dirs} = [
'static',
qr/^(images|css|js)/,
];
Even better, if you don't have application specific files, you can symlink the directory to the one where you keep the same files to be served by Lighttpd.
Catalyst FastCGI in a directory
This configuration allows you to have multiple applications run separately from a single Lighttpd instance, by dispatching to them based on the root directory.
This way it's easier to update single parts, and debug them separately.
This way it's easier to update single parts, and debug them separately.
#----------------------------------------------------------------------------
# this is a lighttpd configuration file for a Catalyst FCGI application
# that lives within a directory
#----------------------------------------------------------------------------
#-----------------------------------------
# ensure there's always a trailing slash
#-----------------------------------------
url.rewrite-once = (
"^/(skunky)$" => "/$1/",
)
#-----------------------------------------
# forward requests to the FCGI server
#-----------------------------------------
$HTTP["url"] =~ "^/skunky" {
alias.url = (
# app-specific favicon (does this work?)
"/favicon.ico" => "/var/www/Skunky/favicon.ico",
# standard js
"/js/" => "/var/www/js/",
# app-specific css
"/css/" => "/var/www/Skunky/css/",
)
# fcgi - does not rewrite the script name
fastcgi.server = (
"/skunky" => (
( "host" => "127.0.0.1", "port" => 3012, "check-local" => "disable"),
)
)
}
Sunday, October 19, 2008
Catalyst: SQLite database location
Using SQLite databases for apps is quick and easy. If you move your app around you can keep your DBI connection pointed to a file that's relative to where the application is located, like so:
my $db = DocBox->path_to( qw(my app data info.db) );
__PACKAGE__->config(
schema_class => 'MyApp::Data::Info',
connect_info => [
"dbi:SQLite:$db"
],
);
Subscribe to:
Posts (Atom)