when trying to open files in repository,but downloading start

Added by jq Wang over 7 years ago

Hi,

I'd like view my python source code in the repository of redmine since it's convenient and the soucecode are very clean and neat in that view. The problem is that sometimes some python source will not be opened but can only be downloaded when I click on it . But some python source do can be viewed online. The file names all end with ".py". Why ?

I'm using Subversion. Is it related to subversion or redmine ?

Many thanks for your help.

Replies (3)

RE: when trying to open files in repository,but downloading start - Added by Felix Schäfer over 7 years ago

Well, there are the "raw" links or links with "?format=raw" that force a download, or redmine tries to infer if the file is binary or text (with String#is_binary_data?), or it forces the download is "too big" as per the Settings.

RE: when trying to open files in repository,but downloading start - Added by Victor Gavro about 7 years ago

simple workaround for this - just add some ascii data.
Attaching script to determine if ruby considers file as binary and know how many ascii data you need more :-)

binary.rb Magnifier (423 Bytes)

RE: when trying to open files in repository,but downloading start - Added by Jeremy Coatelen almost 4 years ago

More than three years later, I just had the same problem.

Victor proposes to add some ascii data but, sadly, I cannot do this. So, I had a look into redmine source code ... here is the tiny trick I did to make redmine able to view given extensions as plain texts :
  1. Set mime-type to text/plain in your repository properties
  2. Let REDMINE_DIR be the path to your redmine install root directory, then edit REDMINE_DIR/lib/redmine/mime_type.rb with your favorite text editor.
  3. At the top of the module, locate MIME_TYPES array definition.
  4. Locate the list of extensions for 'text/plain' and add your extensions at the end of it.
    Example :
      'text/plain' => 'txt,tpl,properties,patch,diff,ini,readme,install,upgrade', 
    becomes :
      'text/plain' => 'txt,tpl,properties,patch,diff,ini,readme,install,upgrade,acf,acm,acq,acl,acr,act',
    

    I added the list acf,acm,acq,acl,acr,act but you may want to add py.

This is NOT a permanent fix. The next upgrade may erase it so that you will need to add your extensions again. I'm still looking for a permanent solution ... I would like redmine to let an administrator add the new extensions via the global repository settings.

(1-3/3)