Feature #22482

Respond with "No preview available" instead of sending the file when no preview is available

Added by Gregor Schmidt over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:SCM
Target version:3.3.0
Resolution:Fixed

Description

For the sake of consistency, I think, that all file types should support "View" within the repository browser. Currently this is only done for images and smaller text files. For other files the View action is similar to Download. I think this behavior is confusing.

The attached patch series, adds this feature.

It does a couple of things:

0001-Add-basic-test-for-image-view-22058.patch

Adds a test case for #22058 since I was working on this anyway. This patch is not essential in this series.

0002-Add-view-for-no-preview-repository-files.patch

It changes RepositoriesController#entry_and_raw so that a download is only triggered, when is_raw is set. Otherwise it always falls back to rendering a template. This might be refactored lateron to remove entry_and_raw all together since entry and raw don't share behavior anymore. To keep changes isolated I did not include this refactoring in this patch series.

It adds extends the entry.html.erb to render the common/other partial if the file does not match the expected file types or if it is to big for inline rendering.

It adds the common/other partial which just renders a message "No preview available"

The private helper method is_entry_text_data? was no longer used and has been removed.

0003-Show-attachment-view-even-is-no-preview-is-available.patch

This change is not directly related to the repository browser. But I thought, it would make sense to also support show on all attachments and the change was simple enough.

The changes within the patch series also make integration of Redmine into other services easier, since the other service may safely link to the URL /attachments/:id or /repository/revisions/:rev/entry/:file and it will always behave similarly. Before this change, this URL would sometimes render an HTML page, sometimes it would send a file directly. A download can still be forced using the ../download/.. and ../raw/.. URLs.

0001-Add-basic-test-for-image-view-22058.patch Magnifier (1.04 KB) Gregor Schmidt, 2016-04-13 13:47

0003-Show-attachment-view-even-is-no-preview-is-available.patch Magnifier (2.5 KB) Gregor Schmidt, 2016-04-13 13:47

no-preview.png (23.9 KB) Gregor Schmidt, 2016-04-13 13:55

0002-Add-view-for-no-preview-repository-files.patch Magnifier (4.96 KB) Gregor Schmidt, 2016-04-15 11:29


Related issues

Blocks Redmine - Feature #22483: Show PDF attachments and repo entries instead of download... Needs feedback

Associated revisions

Revision 15396
Added by Jean-Philippe Lang over 1 year ago

Add basic test for image view (#22482).

Patch by Gregor Schmidt.

Revision 15397
Added by Jean-Philippe Lang over 1 year ago

Add view for "no preview" repository files (#22482).

Patch by Gregor Schmidt.

Revision 15398
Added by Jean-Philippe Lang over 1 year ago

Show attachment view even is no preview is available (#22482).

Patch by Gregor Schmidt.

History

#1 Updated by Gregor Schmidt over 1 year ago

#2 Updated by Gregor Schmidt over 1 year ago

Please wait before reviewing/applying this patch series. An internal code review at Planio revealed a regression, that would be introduced by 0002-Add-view-for-no-preview-repository-files.patch.

I plan to update the patch tomorrow.

#3 Updated by Gregor Schmidt over 1 year ago

The initial 0002-Add-view-for-no-preview-repository-files.patch patch removed the ability to show the contents of text files without a text file ending, i.e. those that were handled in the second case in is_entry_text_data?. In this updated patch, I fixed that regression. Furthermore I have changed the implementation, so that file contents are only loaded into memory, when necessary.

The line

The private helper method is_entry_text_data? was no longer used and has been removed.

within this issue's description is now obsolete.

#4 Updated by Go MAEDA over 1 year ago

  • Blocks Feature #22483: Show PDF attachments and repo entries instead of downloading them added

#5 Updated by Go MAEDA over 1 year ago

  • File deleted (0002-Add-view-for-no-preview-repository-files.patch)

#6 Updated by Go MAEDA over 1 year ago

  • Target version set to 3.3.0

I tried out the patches. I felt that the new behavior is consistent and straightforward.
I think this improvement should be included in Redmine 3.3.0.

#7 Updated by Jean-Philippe Lang over 1 year ago

  • Subject changed from Add View action for all file types within repository browser to Respond with "No preview available" instead of sending the file when no preview is available
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Committed, thanks.

Also available in: Atom PDF