diff --git a/app/controllers/activity_feeds_controller.rb b/app/controllers/activity_feeds_controller.rb deleted file mode 100644 index bcc44ed10..000000000 --- a/app/controllers/activity_feeds_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -# -*- encoding : utf-8 -*- -class ActivityFeedsController < ApplicationController - before_filter :authenticate_user! - - def index - @filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all - @activity_feeds = current_user.activity_feeds - @activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all - @activity_feeds = @activity_feeds.paginate :page => params[:page] - respond_to do |format| - format.html { request.xhr? ? render('_list', :layout => false) : render('index') } - format.atom - end - end -end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 000000000..a2849ab85 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,62 @@ +# -*- encoding : utf-8 -*- +class HomeController < ApplicationController + before_filter :authenticate_user!, :only => [:activity, :issues, :pull_requests] + + def root + render 'pages/tour/abf-tour-project-description-1', :layout => 'tour' + end + + def activity + @filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all + @activity_feeds = current_user.activity_feeds + @activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all + @activity_feeds = @activity_feeds.paginate :page => params[:page] + respond_to do |format| + format.html { request.xhr? ? render('_list', :layout => false) : render('activity') } + format.atom + end + end + + def issues + @created_issues = current_user.issues + @assigned_issues = Issue.where(:assignee_id => current_user.id) + pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id) + @all_issues = Issue.where(:project_id => pr_ids) + @created_issues, @assigned_issues, @all_issues = + if action_name == 'issues' + [@created_issues.without_pull_requests, + @assigned_issues.without_pull_requests, + @all_issues.without_pull_requests] + else + [@created_issues.joins(:pull_request), + @assigned_issues.joins(:pull_request), + @all_issues.joins(:pull_request)] + end + + case params[:filter] + when 'created' + @issues = @created_issues + when 'assigned' + @issues = @assigned_issues + else + params[:filter] = 'all' # default + @issues = @all_issues + end + @filter = params[:filter] + @opened_issues, @closed_issues = @issues.not_closed_or_merged.count, @issues.closed_or_merged.count + + @status = params[:status] == 'closed' ? :closed : :open + @issues = @issues.send( (@status == :closed) ? :closed_or_merged : :not_closed_or_merged ) + + @sort = params[:sort] == 'updated' ? :updated : :created + @direction = params[:direction] == 'asc' ? :asc : :desc + @issues = @issues.order("issues.#{@sort}_at #{@direction}") + .includes(:assignee, :user, :pull_request).uniq + .paginate :per_page => 20, :page => params[:page] + render 'issues', :layout => request.xhr? ? 'with_sidebar' : 'application' + end + + def pull_requests + issues + end +end \ No newline at end of file diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 2c8046360..c52a23086 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,11 +1,5 @@ # -*- encoding : utf-8 -*- class PagesController < ApplicationController - # before_filter :authenticate_user!, :except => [:show, :main, :forbidden] - # load_and_authorize_resource - - def root - render 'pages/tour/abf-tour-project-description-1', :layout => 'tour' - end def tour_inside @entries = case params[:id] diff --git a/app/controllers/users/users_controller.rb b/app/controllers/users/users_controller.rb index 7a0536ecb..94d202ed2 100644 --- a/app/controllers/users/users_controller.rb +++ b/app/controllers/users/users_controller.rb @@ -23,49 +23,6 @@ class Users::UsersController < Users::BaseController render :json => {:name => @user.name}.to_json end - def issues - @created_issues = current_user.issues - @assigned_issues = Issue.where(:assignee_id => current_user.id) - pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id) - @all_issues = Issue.where(:project_id => pr_ids) - @created_issues, @assigned_issues, @all_issues = - if action_name == 'issues' - [@created_issues.without_pull_requests, - @assigned_issues.without_pull_requests, - @all_issues.without_pull_requests] - else - [@created_issues.joins(:pull_request), - @assigned_issues.joins(:pull_request), - @all_issues.joins(:pull_request)] - end - - case params[:filter] - when 'created' - @issues = @created_issues - when 'assigned' - @issues = @assigned_issues - else - params[:filter] = 'all' # default - @issues = @all_issues - end - @filter = params[:filter] - @opened_issues, @closed_issues = @issues.not_closed_or_merged.count, @issues.closed_or_merged.count - - @status = params[:status] == 'closed' ? :closed : :open - @issues = @issues.send( (@status == :closed) ? :closed_or_merged : :not_closed_or_merged ) - - @sort = params[:sort] == 'updated' ? :updated : :created - @direction = params[:direction] == 'asc' ? :asc : :desc - @issues = @issues.order("issues.#{@sort}_at #{@direction}") - .includes(:assignee, :user, :pull_request).uniq - .paginate :per_page => 20, :page => params[:page] - render 'issues_index', :layout => request.xhr? ? 'with_sidebar' : 'application' - end - - def pull_requests - issues - end - protected def find_user_by_key diff --git a/app/models/activity_feed.rb b/app/models/activity_feed.rb index a4ac3a759..194a9ec9b 100644 --- a/app/models/activity_feed.rb +++ b/app/models/activity_feed.rb @@ -15,7 +15,7 @@ class ActivityFeed < ActiveRecord::Base self.per_page = 10 def partial - 'activity_feeds/partials/' + self.kind + 'home/partials/' + self.kind end end diff --git a/app/views/activity_feeds/_feed_tabs.html.haml b/app/views/home/_feed_tabs.html.haml similarity index 68% rename from app/views/activity_feeds/_feed_tabs.html.haml rename to app/views/home/_feed_tabs.html.haml index e02b8c03b..2531a11d4 100644 --- a/app/views/activity_feeds/_feed_tabs.html.haml +++ b/app/views/home/_feed_tabs.html.haml @@ -2,4 +2,4 @@ %nav %ul - (collection = t 'feed_menu').each do |base, title| - %li= link_to title, root_path(:filter => base), :class => controller_name == 'activity_feeds' && @filter == base ? 'active' : '' + %li= link_to title, root_path(:filter => base), :class => @filter == base ? 'active' : '' diff --git a/app/views/activity_feeds/_list.html.haml b/app/views/home/_list.html.haml similarity index 100% rename from app/views/activity_feeds/_list.html.haml rename to app/views/home/_list.html.haml diff --git a/app/views/activity_feeds/_sidebar.html.haml b/app/views/home/_sidebar.html.haml similarity index 100% rename from app/views/activity_feeds/_sidebar.html.haml rename to app/views/home/_sidebar.html.haml diff --git a/app/views/activity_feeds/_top_menu.html.haml b/app/views/home/_top_menu.html.haml similarity index 51% rename from app/views/activity_feeds/_top_menu.html.haml rename to app/views/home/_top_menu.html.haml index f1c53309f..43bae255c 100644 --- a/app/views/activity_feeds/_top_menu.html.haml +++ b/app/views/home/_top_menu.html.haml @@ -2,6 +2,6 @@ .sub-menu %nav %ul - %li= link_to t('activity_menu.activity_feed'), root_path, :class => controller_name == 'activity_feeds' ? 'active' : '' - %li= link_to t('activity_menu.tracker'), issues_path, :class => controller_name == 'users' && action_name == 'issues' ? 'active' : '' - %li= link_to t('activity_menu.pull_requests'), pull_requests_path, :class => controller_name == 'users' && action_name == 'pull_requests' ? 'active' : '' \ No newline at end of file + %li= link_to t('activity_menu.activity_feed'), root_path, :class => action_name == 'activity' ? 'active' : '' + %li= link_to t('activity_menu.tracker'), issues_path, :class => action_name == 'issues' ? 'active' : '' + %li= link_to t('activity_menu.pull_requests'), pull_requests_path, :class => action_name == 'pull_requests' ? 'active' : '' \ No newline at end of file diff --git a/app/views/activity_feeds/index.atom.builder b/app/views/home/activity.atom.builder similarity index 100% rename from app/views/activity_feeds/index.atom.builder rename to app/views/home/activity.atom.builder diff --git a/app/views/activity_feeds/index.html.haml b/app/views/home/activity.html.haml similarity index 88% rename from app/views/activity_feeds/index.html.haml rename to app/views/home/activity.html.haml index 5e84c4279..ed75e4efe 100644 --- a/app/views/activity_feeds/index.html.haml +++ b/app/views/home/activity.html.haml @@ -2,8 +2,8 @@ %h3.fix = t("layout.activity_feed.header") = link_to image_tag("rss.ico", :width => '15px', :height => '15px', :class => 'atom_icon'), atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token) - =render('feed_tabs') + =render 'feed_tabs' =render 'list' - content_for :sidebar, render('sidebar') --render 'top_menu' +- render 'top_menu' diff --git a/app/views/users/users/issues_index.html.haml b/app/views/home/issues.html.haml similarity index 94% rename from app/views/users/users/issues_index.html.haml rename to app/views/home/issues.html.haml index 2b95ad61f..74e2dde80 100644 --- a/app/views/users/users/issues_index.html.haml +++ b/app/views/home/issues.html.haml @@ -1,5 +1,5 @@ -set_meta_tags :title => t("users.users.#{action_name}_index.title") --render('activity_feeds/top_menu') +-render 'top_menu' -content_for :sidebar do =form_tag send("#{action_name}_path"), :id => 'filter_issues', :method => :get do .bordered diff --git a/app/views/activity_feeds/partials/_build_list_notification.haml b/app/views/home/partials/_build_list_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_build_list_notification.haml rename to app/views/home/partials/_build_list_notification.haml diff --git a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml b/app/views/home/partials/_git_delete_branch_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_git_delete_branch_notification.haml rename to app/views/home/partials/_git_delete_branch_notification.haml diff --git a/app/views/activity_feeds/partials/_git_new_push_notification.haml b/app/views/home/partials/_git_new_push_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_git_new_push_notification.haml rename to app/views/home/partials/_git_new_push_notification.haml diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/home/partials/_issue_assign_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_issue_assign_notification.haml rename to app/views/home/partials/_issue_assign_notification.haml diff --git a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml b/app/views/home/partials/_new_comment_commit_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_new_comment_commit_notification.haml rename to app/views/home/partials/_new_comment_commit_notification.haml diff --git a/app/views/activity_feeds/partials/_new_comment_notification.haml b/app/views/home/partials/_new_comment_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_new_comment_notification.haml rename to app/views/home/partials/_new_comment_notification.haml diff --git a/app/views/activity_feeds/partials/_new_issue_notification.haml b/app/views/home/partials/_new_issue_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_new_issue_notification.haml rename to app/views/home/partials/_new_issue_notification.haml diff --git a/app/views/activity_feeds/partials/_new_user_notification.haml b/app/views/home/partials/_new_user_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_new_user_notification.haml rename to app/views/home/partials/_new_user_notification.haml diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/home/partials/_wiki_new_commit_notification.haml similarity index 100% rename from app/views/activity_feeds/partials/_wiki_new_commit_notification.haml rename to app/views/home/partials/_wiki_new_commit_notification.haml diff --git a/config/locales/title.en.yml b/config/locales/title.en.yml index 24a08a7fa..203591d9f 100644 --- a/config/locales/title.en.yml +++ b/config/locales/title.en.yml @@ -6,11 +6,6 @@ en: settings: profile: title: 'Your Profile' - users: - issues_index: - title: 'Your Issues' - pull_requests_index: - title: 'Your Pull Requests' projects: build_lists: index: @@ -38,3 +33,8 @@ en: product_build_lists: index: title: 'Products Monitoring' + pages: + issues: + title: 'Your Issues' + pull_requests: + title: 'Your Pull Requests' diff --git a/config/locales/title.ru.yml b/config/locales/title.ru.yml index 61ed7838f..94aef3936 100644 --- a/config/locales/title.ru.yml +++ b/config/locales/title.ru.yml @@ -6,11 +6,6 @@ ru: settings: profile: title: 'Ваш профиль' - users: - issues_index: - title: 'Ваши задачи' - pull_requests_index: - title: 'Ваши пул реквесты' projects: build_lists: index: @@ -38,3 +33,8 @@ ru: product_build_lists: index: title: 'Мониторинг продуктов' + pages: + issues: + title: 'Ваши задачи' + pull_requests: + title: 'Ваши пул реквесты' diff --git a/config/routes.rb b/config/routes.rb index 81c297a57..39c7734d3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,16 +94,19 @@ Rosa::Application.routes.draw do get '/forbidden' => 'pages#forbidden', :as => 'forbidden' get '/terms-of-service' => 'pages#tos', :as => 'tos' get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/ - match '/invite.html' => redirect('/register_requests/new') + #match '/invite.html' => redirect('/register_requests/new') + + get '/activity_feeds.:format' => 'home#activity', :as => 'atom_activity_feeds', :format => /atom/ + get '/issues' => 'home#issues' + get '/pull_requests' => 'home#pull_requests' - get '/activity_feeds.:format' => 'activity_feeds#index', :as => 'atom_activity_feeds', :format => /atom/ if APP_CONFIG['anonymous_access'] authenticated do - root :to => 'activity_feeds#index' + root :to => 'home#activity' end - root :to => 'pages#root' + root :to => 'home#root' else - root :to => 'activity_feeds#index' + root :to => 'home#activity' end namespace :admin do @@ -209,8 +212,6 @@ Rosa::Application.routes.draw do get '/allowed' => 'users#allowed' get '/check' => 'users#check' get '/discover' => 'users#discover' - get '/issues' => 'users#issues' - get '/pull_requests' => 'users#pull_requests' end scope :module => 'groups' do