Ado
view release on metacpan or search on metacpan
0.47 2014-06-18
- $CODENAME changed to
"Ðлаголи" - U+2C03 GLAGOLITIC CAPITAL LETTER GLAGOLI (â°)
- No more major features (plugins, commands) will be added to Ado for now.
Ado core will be polished, made more stable and some
of the current features and assets will eventually go to plugins.
It is time for plugins.
- Fixed failing tests on Windows.
- Improved and fixed apache2htaccess.ep.
Using $^X in FcgidWrapper so bin/ado is executed with our own Perl.
- Upgraded to Mojolicious 5.09.
- Requiring Module::Build 0.4204 now because $self->install_base
returns string (the path) and not an ARRAY reference when
using --install_base=/custom/path.
- Added notes about local::lib to Ado::Manual/INSTALL.
0.46 2014-06-16
- Added new command Ado::Command::generate::apache2vhost.
- Added new command Ado::Command::generate::apache2htaccess.
- Upgraded to Mojolicious 5.07.
etc/ado-sqlite-schema.sql view on Meta::CPAN
-- 'Last modification time - last HTTP request. Only for statistics',
tstamp INT(11) NOT NULL DEFAULT 0,
-- 'Session data serialized in JSON and packed with Base64',
sessiondata BLOB NOT NULL
);
-- Here we store Intrenationalized messages and labels
DROP TABLE IF EXISTS i18n;
CREATE TABLE i18n (
lang VARCHAR(5) DEFAULT 'en',
msgid VARCHAR(255),
-- files where this message is used
locations TEXT DEFAULT '',
msgstr TEXT DEFAULT '',
-- Set to 1 when the msgstr in the default language changes
fuzzy INT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (lang, msgid)
);
PRAGMA foreign_keys = ON;
/*
PRAGMA foreign_keys = OFF;
DROP TABLE IF EXISTS groups;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS domains;
DROP TABLE IF EXISTS user_group;
DROP TABLE IF EXISTS sessions;
lib/Ado/Command/generate/apache2htaccess.pm view on Meta::CPAN
=head1 NAME
Ado::Command::generate::apache2htaccess - Generates Apache2 .htaccess file
=head1 SYNOPSIS
Usage:
#on the command-line
$ bin/ado generate apache2htaccess --modules cgi,fcgid > .htaccess
#programatically
use Ado::Command::generate::apache2htaccess;
my $v = Ado::Command::generate::apache2htaccess->new;
$v->run('--modules' => 'cgi,fcgid');
=head1 DESCRIPTION
L<Ado::Command::generate::apache2htaccess>
generates an Apache2 C<.htaccess> configuration file for your L<Ado> application.
You can use this command for a shared hosting account.
This is a core command, that means it is always enabled and its code a good
example for learning to build new commands, you're welcome to fork it.
lib/Ado/Command/generate/apache2htaccess.pm view on Meta::CPAN
Full path to the file in which the configuration will be written.
If not provided the configuration is printed to the screen.
=head3 v|verbose
Verbose output.
=head2 M|modules=s@
Apache modules to use for running C<ado>. Currently supported modules are
C<mod_cgi> and C<mod_fcgid>. You can mention them both to add the corresponding
sections and Apache will use C<mod_fcgid> if loaded or C<mod_cgi>
(almost always enabled).
The generated configuration for mod_fcgid will use L<Plack> (C<plackup>) or
L<Mojo::Server::FastCGI>. So make sure you have at least one of them installed.
L<Plack> is recommended.
To use L<Plack> with C<mod_fcgid> you will need to install
L<FCGI>, L<FCGI::ProcManager> and L<Apache::LogFormat::Compiler>.
=head1 ATTRIBUTES
L<Ado::Command::generate::apache2htaccess> inherits all attributes from
L<Ado::Command::generate> and implements the following new ones.
=head2 description
my $description = $htaccess->description;
lib/Ado/Command/generate/apache2htaccess.pm view on Meta::CPAN
=head1 METHODS
L<Ado::Command::generate::apache2htaccess> inherits all methods from
L<Ado::Command::generate> and implements the following new ones.
=head2 run
my $htaccess = Ado::Command::generate::apache2htaccess->run(@ARGV);
my $htaccess = $app->commands->run("generate", "apache2htaccess",
'-m' => 'cgi,fcgid', '-c' => $config_file);
Run this command. Returns C<$self>.
=head1 SEE ALSO
L<Ado::Plugin::Routes>,
L<Apache deployment|https://github.com/kraih/mojo/wiki/Apache-deployment>,
L<Apache - Upgrading to 2.4 from 2.2|http://httpd.apache.org/docs/2.4/upgrading.html>,
L<Ado::Command::generate::apache2vhost>,
L<Ado::Command::generate>, L<Getopt::Long>,
L<Ado::Command> L<Ado::Manual>,
lib/Ado/I18n.pm view on Meta::CPAN
my $self = $class->SUPER::get_handle($language, @{$$config{languages}});
$self->_load_messages_from_db($c->dbix, $$config{default_language})
unless $loaded->{$language};
$loaded->{$language} = 1;
return $self;
}
sub _load_messages_from_db {
my ($self, $dbix, $default) = @_;
my $SQL = <<'SQL';
SELECT d.msgid AS msgid,(
CASE
WHEN cl.msgstr IS NULL OR cl.msgstr=''
THEN d.msgstr
ELSE cl.msgstr
END) AS msgstr
-- default language
FROM (SELECT msgid, msgstr FROM i18n WHERE lang=?) d
-- current language
LEFT JOIN (SELECT msgid, msgstr FROM i18n WHERE lang=?) cl
ON (cl.msgid=d.msgid)
SQL
#get messages from database
my %lex = $dbix->query($SQL, $default, $self->language_tag)->map;
{
no strict 'refs'; ## no critic (ProhibitNoStrict)
my $class_lex = ref($self) . '::Lexicon';
%{$class_lex} = (%{$class_lex}, %lex);
};
return;
lib/Ado/Plugin/Routes.pm view on Meta::CPAN
# $app->routes->add_condition(
# require_formats => sub {
# my ($route, $c, $captures, $formats) = @_;
# $c->debug('$route, $c, $captures, $formats:'
# . $c->dumper( $route, ref $c, $captures, $formats));
# #Carp::cluck(caller);
# return ($c->require_formats($formats) ? 1 : undef);
# }
# );
# Rewrite urls in case we are deployed under Apache and using mod_cgi or mod_fcgid.
# This way we have the same urls as if deployed standalone or with hypnotoad.
# See templates/partials/apache2htaccess.ep
$app->hook(
before_dispatch => sub {
state $cgi = $_[0]->req->env->{GATEWAY_INTERFACE} // '' =~ m/^CGI/;
$_[0]->req->url->base->path($conf->{base_url_path}) if $cgi;
}
) if $conf->{base_url_path};
return $self;
t/command/apache2htaccess.t view on Meta::CPAN
my $IS_DOS = ($^O eq 'MSWin32' or $^O eq 'dos' or $^O eq 'os2');
#plan skip_all => 'Not reliable test under this platform.' if $IS_DOS;
my $t = Test::Mojo->new('Ado');
my $app = $t->app;
my $command = 'Ado::Command::generate::apache2htaccess';
my $tempdir = tempdir(CLEANUP => 1);
my $config_file = catfile($tempdir, '.htaccess');
use_ok($command);
ok( my $c = $app->start("generate", "apache2htaccess", '-M' => 'cgi,fcgid', '-c' => $config_file),
'run() ok'
);
isa_ok($c, $command);
like($c->description, qr/Apache2\s+.htaccess/, 'description looks alike');
like($c->usage, qr/generate\sapache2htaccess.*?mod_fcgid/ms, 'usage looks alike');
ok(my $config_file_content = path($config_file)->slurp, 'generated $config_file');
like($config_file_content, qr/<IfModule\s+mod_cgi.+?"\^\(ado\)\$"/msx, 'mod_cgi block produced');
like($config_file_content, qr/<IfModule\s+mod_fcgid\.c/msx, 'mod_fcgid block produced');
TODO: {
local $TODO = 'Not reliable test under this platform.' if $IS_DOS;
# Note! not sure if the produced .htacces will work fine with Apache on Windows
# so make sure to test locally first.
my ($perl, $app_home) = ($c->args->{perl}, $c->args->{DocumentRoot});
my $plackup = $c->_which('plackup')
if ( eval { require Plack }
&& eval { require FCGI }
&& eval { require FCGI::ProcManager }
&& eval { require Apache::LogFormat::Compiler });
my $has_msfcgi = eval { require Mojo::Server::FastCGI };
if ($has_msfcgi) {
like(
$config_file_content,
qr|FcgidWrapper\s+".+/perl.+$app_home/bin/ado|,
'path to FcgidWrapper is produced (Mojo::Server::FastCGI)'
);
}
if ($plackup) {
like(
$config_file_content,
qr|FcgidWrapper\s+"$plackup\s+$app_home/bin/ado\s+-s\s+FCGI\s+-l\s+|x,
'path to FcgidWrapper is produced (Plack)'
);
}
if (!$plackup && !$has_msfcgi) {
like(
$config_file_content,
qr|no\sPlack\s.+neither\sMojo::Server::FastCGI|x,
'no FcgidWrapper is produced because of missing modules'
);
}
} # end TODO:
done_testing();
templates/partials/apache2htaccess.ep view on Meta::CPAN
# See Ado::Control::Doc as an example on which you can elaborate.
# This is the fallback mode in case no Plack with FCGI and FCGI::ProcManager
# neither Mojo::Server::FastCGI are installed.
<Files ~ "^(<%=$moniker%>)$">
SetHandler cgi-script
</Files>
</IfModule>
% }
% my $has_msfcgi = eval {require Mojo::Server::FastCGI};
% if(grep {$_ eq 'fcgid'} @{$args->{modules}}){
<IfModule mod_fcgid.c>
# See http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
% if(!$plackup && !$has_msfcgi) {
# Sorry! no Plack with FCGI and FCGI::ProcManager neither Mojo::Server::FastCGI are installed.
# Install at least one of them and rerun '<%=$moniker%> apache2htaccess'.
% }
% else {
<Files ~ "^(<%=$moniker%>)$">
SetHandler fcgid-script
</Files>
% }
% if($plackup){
# plackup must be run with the same perl as <%=$moniker%>
% my $sock = File::Spec->catfile(File::Spec->tmpdir(), $moniker.time().$$.'.sock');
% $sock =~ s|\\|/|g;
# Using Plack with FCGI and FCGI::ProcManager
FcgidWrapper "<%= "$plackup $root/bin/$moniker -s FCGI -l $sock" %>"
% }
% if($has_msfcgi){
# Use your own perl. You may need to fix paths if they contain spaces.
# Using Mojo::Server::FastCGI.
# Uncomment the following (and comment any previous "FcgidWrapper")
# if you prefer Mojo::Server::FastCGI.
<%= $plackup? '#':''%> FcgidWrapper "<%= "$args->{perl} $root/bin/$moniker" %> fastcgi"
% }
</IfModule>
% }
# Make Ado handle any 404 errors.
ErrorDocument 404 /bin/<%=$moniker%>
DirectoryIndex /bin/<%=$moniker%>
#Some more security. Redefine the mime type for the most common types of scripts
AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi
( run in 0.940 second using v1.01-cache-2.11-cpan-5735350b133 )