#2 mORMot 1 » compile error using trunk version of fpc » 2018-09-09 10:37:32

velissariouc
Replies: 0

at line 56264 of mormot.pas I get the error Variable identifier expected
I can compile without errors if  I change the line
from:

ParamName := @VMP^.Name; 

to

ParamName := VMP^.NamePtr;

#3 Re: Other components » Mustache English Translate » 2017-04-11 16:18:27

Today I was wondering exactly the same thing.
Here is what i did:

Let's translate the message "Sign in" that apears in view: masthead.partial

1. In masthead.partial change {{Sign In}} to {{"Sign In}}
2. we need to find the hash("Sign In").
   Run the HashProject and get the result:1964225139=Sign In
3. create a text file named: MVCServer.messages with content:

        [Messages]
        1964225139=Sign In

4. create a text file for the greek translation named: GR.msg with content:

        [Messages]
        1964225139=Σύνδεση

5. In unit MVCViewModel create:

  TMVCViewsMustacheLang = class(TMVCViewsMustache)
    procedure Render(methodIndex: Integer; const Context: variant; var View: TMVCView); override;
  end;

  procedure TMVCViewsMustacheLang.Render(methodIndex: Integer;
  const Context: variant; var View: TMVCView);
begin
 View.Content := GetRenderer(methodIndex,View.ContentType).Render(
    Context,fViewPartials,fViewHelpers,  Language.Translate);
  if trim(View.Content)='' then
  with fViews[methodIndex] do begin
    Locker.Enter;
    Mustache := nil; 
    Locker.Leave;
    raise EMVCException.CreateUTF8(
      '%.Render(''%''): Void "%" Template - please put some content!',
        [self,ShortFileName,FileName]);
  end;
end;

The only difference with TMVCViewsMustache is passing the parameter Language.Translate

Then in procedure TBlogApplication.Start(aServer: TSQLRestServer)
add:

var
  LViews: TMVCViewsMustacheLang;

and:
FillChar(LParams, SizeOf(LParams), 0);
  LParams.FileTimestampMonitorAfterSeconds := 1;
  LParams.ExtensionForNotExistingTemplate := '.html';
  LParams.Helpers := TSynMustache.HelpersGetStandardList;
  LViews := TMVCViewsMustacheLang.Create(Factory.InterfaceTypeInfo,
    LParams, aServer.LogClass);
  LViews.RegisterExpressionHelpers(['MonthToText'],[MonthToText]).
  RegisterExpressionHelpers(['TagToText'],[TagToText]);

  fMainRunner := TMVCRunOnRestServer.Create(Self, nil,'',LViews).
    SetCache('Default',cacheRootIfNoSession,15).
    SetCache('ArticleView',cacheWithParametersIfNoSession,60);  

6. at program MVCServer:

   mORMoti18n.SetCurrentLanguage('GR');

Have a look here https://github.com/velissariouc/mormot- … 0-modified

#4 Re: mORMot 1 » views in subfolders » 2017-04-09 14:48:05

One way I found to separate code and views according to functionality is to create more than one TMVCApplication descendants.
Let's say that in sample 30, we want to separate the functionality and the views about authors.
I created a new unit: MVCAuthorViewModel and I declared the type: TAuthorModule = class(TMVCApplication,IAuthorModule).
An instance of this type is created in the program file MVCServer like this:
      aApplication := TBlogApplication.Create;
      aAuthorModule:= TAuthorModule.Create;
You can see my sample at https://github.com/velissariouc/mormot- … 0-modified
Could some of the experienced mormot users have a look at my sample and tell if this is the right way?

#5 mORMot 1 » views in subfolders » 2017-04-08 19:13:27

velissariouc
Replies: 1

Hi, In an a MVC application, like sample 30, is it possible to split the views in sub-folders?

#6 mORMot 1 » TSQLHttpClient requests in Fiddler » 2016-10-31 15:30:13

velissariouc
Replies: 1

How do I get TSQLHttpClient requests to show up in Fiddler?
In a similar question at stackoverflow about Indy the answer was:
lHTTP.ProxyParams.ProxyServer := '127.0.0.1';
  lHTTP.ProxyParams.ProxyPort := 8888;

Board footer

Powered by FluxBB