dnnsoftware / Dnn.Platform

DNN (formerly DotNetNuke) is the leading open source web content management platform (CMS) in the Microsoft ecosystem.
https://dnncommunity.org/
MIT License
1.02k stars 746 forks source link

Web.config on fresh install should include MIME map for woff2 fonts #2408

Closed OllyHodgson closed 9 months ago

OllyHodgson commented 5 years ago

Description of problem

Certain themes bundle webfonts in a variety of formats. If IIS isn't configured correctly they return a 404 error. If you're hosting DNN on an Azure App Service the web.config file is the only way this can be achieved.

Description of solution

Include appropriate mime maps on the fresh unmodified web.config file. I believe we already handle .svg and .woff this way, so adding a new one seems like it ought to be fairly straightforward:

<system.webServer>
    <staticContent>
        <remove fileExtension=".svg" />
        <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
        <remove fileExtension=".woff" />
        <mimeMap fileExtension=".woff" mimeType="font/woff" />
        <remove fileExtension=".woff2" />
        <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
    </staticContent>
</system.webServer>

Screenshots

If applicable, provide screenshots to help explain your problem and/or feature. image

Additional context

As far as I can tell, recent versions of IIS / Azure App Services handle .eot and .ttf font files without issue.

Affected version

Affected browser

Any .woff2 supporting browser.

sleupold commented 5 years ago

I submitted a PR for this last year, but unfortunately, it didn't get merged.

valadas commented 5 years ago

Any opinions on also doing it during upgrades?

sleupold commented 5 years ago

IMO it would be beneficial for all (existing and new) sites, I don't see a risk of breaking anything. Be aware, however, the file extension might already be present (and use a different mime type, as the suggested mime types changed during the past years)

mikesmeltzer commented 5 years ago

While the Mime Types listed in this issue are quite common and should probably be included by default..

I think that extension developers (skins, modules, etc.) need to get into the process of including these types of changes within their install packages so that on extension install the site is updated accordingly.

I don't think this will necessarily happen but we should be mindful of what is added to the core so that we do not create unnecessary dependencies, expectations or just have additional items setup because someone might use them. IMO we should only have what's required by the default installation setup and then extensions add / change config as they are needed.

OllyHodgson commented 5 years ago

The built in Xcillion theme references at least one .woff2 file (the glyphicons font), so I think it makes sense for DNN to support it by default.

bdukes commented 5 years ago

I think @mikesmeltzer's point is that the Xcillion theme package should add woff2 support if it needs it, rather than putting it into the core.

sleupold commented 5 years ago

I agree with @bdukes in general, but common fonts like woff and woff2, we should add by default.

mikesmeltzer commented 5 years ago

Yep, that's exactly what I was meaning.

That being said, is there anything else in the core that uses those resources?

Get Outlook for Android

On Thu, Oct 18, 2018 at 12:30 PM -0300, "Sebastian Leupold" notifications@github.com wrote:

I agree with @bdukes

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

sleupold commented 5 years ago

one Scenario: editors might want to use a font (like fontAwesome) in module templates without the need to edit web.config manually.

OllyHodgson commented 5 years ago

Point taken that the theme packages perhaps ought to add support for any MIME-types they use. This is where things get fuzzy though, because Xcillion effectively appears to be part of core :smile: Is the process for theme packages to add this stuff documented anywhere?

Edit - found it: https://www.dnnsoftware.com/wiki/manifest-config-component

Mind you, any theme which uses Boostrap/Foundation/any web fonts would need to make sure it includes support for a variety of MIME types (svg, ttf, eot, woff, woff2). Feels like it'd be simpler all around to just include the common ones in the core platform.

Finally, @sleupold had a pull request to add .woff2 to https://github.com/dnnsoftware/Dnn.Platform/blob/development/DNN%20Platform/Library/Services/FileSystem/FileContentTypeManager.cs (which was never merged). Does this code allow .woff2 files to be properly handled when served from a DNN folder provider?

OllyHodgson commented 5 years ago

It turns out the .woff and .svg mime types are added to web.config as part of the Personabar installation (they're in the Dnn.PersonaBar.UI extension). They aren't a part of core. My theme framework of choice (nvQuickTheme) now includes the config for .woff2 etc in its manifest.

The only remaining question is should we add the .woff2 mime type to FileContentTypeManager.cs? (It's still not clear to me what that's used for)

sleupold commented 5 years ago

@OllyHodgson AFAIK you need adding a type to FileContentTypeManager.cs to be able to include it in an installable package.

OllyHodgson commented 5 years ago

@sleupold I'm not sure I understand :smile: I can install a theme with .woff2 files, even though FileContentTypeManager.cs doesn't include them.

Is it that if the file type is not specified in FileContentTypeManager.cs, you need to specify a mime type in the <component type="Config"> section of the extension's manifest file?

jeremy-farrance commented 5 years ago

Quick questions: should it be

<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />   

or is this one somehow better?

<mimeMap fileExtension=".woff2" mimeType="font/woff2" />  
bdukes commented 5 years ago

The official MIME type in the IANA standard and WOFF2 standard is font/woff2

valadas commented 5 years ago

I think a quick fix would be to add it to the default theme and bumping it's version, it will fix existing sites on upgrade and be applied on new installs as well. Assigning this to 9.4.1

valadas commented 4 years ago

wofff2 is now part of a 9.6.2 install, not sure how, but I guess by a theme update. image

closing this issue but feel free to comment if there is more to it.

jeremy-farrance commented 4 years ago

Suggestion, thinking out loud...

Leaving this here for future reference. What we need is to be able to account for older versions of IIS. WOFF2 is there for us nowadays in IIS 10 and later. You can read a lot about it here in this article from 2016.

Instead of debating this we should keep things simple. Once a mime type becomes pervasive and popular enough and it not yet in a version of IIS, DNN should be adding it, where it is missing, back to the oldest supported version of IIS.

This doesn't need code or any complex solution (IMHO). We should just simply do something like this, Mozilla has a list of common mime types here. If we support DNN on a version of IIS (7+ at this time, right?) that does not include any of the common ones Mozilla lists, those (hopefully few) should be added. This would/will make life MUCH easier for administrators, hosters, developers, etc. I know I have lost a few hours over the years on these issues, and an approach like this seems easy to follow and implement moving forward.

Maybe there is a downside that I don't see?

Timo-Breumelhof commented 10 months ago

I know old issue, but still. The woff-2 MIME type definition currently in web.config does not work anymore. IMO we should support these font MIME types by default and use the ones in the list @jeremy-farrance mentioned.

Re-open or new issues? @valadas

jeremy-farrance commented 10 months ago

Thanks for the reminder, I hope its worth mentioning, I now maintain my own list and keep it up to date with notes specific to DNN (that work for us as an agency). https://www.accu4.com/H2R2S/IIS-Notes-and-Reminders

valadas commented 10 months ago

@david-poindexter is working on a new theme and we should probably handle it in that new one

david-poindexter commented 9 months ago

I agree and this is already handled in the new DNN 10 theme (currently on a forked branch). I propose we go ahead and close this issue in light of that.

Timo-Breumelhof commented 9 months ago

ok thanks @david-poindexter