Alice
view release on metacpan or search on metacpan
lib/Alice/HTTP/Server.pm view on Meta::CPAN
my $dest = $req->param("dest") || "/";
# no auth is required
if (!$self->auth_enabled) {
$res->redirect($dest);
$res->send;
}
# we have credentials
elsif (my $user = $req->param('username')
and my $pass = $req->param('password')) {
$self->authenticate($user, $pass, sub {
my $app = shift;
if ($app) {
$req->env->{"psgix.session"} = {
is_logged_in => 1,
username => $user,
userid => $app->user,
};
$res->redirect($dest);
}
else {
$req->env->{"psgix.session"}{is_logged_in} = 0;
$req->env->{"psgix.session.options"}{expire} = 1;
$res->content_type("text/html; charset=utf-8");
$res->body($self->render("login", $dest, "bad username or password"));
}
$res->send;
});
}
# render the login page
else {
$res->content_type("text/html; charset=utf-8");
$res->body($self->render("login", $dest));
$res->send;
lib/Alice/Readme.pod view on Meta::CPAN
by hand. You can find this file at ~/.alice/config.
The config is simply a perl hash. So, if you are familiar with perl it
should not be too intimidating. If you do not know perl, sorry! :)
You will need to add "user" and "pass" values to the "auth" hash.
The resulting section of configuration might look like this:
'auth' => {
'user' => 'lee',
'pass' => 'mypassword',
},
=head1 COMMANDS
=over 4
=item /j[oin] [-network] $channel
Takes a channel name as an argument, and an optional network flag.
If no network flag is provided, it will use the network of the
lib/Alice/Role/Commands.pm view on Meta::CPAN
my @nicks = $req->irc->channel_nicks($req->window->title);
$req->reply($req->window->nick_table(@nicks));
},
};
command qr{join|j} => {
name => "join",
opts => qr{(\S+)\s*(\S+)?},
connection => 1,
network => 1,
eg => "/JOIN [-<network>] <channel> [<password>]",
desc => "Joins the specified channel.",
cb => sub {
my ($self, $req, $opts) = @_;
my $channel = $opts->[0];
$req->reply("joining $channel on ". $req->irc->name);
$req->send_srv(JOIN => @$opts);
},
};
lib/Alice/Role/IRCEvents.pm view on Meta::CPAN
$self->broadcast({
type => "action",
event => "connect",
network => $irc->name,
});
my $config = $self->config->servers->{$irc->name};
$irc->cl->register(
$config->{nick}, $config->{username}, $config->{ircname}, $config->{password}
);
};
irc_event registered => sub {
my ($self, $irc) = @_;
my $config = $self->config->servers->{$irc->name};
$irc->reset_reconnect_count;
$irc->cl->{connected} = 1; # AE::IRC seems broken here...
share/static/alice.js view on Meta::CPAN
},
radio: function(elem){
return "radio" === elem.type;
},
checkbox: function(elem){
return "checkbox" === elem.type;
},
file: function(elem){
return "file" === elem.type;
},
password: function(elem){
return "password" === elem.type;
},
submit: function(elem){
return "submit" === elem.type;
},
image: function(elem){
return "image" === elem.type;
},
reset: function(elem){
return "reset" === elem.type;
},
share/templates/config.html view on Meta::CPAN
</tr>
<tr>
<td>
<label>Username</label>
<input type="text" name="<?= $network ?>_username" value="<?= $config->{username} || ""?>" size="15" />
</td>
<td>
<label>Password</label>
<input type="text" name="<?= $network ?>_password" value="<?= $config->{password} || ""?>" size="15" />
</td>
</tr>
<tr>
<td>
<label>Channels
<span style="font-size:0.8em">(e.g. <span style="font-family:monospace;font-size:1em">#alice</span>)</span>
</label>
<select name="<?= $network ?>_channels" multiple="multiple" id="channels_<?= $network ?>" class="channelselect">
<? for my $channel (@{$config->{channels}}) { ?>
share/templates/login.html view on Meta::CPAN
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
</head>
<body>
<form action="/login" method="post">
<input type="hidden" name="dest" value="<?= $dest || "/" ?>" />
<label for="username">User Name:</label>
<input type="text" name="username" value="" id="username" />
<label for="password">Password:</label>
<input type="password" name="password" value="" id="password" />
<input type="submit" value="Log in" />
<? if ($error) { ?>
<span class="error"><?= $error ?></span>
<? } ?>
</form>
</body>
</html>
share/templates/new_server.html view on Meta::CPAN
</tr>
<tr>
<td>
<label>Username</label>
<input type="text" name="<?= $alias ?>_username" value="" size="15" />
</td>
<td>
<label>Password</label>
<input type="text" name="<?= $alias ?>_password" value="" size="15" />
</td>
</tr>
<tr>
<td>
<label>Channels
<span style="font-size:0.8em">(e.g. <span style="font-family:monospace;font-size:1em">#alice</span>)</span>
</label>
<select name="<?= $alias ?>_channels" multiple="multiple" id="channels_<?= $alias ?>" class="channelselect">
</select>
( run in 0.622 second using v1.01-cache-2.11-cpan-49f99fa48dc )