2

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-typetext/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

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?.
  • You say, "It is unlikely that I can get anything changed in the Subversion server," does this only mean you can't edit server settings, or does it also mean you cannot commit any changes to files? – Ben Jun 9 '16 at 14:09
  • Edited to clarify that I mean the former. – PJTraill Jun 9 '16 at 14:29
2

Often SVN servers will automatically use a text context type when serving up .c/.h files, so I'm surprised this isn't already happening for you.

You can try setting the svn:mime-type property on these files to "text/plain", or verifying that a different mime type is not already set on those files. SVN servers use this property to determine the http content type in the response to a GET query. Experiment with one or two files before applying it globally, however!


http://svnbook.red-bean.com/en/1.8/svn.advanced.props.file-portability.html#svn.advanced.props.special.mime-type

  • Thanks. I have edited the question to indicate that this works, but that I wonder whether I could instead use mimeTypes.rdf. – PJTraill Jan 13 '17 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.