#1 2022-09-23 03:12:58

Mark
Member
Registered: 2013-11-30
Posts: 19

Mormot2 filesystem register as wwwroot

Hello Ab,

I face a problem that how to register a folder like  as "wwwroot" in web app,
also "Cache" folder too
I am using method based SOA
so that I would place all the js, css, ico, img for <link> in index,html
(eg. <script src="static/js/jquery.min.js"></script>)

Please point me the right direction, thanks

Last edited by Mark (2022-09-23 03:26:01)

Offline

#2 2022-09-23 15:39:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Mormot2 filesystem register as wwwroot

There is already a static folder in the Views folder, which purposes is to serve... static content.

Offline

#3 2022-09-27 09:17:39

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 filesystem register as wwwroot

Hi, Ab.

Could change the Views folder to others? (eg. "wwwroot" folder)

Could change the .static folder to others? (eg. "resource" folder)

Thanks

Offline

#4 2022-09-27 09:57:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Mormot2 filesystem register as wwwroot

You can customize the TMvcViewsAbstract instance via the ViewTemplateFolder and ViewStaticFolder properties.

The views folder is also customizable by the TMvcViewsMustacheParameters.Folder value.

Please search a little in the source comments before asking.

Offline

#5 2022-09-28 02:44:37

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 filesystem register as wwwroot

Yes, I have studied comment several times and tried,
it could change the "Views" folder to other name.

BUT, the ".static" folder couldn't because it is read-only property, couldn't write value.

from code:
property ViewStaticFolder: TFileName
      read fViewStaticFolder;

Last edited by Mark (2022-09-28 02:45:11)

Offline

#6 2022-09-28 07:54:33

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Mormot2 filesystem register as wwwroot

It could be changed from ViewTemplateFolder as '\.static' sub-folder.

I have made the property writable:
https://github.com/synopse/mORMot2/commit/b832c99f

Offline

#7 2022-09-28 12:28:46

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 filesystem register as wwwroot

The new update program could complie  ViewStaticFolder := 'ccc',
but my browser could not access file under "Views/ccc/blog.css"


Code:
MvcViewsAbstract := TMvcViewsAbstract.Create(Factory.InterfaceTypeInfo, (RestModel as TRestServer).LogClass);   

loMvcViewsAbstract.ViewStaticFolder := 'ccc';

fMainRunner := TMvcRunOnRestServer.Create(Self,nil,'',MvcViewsAbstract);

Last edited by Mark (2022-09-28 12:29:12)

Offline

#8 2022-09-28 13:52:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Mormot2 filesystem register as wwwroot

It changes the folder, not the URI.

Offline

#9 2022-09-28 15:12:47

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 filesystem register as wwwroot

That function only changes folder location but not URI.
It is my I misunderstand.

I choose to use the default ".static" folder. : )

Thanks Ab

Last edited by Mark (2022-09-28 15:13:10)

Offline

Board footer

Powered by FluxBB