Closed xantari closed 4 years ago
Hi @xantari ,
thanks very much for the feedback! I guess we're talking about the HtmlHelperExtensions
, right?
Could you please provide a little bit more context on:
Additional context for the implementer:
MvcHtmlString
is now HtmlString
in .NET Core 3HtmlHelper
is now IHtmlHelper
in .NET Core 3@petrsvihlik Thanks for the response back!.
Yes I am talking about those HtmlHelperExtensions in the MVC 5 project.
The current .NET Core 3 boiler plate has a few HTML helpers ported over from the older MVC 5 template such as AssetImage.
I guess I'm just asking for the ones that are not specific to that sample site ported over. In particular the edit feature links are really helpful in that boilerplate and consumers of the .NET Core 3 sample might not understand that capability exists, so it would be helpful if it was included.
Right now only the edit link ones are the ones that I think are worth extracting if they could be made in a generic way (which I'm not sure is possible).
At the very least, if you don't want to add to the .NET Core boilerplate, perhaps the .NET Core 3 version of the Dancing Goats sample, with a link on this boilerplate readme.md to that sample so that folks understand how to implement it in their own site.
As for a nuget package, not sure about that. I kinda like the code being available to edit. And stripping the CSS classes is fine, perhaps those could be made as parameters to the function?
We'll discuss it internally and let you know :)
I copied the code over from the MVC 5 project, but it took a little adjusting. It seems to be working with the Boilerplate. The issues mostly revolved around .NET Core's configuration, so I had to find new ways to get the projectId, etc.
hi @ewomack2000 , could you please elaborate a bit more on what issues you had with the configuration? is there something that could be described better at our side?
The issues weren't huge, but they mostly revolved around getting configuration data in places that needed injection. The EditLinkHelper was using pre-Core configuration and it was called in a way that did not evoke the constructor, so I ended up passing the project id as a parameter, but that bypasses the instance call, which is something I still need to fix, but it allowed the edit panel to work. I believe that I also had to change the types for the generated HTML in the HtmlHelperExtension's "InlineElementLink" and "BlockElementEditLink" methods, because Core didn't like the MvcString type. It was more a lot of little things, but I did get it to work with .NET Core 3.0.
Thanks for the details! We'll first port the sample app to .NET Core 3 (along with the HtmlHelperExtensions
) and then decide how we could extract the helpers so that they can be reused in multiple projects.
Again, I appreciate your feedback - it's very helpful.
Outstanding:
@ewomack2000 the "edit mode" code was rewritten to use tag helpers
which depend on the IEditLinkBuilder
which can be injected via DI. The configuration of the mentioned service is shown in the Startup
class and the final usage in the FactAboutUsViewModel.cshtml.
So the configuration should now be in line with netcore's best practices.
@xantari given the number of custom CSS classes in the EditPanelTagHelper, I don't think this is a good candidate to be extracted to https://github.com/Kentico/kontent-aspnetcore. If everything was made parametrizable, it would make things unreadable and bring almost no added value. What do you think? Do you see a better way to do it?
Oh yeah, and I almost forgot - I cleaned up the readme. It should contain less fluff and more up-to-date info.
https://github.com/Kentico/kontent-sample-app-net/blob/master/README.md
Yeah those EditPanel ones are hard. I agree they probably should be left only in the dancing goat sample and not in the main nuget packages.
thanks for the confirmation @xantari ! I'm closing this issue now...let's see if we identify more stuff that could be extracted to https://github.com/Kentico/kontent-aspnetcore
Motivation
Some HTML helpers can be reused in production projects.
Proposed solution
Extract HTML helpers to a separate project: https://github.com/Kentico/kontent-aspnetcore
Outstanding:
IConfiguration
)To be considered: