TASVideos / tasvideos

The code for the live TASVideos website
https://tasvideos.org/
GNU General Public License v3.0
63 stars 29 forks source link

[F.Rq.] "Source map" for HTML to make contributing easier #1845

Open YoshiRulz opened 1 month ago

YoshiRulz commented 1 month ago

My experience with contributing to the site, being a novice to ASP.NET, has involved a lot of grepping the codebase for tag/attribute names in order to find the source file where the thing I'm looking at originates. I've since learned that the directory structure under /TASVideos/Pages roughly corresponds to page paths, but that doesn't account for 'partials'. I propose that every source file which 'renders' output should also include its own path as a simple HTML comment, such that more people might be able to submit fixes or at least precisely identify where problems are. I've found that Html.ViewContext.ExecutingFilePath produces the right path (relative to $(ProjectDir)), but it would be a pain to manually include that in every page and partial. Does anyone know of a better way?

nattthebear commented 1 month ago

I agree that the file structure is difficult to follow. ASP.NET is heavily convention based and I haven't kept up on the conventions.

I propose that every source file which 'renders' output should also include its own path as a simple HTML comment

Does that mean the final emitted markup served to the end user would have these comments in it? Would that inflate our document size too much?

YoshiRulz commented 1 month ago

Just as a ballpark figure I'd say the worst-affected pages would grow by at most 1 KiB before compression. This could be locked to only development environments if that's a problem, given that contributors are expected to test locally anyway.

Masterjun3 commented 1 month ago

One idea is to add one line to _ViewStart.cshtml that does something similar. <!-- @(Html.ViewContext.View.Path) --> Result: image

But this only works for views, not for partials.

Masterjun3 commented 1 month ago

Okay actually, we can override (or I think it's called to shadow) the Activate method of the RazorPageActivator and use that in the services.

image

This way we see the beginning of every new view or partial or other things. (Not the end though, since there is no "Deactivate".)

image