Ignore:
Timestamp:
Jun 18, 2012, 8:48:28 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Obsluhuj generování stránek dle vlastního seznamu stránek a pokud nenajdeš přímou obsluhu, tak zkus generovat ze souboru.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/UMainModule.pas

    r76 r77  
    1515
    1616type
     17  TSession = class
     18
     19  end;
     20
    1721  { TMainModule }
    1822
     
    2125    Database: TSqlDatabase;
    2226    WebApp1: TWebApp;
    23     procedure DoBeforePageProduce(HandlerData: THTTPHandlerData);
     27    procedure WebApp1PageProduce(HandlerData: THTTPHandlerData);
    2428  private
    2529    procedure Footer;
     
    4650    NetworkPort: Integer;
    4751    MaxConnections: Integer;
     52    Pages: TPageList;
     53    procedure LoadUserInfo(HandlerData: THTTPHandlerData);
    4854    procedure LoadFromRegistry;
    4955    procedure SaveToRegistry;
     
    115121begin
    116122  inherited;
    117   with WebApp1 do begin
     123  Pages := TPageList.Create;
     124  HtmlDocument := THtmlDocument.Create;
     125  User := TWebUser.Create;
     126  User.Database := Database;
     127  UserOnline := TWebOnlineUser.Create;
     128  UserOnline.Database := Database;
     129  LoadFromRegistry;
     130  with Pages do begin
    118131    RegisterPage(TInternetPage, InternetPage, 'internet');
    119132    RegisterPage(THostingPage, HostingPage, 'hosting');
     
    130143    RegisterPage(TAboutPage, AboutPage, '');
    131144    //RegisterPage(TUserControlPage, UserControlPage, '');
     145  end;
     146  with WebApp1 do begin
    132147    if ServerType = stTCP then begin
    133       THTTPServerTCP(HTTPServer).Socket.Address := MainModule.NetworkAddress;
    134       THTTPServerTCP(HTTPServer).Socket.Port := MainModule.NetworkPort;
    135       THTTPServerTCP(HTTPServer).MaxConnection := MainModule.MaxConnections;
    136     end;
    137   end;
    138 
    139   HtmlDocument := THtmlDocument.Create;
    140   User := TWebUser.Create;
    141   User.Database := Database;
    142   UserOnline := TWebOnlineUser.Create;
    143   UserOnline.Database := Database;
    144   LoadFromRegistry;
     148      THTTPServerTCP(HTTPServer).Socket.Address := NetworkAddress;
     149      THTTPServerTCP(HTTPServer).Socket.Port := NetworkPort;
     150      THTTPServerTCP(HTTPServer).MaxConnection := MaxConnections;
     151    end;
     152  end;
    145153end;
    146154
     
    151159  User.Free;
    152160  UserOnline.Free;
     161  Pages.Free;
    153162  inherited Destroy;
    154163end;
     
    240249      '<li><a href="http://wiki.zdechov.net/">Wiki</a></li>' +
    241250      '</ul><ul class="MenuItem2">'; //<li>&nbsp;</li>';
    242     if Assigned(MainModule.WebApp1.Pages.FindByName('uzivatel')) then begin
     251    if Assigned(MainModule.Pages.FindByName('uzivatel')) then begin
    243252      if UserOnline.User = AnonymousUserId then begin
    244253        Text := Text + '</ul>' +
     
    260269end;
    261270
    262 procedure TMainModule.DoBeforePageProduce(HandlerData: THTTPHandlerData);
     271procedure TMainModule.LoadUserInfo(HandlerData: THTTPHandlerData);
    263272begin
    264273  User.HandlerData := HandlerData;
     
    267276  User.Id := UserOnline.User;
    268277  User.Load;
     278end;
     279
     280procedure TMainModule.WebApp1PageProduce(HandlerData: THTTPHandlerData);
     281var
     282  FileName: string;
     283begin
     284  with HandlerData do begin
     285    if not Pages.ProducePage(HandlerData) then begin
     286      WebApp1.HTTPServer.FileResponse(HandlerData)
     287    end;
     288  end;
    269289end;
    270290
     
    325345  InitDatabase;
    326346  //Database.Query('SELECT * FROM ssss');
     347
    327348  WebApp1.Run;
    328349end;
Note: See TracChangeset for help on using the changeset viewer.