From 7da70b5f12d62fb1b885dc96ae42343d7c9282bc Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 8 Sep 2013 17:56:43 +0600 Subject: [PATCH] [#277] profile projects 1 ver. --- .gitignore | 5 +- app/assets/images/bg_blue.png | Bin 0 -> 176 bytes app/assets/images/profile-hover.png | Bin 0 -> 2793 bytes app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/design/custom.scss | 40 +---- app/assets/stylesheets/design/profile.scss | 146 ++++++++++++++++++ app/controllers/groups/profile_controller.rb | 2 +- app/controllers/users/profile_controller.rb | 2 +- app/helpers/commit_helper.rb | 11 +- .../partials/_git_new_push_notification.haml | 4 +- app/views/shared/_profile.html.haml | 33 ++-- app/views/shared/_profile_projects.html.haml | 11 ++ config/locales/models/project.en.yml | 3 + config/locales/models/project.ru.yml | 3 + lib/modules/models/git.rb | 5 + 15 files changed, 210 insertions(+), 56 deletions(-) create mode 100644 app/assets/images/bg_blue.png create mode 100644 app/assets/images/profile-hover.png create mode 100644 app/assets/stylesheets/design/profile.scss create mode 100644 app/views/shared/_profile_projects.html.haml diff --git a/.gitignore b/.gitignore index f98b0074d..7f6472601 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,7 @@ crash.log config/newrelic.yml config/deploy/*.rb config/deploy.rb -*.swo +.swo +.swn +.ruby-gemset +.ruby-version \ No newline at end of file diff --git a/app/assets/images/bg_blue.png b/app/assets/images/bg_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..ecfede3608f8519fc1d6ef8a2b04d5e60afaa184 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^d_b(t!3HEfGFdgVmqSK?pV_PC#U`MTt*47)h{y3{o}7Ch<~Q;jIO3ot zan)i~VaVeZ#{zp7OSzl&`Sj`-9Q*(Oh^d`~q~yvJzopr07T|AxBvhE literal 0 HcmV?d00001 diff --git a/app/assets/images/profile-hover.png b/app/assets/images/profile-hover.png new file mode 100644 index 0000000000000000000000000000000000000000..09427d06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951U69E94oEQKA00(qQO+^RY2pkXz9)BPs?EnA(8%ab# vR0!8&`2YVu0}}%S1C params[:page], :per_page => 25) + .paginate(:page => params[:page], :per_page => 24) end def new diff --git a/app/controllers/users/profile_controller.rb b/app/controllers/users/profile_controller.rb index 80a1599df..b19d1b047 100644 --- a/app/controllers/users/profile_controller.rb +++ b/app/controllers/users/profile_controller.rb @@ -4,6 +4,6 @@ class Users::ProfileController < Users::BaseController def show @projects = @user.projects.opened.search(params[:search]).recent - .paginate(:page => params[:page], :per_page => 25) + .paginate(:page => params[:page], :per_page => 24) end end diff --git a/app/helpers/commit_helper.rb b/app/helpers/commit_helper.rb index 5110b2e9c..9fb195721 100644 --- a/app/helpers/commit_helper.rb +++ b/app/helpers/commit_helper.rb @@ -1,6 +1,5 @@ # -*- encoding : utf-8 -*- module CommitHelper - def render_commit_stats(stats) res = [""] ind=0 @@ -44,4 +43,14 @@ module CommitHelper u = User.where(:email => email).first u.present? ? link_to(name, user_path(u)) : mail_to(email, name) end + + def commits_pluralize(commits_count) + Russian.p(commits_count, *commits_pluralization_arr) + end + + protected + + def commits_pluralization_arr + pluralize ||= t('layout.commits.pluralize').map {|base, title| title.to_s} + end end diff --git a/app/views/home/partials/_git_new_push_notification.haml b/app/views/home/partials/_git_new_push_notification.haml index d144beed8..f9553f91f 100644 --- a/app/views/home/partials/_git_new_push_notification.haml +++ b/app/views/home/partials/_git_new_push_notification.haml @@ -15,6 +15,6 @@ = commit[1] %br - if defined? other_commits - -pluralize = t('layout.commits.pluralize').map {|base, title| title.to_s} %br - =link_to t('notifications.bodies.more_commits', :count => other_commits_count, :commits => Russian.p(other_commits_count, *pluralize)), diff_path(project_owner, project_name, :diff => other_commits) + =link_to t('notifications.bodies.more_commits', :count => other_commits_count, :commits => commits_pluralize(other_commits_count)), + diff_path(project_owner, project_name, :diff => other_commits) diff --git a/app/views/shared/_profile.html.haml b/app/views/shared/_profile.html.haml index 119a93076..1c87bbe62 100644 --- a/app/views/shared/_profile.html.haml +++ b/app/views/shared/_profile.html.haml @@ -35,16 +35,23 @@ %hr.profile_line{:color => 'dfe8ef', :size => '3'} -.content - %h4= t("layout.projects.public_projects_list") + ":" - %p - =form_tag search_path, :id => 'filter_projects', :method => :get do - =tracker_search_field(:search, t('layout.find_project')) - %br - %p - - projects.each do |project| - = link_to project.name, project - %br - %br - = will_paginate projects - %br +.row-fluid.profile-content + .span12.content + %nav + %ul + %li + = link_to t('layout.projects.list_header'), '#', :class => 'projects active' + .span12.sub-menu + %nav + %ul + %li= link_to t('layout.projects.public'), '#', :class => "public-projects #{@public ? 'active' : ''}" + %li= link_to t('layout.projects.private'), '#', :class => "private-projects #{!@public ? 'active' : ''}" + .search + .pic + .field= text_field_tag 'query', @query, :placeholder => t('layout.find_project') + + %table.profile-table + %tbody= render 'shared/profile_projects', :projects => projects +%br += will_paginate projects + diff --git a/app/views/shared/_profile_projects.html.haml b/app/views/shared/_profile_projects.html.haml new file mode 100644 index 000000000..3762c49a7 --- /dev/null +++ b/app/views/shared/_profile_projects.html.haml @@ -0,0 +1,11 @@ +- pr_groups = projects.in_groups(2) +- pr_groups[0].each_with_index do |project, ind| + %tr{:class => ind.odd? ? 'odd' : 'even'} + - [project, pr_groups[1][ind]].each do |project| + %th + - if project.present? + .project-link= link_to project.name, project + .row-fluid + = datetime_moment project.updated_at, :class => :span3 + - commits_count = project.total_commits_count + .span3= "#{commits_count > 10000 ? '10000+' : commits_count} #{commits_pluralize(commits_count)}" diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml index 542571860..d616729d1 100644 --- a/config/locales/models/project.en.yml +++ b/config/locales/models/project.en.yml @@ -71,6 +71,9 @@ en: current_commit: Current commit files_in_project: Files in + public: Public + private: Private + flash: project: saved: Project saved diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml index 560f96151..5360e237c 100644 --- a/config/locales/models/project.ru.yml +++ b/config/locales/models/project.ru.yml @@ -71,6 +71,9 @@ ru: cloning: Клонирование этого репозитория remote: Добавление этого репозитория как удаленного к существующему локальному репозиторию + public: Публичные + private: Приватные + flash: project: saved: Проект успешно сохранен diff --git a/lib/modules/models/git.rb b/lib/modules/models/git.rb index 032d8bb57..246652074 100644 --- a/lib/modules/models/git.rb +++ b/lib/modules/models/git.rb @@ -115,6 +115,11 @@ module Modules repo.branches.count == 0 end + def total_commits_count + return 0 if is_empty? + %x(cd #{path} && git rev-list --all | wc -l).to_i + end + protected def build_path(dir)