| |   |
| 2 | 2 | acts_as_taggable |
| 3 | 3 | |
| 4 | 4 | belongs_to :user |
| 5 | | has_many :repositories, :order => "mainline desc, created_at desc", |
| 5 | has_many :repositories, :order => "mainline desc, created_at asc", |
| 6 | 6 | :dependent => :destroy |
| 7 | 7 | has_one :mainline_repository, :conditions => ["mainline = ?", true], |
| 8 | 8 | :class_name => "Repository" |
| toggle raw diff |
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -2,7 +2,7 @@ class Project < ActiveRecord::Base
acts_as_taggable
belongs_to :user
- has_many :repositories, :order => "mainline desc, created_at desc",
+ has_many :repositories, :order => "mainline desc, created_at asc",
:dependent => :destroy
has_one :mainline_repository, :conditions => ["mainline = ?", true],
:class_name => "Repository" |
| |   |
| 28 | 28 | <th>Created</th> |
| 29 | 29 | <th></th> |
| 30 | 30 | </thead> |
| 31 | | <% @repositories.each do |repos| -%> |
| 32 | | <tr class="<%= cycle("even", "odd") -%><%= repos.mainline? ? ' mainline' : '' -%>"> |
| 33 | | <td> |
| 31 | <% @repositories.each do |repos, clones| -%> |
| 32 | <% next if repos.nil? -%> |
| 33 | <tr class="<%= cycle("even", "odd") -%> mainline"> |
| 34 | <td class="name"> |
| 34 | 35 | <%= link_to h(repos.name), project_repository_path(@project, repos) -%> |
| 35 | | <!-- <% if repos.mainline? -%> <small><em>(Mainline)</em></small><% end -%> --> |
| 36 | 36 | </td> |
| 37 | 37 | <td> |
| 38 | | <% if repos.mainline? -%> |
| 39 | | <%= h(@project.slug) -%> (<%= link_to h(repos.user.login), user_path(repos.user) -%>) |
| 40 | | <% else -%> |
| 41 | | <%= link_to h(repos.user.login), user_path(repos.user) -%> |
| 42 | | <% end -%> |
| 38 | <%= h(@project.slug) -%> (<%= link_to h(repos.user.login), user_path(repos.user) -%>) |
| 43 | 39 | </td> |
| 44 | 40 | <td> |
| 45 | 41 | <%= repos.created_at.to_s(:short) -%> |
| 46 | 42 | </td> |
| 47 | 43 | <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td> |
| 48 | 44 | </tr> |
| 45 | <% clones.each do |repos| -%> |
| 46 | <tr class="<%= cycle("even", "odd") -%> clone"> |
| 47 | <td class="name"> |
| 48 | <%= link_to h(repos.name), project_repository_path(@project, repos) -%> |
| 49 | </td> |
| 50 | <td> |
| 51 | <%= link_to h(repos.user.login), user_path(repos.user) -%> |
| 52 | </td> |
| 53 | <td> |
| 54 | <%= repos.created_at.to_s(:short) -%> |
| 55 | </td> |
| 56 | <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td> |
| 57 | </tr> |
| 58 | <% end -%> |
| 49 | 59 | <% end -%> |
| 50 | 60 | </table> |
| 51 | 61 | |
| toggle raw diff |
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -28,24 +28,34 @@
<th>Created</th>
<th></th>
</thead>
- <% @repositories.each do |repos| -%>
- <tr class="<%= cycle("even", "odd") -%><%= repos.mainline? ? ' mainline' : '' -%>">
- <td>
+ <% @repositories.each do |repos, clones| -%>
+ <% next if repos.nil? -%>
+ <tr class="<%= cycle("even", "odd") -%> mainline">
+ <td class="name">
<%= link_to h(repos.name), project_repository_path(@project, repos) -%>
- <!-- <% if repos.mainline? -%> <small><em>(Mainline)</em></small><% end -%> -->
</td>
<td>
- <% if repos.mainline? -%>
- <%= h(@project.slug) -%> (<%= link_to h(repos.user.login), user_path(repos.user) -%>)
- <% else -%>
- <%= link_to h(repos.user.login), user_path(repos.user) -%>
- <% end -%>
+ <%= h(@project.slug) -%> (<%= link_to h(repos.user.login), user_path(repos.user) -%>)
</td>
<td>
<%= repos.created_at.to_s(:short) -%>
</td>
<td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td>
</tr>
+ <% clones.each do |repos| -%>
+ <tr class="<%= cycle("even", "odd") -%> clone">
+ <td class="name">
+ <%= link_to h(repos.name), project_repository_path(@project, repos) -%>
+ </td>
+ <td>
+ <%= link_to h(repos.user.login), user_path(repos.user) -%>
+ </td>
+ <td>
+ <%= repos.created_at.to_s(:short) -%>
+ </td>
+ <td><%= link_to "browse", project_repository_browse_path(@project, repos) -%></td>
+ </tr>
+ <% end -%>
<% end -%>
</table>
|
| |   |
| 2 | 2 | def to_sentence(options={}) |
| 3 | 3 | super({:skip_last_comma => true}.merge(options)) |
| 4 | 4 | end |
| 5 | end |
| 6 | |
| 7 | module Enumerable |
| 8 | # http://dev.rubyonrails.org/changeset/8516 |
| 9 | def group_by |
| 10 | inject([]) do |groups, element| |
| 11 | value = yield(element) |
| 12 | if (last_group = groups.last) && last_group.first == value |
| 13 | last_group.last << element |
| 14 | else |
| 15 | groups << [value, [element]] |
| 16 | end |
| 17 | groups |
| 18 | end |
| 19 | end if RUBY_VERSION < '1.9' |
| 5 | 20 | end |
| toggle raw diff |
--- a/lib/core_ext.rb
+++ b/lib/core_ext.rb
@@ -2,4 +2,19 @@ class Array
def to_sentence(options={})
super({:skip_last_comma => true}.merge(options))
end
+end
+
+module Enumerable
+ # http://dev.rubyonrails.org/changeset/8516
+ def group_by
+ inject([]) do |groups, element|
+ value = yield(element)
+ if (last_group = groups.last) && last_group.first == value
+ last_group.last << element
+ else
+ groups << [value, [element]]
+ end
+ groups
+ end
+ end if RUBY_VERSION < '1.9'
end
\ No newline at end of file |