diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-24 10:15:13 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-24 10:15:13 +0000 |
commit | b0ed2ff1a69df384a1cb9a184c0528bec1986827 (patch) | |
tree | bc3bfb310f541b9f8cb45724282085f87b586b1a | |
parent | 160799ca9b6d6e1695521444d787da78b93feef8 (diff) | |
parent | a12d50c5e5ebba17e6e16d3d628f449caf24b6d2 (diff) | |
download | gitlab-ce-b0ed2ff1a69df384a1cb9a184c0528bec1986827.tar.gz |
Merge branch 'atom-feeds-everywhere' into 'master'
Add project activity atom feed and show atom feed buttons everywhere where applicable.
See merge request !555
24 files changed, 133 insertions, 57 deletions
diff --git a/CHANGELOG b/CHANGELOG index 2e91c72a25f..135603d2b11 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,8 @@ v 7.11.0 (unreleased) - Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention. - Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention. - + - Show Atom feed buttons everywhere where applicable. + - Add project activity atom feed. - - - diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1422f2b8a4c..883e5865a21 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -66,8 +66,6 @@ class ProjectsController < ApplicationController return end - limit = (params[:limit] || 20).to_i - @show_star = !(current_user && current_user.starred?(@project)) respond_to do |format| @@ -85,11 +83,14 @@ class ProjectsController < ApplicationController end format.json do - @events = @project.events.recent - @events = event_filter.apply_filter(@events).with_associations - @events = @events.limit(limit).offset(params[:offset] || 0) + load_events pager_json('events/_events', @events.count) end + + format.atom do + load_events + render layout: false + end end end @@ -167,6 +168,13 @@ class ProjectsController < ApplicationController current_user ? 'projects' : 'public_projects' end + def load_events + @events = @project.events.recent + @events = event_filter.apply_filter(@events).with_associations + limit = (params[:limit] || 20).to_i + @events = @events.limit(limit).offset(params[:offset] || 0) + end + def project_params params.require(:project).permit( :name, :path, :description, :issues_tracker, :tag_list, diff --git a/app/views/dashboard/_activities.html.haml b/app/views/dashboard/_activities.html.haml index c1fc1602d0a..b4fe8fecf99 100644 --- a/app/views/dashboard/_activities.html.haml +++ b/app/views/dashboard/_activities.html.haml @@ -1,4 +1,13 @@ = render "events/event_last_push", event: @last_push + +- if current_user + %ul.nav.nav-pills.event_filter.pull-right + %li.pull-right + = link_to dashboard_path(:atom, { private_token: current_user.private_token }), class: 'rss-btn' do + %i.fa.fa-rss + Activity Feed + = render 'shared/event_filter' +%hr .content_list = spinner diff --git a/app/views/dashboard/issues.atom.builder b/app/views/dashboard/issues.atom.builder index 72e9e361dc3..6e88fc9be40 100644 --- a/app/views/dashboard/issues.atom.builder +++ b/app/views/dashboard/issues.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{current_user.name} issues" - xml.link href: issues_dashboard_url(:atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" - xml.link href: issues_dashboard_url(private_token: current_user.private_token), rel: "alternate", type: "text/html" - xml.id issues_dashboard_url(private_token: current_user.private_token) + xml.link href: issues_dashboard_url(format: :atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" + xml.link href: issues_dashboard_url, rel: "alternate", type: "text/html" + xml.id issues_dashboard_url xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? @issues.each do |issue| diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index db19a46cb26..62cc80a30dc 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, issues_dashboard_url(format: :atom, private_token: current_user.private_token), title: "#{current_user.name} issues") + %h3.page-title Issues @@ -6,5 +10,11 @@ %hr .append-bottom-20 + .pull-right + - if current_user + .hidden-xs.pull-left + = link_to issues_dashboard_url(format: :atom, private_token: current_user.private_token), class: 'btn' do + %i.fa.fa-rss + = render 'shared/issuable_filter' = render 'shared/issues' diff --git a/app/views/dashboard/show.atom.builder b/app/views/dashboard/show.atom.builder index da631ecb33e..71edb73cd8a 100644 --- a/app/views/dashboard/show.atom.builder +++ b/app/views/dashboard/show.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}" - xml.link href: dashboard_url(:atom), rel: "self", type: "application/atom+xml" + xml.title "Activity" + xml.link href: dashboard_url(format: :atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" xml.link href: dashboard_url, rel: "alternate", type: "text/html" - xml.id projects_url + xml.id dashboard_url xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? @events.each do |event| diff --git a/app/views/dashboard/show.html.haml b/app/views/dashboard/show.html.haml index fa8946011b7..2754a4894da 100644 --- a/app/views/dashboard/show.html.haml +++ b/app/views/dashboard/show.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, dashboard_url(format: :atom, private_token: current_user.private_token), title: "All activity") + - if @projects.any? .dashboard.row %section.activities.col-md-8 diff --git a/app/views/groups/issues.atom.builder b/app/views/groups/issues.atom.builder index 240001967f3..66fe7e25871 100644 --- a/app/views/groups/issues.atom.builder +++ b/app/views/groups/issues.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{@user.name} issues" - xml.link :href => issues_dashboard_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml" - xml.link :href => issues_dashboard_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html" - xml.id issues_dashboard_url(:private_token => @user.private_token) + xml.link href: issues_dashboard_url(format: :atom, private_token: @user.private_token), rel: "self", type: "application/atom+xml" + xml.link href: issues_dashboard_url, rel: "alternate", type: "text/html" + xml.id issues_dashboard_url xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? @issues.each do |issue| diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index 6c0d89c4e7c..cf0da2da466 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, issues_group_url(@group, format: :atom, private_token: current_user.private_token), title: "#{@group.name} issues") + %h3.page-title Issues @@ -10,5 +14,11 @@ %hr .append-bottom-20 + .pull-right + - if current_user + .hidden-xs.pull-left + = link_to issues_group_url(@group, format: :atom, private_token: current_user.private_token), class: 'btn' do + %i.fa.fa-rss + = render 'shared/issuable_filter' = render 'shared/issues' diff --git a/app/views/groups/show.atom.builder b/app/views/groups/show.atom.builder index c78bd1bd263..b52e78faaa3 100644 --- a/app/views/groups/show.atom.builder +++ b/app/views/groups/show.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Group feed - #{@group.name}" - xml.link href: group_path(@group, :atom), rel: "self", type: "application/atom+xml" - xml.link href: group_path(@group), rel: "alternate", type: "text/html" - xml.id projects_url + xml.title "#{@group.name} activity" + xml.link href: group_url(@group, format: :atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" + xml.link href: group_url(@group), rel: "alternate", type: "text/html" + xml.id group_url(@group) xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? @events.each do |event| diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 8df9366ecbe..70a18f064be 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, group_url(@group, format: :atom, private_token: current_user.private_token), title: "#{@group.name} activity") + .dashboard .header-with-avatar.clearfix = image_tag group_icon(@group), class: "avatar group-avatar s90" @@ -13,7 +17,17 @@ %section.activities.col-md-8 - if current_user = render "events/event_last_push", event: @last_push + + - if current_user + %ul.nav.nav-pills.event_filter.pull-right + %li + = link_to group_path(@group, { format: :atom, private_token: current_user.private_token }), title: "Feed", class: 'rss-btn' do + %i.fa.fa-rss + Activity Feed + = render 'shared/event_filter' + %hr + .content_list = spinner %aside.side.col-md-4 diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 5a6ae09a506..0ff1665455e 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -5,6 +5,7 @@ %title = "#{title} | " if defined?(title) GitLab + = favicon_link_tag 'favicon.ico' = stylesheet_link_tag "application", :media => "all" = stylesheet_link_tag "print", :media => "print" @@ -14,16 +15,8 @@ %meta{name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1'} %meta{name: 'theme-color', content: '#474D57'} + = yield(:meta_tags) + = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') = render 'layouts/bootlint' if Rails.env.development? - - -# Atom feed - - if current_user - - if controller_name == 'projects' && action_name == 'index' - = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" - - if @project && !@project.new_record? - - if current_controller?(:tree, :commits) - = auto_discovery_link_tag(:atom, namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - - if current_controller?(:issues) - = auto_discovery_link_tag(:atom, namespace_project_issues_url(@project.namespace, @project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") diff --git a/app/views/projects/commits/show.atom.builder b/app/views/projects/commits/show.atom.builder index 9211de72b1b..01edd9447ce 100644 --- a/app/views/projects/commits/show.atom.builder +++ b/app/views/projects/commits/show.atom.builder @@ -1,18 +1,18 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Recent commits to #{@project.name}:#{@ref}" - xml.link :href => namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom), :rel => "self", :type => "application/atom+xml" - xml.link :href => namespace_project_commits_url(@project.namespace, @project, @ref), :rel => "alternate", :type => "text/html" + xml.title "#{@project.name}:#{@ref} commits" + xml.link href: namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" + xml.link href: namespace_project_commits_url(@project.namespace, @project, @ref), rel: "alternate", type: "text/html" xml.id namespace_project_commits_url(@project.namespace, @project, @ref) xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? @commits.each do |commit| xml.entry do - xml.id namespace_project_commit_url(@project.namespace, @project, :id => commit.id) - xml.link :href => namespace_project_commit_url(@project.namespace, @project, :id => commit.id) - xml.title truncate(commit.title, :length => 80) + xml.id namespace_project_commit_url(@project.namespace, @project, id: commit.id) + xml.link href: namespace_project_commit_url(@project.namespace, @project, id: commit.id) + xml.title truncate(commit.title, length: 80) xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") - xml.media :thumbnail, :width => "40", :height => "40", :url => avatar_icon(commit.author_email) + xml.media :thumbnail, width: "40", height: "40", url: avatar_icon(commit.author_email) xml.author do |author| xml.name commit.author_name xml.email commit.author_email diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml index 7ea855e1a4e..fb1012deb74 100644 --- a/app/views/projects/commits/show.html.haml +++ b/app/views/projects/commits/show.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom, private_token: current_user.private_token), title: "#{@project.name}:#{@ref} commits") + = render "head" .tree-ref-holder diff --git a/app/views/projects/issues/index.atom.builder b/app/views/projects/issues/index.atom.builder index 126f2c07faa..5fa8fbdf893 100644 --- a/app/views/projects/issues/index.atom.builder +++ b/app/views/projects/issues/index.atom.builder @@ -1,8 +1,8 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{@project.name} issues" - xml.link :href => namespace_project_issues_url(@project.namespace, @project, :atom), :rel => "self", :type => "application/atom+xml" - xml.link :href => namespace_project_issues_url(@project.namespace, @project), :rel => "alternate", :type => "text/html" + xml.link href: namespace_project_issues_url(@project.namespace, @project, format: :atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" + xml.link href: namespace_project_issues_url(@project.namespace, @project), rel: "alternate", type: "text/html" xml.id namespace_project_issues_url(@project.namespace, @project) xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index d3c7ae24a75..c2522816f3b 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, namespace_project_issues_url(@project.namespace, @project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") + .append-bottom-10 .pull-right .pull-left diff --git a/app/views/projects/show.atom.builder b/app/views/projects/show.atom.builder new file mode 100644 index 00000000000..bb713dcafa5 --- /dev/null +++ b/app/views/projects/show.atom.builder @@ -0,0 +1,12 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "#{@project.name} activity" + xml.link href: namespace_project_url(@project.namespace, @project, format: :atom, private_token: current_user.private_token), rel: "self", type: "application/atom+xml" + xml.link href: namespace_project_url(@project.namespace, @project), rel: "alternate", type: "text/html" + xml.id namespace_project_url(@project.namespace, @project) + xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? + + @events.each do |event| + event_to_atom(xml, event) + end +end diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 4464c51744a..f85705ffdd2 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "#{@project.name} activity") + - if current_user && can?(current_user, :download_code, @project) = render 'shared/no_ssh' = render 'shared/no_password' @@ -39,7 +43,16 @@ %i.fa.fa-angle-left %section.col-md-9 = render "events/event_last_push", event: @last_push + + - if current_user + %ul.nav.nav-pills.event_filter.pull-right + %li + = link_to namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "Feed", class: 'rss-btn' do + %i.fa.fa-rss + Activity Feed + = render 'shared/event_filter' + %hr .content_list = spinner %aside.col-md-3.project-side diff --git a/app/views/projects/tree/show.html.haml b/app/views/projects/tree/show.html.haml index feca1453697..a8a580944e1 100644 --- a/app/views/projects/tree/show.html.haml +++ b/app/views/projects/tree/show.html.haml @@ -1,3 +1,7 @@ += content_for :meta_tags do + - if current_user + = auto_discovery_link_tag(:atom, namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom, private_token: current_user.private_token), title: "#{@project.name}:#{@ref} commits") + .tree-ref-holder = render 'shared/ref_switcher', destination: 'tree', path: @path diff --git a/app/views/shared/_event_filter.html.haml b/app/views/shared/_event_filter.html.haml index d07a9e2b924..334db60690d 100644 --- a/app/views/shared/_event_filter.html.haml +++ b/app/views/shared/_event_filter.html.haml @@ -3,17 +3,3 @@ = event_filter_link EventFilter.merged, 'Merge events' = event_filter_link EventFilter.comments, 'Comments' = event_filter_link EventFilter.team, 'Team' - - - if current_user - - if current_controller?(:dashboard) - %li.pull-right - = link_to dashboard_path(:atom, { private_token: current_user.private_token }), class: 'rss-btn' do - %i.fa.fa-rss - News Feed - - - if current_controller?(:groups) - %li.pull-right - = link_to group_path(@group, { format: :atom, private_token: current_user.private_token }), title: "Feed", class: 'rss-btn' do - %i.fa.fa-rss - News Feed -%hr diff --git a/app/views/users/show.atom.builder b/app/views/users/show.atom.builder index 8fe30b23635..50232dc7186 100644 --- a/app/views/users/show.atom.builder +++ b/app/views/users/show.atom.builder @@ -1,9 +1,9 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Activity feed for #{@user.name}" + xml.title "#{@user.name} activity" xml.link href: user_url(@user, :atom), rel: "self", type: "application/atom+xml" xml.link href: user_url(@user), rel: "alternate", type: "text/html" - xml.id projects_url + xml.id user_url(@user) xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? @events.each do |event| diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 9dd8cb0738c..15a3f741e6c 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,3 +1,6 @@ += content_for :meta_tags do + = auto_discovery_link_tag(:atom, user_url(@user, format: :atom), title: "#{@user.name} activity") + .row = link_to '#aside', class: 'show-aside' do %i.fa.fa-angle-left diff --git a/config/routes.rb b/config/routes.rb index 86939a1d7ea..e059f5830f5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -236,7 +236,7 @@ Gitlab::Application.routes.draw do constraints: { username: /.*/ } get '/u/:username' => 'users#show', as: :user, - constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } + constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ } # # Dashboard Area @@ -263,7 +263,7 @@ Gitlab::Application.routes.draw do # # Groups Area # - resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } do + resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ } do member do get :issues get :merge_requests @@ -295,7 +295,7 @@ Gitlab::Application.routes.draw do # Project Area # resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do - resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+/ }, except: + resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except: [:new, :create, :index], path: "/") do member do put :transfer diff --git a/features/steps/project/commits/commits.rb b/features/steps/project/commits/commits.rb index 57b727f837e..30b1934b363 100644 --- a/features/steps/project/commits/commits.rb +++ b/features/steps/project/commits/commits.rb @@ -18,7 +18,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps step 'I see commits atom feed' do commit = @project.repository.commit response_headers['Content-Type'].should have_content("application/atom+xml") - body.should have_selector("title", text: "Recent commits to #{@project.name}") + body.should have_selector("title", text: "#{@project.name}:master commits") body.should have_selector("author email", text: commit.author_email) body.should have_selector("entry summary", text: commit.description[0..10]) end |