Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 12 2020 01:41

    jtkech on patch-1

    (compare)

  • Apr 12 2020 01:39

    jtkech on patch-1

    Update ZoneShapes.cs (compare)

Andrii Chebukin
@xperiandri
No such line
Jasmin Savard
@Skrypt
Then last guess is mime type
Andrii Chebukin
@xperiandri
Where can I check that?
Orchard Core tries to return a page
And respond with 404
Jean-Thierry Kéchichian
@jtkech
@xperiandri @Skrypt You need to override the ContentTypeProvider of the
StaticFileOptions, the default one doesn't include scss
https://github.com/dotnet/aspnetcore/blob/master/src/Middleware/StaticFiles/src/FileExtensionContentTypeProvider.cs#L26
5 replies
Sotiris Roussos
@urbanit
@agriffard @Skrypt how difficult is to apply the content items pager to blogposts pager?
1 reply
Andrii Chebukin
@xperiandri
What is the right path to locating embedded file inside a module?
fileProvider.GetDirectoryContents("/SecretCircle.BmwTheme/wwwroot/scripts/app.js");
This returns nothing
Jean-Thierry Kéchichian
@jtkech

It depends on how you init the fileProvider, e.g. we have a `ModuleEmbeddedStaticFileProvider that return nothing on GetDirectoryContents(), and we have a ModuleEmbeddedFileProvider that implements it. The paths of an embedded file is e.g. Areas/TheModule/subpath, subpath being e.g. wwwroot/style/style.css. I will try your use case with an scss file soon ;)

`

Andrii Chebukin
@xperiandri
OK, so I discovered that something responds instead of WebOptimizer
When I try https://localhost:44364/SecretCircle.BmwTheme/scripts/pages/main.js
It comes back not minified
Andrii Chebukin
@xperiandri
fileProvider.GetDirectoryContents("Areas/SecretCircle.BmwTheme/wwwroot/scripts/app.js") - 0 results
fileProvider.GetDirectoryContents("Areas/SecretCircle.BmwTheme/scripts/app.js") - 0 results
image.png
Jean-Thierry Kéchichian
@jtkech
Okay, just tried i could get it working, you were creating a new StaticFileOptions in place of collaborating to its configuration, so that you keep its file provider that we compose with the content root file provider and our embedded file rpoviders, i will show you the code i used in the main startup
Andrii Chebukin
@xperiandri
it is composite file provider from Orchard
Jean-Thierry Kéchichian
@jtkech
        services.AddOrchardCms();

        var contentTypeProvider = new FileExtensionContentTypeProvider();
        contentTypeProvider.Mappings.Add(".scss", "text/scss");
        services.Configure<StaticFileOptions>(o => o.ContentTypeProvider = contentTypeProvider);
Andrii Chebukin
@xperiandri
OK
What about getting a file from composite file provider?
I cannot retrieve any file
Look like I miss something
public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
     var contentTypeProvider = serviceProvider.GetRequiredService<IContentTypeProvider>() as FileExtensionContentTypeProvider;
     contentTypeProvider.Mappings.Add(".scss", "text/scss");
 }
What if I do this in a module?
You register IContentTypeProvider on Orchard startup
Jean-Thierry Kéchichian
@jtkech
I removed useless lines in my above example
No, i don't think so, the StaticFileMiddleware grab it from the options, not through the DI https://github.com/dotnet/aspnetcore/blob/master/src/Middleware/StaticFiles/src/StaticFileMiddleware.cs#L59
Andrii Chebukin
@xperiandri
Perfect, your solution with SCSS works
So the last step is composite file provider
@jtkech how can I retrieve a file from it?
Jean-Thierry Kéchichian
@jtkech

Just tried directly from the embedded file provider, you need to inject IApplicationContext

        var fileProvider = new ModuleEmbeddedFileProvider(_applicationContext);
        var test1 = fileProvider.GetDirectoryContents("/Areas/TheBlogTheme/scss/_footer.scss");
        var test2 = fileProvider.GetFileInfo("/Areas/TheBlogTheme/scss/_footer.scss");

The first line on test1 returns nothing, normal ;)
The second line on test 2 returns the requested file info

The file provider that we compose is set in place of the content root file provider, i will show you how to retrieve it from the hosting environment

Jean-Thierry Kéchichian
@jtkech
Okay, the same code works, by injecting IHostEnvironment and using its .ContentRootFileProvider that here is a composite file provider including our custom embedded file provider
Andrii Chebukin
@xperiandri
Do you mean the first line of your excerpt?
My code crashes there
fileProvider is composite file rpovider
Andrii Chebukin
@xperiandri
Even fileProvider.GetFileInfo("/Areas/SecretCircle.BmwTheme/scripts/app.js") returns nothing
2 replies
Ah!
SecretCircle.Bmw
Instead of SecretCircle.BmwTheme
Jean-Thierry Kéchichian
@jtkech
Cool !!!
Andrii Chebukin
@xperiandri
But there Orchard substitutes /Areas/SecretCircle.Bmw to /SecretCircle.BmwTheme?
Andrii Chebukin
@xperiandri
OK, so the final path that works is /Areas/SecretCircle.BmwTheme/wwwroot/scripts/app.js
Jean-Thierry Kéchichian
@jtkech
Yes because you use the embedded file provider directly, so you need the wwwroot segment, the module segment is the module assembly name
Andrii Chebukin
@xperiandri
Thank you very much for help!
So the last question for now is where /Areas/SecretCircle.BmwTheme/wwwroot/scripts/app.js becomes /SecretCircle.BmwTheme/scripts/app.js?
Jean-Thierry Kéchichian
@jtkech
When used as a static file provider the wwwroot segment is implicit, as done by the aspnetcore one
lengockyquang
@lengockyquang
how to set required as default setting for input field in Orchard Core Form ?