Skip to content

Commit

Permalink
Merge pull request #6 from gabrielbaltazar/master
Browse files Browse the repository at this point in the history
Update Resources and Splash Registration
  • Loading branch information
viniciussanchez authored Nov 1, 2021
2 parents d61bf23 + 6f6a51a commit 53a7812
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 936 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ This Wizard is compatible with projects developed in:
- [ ] Lazarus


## ⚙️ Demo and Installation
<a href="https://www.youtube.com/watch?v=44gM_teUmzQ&list=PLN9ocnDzQL12myZz-uZ5X3fZ__4quBIAB
" target="_blank"><img src="img/Horse-Wizard-Demo.png"
alt="Demo and Installation Horse Wizard" width="240" height="150" /></a>



## Wizard
![horse-wizard](img/Horse-Wizard.png)

Expand Down
1 change: 1 addition & 0 deletions horse_wizard.dpk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package horse_wizard;

{$R *.res}
{$R *.dres}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
Expand Down
886 changes: 17 additions & 869 deletions horse_wizard.dproj

Large diffs are not rendered by default.

Binary file added img/Horse-Wizard-Demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 30 additions & 53 deletions src/Horse.NewController.Model.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,65 +37,18 @@ function THorseNewControllerModel.UnitContent(const AUnitName: string): string;
'' + sLineBreak +
'uses' + sLineBreak +
' Horse;' + sLineBreak +
'' + sLineBreak +
'const' + sLineBreak +
' ROUTE = ''%1:s'';' + sLineBreak +
' ROUTE_ID = ''%1:s/:id'';' + sLineBreak +
'' + sLineBreak;

if Self.Get then
Result := Result +
'procedure %0:sGet(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak;

if Self.GetById then
Result := Result +
'procedure %0:sGetById(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak;

if Self.Post then
Result := Result +
'procedure %0:sPost(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak;

if Self.Put then
Result := Result +
'procedure %0:sPut(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak;

if Self.Delete then
Result := Result +
'procedure %0:sDelete(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak;

Result := Result +
'' + sLineBreak +
'procedure %0:sRegistry;' + sLineBreak +
'procedure Registry;' + sLineBreak +
'' + sLineBreak +
'implementation' + sLineBreak +
'' + sLineBreak +
'procedure %0:sRegistry;' + sLineBreak +
'begin' + sLineBreak +
' THorse' + sLineBreak;

if Self.Get then
Result := Result + ' .Get(ROUTE, %0:sGet)' + sLineBreak;

if Self.Post then
Result := Result + ' .Post(ROUTE, %0:sPost)' + sLineBreak;

if Self.GetById then
Result := Result + ' .Get(ROUTE_ID, %0:sGetById)' + sLineBreak;

if Self.Put then
Result := Result + ' .Put(ROUTE_ID, %0:sPut)' + sLineBreak;

if Self.Delete then
Result := Result + ' .Delete(ROUTE_ID, %0:sDelete)' + sLineBreak;

Result := Result +
'end;' + sLineBreak +
'' + sLineBreak;

if Self.Get then
begin
Result := Result +
'procedure %0:sGet(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'procedure DoGet%0:s(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'begin' + sLineBreak +
'' + sLineBreak +
'end;' + sLineBreak +
Expand All @@ -105,7 +58,7 @@ function THorseNewControllerModel.UnitContent(const AUnitName: string): string;
if Self.GetById then
begin
Result := Result +
'procedure %0:sGetById(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'procedure DoGetById%0:s(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'var' + sLineBreak +
' id: string;' + sLineBreak +
'begin' + sLineBreak +
Expand All @@ -118,7 +71,7 @@ function THorseNewControllerModel.UnitContent(const AUnitName: string): string;
if Self.Post then
begin
Result := Result +
'procedure %0:sPost(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'procedure DoPost%0:s(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'begin' + sLineBreak +
'' + sLineBreak +
'end;' + sLineBreak +
Expand All @@ -128,7 +81,7 @@ function THorseNewControllerModel.UnitContent(const AUnitName: string): string;
if Self.Put then
begin
Result := Result +
'procedure %0:sPut(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'procedure DoPut%0:s(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'var' + sLineBreak +
' id: string;' + sLineBreak +
'begin' + sLineBreak +
Expand All @@ -141,7 +94,7 @@ function THorseNewControllerModel.UnitContent(const AUnitName: string): string;
if Self.Delete then
begin
Result := Result +
'procedure %0:sDelete(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'procedure DoDelete%0:s(Req: THorseRequest; Res: THorseResponse; Next: TProc);' + sLineBreak +
'var' + sLineBreak +
' id: string;' + sLineBreak +
'begin' + sLineBreak +
Expand All @@ -151,6 +104,30 @@ function THorseNewControllerModel.UnitContent(const AUnitName: string): string;
'' + sLineBreak;
end;

Result := result +
'procedure Registry;' + sLineBreak +
'begin' + sLineBreak +
' THorse' + sLineBreak;

if Self.Get then
Result := Result + ' .Get(''%1:s'', DoGet%0:s)' + sLineBreak;

if Self.Post then
Result := Result + ' .Post(''%1:s'', DoPost%0:s)' + sLineBreak;

if Self.GetById then
Result := Result + ' .Get(''%1:s/:id'', DoGetById%0:s)' + sLineBreak;

if Self.Put then
Result := Result + ' .Put(''%1:s/:id'', DoPut%0:s)' + sLineBreak;

if Self.Delete then
Result := Result + ' .Delete(''%1:s/:id'', DoDelete%0:s)' + sLineBreak;

Result := Result +
'end;' + sLineBreak +
'' + sLineBreak;

Result := Result + 'end.';
Result := Format(Result, [ControllerName, Route, AUnitName]);
end;
Expand Down
12 changes: 10 additions & 2 deletions src/Horse.NewController.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ class procedure THorseNewController.CreateController;
try
LCreator := THorseNewControllerCreator.New(LController);
LModule := (BorlandIDEServices as IOTAModuleServices).CreateModule(LCreator);
RegisterController(LController, LModule);

LModule.FileName := Format('%sControllers.%s.pas',
[ExtractFilePath(GetActiveProject.FileName),
LController.ControllerName]);

if LModule.Save(True, True) then
RegisterController(LController, LModule);
finally
LController.Free;
end;
Expand All @@ -47,9 +53,11 @@ class procedure THorseNewController.RegisterController(const AController: THorse
I: Integer;
LListenPosition: Integer;
LEditView: IOTAEditView;
LUnitName: String;
begin
LListenPosition := 0;
GetActiveProject.ShowFilename(GetActiveProject.FileName);
LUnitName := ChangeFileExt(ExtractFileName(AModule.FileName), EmptyStr);

LEditorList := EditorAsStringList;
try
Expand All @@ -67,7 +75,7 @@ class procedure THorseNewController.RegisterController(const AController: THorse
begin
LEditView.Buffer.EditPosition.GotoLine(LListenPosition + 1);
LEditView.Buffer.EditPosition.Tab(1);
LEditView.Buffer.EditPosition.InsertText(AController.ControllerName + 'Registry;' + Chr(13));
LEditView.Buffer.EditPosition.InsertText(LUnitName + '.Registry;' + Chr(13));
end;

AModule.Show;
Expand Down
13 changes: 1 addition & 12 deletions src/Horse.Registration.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@

interface

uses ToolsApi, DesignIntf, System.SysUtils, Winapi.Windows, Horse.NewController.Wizard, Horse.NewController.Binding,
uses ToolsApi, DesignIntf, System.SysUtils, Horse.NewController.Wizard, Horse.NewController.Binding,
Horse.NewProject.Wizard;

var
bmSplashScreen: HBITMAP;

procedure register;

implementation

resourcestring
resPackageName = 'Horse';
resLicense = 'MIT License';

procedure Register;
begin
ForceDemandLoadState(dlDisable);
Expand All @@ -24,8 +17,4 @@ procedure Register;
RegisterNewControllerBinding;
end;

initialization
bmSplashScreen := LoadBitmap(HInstance, 'HashloadSplash');
(SplashScreenServices as IOTASplashScreenServices).AddPluginBitmap(resPackageName, bmSplashScreen);

end.

0 comments on commit 53a7812

Please sign in to comment.