Skip to content

Commit

Permalink
Package refactor: The main cause was that authorized Github conditona…
Browse files Browse the repository at this point in the history
…l requests were counting towards rate limit, use rss feed to detect changes
  • Loading branch information
ollydev committed Apr 4, 2024
1 parent 06db8d9 commit dab5d90
Show file tree
Hide file tree
Showing 28 changed files with 1,609 additions and 1,163 deletions.
Binary file added Images/refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/refresh_150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/refresh_200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 33 additions & 8 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<Libraries Value="../Third-Party/lape/extensions/ffi/bin/win32"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -101,7 +101,7 @@
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<Libraries Value="../Third-Party/lape/extensions/ffi/bin/win64"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -150,7 +150,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -198,7 +198,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -245,7 +245,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -298,7 +298,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -379,7 +379,7 @@
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="49">
<Units Count="55">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -626,6 +626,7 @@
<Filename Value="simba.dialog.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaDialogForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit46>
<Unit47>
Expand All @@ -636,6 +637,30 @@
<Filename Value="simba.array_algorithm.pas"/>
<IsPartOfProject Value="True"/>
</Unit48>
<Unit49>
<Filename Value="ide/simba.ide_package_autoupdater.pas"/>
<IsPartOfProject Value="True"/>
</Unit49>
<Unit50>
<Filename Value="ide/simba.ide_package_installer.pas"/>
<IsPartOfProject Value="True"/>
</Unit50>
<Unit51>
<Filename Value="ide/simba.ide_package.pas"/>
<IsPartOfProject Value="True"/>
</Unit51>
<Unit52>
<Filename Value="ide/simba.ide_package_components.pas"/>
<IsPartOfProject Value="True"/>
</Unit52>
<Unit53>
<Filename Value="ide/simba.ide_package_endpointcustom.pas"/>
<IsPartOfProject Value="True"/>
</Unit53>
<Unit54>
<Filename Value="ide/simba.ide_package_endpointgithub.pas"/>
<IsPartOfProject Value="True"/>
</Unit54>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand All @@ -646,7 +671,7 @@
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;shapebuilders"/>
<Libraries Value="../Third-Party/lape/extensions/ffi/bin/win64"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;algorithms;imagebox;components;image;hash;ide;tools"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;matchtemplate;imagebox;components;image;hash;ide;tools"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down
137 changes: 71 additions & 66 deletions Source/ide/simba.form_openexample.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ TSimbaOpenExampleForm = class(TForm)
procedure DoSplitterEnterExit(Sender: TObject);
procedure DoTreeViewSelectionChanged(Sender: TObject);

procedure AddPackageExamples;
procedure UpdateTreeSize;

procedure AddSimbaExamples;
public
procedure ClearPackageExamples;
procedure AddPackageExamples(PackageName: String; Files: TStringArray);
end;

var
Expand All @@ -45,8 +50,7 @@ implementation

uses
LCLType, AnchorDocking,
simba.form_main, simba.form_tabs, simba.ide_package, simba.files, simba.ide_theme,
simba.vartype_string;
simba.form_main, simba.form_tabs, simba.files, simba.ide_theme;

function ReadResourceString(ResourceName: String): String;
begin
Expand All @@ -69,63 +73,70 @@ TExampleNode = class(TTreeNode)
Script: String;
end;

procedure TSimbaOpenExampleForm.AddPackageExamples;
procedure TSimbaOpenExampleForm.AddSimbaExamples;
var
SimbaNode: TTreeNode;

procedure AddNode(const AParentNode: TTreeNode; const AFileName: String);
procedure AddNode(const Name, ResourceName: String);
begin
with TExampleNode(TreeView.AddNode(AParentNode, TSimbaPath.PathExtractNameWithoutExt(AFileName), IMG_SIMBA)) do
FileName := AFileName;
with TExampleNode(TreeView.AddNode(SimbaNode, Name, IMG_SIMBA)) do
Script := ReadResourceString(ResourceName);
end;

var
I, MaxWidth: Integer;
Node, ParentNode: TTreeNode;
FileName: String;
Files: TStringArray;
Packages: TSimbaPackageArray;
Str: String;
begin
TreeView.BeginUpdate();
for I := 1 to TreeView.Items.TopLvlCount - 1 do // I := 1 to skip Simba node
TreeView.Items.TopLvlItems[I].Free();

Packages := GetInstalledPackages();
for I := 0 to High(Packages) do
begin
Files := Packages[I].GetExamples();
if (Length(Files) = 0) then
Continue;

Str := Packages[I].URL;
while (Str.Count('/') > 1) do
Str := Str.After('/');
SimbaNode := TExampleNode(TreeView.AddNode('Simba', IMG_PACKAGE));

ParentNode := TreeView.AddNode(Str, IMG_PACKAGE);
for FileName in Files do
AddNode(ParentNode, FileName);
end;
FreePackages(Packages);
AddNode('Array', 'EXAMPLE_ARRAY' );
AddNode('Image', 'EXAMPLE_IMAGE' );
AddNode('Function', 'EXAMPLE_FUNCTION' );
AddNode('Loop', 'EXAMPLE_LOOP' );
AddNode('Stopwatch', 'EXAMPLE_STOPWATCH' );
AddNode('Point Cluster', 'EXAMPLE_CLUSTER_POINTS' );
AddNode('Mouse Teleport Event', 'EXAMPLE_MOUSE_TELEPORT_EVENT');
AddNode('Static Method', 'EXAMPLE_STATIC_METHOD' );
AddNode('JSON', 'EXAMPLE_JSON' );
AddNode('Form', 'EXAMPLE_FORM' );
AddNode('Image Box', 'EXAMPLE_IMAGEBOX' );
AddNode('IRC', 'EXAMPLE_IRC' );
AddNode('Draw Text', 'EXAMPLE_DRAWTEXT' );
AddNode('RandomLeft', 'EXAMPLE_RANDOMLEFT' );

TreeView.EndUpdate();
end;

MaxWidth := 0;
Node := TreeView.Items.GetFirstNode();
while Assigned(Node) do
begin
MaxWidth := Max(MaxWidth, Node.DisplayTextRight);
procedure TSimbaOpenExampleForm.ClearPackageExamples;
var
I: Integer;
begin
for I := TreeView.Items.TopLvlCount - 1 downto 1 do
TreeView.Items.TopLvlItems[I].Free();
end;

Node := Node.GetNext();
end;
procedure TSimbaOpenExampleForm.AddPackageExamples(PackageName: String; Files: TStringArray);
var
I: Integer;
Node: TTreeNode;
begin
TreeView.BeginUpdate();
if Assigned(TreeView.Items.FindTopLvlNode(PackageName)) then
TreeView.Items.FindTopLvlNode(PackageName).Free();

LeftPanel.Width := MaxWidth + TreeView.ScrollbarVert.Width+1;
Node := TreeView.AddNode(PackageName, IMG_PACKAGE);
for I := 0 to High(Files) do
with TExampleNode(TreeView.AddNode(Node, TSimbaPath.PathExtractNameWithoutExt(Files[I]), IMG_SIMBA)) do
FileName := Files[I];

TreeView.EndUpdate();

UpdateTreeSize();
end;

procedure TSimbaOpenExampleForm.FormShow(Sender: TObject);
begin
Splitter.Width := DockMaster.SplitterWidth;

AddPackageExamples();

TreeView.ClearSelection();
TreeView.FullExpand();
end;
Expand Down Expand Up @@ -161,15 +172,6 @@ procedure TSimbaOpenExampleForm.DoSplitterEnterExit(Sender: TObject);
end;

procedure TSimbaOpenExampleForm.FormCreate(Sender: TObject);
var
SimbaNode: TTreeNode;

procedure AddNode(const Name, ResourceName: String);
begin
with TExampleNode(TreeView.AddNode(SimbaNode, Name, IMG_SIMBA)) do
Script := ReadResourceString(ResourceName);
end;

begin
Width := Scale96ToScreen(800);
Height := Scale96ToScreen(600);
Expand All @@ -195,22 +197,8 @@ procedure TSimbaOpenExampleForm.FormCreate(Sender: TObject);
ButtonPanel.Parent := Self;
ButtonPanel.ButtonOk.OnClick := @DoButtonOkClick;

SimbaNode := TExampleNode(TreeView.AddNode('Simba', IMG_PACKAGE));

AddNode('Array', 'EXAMPLE_ARRAY' );
AddNode('Image', 'EXAMPLE_IMAGE' );
AddNode('Function', 'EXAMPLE_FUNCTION' );
AddNode('Loop', 'EXAMPLE_LOOP' );
AddNode('Stopwatch', 'EXAMPLE_STOPWATCH' );
AddNode('Point Cluster', 'EXAMPLE_CLUSTER_POINTS' );
AddNode('Mouse Teleport Event', 'EXAMPLE_MOUSE_TELEPORT_EVENT');
AddNode('Static Method', 'EXAMPLE_STATIC_METHOD' );
AddNode('JSON', 'EXAMPLE_JSON' );
AddNode('Form', 'EXAMPLE_FORM' );
AddNode('Image Box', 'EXAMPLE_IMAGEBOX' );
AddNode('IRC', 'EXAMPLE_IRC' );
AddNode('Draw Text', 'EXAMPLE_DRAWTEXT' );
AddNode('RandomLeft', 'EXAMPLE_RANDOMLEFT' );
AddSimbaExamples();
UpdateTreeSize();
end;

procedure TSimbaOpenExampleForm.DoTreeViewSelectionChanged(Sender: TObject);
Expand All @@ -236,5 +224,22 @@ procedure TSimbaOpenExampleForm.DoTreeViewSelectionChanged(Sender: TObject);
Editor.Visible := False;
end;

procedure TSimbaOpenExampleForm.UpdateTreeSize;
var
Node: TTreeNode;
MaxWidth: Integer;
begin
MaxWidth := 0;

Node := TreeView.Items.GetFirstNode();
while Assigned(Node) do
begin
MaxWidth := Max(MaxWidth, Node.DisplayTextRight);
Node := Node.GetNext();
end;

LeftPanel.Width := MaxWidth + TreeView.ScrollbarVert.Width + 1;
end;

end.

47 changes: 24 additions & 23 deletions Source/ide/simba.form_package.lfm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
object SimbaPackageForm: TSimbaPackageForm
Left = 1486
Left = -1009
Height = 688
Top = 323
Top = 489
Width = 978
Caption = 'Simba Packages'
ClientHeight = 688
ClientWidth = 978
ClientHeight = 0
ClientWidth = 0
Constraints.MinHeight = 312
Constraints.MinWidth = 312
DesignTimePPI = 120
Expand All @@ -21,7 +21,7 @@ object SimbaPackageForm: TSimbaPackageForm
PageIndex = 0
Align = alClient
TabOrder = 0
object Page1: TPage
object MainPage: TPage
object ListPanel: TPanel
Left = 0
Height = 393
Expand All @@ -31,26 +31,18 @@ object SimbaPackageForm: TSimbaPackageForm
BevelOuter = bvNone
TabOrder = 0
end
object Bevel2: TBevel
Left = 0
Height = 2
Top = 393
Width = 978
Align = alTop
Shape = bsTopLine
end
object BottomNotebook: TNotebook
Left = 0
Height = 218
Top = 395
Height = 214
Top = 399
Width = 978
PageIndex = 0
Align = alClient
TabOrder = 1
object PageVersions: TPage
object ScrollBox1: TScrollBox
Left = 0
Height = 218
Height = 214
Top = 0
Width = 978
HorzScrollBar.Page = 1
Expand Down Expand Up @@ -174,17 +166,26 @@ object SimbaPackageForm: TSimbaPackageForm
end
end
end
object Splitter1: TSplitter
Cursor = crVSplit
Left = 0
Height = 6
Top = 393
Width = 978
Align = alTop
ResizeAnchor = akTop
end
end
object Page2: TPage
object LoadingPage: TPage
object LoadingLabel: TLabel
AnchorSideLeft.Control = Page2
AnchorSideLeft.Control = LoadingPage
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Page2
AnchorSideTop.Control = LoadingPage
AnchorSideTop.Side = asrCenter
Left = 351
Height = 20
Top = 300
Width = 277
Left = 320
Height = 25
Top = 294
Width = 339
Caption = 'Downloading package list. Please wait...'
Font.Style = [fsBold]
ParentColor = False
Expand Down
Loading

0 comments on commit dab5d90

Please sign in to comment.