ASP4

 view release on metacpan or  search on metacpan

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;
}

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/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.278 second using v1.01-cache-2.11-cpan-4d50c553e7e )