ASP4

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

2010-03-01    v1.018
  - Updated asphelper script so that the POD on CPAN is not contaminated with POD
    from within one of the modules that asphelper generates.
  - Now asphelper will not create a Class::DBI::Lite model class unless 
    Class::DBI::Lite is installed.

2010-03-01    v1.017
  - Updated asphelper script to only accept options on the command-line, like "normal" scripts.

2010-02-28    v1.016
  - A vestigial "use encoding 'utf8'" was removed from ASP4::Server.
  - It was causing Apache to segfault on ubuntu 9.10.

2010-02-19    v1.015
  - Hostnames like http://myapplication/ were not setting session cookies properly.
  - $Config->data_connections->session->cookie_domain should set to "*" in these cases.
  - $Response->SetCookie accepts the "*" value for domain also.
  - The result is that no "domain=xyz" attribute is given to these cookies.

2010-02-18    v1.014
  - $Response->ContentType now functions correctly.

README.markdown  view on Meta::CPAN

    ...

Suppose you had the following tables in your database:

    create table users (
      user_id     bigint unsigned not null primary key auto_increment,
      email       varchar(200) not null,
      password    char(32) not null,
      created_on  timestamp not null default current_timestamp,
      unique(email)
    ) engine=innodb charset=utf8;
    

    create table messages (
      message_id    bigint unsigned not null primary key auto_increment,
      from_user_id  bigint unsigned not null,
      to_user_id    bigint unsigned not null,
      subject       varchar(100) not null,
      body          text,
      created_on    timestamp not null default current_timestamp,
      foreign key fk_messages_to_senders (from_user_id) references users (user_id) on delete cascade,
      foreign key fk_messages_to_recipients (to_user_id) references users (user_id) on delete cascade
    ) engine=innodb charset=utf8;

__NOTE:__ It's best to assign every ASP4 application its own namespace.  For this
example the namespace is `App::db::`

Create the file `lib/App::db/model.pm` and add the following lines:

    package App::db::model;
    

    use strict;

README.markdown  view on Meta::CPAN


Create your MasterPage like this:

File: `htdocs/masters/global.asp`

    <%@ MasterPage %>
    <!DOCTYPE html>
    <html>
      <head>
        <title><asp:ContentPlaceHolder id="meta_title"></asp:ContentPlaceHolder></title>
        <meta charset="utf-8" />
      </head>
      <body>
        <h1><asp:ContentPlaceHolder id="headline"></asp:ContentPlaceHolder></h1>
        <asp:ContentPlaceHolder id="main_content"></asp:ContentPlaceHolder>
      </body>
    </html>

File: `htdocs/index.asp`

    <%@ Page UseMasterPage="/masters/global.asp" %>

lib/ASP4.pm  view on Meta::CPAN

  ...

Suppose you had the following tables in your database:

  create table users (
    user_id     bigint unsigned not null primary key auto_increment,
    email       varchar(200) not null,
    password    char(32) not null,
    created_on  timestamp not null default current_timestamp,
    unique(email)
  ) engine=innodb charset=utf8;
  
  create table messages (
    message_id    bigint unsigned not null primary key auto_increment,
    from_user_id  bigint unsigned not null,
    to_user_id    bigint unsigned not null,
    subject       varchar(100) not null,
    body          text,
    created_on    timestamp not null default current_timestamp,
    foreign key fk_messages_to_senders (from_user_id) references users (user_id) on delete cascade,
    foreign key fk_messages_to_recipients (to_user_id) references users (user_id) on delete cascade
  ) engine=innodb charset=utf8;

B<NOTE:> It's best to assign every ASP4 application its own namespace.  For this
example the namespace is C<App::db::>

Create the file C<lib/App::db/model.pm> and add the following lines:

  package App::db::model;
  
  use strict;
  use warnings 'all';

lib/ASP4.pm  view on Meta::CPAN


Create your MasterPage like this:

File: C<htdocs/masters/global.asp>

  <%@ MasterPage %>
  <!DOCTYPE html>
  <html>
    <head>
      <title><asp:ContentPlaceHolder id="meta_title"></asp:ContentPlaceHolder></title>
      <meta charset="utf-8" />
    </head>
    <body>
      <h1><asp:ContentPlaceHolder id="headline"></asp:ContentPlaceHolder></h1>
      <asp:ContentPlaceHolder id="main_content"></asp:ContentPlaceHolder>
    </body>
  </html>

File: C<htdocs/index.asp>

  <%@ Page UseMasterPage="/masters/global.asp" %>

lib/ASP4/ErrorHandler.pm  view on Meta::CPAN



sub error_html
{
  my ($s, $error) = @_;
  
  my $msg = <<"ERROR";
<!DOCTYPE html>
<html>
<head><title>500 Server Error</title>
<meta charset="utf-8" />
<style type="text/css">
HTML,BODY {
  background-color: #FFFFFF;
}
HTML,BODY,P,DIV {
  font-family: Arial, Helvetica, Sans-Serif;
}
HTML,BODY,P,PRE,DIV {
  font-size: 12px;
}

lib/ASP4/SimpleCGI.pm  view on Meta::CPAN

  $toencode;
}# end escape()


sub unescape
{
  my ($s, $todecode) = @_;
  return unless defined($todecode);
  $todecode =~ tr/+/ /;       # pluses become spaces
  $todecode =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
  defined($1)? chr hex($1) : utf8_chr(hex($2))/ge;
  return $todecode;
}# end unescape()


sub DESTROY
{
  my $s = shift;
  
  map {
    close($s->{uploads}->{$_}->{filehandle});

sbin/asphelper  view on Meta::CPAN


set foreign_key_checks = 0;
drop table if exists asp_sessions;
set foreign_key_checks = 1;

create table asp_sessions (
  session_id   char(32) not null primary key,
  session_data blob,
  created_on   datetime default null,
  modified_on  datetime default null
) engine=innodb charset=utf8;

SQL
  close($ofh);
  open my $ifh, "common/sbin/ddl.sql"
    or die "Cannot open 'common/sbin/ddl.sql' for reading: $!";
  local $/ = ';';
  while( my $cmd = <$ifh> )
  {
    $cmd =~ s/^\s+//s;
    $cmd =~ s/\s+$//s;

t/050-encoding/010-default.t  view on Meta::CPAN

#!/usr/bin/perl -w

use utf8;
use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;

my $hellos = {
  arabic  => {
    original  => 'مرحبا ، العالم!',
    encoded => 'JiMxNjA1OyYjMTU4NTsmIzE1ODE7JiMxNTc2OyYjMTU3NTsgJiMxNTQ4OyAmIzE1NzU7JiMxNjA0
OyYjMTU5MzsmIzE1NzU7JiMxNjA0OyYjMTYwNTsh'

t/handlers/dev/encoding/hello.pm  view on Meta::CPAN


package dev::encoding::hello;

use strict;
use warnings 'all';
use base 'ASP4::FormHandler';
use vars __PACKAGE__->VARS;
use MIME::Base64;
use Encode;
use utf8;

# TODO: Encoding tests to make sure we get round-trip encoding integrity.
sub run
{
  my ($s, $context) = @_;
  
  my $hellos = {
    arabic  => {
      original  => 'مرحبا ، العالم!',
      encoded => 'JiMxNjA1OyYjMTU4NTsmIzE1ODE7JiMxNTc2OyYjMTU3NTsgJiMxNTQ4OyAmIzE1NzU7JiMxNjA0

t/handlers/dev/encoding/hello.pm  view on Meta::CPAN

      original  => '你好,世界!',
      encoded   => 'JiMyMDMyMDsmIzIyOTA5OyYjNjUyOTI7JiMxOTk5MDsmIzMwMDI4OyYjNjUyODE7',
    },
    foo => {
      original  => 'Bjòrknù',
    }
  };
  
  my $lang = $Form->{lang}
    or return;
  $Response->ContentType("text/plain; charset=utf-8");
  $Response->Write(
    encode_utf8(
      $hellos->{$lang}->{original}
    )
  );
}# end run()

1;# return true:

t/htdocs/index.asp  view on Meta::CPAN

<!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" xml:lang="en" lang="en" dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>ASP4 Installed</title>
  <style type="text/css">
  HTML, BODY {
    margin: 0px;
    padding: 0px;
    border: 0px;
    font-size: 14px;
    font-family: Verdana, Arial, Sans-Serif;
    background-color: #333333;
    color: #000000;



( run in 0.323 second using v1.01-cache-2.11-cpan-4d50c553e7e )