Ignore:
Timestamp:
Mar 18, 2022, 1:32:32 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Build with Lazarus 2.2.0.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UWebSession.pas

    r115 r130  
    3434  end;
    3535
     36
    3637implementation
    3738
     
    4344resourcestring
    4445  SError = '<div>Error: %s</div>';
    45 
    4646
    4747{ TWebSession }
     
    8686  ModuleManager.StartInstalled;
    8787
    88       try
    89         BaseUrlParts := TListString.Create;
    90         BaseUrlParts.Explode(BaseURL, '/', StrToStr);
    91         while (BaseUrlParts.Count > 0) and (Request.Path.Count > 0) and
    92            (BaseUrlParts[0] = Request.Path[0]) do begin
    93              BaseUrlParts.Delete(0);
    94              Request.Path.Delete(0);
    95            end;
    96       finally
    97         BaseUrlParts.Free;
     88  try
     89    BaseUrlParts := TListString.Create;
     90    BaseUrlParts.Explode(BaseURL, '/', StrToStr);
     91    while (BaseUrlParts.Count > 0) and (Request.Path.Count > 0) and
     92      (BaseUrlParts[0] = Request.Path[0]) do begin
     93        BaseUrlParts.Delete(0);
     94        Request.Path.Delete(0);
    9895      end;
    99       if Request.Path.Count > 0 then PageName := Request.Path[0]
    100         else PageName := '';
    101       ModuleBase := TModuleBase(ModuleManager.FindModuleByName('Base'));
    102       Page := ModuleBase.Pages.FindByName(PageName);
    103       if Assigned(Page) then begin
    104         try
    105           Page.Page.OnProduce(Self);
    106         except
    107           on E: Exception do begin
    108             THTMLString(Self.HtmlDocument.Body.SubItems.AddNew(THtmlString.Create)).
    109               Text := Format(SError, [E.Message]);
    110             GeneratePage(Page.Page);
    111           end;
    112         end;
    113       end else begin
    114         Core.WebApp1.HTTPServer.FileResponse(Self)
     96  finally
     97    BaseUrlParts.Free;
     98  end;
     99  if Request.Path.Count > 0 then PageName := Request.Path[0]
     100    else PageName := '';
     101  ModuleBase := TModuleBase(ModuleManager.FindModuleByName('Base'));
     102  Page := ModuleBase.Pages.FindByName(PageName);
     103  if Assigned(Page) then begin
     104    try
     105      if Assigned(Page.Page) then Page.Page.OnProduce(Self);
     106    except
     107      on E: Exception do begin
     108        THTMLString(Self.HtmlDocument.Body.SubItems.AddNew(THtmlString.Create)).
     109          Text := Format(SError, [E.Message]);
     110        GeneratePage(Page.Page);
    115111      end;
     112    end;
     113  end else begin
     114    Core.WebApp1.HTTPServer.FileResponse(Self)
     115  end;
    116116end;
    117117
     
    124124    GlobalTitle := 'WebSystem';
    125125
    126       //Page.Page.OnProduce(HandlerData);
    127       HtmlDocument.Title := Page.Caption;
    128       with HtmlDocument.AsXmlDocument do
    129       try
    130         Formated := TCore(MainModule).FormatHTML;
    131         Response.Content.WriteString(AsString);
    132       finally
    133         Free;
    134       end;
     126    //Page.Page.OnProduce(HandlerData);
     127    HtmlDocument.Title := Page.Caption;
     128    with HtmlDocument.AsXmlDocument do
     129    try
     130      Formated := TCore(MainModule).FormatHTML;
     131      Response.Content.WriteString(AsString);
     132    finally
     133      Free;
    135134    end;
     135  end;
    136136end;
    137 
    138137
    139138procedure TWebSession.InitDatabase;
Note: See TracChangeset for help on using the changeset viewer.