From 6de7dc1e67a8595c80626e35987a96e190515230 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 3 Mar 2012 00:09:17 +0200 Subject: [PATCH] New projects page --- app/assets/stylesheets/common.scss | 91 ++++++++++++-------------- app/controllers/projects_controller.rb | 16 ++++- app/views/projects/_show.html.haml | 23 +++++++ app/views/projects/_tile.html.haml | 13 ---- app/views/projects/index.html.haml | 38 +++++++---- app/views/projects/show.js.haml | 7 ++ 6 files changed, 111 insertions(+), 77 deletions(-) create mode 100644 app/views/projects/_show.html.haml delete mode 100644 app/views/projects/_tile.html.haml create mode 100644 app/views/projects/show.js.haml diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 19686ac2..4e345208 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1,4 +1,5 @@ a { + outline: none; color: $link_color; &:hover { text-decoration:none; @@ -10,6 +11,10 @@ a { } } +a:focus { + outline: none; +} + .vlink { color: $link_color !important; } @@ -442,36 +447,6 @@ input.git_clone_url { background:#fff !important; } -.project_tile { - @include shade; - @include round-borders-all(4px); - margin-bottom:20px; - width:298px; - float:left; - margin-left:20px; - border: 1px solid #DDD; - padding-bottom:20px; - - .title { - background:#f5f5f5; - padding: 5px 10px 2px 20px; - border-bottom: 1px solid #DDD; - margin-bottom: 15px; - - h3 { - &:hover { - text-decoration: underline; - } - } - } - .data { - margin: 0 20px; - } - .buttons { - margin: 0 20px; - } -} - /** * * COMMIT SHOw @@ -610,26 +585,6 @@ p.time { .dashboard_category { margin-bottom:30px; - .ico { - background: url("images.png") no-repeat -85px -77px; - width: 19px; - height: 16px; - float: left; - position: relative; - margin-right: 10px; - top: 8px; - - &.project { - background-position: -37px -77px; - } - - &.activities { - background-position:-162px -22px; - } - &.projects { - background-position:-209px -21px; - } - } h3 a { @@ -688,3 +643,39 @@ p.time { .wll:hover { background:none } } + +.projects_list { + a.project { + h4 { + color:#888; + } + &.active { + h4 { + color:#111; + .ico.project { + background-position:-209px -21px; + } + } + } + } +} +.ico { + background: url("images.png") no-repeat -85px -77px; + width: 19px; + height: 16px; + float: left; + position: relative; + margin-right: 10px; + top: 8px; + + &.project { + background-position: -37px -77px; + } + + &.activities { + background-position:-162px -22px; + } + &.projects { + background-position:-209px -21px; + } +} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 51fd2732..90372cf5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -11,8 +11,8 @@ class ProjectsController < ApplicationController before_filter :require_non_empty_project, :only => [:blob, :tree, :graph] def index - @limit, @offset = (params[:limit] || 16), (params[:offset] || 0) - @projects = current_user.projects.limit(@limit).offset(@offset) + @projects = current_user.projects + @projects = @projects.select(&:last_activity_date).sort_by(&:last_activity_date).reverse end def new @@ -67,9 +67,19 @@ class ProjectsController < ApplicationController end def show - return render "projects/empty" unless @project.repo_exists? && @project.has_commits? limit = (params[:limit] || 20).to_i @events = @project.events.recent.limit(limit) + + respond_to do |format| + format.html do + if @project.repo_exists? && @project.has_commits? + render :show + else + render "projects/empty" + end + end + format.js + end end def files diff --git a/app/views/projects/_show.html.haml b/app/views/projects/_show.html.haml new file mode 100644 index 00000000..ee0b19e1 --- /dev/null +++ b/app/views/projects/_show.html.haml @@ -0,0 +1,23 @@ +%h4 + = @project.name +%hr +%div + %a.btn.info{:href => tree_project_ref_path(@project, @project.root_ref)} Browse code +   + %a.btn{:href => project_commits_path(@project)} Commits + %strong.right + = link_to project_path(@project) do + Switch to project → +%hr +.alert-message.block-message.warning + .input + .input-prepend + %span.add-on git clone + = text_field_tag :project_clone, @project.url_to_repo, :class => "xlarge one_click_select git_clone_url" + += simple_format @project.description +- unless @events.blank? + %h5.cgray Recent Activity + .content_list= render @events + + diff --git a/app/views/projects/_tile.html.haml b/app/views/projects/_tile.html.haml deleted file mode 100644 index e49aa076..00000000 --- a/app/views/projects/_tile.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -- @projects.in_groups_of(3, false) do |projects| - .row - - projects.each_with_index do |project, i| - %div.project_tile - .title - = link_to project_path(project) do - %h3= truncate(project.name, :length => 28) - .data - %p - %input{ :value => project.url_to_repo, :class => ['git-url', 'one_click_select', 'text', 'project_list_url'], :readonly => 'readonly' } - .buttons - %a.btn.info{:href => tree_project_ref_path(project, project.root_ref)} Browse code - %a.btn{:href => project_commits_path(project)} Commits diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index 3838c339..b26a8672 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -7,17 +7,33 @@ New Project %hr - unless @projects.empty? - %div.content_list= render "tile" + .row + .span5 + %div.content_list.projects_list + - @projects.each do |project| + = link_to project_path(project), :remote => true, :class => dom_class(project) do + %h4 + %span.ico.project + = truncate(project.name, :length => 26) + .span11.right.show_holder + .loading - -# If projects requris paging - -# We add ajax loader & init script - - if @projects.count == @limit - .loading{ :style => "display:none;"} - %center= image_tag "ajax-loader.gif" - - :javascript - $(function(){ - Pager.init(#{@limit}); - }); - else %h2 Nothing here + + +:javascript + $(function(){ + $("a.project").live("ajax:before", function() { + $(".show_holder").html("
"); + $('a.project').removeClass("active"); + $(this).addClass("active"); + }); + $('a.project:first-child').trigger("click"); + }); + +- if @projects.count == @limit + :javascript + $(function(){ + Pager.init(#{@limit}); + }); diff --git a/app/views/projects/show.js.haml b/app/views/projects/show.js.haml new file mode 100644 index 00000000..132ebebf --- /dev/null +++ b/app/views/projects/show.js.haml @@ -0,0 +1,7 @@ +- if @project.repo_exists? && @project.has_commits? + :plain + $(".show_holder").html("#{escape_javascript(render(:partial => 'projects/show'))}"); +- else + :plain + $(".show_holder").html("#{escape_javascript(render(:template => 'projects/empty'))}"); +