Commit 6de7dc1e67a8595c80626e35987a96e190515230

Authored by Dmitriy Zaporozhets
1 parent 9f1a5f41

New projects page

app/assets/stylesheets/common.scss
1 1 a {
  2 + outline: none;
2 3 color: $link_color;
3 4 &:hover {
4 5 text-decoration:none;
... ... @@ -10,6 +11,10 @@ a {
10 11 }
11 12 }
12 13  
  14 +a:focus {
  15 + outline: none;
  16 +}
  17 +
13 18 .vlink {
14 19 color: $link_color !important;
15 20 }
... ... @@ -442,36 +447,6 @@ input.git_clone_url {
442 447 background:#fff !important;
443 448 }
444 449  
445   -.project_tile {
446   - @include shade;
447   - @include round-borders-all(4px);
448   - margin-bottom:20px;
449   - width:298px;
450   - float:left;
451   - margin-left:20px;
452   - border: 1px solid #DDD;
453   - padding-bottom:20px;
454   -
455   - .title {
456   - background:#f5f5f5;
457   - padding: 5px 10px 2px 20px;
458   - border-bottom: 1px solid #DDD;
459   - margin-bottom: 15px;
460   -
461   - h3 {
462   - &:hover {
463   - text-decoration: underline;
464   - }
465   - }
466   - }
467   - .data {
468   - margin: 0 20px;
469   - }
470   - .buttons {
471   - margin: 0 20px;
472   - }
473   -}
474   -
475 450 /**
476 451 *
477 452 * COMMIT SHOw
... ... @@ -610,26 +585,6 @@ p.time {
610 585 .dashboard_category {
611 586 margin-bottom:30px;
612 587  
613   - .ico {
614   - background: url("images.png") no-repeat -85px -77px;
615   - width: 19px;
616   - height: 16px;
617   - float: left;
618   - position: relative;
619   - margin-right: 10px;
620   - top: 8px;
621   -
622   - &.project {
623   - background-position: -37px -77px;
624   - }
625   -
626   - &.activities {
627   - background-position:-162px -22px;
628   - }
629   - &.projects {
630   - background-position:-209px -21px;
631   - }
632   - }
633 588  
634 589  
635 590 h3 a {
... ... @@ -688,3 +643,39 @@ p.time {
688 643 .wll:hover { background:none }
689 644 }
690 645  
  646 +
  647 +.projects_list {
  648 + a.project {
  649 + h4 {
  650 + color:#888;
  651 + }
  652 + &.active {
  653 + h4 {
  654 + color:#111;
  655 + .ico.project {
  656 + background-position:-209px -21px;
  657 + }
  658 + }
  659 + }
  660 + }
  661 +}
  662 +.ico {
  663 + background: url("images.png") no-repeat -85px -77px;
  664 + width: 19px;
  665 + height: 16px;
  666 + float: left;
  667 + position: relative;
  668 + margin-right: 10px;
  669 + top: 8px;
  670 +
  671 + &.project {
  672 + background-position: -37px -77px;
  673 + }
  674 +
  675 + &.activities {
  676 + background-position:-162px -22px;
  677 + }
  678 + &.projects {
  679 + background-position:-209px -21px;
  680 + }
  681 +}
... ...
app/controllers/projects_controller.rb
... ... @@ -11,8 +11,8 @@ class ProjectsController < ApplicationController
11 11 before_filter :require_non_empty_project, :only => [:blob, :tree, :graph]
12 12  
13 13 def index
14   - @limit, @offset = (params[:limit] || 16), (params[:offset] || 0)
15   - @projects = current_user.projects.limit(@limit).offset(@offset)
  14 + @projects = current_user.projects
  15 + @projects = @projects.select(&:last_activity_date).sort_by(&:last_activity_date).reverse
16 16 end
17 17  
18 18 def new
... ... @@ -67,9 +67,19 @@ class ProjectsController < ApplicationController
67 67 end
68 68  
69 69 def show
70   - return render "projects/empty" unless @project.repo_exists? && @project.has_commits?
71 70 limit = (params[:limit] || 20).to_i
72 71 @events = @project.events.recent.limit(limit)
  72 +
  73 + respond_to do |format|
  74 + format.html do
  75 + if @project.repo_exists? && @project.has_commits?
  76 + render :show
  77 + else
  78 + render "projects/empty"
  79 + end
  80 + end
  81 + format.js
  82 + end
73 83 end
74 84  
75 85 def files
... ...
app/views/projects/_show.html.haml 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +%h4
  2 + = @project.name
  3 +%hr
  4 +%div
  5 + %a.btn.info{:href => tree_project_ref_path(@project, @project.root_ref)} Browse code
  6 +  
  7 + %a.btn{:href => project_commits_path(@project)} Commits
  8 + %strong.right
  9 + = link_to project_path(@project) do
  10 + Switch to project →
  11 +%hr
  12 +.alert-message.block-message.warning
  13 + .input
  14 + .input-prepend
  15 + %span.add-on git clone
  16 + = text_field_tag :project_clone, @project.url_to_repo, :class => "xlarge one_click_select git_clone_url"
  17 +
  18 += simple_format @project.description
  19 +- unless @events.blank?
  20 + %h5.cgray Recent Activity
  21 + .content_list= render @events
  22 +
  23 +
... ...
app/views/projects/_tile.html.haml
... ... @@ -1,13 +0,0 @@
1   -- @projects.in_groups_of(3, false) do |projects|
2   - .row
3   - - projects.each_with_index do |project, i|
4   - %div.project_tile
5   - .title
6   - = link_to project_path(project) do
7   - %h3= truncate(project.name, :length => 28)
8   - .data
9   - %p
10   - %input{ :value => project.url_to_repo, :class => ['git-url', 'one_click_select', 'text', 'project_list_url'], :readonly => 'readonly' }
11   - .buttons
12   - %a.btn.info{:href => tree_project_ref_path(project, project.root_ref)} Browse code
13   - %a.btn{:href => project_commits_path(project)} Commits
app/views/projects/index.html.haml
... ... @@ -7,17 +7,33 @@
7 7 New Project
8 8 %hr
9 9 - unless @projects.empty?
10   - %div.content_list= render "tile"
  10 + .row
  11 + .span5
  12 + %div.content_list.projects_list
  13 + - @projects.each do |project|
  14 + = link_to project_path(project), :remote => true, :class => dom_class(project) do
  15 + %h4
  16 + %span.ico.project
  17 + = truncate(project.name, :length => 26)
  18 + .span11.right.show_holder
  19 + .loading
11 20  
12   - -# If projects requris paging
13   - -# We add ajax loader & init script
14   - - if @projects.count == @limit
15   - .loading{ :style => "display:none;"}
16   - %center= image_tag "ajax-loader.gif"
17   -
18   - :javascript
19   - $(function(){
20   - Pager.init(#{@limit});
21   - });
22 21 - else
23 22 %h2 Nothing here
  23 +
  24 +
  25 +:javascript
  26 + $(function(){
  27 + $("a.project").live("ajax:before", function() {
  28 + $(".show_holder").html("<div class='loading'>");
  29 + $('a.project').removeClass("active");
  30 + $(this).addClass("active");
  31 + });
  32 + $('a.project:first-child').trigger("click");
  33 + });
  34 +
  35 +- if @projects.count == @limit
  36 + :javascript
  37 + $(function(){
  38 + Pager.init(#{@limit});
  39 + });
... ...
app/views/projects/show.js.haml 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +- if @project.repo_exists? && @project.has_commits?
  2 + :plain
  3 + $(".show_holder").html("#{escape_javascript(render(:partial => 'projects/show'))}");
  4 +- else
  5 + :plain
  6 + $(".show_holder").html("#{escape_javascript(render(:template => 'projects/empty'))}");
  7 +
... ...