diff --git a/.gitattributes b/.gitattributes index c120612244..c1e0de0345 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/components/fpweb/README.txt b/components/fpweb/README.txt index fe8080d51a..ef2a30efb1 100644 --- a/components/fpweb/README.txt +++ b/components/fpweb/README.txt @@ -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 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
which allows to show a single record of a dataset. +THTMLDataSetFormEditProducer + Creates a 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 diff --git a/components/fpweb/frmrpcmoduleoptions.lfm b/components/fpweb/frmrpcmoduleoptions.lfm new file mode 100644 index 0000000000..bbd93c44ca --- /dev/null +++ b/components/fpweb/frmrpcmoduleoptions.lfm @@ -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 diff --git a/components/fpweb/frmrpcmoduleoptions.pp b/components/fpweb/frmrpcmoduleoptions.pp new file mode 100644 index 0000000000..ceff0a735b --- /dev/null +++ b/components/fpweb/frmrpcmoduleoptions.pp @@ -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. + diff --git a/components/fpweb/lazwebextra.lpk b/components/fpweb/lazwebextra.lpk new file mode 100644 index 0000000000..03b4ecf137 --- /dev/null +++ b/components/fpweb/lazwebextra.lpk @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/fpweb/reglazwebextra.pp b/components/fpweb/reglazwebextra.pp new file mode 100644 index 0000000000..f2f9b290db --- /dev/null +++ b/components/fpweb/reglazwebextra.pp @@ -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. + diff --git a/packager/globallinks/lazwebextra-0.lpl b/packager/globallinks/lazwebextra-0.lpl new file mode 100644 index 0000000000..ebe1852d0a --- /dev/null +++ b/packager/globallinks/lazwebextra-0.lpl @@ -0,0 +1 @@ +$(LazarusDir)/components/fpweb/lazwebextra.lpk