diff options
author | Imre Farkas <ifarkas@gitlab.com> | 2018-06-12 11:35:34 +0200 |
---|---|---|
committer | Imre Farkas <ifarkas@gitlab.com> | 2018-06-15 16:03:38 +0200 |
commit | a0ac000ad397fb4111d3184d084a9d293eb184c7 (patch) | |
tree | b8ab4b315437cf1aee270ccf83d031cba01cea11 /app/controllers/concerns/issues_calendar.rb | |
parent | 1ed954e8a7abd3a8bc1649d0deec6d1ee2149496 (diff) | |
download | gitlab-ce-47672-set_inline_content_type_for_ics.tar.gz |
Render calendar feed inline when accessed from GitLab47672-set_inline_content_type_for_ics
With text/calendar as Content-Type, the browser always downloads the
content as a file (even ignoring the Content-Disposition header). We
want to display the content inline when accessed from Gitlab, similarly
to the RSS feed.
Diffstat (limited to 'app/controllers/concerns/issues_calendar.rb')
-rw-r--r-- | app/controllers/concerns/issues_calendar.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/concerns/issues_calendar.rb b/app/controllers/concerns/issues_calendar.rb new file mode 100644 index 00000000000..96f6d1865e9 --- /dev/null +++ b/app/controllers/concerns/issues_calendar.rb @@ -0,0 +1,24 @@ +module IssuesCalendar + extend ActiveSupport::Concern + + # rubocop:disable Gitlab/ModuleWithInstanceVariables + def render_issues_calendar(issuables) + @issues = issuables + .non_archived + .with_due_date + .limit(100) + + respond_to do |format| + format.ics do + # NOTE: with text/calendar as Content-Type, the browser always downloads + # the content as a file (even ignoring the Content-Disposition + # header). We want to display the content inline when accessed + # from Gitlab, similarly to the RSS feed. + if request.referer&.start_with?(::Settings.gitlab.base_url) + response.headers['Content-Type'] = 'text/plain' + end + end + end + end + # rubocop:enable Gitlab/ModuleWithInstanceVariables +end |