How to make CQ5 use .htm extensions instead of .html? - adobe

I am converting a huge site from MS CMS 2002 to Adobe CQ5. In the existing CMS all pages are referenced with .htm extension. When I create a new page in CQ5 it always has .html extension. Is there any way to force CQ5 to use .htm extension for pages?

A list of default extensions rendering the content can be modified in the configuration of an OSGi service called SlingServletResolver. In order to change it, open the following path:
/system/console/configMgr/org.apache.sling.servlets.resolver.SlingServletResolver
on your CQ installation and add htm to the last option (Default Extensions). You may also use sling:OsgiConfig nodes to have the service configured automatically.

In addition to the other answers a different approach is to create an internal redirect from your htm to the new html pages. You can create a Sling mapping under /etc/map which will redirect htm requests to html.
Information on configuring the sling mapping can be found here http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html under Root Level Mappings -> Mapping Entry Specification

Tomek has provided the best solution for this problem. However, this solution will change the extension type for all the pages. If you want another solution to target specific pages then here is the solution:
Override the head.jsp for /libs/foundation/components/page by copying this file to apps folder and there specify the content-type and content="text/htm.
Now you have to refer to this component as a superResoucetype for every component or template wherever you want a htm or any other extension extension.

Related

Ghost CMS Custom Page assets route

I'm trying to create custom page in Ghost. I named file "news.hbs" for listing all the news items. Also I use webpack. Why while creating new custom page in template all the routes are matching as "news/*"? For example, while webpack generates "news.hbs" file, Ghost requires not an original path "img/header-bg.png", but an "news/img/header-bg.png". How to handle that? In main file "index.hbs" all the paths are valid, without extra folder's names.
You should modify the routes.yaml file for the routes to start working. Look at this documentation for more info: https://ghost.org/docs/api/v3/handlebars-themes/routing/

Cannot route static files in ASP.NET WebForms

We have legacy code to maintain and, to solve a specific customer customization problem, we want to route calls to some files to other files. That is, when the app calls a particular ASPX, it will end up hitting another ASPX.
If you call:
www.foo.com/admin/admin.aspx
It will actually hit:
www.foo.com/customizations/customer1/admin/admin.aspx
This is not a good design but this is legacy code. We just want to solve this.
We are using the System.Web.Routing framework to solve it. This works fine when you set RouteExistingFiles to true, except for static files (CSS, JavaScript and Images).
When I first tried it, it retrieved this error:
There is no build provider register for the extension '.css'.
So I did register a build provider in the web.config file for the .css extension. I used this build provider: PageBuilderProvider because someone recommended it in the internet.
It works! But the CSS is being served with text\html content type.
How do I achieve this?
TL;DR: I want to use routes in ASP.NET Web Forms to make a call for a specific CSS file to actually retrieve another one. A customer needs this for customization.
Try coding a HttpHandler. I had to do something similar but for PDF files, I coded a custom HttpHandler in the end - works very well. You can even set the content type in the HttpHandler code and have a pattern matched path the handler will be used for in the web.config. You can also configure it in web.config not to execute if the path does not point to an existing file e.g. so a 404 is returned without having to code that in the handler itself. I can't post my code (VB.NET) ATM because I'm using a tablet but google search for tutorials. You will also probably need to use the TransmitFile function to actually write out the css file. Is it a web forms project or web site? If its a web site there is a special way of registering the HttpHandler in the web.config.

How does people make ASP.NET page in URL with html file name?

I seen an ASP.NET application, in the URL is saying:
http://xxxxxxxxx/FILENAME.html?xxxx=xxx
How come it is html file? But not aspx file? How did they do it?
I heard from my manager that's an ASP.NET project he outsourced.
Sometime I seen people with their web page is ended in .html too, but obviously that is generated dynamically...
Files ending with .html are optional. These are static HTML-pages without any code-behind and can be included as part of any web application. They are not parsed and compiled by the server but rather just sent as good old predefined HTML.
You can also configure the web server so that it routes requests with different endings through the ASP.net rendering engine. This way you can keep the widely recognized ending .html and still have dynamic page generation.
The file extension is not necessarily tied to the execution engine. You can make ASP.NET process .aspx, .html, .htm, .bob, .foobar, .css, etc.
There are multiple of ways to do this:
In IIS manager, set the file extension mapping for .html to point to ASP.NET. If you're using MVC, you can handle this via routing.
Use a rewrite engine to map anything with a .htm* extension to .aspx
There are probably other ways, but these are the most direct.
Also, the .html extension doesn't mean that the file was dynamically generated.
You can use URL rewriting. There are a lot of different rewriters most popular being the URL rewrite module ( http://www.iis.net/download/urlrewrite ) and the built in (in ASP.NET 4.0) Routing Engine ( http://msdn.microsoft.com/en-us/library/cc668201.aspx ).
The URL Rewrite module is external to your application and it translates incoming URLs to regular .aspx URLs. You are responsible for generating the links with .html. It is good if you are adding it to an existing application.
The built in routing can generate urls based on routes and is configured in Global.asax (usually) with code.
Right click on the project.
Add new...
pick the HTML file type.
Some people prefer to use a different extension (or even none at all) in order to hide the technology used to develop the site.
Bear in mind that you would have to properly configure IIS to let the .net engine handle the .html file types.

Defining the Cache Manifest file within ASP.NET

When using a cache manifest file within ASP.NET can I just add a standard text file called something like app.manifest? (which is then referenced from the html in each relevant page).
Or are there other considerations (such as mime type) that demand a more convoluted approach?
In this approach: http://stephenwalther.com/blog/archive/2011/01/26/creating-html5-offline-web-applications-with-asp-net.aspx then Stephen Walther sets up the manifest as a handler. Do I really have to do it that way in ASP.NET, or is there a 'simpler' way in ASP.NET? Just striving for less code!
Thanks.
Well, in sighted article, author has created a custom handler to server the manifest with correct MIME type. This is indeed a good way in ASP.NET where you don't have to touch web server configuration.
If you don't want to write such handler and wish to serve file directly such as "app.manifest" then you have to make sure to modify IIS configuration (for the web-site) map the correct MIME Type (text/cache-manifest) for manifest extension (see this and this for how to register a new MIME type in IIS)

IIS Server Side Includes doesn't process ColdFusion

How can I use the Server Side Includes module in IIS to include and process a ColdFusion file from a .htm file? I'm currently doing something like this in my html file:
<!--#include virtual="navmenu.cfm"-->
This includes the raw contents of the navmenu file. I need it to execute the ColdFusion code and return the output of that process rather than including the raw ColdFusion code.
This same syntax works properly in Apache.
Are you just trying to avoid the CFM extension in the URL?
You can't use SSI to include a CFM files into a static HTM file. You can configure IIS to send HTM files to the CF server to be parsed. This would allow you to use CFINCLUDE inside any HTM file.
Alternately, you can use ajax from your HTM file and load the parsed CFM content into a DIV.
If you can't make the top page appear to be a cfm to the outside have you thought about using the URL Rewrite Module for IIS? That way you could just make certain files cfms with some explicit htm to cfm rewrite rules but leave all others unprocessed. Beyond that I think there may not be an elegant answer since you are mixing static and dynamic content.
On your comment about ajax - personally I don't find anything tedious about using ajax but then again jquery spoils you...
<div id='menuhere'></div>
$.get('navmenu.cfm', function(data) {$('.menuhere').html(data); });
Accomplishes the same thing as the SSI plus (assuming jQuery is cached) you get faster main content page loads to boot.
If you are using a Coldfusion page it is:
<cfinclude template="navmenu.cfm">
If you are using another type of page you will need to put that content in an IFRAME
<iframe src="navmenu.cfm"></iframe>
The question is if you have Coldfusion technology available on the server, why not change that page to a .cfm page and use the above example?

Resources