I have a markdown file that I would like to have delivered by my tomcat 7. Currently when calling the url of the file, it offers me the file to download. But I want to have it just rendered. I have a plugin in the browser to convert md files into html, so I don't care if I just see the md "source code".
If there is even an md => html converter plugin for Tomcat, even better. Does anyone have an idea?
You need to look at what your browser is doing with that file. A quick test on a clean Tomcat installation with a file named test.md displays the contents of that file in the browser (FireFox).
If the browser is expecting a particular MIME type, then you can configure that in $CATALINA_BASE/conf/web.xml (look for the very long section setting MIME mappings).
Related
Our team has installed the Markdown Mode extension in Visual Studio on our Windows PCs, and we're happy with that as an editor for Markdown files, but we need a way to generate a wiki from those files where we can click on links that cross-link the files of the wiki. I've been trying to find something, but haven't had any success getting something running.
I tried creating an empty web application and pasting in the html file from here http://dynalon.github.io/mdwiki/#!index.md and naming it index.html, and adding a couple of md files to the same directory that I set to always copy to the build directory, but I got 404-3 errors when it tried to access the .md file.
I see a couple of tools that look possibly good but need Python or Ruby installed, which isn't ideal: http://markdoc.org/quickstart or http://helloform.com/projects/commonplace/
I see this ASP.NET control for embedding a Markdown file into a page http://wikicontrol.codeplex.com/ but the control is for VS 2010 so clearly is not being actively maintained, plus to use it I'll need to build something to take the relative links and find the related .md files and load them up in MVC - sounds like a hassle to get working, and it will require me to put MVC in my docs project.
Is there something that is just designed so that I can put an html file or similar in a directory with a root .md file and have it just immediately act like a wiki and allow navigation between them?
We have decided to use MarkdownDeep NuGet package and a single MVC controller to handle this. The MVC controller looks at the requested path, uses it to figure out the location of the Markdown file, reads that file and renders it to HTML and returns the HTML.
A couple of years ago, I designed a bunch of automatic tests for a webapplication using Molybdenum. Some of these checked the data showed in a rss feed through an xml parser. The test required the browser to show the rss as a simple xml file.
At that time I managed to turn off firefox built-in rss reader changing a parameter in the feedconverter.js file. With the major updates in Firefox (4.0 to now) this file is missing and the developers seems to have left no room for this kind of trick.
Do you know a native way to turn off the built-in rss reader?
P.S. = Solutions using the view-source: URL suffix does not work in this case, because the open command answers Failure: Access to restricted URI denied
Things that don't work:
setting "Web feed" content handler to "Preview in Firefox" (shows formatted HTML version, not plaintext XML)
setting browser.feeds.handler to "Reader" (this is an about:config alternative to above) or anything else. There's no plaintext option.
editing mimeTypes.rdf in one's profile folder - Firefox seems not to care about feed settings there
adding a new web content handler with URI view-source:%s - I think it was pretty close, but Firefox escapes the forwarded URL and refuses to open it
storeHtmlSource as it is too smart and does return the code of the formatted page, not the XML source
In my Silverlight project, images for which the source URI does not contain the file extension don`t display, although the documentation says it should.
I set the image source like so:
imgCompanyLogo.Source = new BitmapImage(new Uri(Application.Current.Host.Source, "/Files/" + logoName));
Now, if "logoName" contains the file extension (like ".png" for example), the image is displayed fine, but it simply doesn't if the file is stored without an extension.
This seems to contradict the documentation here which states:
"The format-specific filename extensions such as .png are not necessarily required to be in the URI naming, but if the retrieved file is not determined to be a valid image format, a runtime exception is thrown."
I'm not getting any runtime exception either.
Is this a known issue or am I missing something simple?
Thanks!
PS: Just a little twist, the images display fine while debugging, not when the system is deployed...
I've made some test and the problem seems to be due to the response from the server.
If you try using .png within your project with a Build Action sets to Resource, both images will load regardless the extension.
Now if you try with images hosted on a server, it won't have the same behavior. Actually, if you try to browse the link to an image without extension directly in your browser, it will result in something else. On Chrome it will download the file, and on IE it will display the result as plain text.
That's because of the MIME type. A png should be returned with the type image\png.
There is a trick with .htaccess to set up the MIME-type but you need to have to specify for which extension. It works like this:
AddType image\png yourExtension [Extension2] [Extension3] ..
And if you want to see if why the image didn't load on your Image control, you can add an eventhandler to the ImageFailed event:
<Image Source="..." ImageFailed="Image_ImageFailed" />
But the error message that you will see is not really helpful:
ErrorException = {System.Exception: AG_E_NETWORK_ERROR}
I have a simple HTML file which references .gadget so that it can be downloaded:
Download me!
IE, Opera, Safari and Chrome all offer saving file to disk, however Firefox loads binary file in a tab. Why does Firefox hate me and what must I do to force Firefox to offer download dialog?
I don't really want to instruct users to "right-click and choose 'save file as'", or that they have to remove .zip extension after downloading.
Server is Apache/2.2.17, in case that it's relevant. Interesting fact is that Firefox does behave like all other browsers - if I load open .html file from local disk. But once it's on the server, it loads file in a tab.
So, here's the solution.
The problem is that Apache returns Content-Type=text/plain HTTP header by default for all "unknown" file types. Firefox adheres to the standards unlike all other browsers so it displays the content. Here's what they have to say about it. You can inspect header in Firefox with Firebug (or simply use curl if you're on Unix).
The above link also hints the solution; register application/x-windows-gadget MIME type with the server. If you don't have access to the server configuration, put .htaccess file in the same directory as your file (or in any of the directories above your directory) with the following line:
AddType application/x-windows-gadget .gadget
After that, don't forget to clear your browser cache.
I would like to save a web page programmatically.
I don't mean merely save the HTML. I would also like automatically to store all associated files (images, CSS files, maybe embedded SWF, etc), and hopefully rewrite the links for local browsing.
The intended usage is a personal bookmarks application, in which link content is cached in case the original copy is taken down.
Take a look at wget, specifically the -p flag
−p −−page−requisites
This option causes Wget to download all the files
that are necessary to properly display
a givenHTML page. Thisincludes such
things as inlined images, sounds, and
referenced stylesheets.
The following command:
wget -p http://<site>/1.html
Will download page.html and all files it requires.
On Windows: you can run IE as a com object and pull everything out.
On other thing, you can take the source of Mozilla.
In Java, Lobo.
Or commons-httpclient and write a lot of code.
You could try the MHTML format (which is what IE uses). http://en.wikipedia.org/wiki/MHTML
In other words, you'd be downloading each object (image, css, etc.) to your computer, and then "embedding" them, via Base64, into a single file.