When browsing a Subversion repository using Firefox and the http
(s
):
URL, I want to take a quick look at text files in the browser itself. However, while Firefox displays unknown file types as text, when I click on a C header it only offers to save it or open it with MSVS (Visual Studio), not to display it.
Requirements
- One should be able to open a link as text in the browser in the same or a new tab or window.
- Preferably also to retain the option to save or open in an application
- One should preferably be able to do so just using mouse clicks.
- While the problem may be related to the Subversion server, a solution for arbitrary sites is clearly preferable.
- A nice extra would be if one could configure the behaviour differently per site or page.
Constraints
- It is unlikely that I can get any settings changed in the Subversion server. (I can commit file and attribute modifications normally.)
Ideas and attempts
I suspect that the current behaviour is because .h
is a known file type, but it used to behave differently even though MSVS was installed; the server may however have been older.
I hoped choosing “Open with Notepad” + “Do this automatically” would make it appear in the Options/Applications, letting me change it, but at first that did not work at all, until I thought of refreshing the options page! But even then, I only get the choice of downloading or opening with an application, while I want to open it as text in a Firefox tab.
Manually prefixing view-source:
to the URL of the repository element works.
It occurs to me that defining an “application” that opens the URL prefixed by view-source:
in Firefox (in a new tab or the same) might work.
(2017-01-13) Using Firefox Network Monitor I see that the file is served with mime-type text/x-c
. The related information in mimeTypes.rdf
is:
<RDF:li RDF:resource="urn:mimetype:text/x-c"/>
…
<RDF:Description RDF:about="urn:mimetype:externalApplication:text/x-c"
NC:prettyName="notepad.exe"
NC:path="C:\Windows\System32\notepad.exe" />
…
<RDF:Description RDF:about="urn:mimetype:handler:text/x-c"
NC:alwaysAsk="true">
<NC:externalApplication RDF:resource="urn:mimetype:externalApplication:text/x-c"/>
<NC:possibleApplication RDF:resource="urn:handler:local:C:\Windows\System32\notepad.exe"/>
</RDF:Description>
…
<RDF:Description RDF:about="urn:mimetype:text/x-c"
NC:value="text/x-c"
NC:editable="true"
NC:fileExtensions="h"
NC:description="C/C++ Header">
<NC:handlerProp RDF:resource="urn:mimetype:handler:text/x-c"/>
</RDF:Description>
Following Ben’s answer, setting the Subversion property svn:mime-type
↦ text/plain
solves the problem – it is then served as such, but if that is not wanted, one may want to use the Mozilla documentation of mimeTypes.rdf to modify the treatment of text/x-c
– but it is not clear to me how.
Related questions
- How to have Firefox save txt files automatically instead of opening in browser — This is the other way round: they want to prevent opening it in the browser; I want to force or offer that.
- Firefox — How to open a link (to any text-based file) in Vim? – This is about getting a desired application into the list. It mentions the interesting extension Open with, but that doesn’t really help.
- How can I make Google Chrome display a plain text HTTP response, rather than downloading it in a file? — This applies to Google Chrome and does not seem to offer a solution. It may however explain the change in behaviour: use of
Content-disposition: attachment
in the header? The trick of prefixingview-source:
to the URL does work (for.h
), but requires manual intervention. - Make Chrome always open PDFs itself — This applies to Google Chrome but is somewhat similar; it also mentions a Chrome extension Redirector to remove
Content-disposition: attachment
, but I see no documentation there. - How can I make Firefox annotate links which point to files such as PDFs, which won't be opened in Firefox? — Sounds powerful enough to do the job, but involves some programming and a learning curve, unless a script is available.
Notes
- Tagged with [svn] as it may depend on how the links are served.
- Tagged with [windows] as it may depend on the known file types defined in MS Windows.
- The Subversion server is a TeamForge/CollabNet© 2014 ¿unable to get version by any of the methods in SO / how-to-find-my-subversion-server-version-number?.