added package lazwebextra from Michael Van Canneyt

git-svn-id: trunk@25949 -
This commit is contained in:
mattias 2010-06-06 10:16:08 +00:00
parent fcff6da8ef
commit 02a45e2d4d
7 changed files with 627 additions and 1 deletions

5
.gitattributes vendored
View File

@ -919,7 +919,11 @@ components/fpweb/demo/session/sessiondemo.lpr svneol=native#text/plain
components/fpweb/demo/session/wmsession.lfm svneol=native#text/plain
components/fpweb/demo/session/wmsession.lrs svneol=native#text/pascal
components/fpweb/demo/session/wmsession.pp svneol=native#text/plain
components/fpweb/frmrpcmoduleoptions.lfm svneol=native#text/plain
components/fpweb/frmrpcmoduleoptions.pp svneol=native#text/plain
components/fpweb/lazweb.pp svneol=native#text/plain
components/fpweb/lazwebextra.lpk svneol=native#text/plain
components/fpweb/reglazwebextra.pp svneol=native#text/plain
components/fpweb/weblaz.lpk svneol=native#text/plain
components/fpweb/weblaz.pas svneol=native#text/plain
components/fpweb/weblazideintf.pp svneol=native#text/plain
@ -5145,6 +5149,7 @@ packager/globallinks/lazreport-0.9.5.lpl svneol=native#text/plain
packager/globallinks/lazreportpdfexport-0.lpl svneol=native#text/plain
packager/globallinks/lazsvnpkg-0.lpl svneol=native#text/plain
packager/globallinks/lazthread-0.lpl svneol=native#text/plain
packager/globallinks/lazwebextra-0.lpl svneol=native#text/plain
packager/globallinks/leakview-0.lpl svneol=native#text/plain
packager/globallinks/lhelpcontrolpkg-0.lpl svneol=native#text/plain
packager/globallinks/lr_add_function-0.lpl svneol=native#text/plain

View File

@ -1 +1,117 @@
Author: Michael Van Canneyt
This is the fpWeb components directory README.
It contains 2 packages:
The LazWeb package implements IDE functionality for FCL-Web.
It should work with version 2.4.x of FPC.
The LazWebExtra package implements more IDE projects and components,
which are available only as of version 2.5.1 of the compiler.
As these items become available in a stable release, the package will be
merged in Lazweb.
Both packages registers a series of project wizards, and some components.
The following project types are registered in the lazweb package:
- CGI application
- Apache Application (an apache module)
- Custom CGI application ("bare bones" cgi, no web modules)
- FastCGI application
- Custom FastCGI application ("bare bones" fastcgi, no web modules)
For each of these projects, a Web Module is created by default.
The following web modules can be created:
- WebDataModule (TFPWebModule)
This is a general-purpose HTTP request handling module,
which can be used to handle any HTTP request for any kind of data.
- HTMLModule (TFPHTMLModule)
This is a specific HTTP request handling module, aimed specially
at producing a HTML response.
The following components are registered:
THTMLDatasetContentProducer
Creates a HTML table based on a TDataset descendent
THTMLSelectProducer
Creates a <SELECT> element based on a TStringList.
THTMLDatasetSelectProducer
Creates a <SELECT> element based on a dataset (a lookup combo)
THTMLEntityProducer
Creates a HTML ENTITY document
THTMLPageProducer
Creates a HTML page using an event handler.
THTMLDataSetFormShowProducer
Creates a <FORM> which allows to show a single record of a dataset.
THTMLDataSetFormEditProducer
Creates a <FORM> which allows to edit a single record of a dataset.
THTMLDataSetFormGridProducer
Creates a series of forms.
The lazwebextra package additionally registers the following web modules
and components:
- Web Data Provider module (TFPWebProviderDataModule)
Used to convert TDataset to a variety of formats and to handle updates to the data.
(ExtJS JSON and XML currently)
- JSON-RPC request handling module (TJSONRPCModule)
Used to handle JSON-RPC requests.
- Ext.Direct handling of JSON-RPC requests (TExtDirectModule)
Handles the Ext.Direct variant of JSON-RPC.
The following components are registered:
TFPWebDataProvider
Handles CRUD (Create/Read/Update/Delete) operations on a TDataset
TSQLDBWebDataProvider
Handles CRUD (Create/Read/Update/Delete) operations on a TSQLConnection.
(INSERT/SELECT/UPDATE/DELETE SQL statements can be specified).
TWebdataInputAdaptor
Transforms HTTP request to a format that TFPWebDataProvider
understands, using event handlers.
TExtJSJSonWebdataInputAdaptor
TWebdataInputAdaptor descendent that transforms a ExtJS Datastore
JSON request to input usable by TFPWebDataProvider.
TExtJSJSONDataFormatter
Outputs JSON as expected by ExtJS datastores from all operations on a
TFPWebDataProvider instance.
TExtJSXMLWebdataInputAdaptor
TWebdataInputAdaptor descendent that transforms a ExtJS Datastore
XML request to input usable by TFPWebDataProvider.
TExtJSXMLDataFormatter,
Outputs XML as expected by ExtJS datastores from all operations on a
TFPWebDataProvider instance.
TJSONRPCHandler
Component that handles a single JSON-RPC request.
TJSONRPCDispatcher
Component that dispatches a batch of JSON-RPC requests to appropriate
TJSONRPCHandler instances.
TSessionJSONRPCDispatcher
Component that dispatches a batch of JSON-RPC requests to appropriate
TJSONRPCHandler instances, and which is session-aware. (session in the
fcl-web sense of the word)
TJSONRPCContentProducer
Component that handles input from a HTTP request, passes it on to a
TJSONRPCDispatcher instance and formats the result.
TExtDirectDispatcher
TExtDirectContentProducer
Descendents of TJSONRPCDispatcher and TJSONRPCContentProducer that
understand the Ext.Direct variant of extJS.
Demo projects are available in the demo subdirectory, and additional demos
can be found in the fcl-web/examples directory of FPC.
Additional READMEs with information on the components are in the fcl-web/src/*
directories.
Author: Michael Van Canneyt & Joost van der Sluis

View File

@ -0,0 +1,77 @@
object JSONRPCModuleOptionsForm: TJSONRPCModuleOptionsForm
Left = 370
Height = 219
Top = 500
Width = 439
ActiveControl = CBRegisterHandlers
Caption = 'Create a new JSON-RPC module'
ClientHeight = 219
ClientWidth = 439
LCLVersion = '0.9.29'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 35
Top = 178
Width = 427
TabOrder = 0
ShowButtons = [pbOK, pbCancel]
end
object CBRegisterHandlers: TCheckBox
Left = 24
Height = 21
Top = 24
Width = 336
AutoSize = False
Caption = 'Register JSON-RPC handlers in factory'
OnChange = CBRegisterHandlersChange
TabOrder = 1
end
object CBRegisterModule: TCheckBox
Left = 24
Height = 21
Top = 104
Width = 248
AutoSize = False
Caption = 'Register web module'
Checked = True
OnChange = CBRegisterModuleChange
State = cbChecked
TabOrder = 2
end
object ERegModuleClassName: TEdit
Left = 144
Height = 25
Top = 56
Width = 254
TabOrder = 3
end
object ERegModuleName: TEdit
Left = 144
Height = 25
Top = 140
Width = 248
TabOrder = 4
end
object Label1: TLabel
Left = 23
Height = 25
Top = 56
Width = 107
Alignment = taRightJustify
AutoSize = False
Caption = 'JSON-RPC class'
Layout = tlCenter
ParentColor = False
end
object Label2: TLabel
Left = 56
Height = 25
Top = 140
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'HTTP Path'
Layout = tlCenter
ParentColor = False
end
end

View File

@ -0,0 +1,91 @@
unit frmrpcmoduleoptions;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ButtonPanel, StdCtrls;
type
{ TJSONRPCModuleOptionsForm }
TJSONRPCModuleOptionsForm = class(TForm)
ButtonPanel1: TButtonPanel;
CBRegisterHandlers: TCheckBox;
CBRegisterModule: TCheckBox;
ERegModuleClassName: TEdit;
ERegModuleName: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure CBRegisterHandlersChange(Sender: TObject);
procedure CBRegisterModuleChange(Sender: TObject);
private
function GetHP: String;
function GetJC: String;
function GetRH: Boolean;
function GetRM: Boolean;
procedure SetHP(const AValue: String);
procedure SetJC(const AValue: String);
{ private declarations }
public
{ public declarations }
Property RegisterHandlers : Boolean Read GetRH;
Property RegisterModule : Boolean Read GetRM;
Property JSONRPCClass : String Read GetJC Write SetJC;
Property HTTPPath : String Read GetHP Write SetHP;
end;
var
JSONRPCModuleOptionsForm: TJSONRPCModuleOptionsForm;
implementation
{$R *.lfm}
{ TJSONRPCModuleOptionsForm }
procedure TJSONRPCModuleOptionsForm.CBRegisterHandlersChange(Sender: TObject);
begin
ERegModuleCLassName.Enabled:=CBRegisterHandlers.Checked;
end;
procedure TJSONRPCModuleOptionsForm.CBRegisterModuleChange(Sender: TObject);
begin
ERegModuleName.Enabled:=CBRegisterModule.Checked;
end;
function TJSONRPCModuleOptionsForm.GetHP: String;
begin
Result:=ERegModuleName.Text;
end;
function TJSONRPCModuleOptionsForm.GetJC: String;
begin
Result:=ERegModuleClassName.Text;
end;
function TJSONRPCModuleOptionsForm.GetRH: Boolean;
begin
Result:=CBRegisterHandlers.Checked;
end;
function TJSONRPCModuleOptionsForm.GetRM: Boolean;
begin
Result:=CBRegisterModule.Checked;
end;
procedure TJSONRPCModuleOptionsForm.SetHP(const AValue: String);
begin
ERegModuleName.Text:=AValue;
end;
procedure TJSONRPCModuleOptionsForm.SetJC(const AValue: String);
begin
ERegModuleClassName.Text:=AValue;
end;
end.

View File

@ -0,0 +1,94 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="3">
<Name Value="lazwebextra"/>
<AddToProjectUsesSection Value="False"/>
<CompilerOptions>
<Version Value="8"/>
<SearchPaths>
<OtherUnitFiles Value="/home/michael/public_html/extjs/"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<Optimizations>
<OptimizationLevel Value="0"/>
</Optimizations>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="11">
<Item1>
<Filename Value="reglazwebextra.pp"/>
<HasRegisterProc Value="True"/>
<UnitName Value="reglazwebextra"/>
</Item1>
<Item2>
<Filename Value="extjsjson.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="extjsjson"/>
</Item2>
<Item3>
<Filename Value="extjsxml.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="extjsxml"/>
</Item3>
<Item4>
<Filename Value="fpextjs.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="fpextjs"/>
</Item4>
<Item5>
<Filename Value="fpwebdata.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="fpwebdata"/>
</Item5>
<Item6>
<Filename Value="sqldbwebdata.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="sqldbwebdata"/>
</Item6>
<Item7>
<Filename Value="frmrpcmoduleoptions.lfm"/>
<Type Value="LFM"/>
</Item7>
<Item8>
<Filename Value="frmrpcmoduleoptions.pp"/>
<UnitName Value="frmrpcmoduleoptions"/>
</Item8>
<Item9>
<Filename Value="fpextdirect.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="fpextdirect"/>
</Item9>
<Item10>
<Filename Value="fpjsonrpc.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="fpjsonrpc"/>
</Item10>
<Item11>
<Filename Value="webjsonrpc.pp"/>
<Type Value="Virtual Unit"/>
<UnitName Value="webjsonrpc"/>
</Item11>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="weblaz"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)/"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,242 @@
unit reglazwebextra;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpwebdata,
sqldbwebdata, LazIDEIntf,
ProjectIntf, fpextjs,
extjsjson, extjsxml,
fpjsonrpc,
fpextdirect,
webjsonrpc;
Type
{ TFileDescWebProviderDataModule }
TFileDescWebProviderDataModule = class(TFileDescPascalUnitWithResource)
public
constructor Create; override;
function GetInterfaceUsesSection: string; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function GetImplementationSource(const Filename, SourceName, ResourceName: string): string;override;
end;
{ TFileDescWebJSONRPCModule }
TFileDescWebJSONRPCModule = class(TFileDescPascalUnitWithResource)
public
constructor Create; override;
function GetInterfaceUsesSection: string; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function GetImplementationSource(const Filename, SourceName, ResourceName: string): string;override;
end;
{ TFileDescExtDirectModule }
TFileDescExtDirectModule = class(TFileDescPascalUnitWithResource)
public
constructor Create; override;
function GetInterfaceUsesSection: string; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function GetImplementationSource(const Filename, SourceName, ResourceName: string): string;override;
end;
Procedure Register;
Var
FileDescriptorWebProviderDataModule: TFileDescWebProviderDataModule;
FileDescriptorJSONRPCModule : TFileDescWebJSONRPCModule;
FileDescriptorExtDirectModule : TFileDescExtDirectModule;
implementation
uses FormEditingIntf, controls, forms,frmrpcmoduleoptions;
Procedure Register;
begin
RegisterComponents('fpWeb',[TWebdataInputAdaptor,TFPWebDataProvider, TSQLDBWebDataProvider,
TExtJSJSonWebdataInputAdaptor,TExtJSJSONDataFormatter,
TExtJSXMLWebdataInputAdaptor,TExtJSXMLDataFormatter,
TJSONRPCHandler,TJSONRPCDispatcher,TSessionJSONRPCDispatcher,
TJSONRPCContentProducer,
TExtDirectDispatcher,TExtDirectContentProducer]);
FileDescriptorWebProviderDataModule:=TFileDescWebProviderDataModule.Create;
FileDescriptorJSONRPCModule:=TFileDescWebJSONRPCModule.Create;
FileDescriptorExtDirectModule:=TFileDescExtDirectModule.Create;
RegisterProjectFileDescriptor(FileDescriptorWebProviderDataModule);
RegisterProjectFileDescriptor(FileDescriptorJSONRPCModule);
RegisterProjectFileDescriptor(FileDescriptorExtDirectModule);
FormEditingHook.RegisterDesignerBaseClass(TFPCustomWebProviderDataModule);
FormEditingHook.RegisterDesignerBaseClass(TFPWebProviderDataModule);
FormEditingHook.RegisterDesignerBaseClass(TJSONRPCModule);
FormEditingHook.RegisterDesignerBaseClass(TExtDirectModule);
end;
{ TFileDescWebProviderDataModule }
constructor TFileDescWebProviderDataModule.Create;
begin
inherited Create;
Name:='Web DataProvider Module';
ResourceClass:=TFPWebProviderDataModule;
UseCreateFormStatements:=False;
end;
function TFileDescWebProviderDataModule.GetInterfaceUsesSection: string;
begin
Result:=inherited GetInterfaceUsesSection;
Result:=Result+', HTTPDefs, websession, fpHTTP, fpWeb, fpwebdata';
end;
function TFileDescWebProviderDataModule.GetLocalizedName: string;
begin
Result:='Web DataProvider Module';
end;
function TFileDescWebProviderDataModule.GetLocalizedDescription: string;
begin
Result:='WEB DataProvider Module'#13
+'A datamodule to handle data requests for WEB (HTTP) applications using WebDataProvider components.';
end;
function TFileDescWebProviderDataModule.GetImplementationSource(const Filename,
SourceName, ResourceName: string): string;
begin
Result:=Inherited GetImplementationSource(FileName,SourceName,ResourceName);
Result:=Result+' RegisterHTTPModule(''T'+ResourceName+''',T'+ResourceName+');'+LineEnding;
end;
{ TFileDescWebJSONFPCModule }
constructor TFileDescWebJSONRPCModule.Create;
begin
inherited Create;
Name:='JSON-RPC Module';
ResourceClass:=TJSONRPCModule;
UseCreateFormStatements:=False;
end;
function TFileDescWebJSONRPCModule.GetInterfaceUsesSection: string;
begin
Result:=inherited GetInterfaceUsesSection;
Result:=Result+', HTTPDefs, websession, fpHTTP, fpWeb, fpjsonrpc, webjsonrpc';
end;
function TFileDescWebJSONRPCModule.GetLocalizedName: string;
begin
Result:='Web JSON-RPC Module';
end;
function TFileDescWebJSONRPCModule.GetLocalizedDescription: string;
begin
Result:='WEB JSON-RPC Module'#13
+'A datamodule to dispatch JSON-RPC requests in WEB (HTTP) applications using TJSONRPCHandler components.';
end;
function TFileDescWebJSONRPCModule.GetImplementationSource(const Filename,
SourceName, ResourceName: string): string;
Var
RH,RM : Boolean;
CN,HP : String;
begin
RH:=False;
RM:=False;
CN:=ResourceName;
HP:=ResourceName;
With TJSONRPCModuleOptionsForm.Create(Application) do
try
If (ShowModal=mrOK) then
begin
RH:=RegisterHandlers;
If RH Then
CN:=JSONRPCClass;
RM:=RegisterModule;
If RM then
HP:=HTTPPath;
end;
finally
Free;
end;
Result:=Inherited GetImplementationSource(FileName,SourceName,ResourceName);
If RM then
Result:=Result+' RegisterHTTPModule('''+HP+''',T'+ResourceName+');'+LineEnding;
If RH then
Result:=Result+' JSONRPCHandlerManager.RegisterDatamodule(T'+ResourceName+','''+HP+''',);'+LineEnding;
end;
{ TFileDescExtDirectModule }
constructor TFileDescExtDirectModule.Create;
begin
inherited Create;
Name:='Ext.Direct Module';
ResourceClass:=TExtDirectModule;
UseCreateFormStatements:=False;
end;
function TFileDescExtDirectModule.GetInterfaceUsesSection: string;
begin
Result:=inherited GetInterfaceUsesSection;
Result:=Result+', HTTPDefs, websession, fpHTTP, fpWeb, fpjsonrpc, webjsonrpc, fpextdirect';
end;
function TFileDescExtDirectModule.GetLocalizedName: string;
begin
Result:=inherited GetLocalizedName;
Result:='Web Ext.Direct Module';
end;
function TFileDescExtDirectModule.GetLocalizedDescription: string;
begin
Result:='WEB Ext.Direct Module'#13
+'A datamodule to dispatch Ext.Direct requests in WEB (HTTP) applications using TJSONRPCHandler components.';
end;
function TFileDescExtDirectModule.GetImplementationSource(const Filename,
SourceName, ResourceName: string): string;
Var
RH,RM : Boolean;
CN,HP : String;
begin
RH:=False;
RM:=False;
CN:=ResourceName;
HP:=ResourceName;
With TJSONRPCModuleOptionsForm.Create(Application) do
try
If (ShowModal=mrOK) then
begin
RH:=RegisterHandlers;
If RH Then
CN:=JSONRPCClass;
RM:=RegisterModule;
If RM then
HP:=HTTPPath;
end;
finally
Free;
end;
Result:=Inherited GetImplementationSource(FileName,SourceName,ResourceName);
If RM then
Result:=Result+' RegisterHTTPModule('''+HP+''',T'+ResourceName+');'+LineEnding;
If RH then
Result:=Result+' JSONRPCHandlerManager.RegisterDatamodule(T'+ResourceName+','''+HP+''',);'+LineEnding;
end;
end.

View File

@ -0,0 +1 @@
$(LazarusDir)/components/fpweb/lazwebextra.lpk