You are not logged in.
Pages: 1
Hi,
Here is an example of a c# client connecting to a mormot server:
https://github.com/velissariouc/mormotCSharpClient
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;
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
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?
Hi, In an a MVC application, like sample 30, is it possible to split the views in sub-folders?
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;
Pages: 1