4. USB Drive
Copy the WebGUI Workshop folder to your hard disk
Pass the USB Drive off to someone else
(You’re going to need ~6GB of free space.)
5. Install
Install VMWare Player (or Fusion if on Mac)
(If you already have VMWare Player 2 or higher you can ignore this.)
Decompress the Zip File
Open VMWare
Browse to the folder where you extracted WebGUI
Open WebGUI
6. Test The Image
In the VMWare window log in to the command line
It should tell you what IP address to visit
Open your web browser and go to that IP address
7. File Share
You can access the VM’s filesystem from your computer
Windows: 192.168.47.131data (The IP may be
different on your
Mac/Linux: cifs://192.168.47.131/data install.)
Username: webgui
Password: 123qwe
9. OUR USERS
And 10000+ more...
Fred Rogers Foundation
10. Figures based upon an actual client intranet project that
was built in both Oracle Portals® and WebGUI®, and
estimated for MS Sharepoint®.
Licensing Implementation Hardware WebGUI® Oracle Portals®
3,000,000
80
2,250,000 60
1,500,000 40
750,000 20
Oracle Portals®
0 MS Sharepoint® 0
WebGUI® Site Online Base Apps Full Suite
Physical Cost (Dollars) Time Cost (Months)
13. Sprawling API
WebGUI’s API is huge, can’t cover it all today.
Your brain will hurt without it anyway.
View the full API at:
http://www.plainblack.com/downloads/builds/7.7.20-stable/api/
- or -
perldoc /data/WebGUI/lib/WebGUI/User.pm
We’ll cover some basics now, and the rest as we go.
16. WebGUI::Session
$session is the circulatory and nervous system of WebGUI
Here’s how you create or reopen one:
my $session = WebGUI::Session->open($rootPath, $config);
Here’s how you close one:
$session->close;
Here’s how you destroy one:
$session->var->end;
$session->close;
17. Macros Are Easy
Used to put programmer power into an easy package content
publishers can handle.
Macros reside in /data/WebGUI/lib/WebGUI/Macro
Single subroutine API
Gets a single argument, $session
Start by copying the _macro.skeleton file.
21. How do we know it works?
In your workshop folder find macroRunner.pl
Copy into /data/WebGUI/sbin
Type:
perl macroRunner.pl
--config=www.example.com.conf
--macro=HelloWorld
And you should get:
Hello World!
24. $session | Current User
A reference to the current user:
my $user = $session->user;
ISA WebGUI::User object.
Get a param:
my $username = $user->username;
Set a param:
$user->username($username);
25. Username Macro
Create a macro called ‘Username’
Output the current user’s username.
WRITE IT!
Hint: $session->user
Hint 2: $session->user->username
28. Macros Can Have Params
^Sum(1,2,3,4,5);
Should produce: 15
Parameters are passed in to process() after $session
WRITE IT!
Hint: my ($session, @args) = @_;
Hint 2: $total += $_ foreach @args;
32. Content Handlers Are
Powerful
As easy to write as a macro, but way more powerful.
Can write a full web app with just a content handler.
Used mainly for writing simple round trip services.
Receives a single parameter of $session.
36. Install It
Edit /data/WebGUI/etc/www.example.com.conf
Find the ‘contentHandlers’ section
Add the following to your config file:
“WebGUI::Content::HelloWorld”,
Order is important. If something returns content before your
content handler, then your content handler will never be called.
38. $session | Forms
A reference to the form processor
my $form = $session->form
Fetch a form parameter
my $value = $form->get(“foo”);
Validate it against a specific field type
my $value = $form->get(“foo”,”integer”);
39. Conditionality
Content handlers should be conditional
Based on some setting
A specific URL
A parameter in the URL
A time of day
Anything else you choose
40. Conditional Hello World
Modify HelloWorld so that it only displays if a form parameter
called ‘op’ has a value of ‘helloworld’.
WRITE IT!
Hint: my $value = $session->form->get(‘op’);
42. Sum
Task:
Triggered by form variable called ‘op=Sum’
User enters comma separated list of numbers in form variable
called ‘values’
Sum them
Display the result
Test: http://localhost:8081/?op=Sum;values=1,2,3,4,5
WRITE IT!
43. Sum
package WebGUI::Content::Sum;
use strict;
sub handler {
my ($session) = @_;
if ($session->form->get(‘op’) eq ‘Sum’) {
my @values = split(‘,’, $session->form->get(‘values’));
my $total = 0;
$total += $_ foreach @values;
return $total
}
return undef;
}
1;
45. Making A Form
use WebGUI::HTMLForm;
my $f = WebGUI::HTMLForm->new($session);
$f->hidden( name=>”ip”, value=>$ip );
$f->text( name=>”username”, label=>”Username”);
$f->integer( name=>”guess”, label=>”Pick a number”);
$f->date( name=>”birthday”, label=>”Birth Date”);
$f->submit;
return $f->print;
46. Sum with Form
Task:
Now add a form to make it easier for users to use
WRITE IT!
Hint: my $f = WebGUI::HTMLForm->new($session);
47. Sum
use WebGUI::HTMLForm;
my $f = WebGUI::HTMLForm->new($session);
$f->hidden( name=>’op’, value=>’Sum’ );
$f->text( name=>’values’, defaultValue=>$session->form->get(‘values’),
label => ‘Values to Sum’, subtext => ‘Separated by commas’);
$f->submit;
return $total . “<br />” . $f->print;
48. $session | Styles
You can easily wrap output in a style to make it prettier.
You get the style reference from $session.
my $style = $session->style;
Then you just wrap your output in the style using the userStyle()
method.
return $style->userStyle($output);
58. i18n / Help
i18n allows you to internationalize any other plugins
Help allows you to document your plugins using the i18n
system.
59. Shipping , Payment, and Tax
Drivers
Tie in to shippers like UPS, Fedex, USPS, DHL, etc.
Tie in to payment gateways like PayPal, Google Checkout,
Authorize.net, etc.
Tie in to various tax mechanisms set up by regional governments.
67. Database
A reference to your WebGUI database:
my $db = $session->db;
ISA WebGUI::SQL object.
Read:
my $sth = $db->read($sql, @params);
Write:
$db->write($sql, @params);
69. Database Helpers
Get a row
my @array = $db->quickArray($sql, @params);
my %hash = $db->quickHash($sql, @params);
Get a column
my @array = $db->buildArray($sql, @params);
my %hash = $db->buildHash($sql, @params);
Get a single column from a single row
my $scalar = $db->quickScalar($sql, @params);
70. Log
A reference to the log file
my $log = $session->log;
Write to the log
$log->error($message);
$log->warn($message);
$log->info($message);
$log->debug($message);
71. HTTP
Interact with HTTP
my $http = $session->http;
Set a redirect
$http->setRedirect($url);
Send header
$http->sendHeader;
73. Output
Output back to browser
my $output = $session->output;
Print some content
$output->print($content);
Don’t process macros as printing:
$output->print($content,1);
Set the output handle
$output->setHandle($someFileHandle);