New projects page

This commit is contained in:
Dmitriy Zaporozhets 2012-03-03 00:09:17 +02:00
parent 9f1a5f415a
commit 6de7dc1e67
6 changed files with 111 additions and 77 deletions

View file

@ -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;
}
}

View file

@ -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

View file

@ -0,0 +1,23 @@
%h4
= @project.name
%hr
%div
%a.btn.info{:href => tree_project_ref_path(@project, @project.root_ref)} Browse code
&nbsp;
%a.btn{:href => project_commits_path(@project)} Commits
%strong.right
= link_to project_path(@project) do
Switch to project &rarr;
%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

View file

@ -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

View file

@ -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("<div class='loading'>");
$('a.project').removeClass("active");
$(this).addClass("active");
});
$('a.project:first-child').trigger("click");
});
- if @projects.count == @limit
:javascript
$(function(){
Pager.init(#{@limit});
});

View file

@ -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'))}");