Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-10-12 00:00:00 +0400
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-10-12 17:19:14 +0400
commitbd34ca3c33a56550a1b42b8c150bdba61c96bfbd (patch)
tree8a4dfb097ba4e6666dc2f6565e4e71100d27db3a
parent495d29da738c8ac53406110d7c3af3f6a3a59bfc (diff)
project tile view
-rw-r--r--app/assets/images/list_view_icon.jpgbin0 -> 357 bytes
-rw-r--r--app/assets/javascripts/jquery.cookie.js41
-rw-r--r--app/assets/stylesheets/projects.css.scss14
-rw-r--r--app/controllers/dashboard_controller.rb3
-rw-r--r--app/helpers/projects_helper.rb4
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/dashboard/index.html.haml1
-rw-r--r--app/views/layouts/application.html.haml1
-rw-r--r--app/views/projects/_list.html.haml26
-rw-r--r--app/views/projects/_projects_top_menu.html.haml16
-rw-r--r--app/views/projects/_tile.html.haml16
-rw-r--r--app/views/projects/_tree_item.html.haml2
-rw-r--r--app/views/projects/index.html.haml30
13 files changed, 131 insertions, 27 deletions
diff --git a/app/assets/images/list_view_icon.jpg b/app/assets/images/list_view_icon.jpg
new file mode 100644
index 00000000000..45a34cb465f
--- /dev/null
+++ b/app/assets/images/list_view_icon.jpg
Binary files differ
diff --git a/app/assets/javascripts/jquery.cookie.js b/app/assets/javascripts/jquery.cookie.js
new file mode 100644
index 00000000000..6a3e394b403
--- /dev/null
+++ b/app/assets/javascripts/jquery.cookie.js
@@ -0,0 +1,41 @@
+/**
+ * jQuery Cookie plugin
+ *
+ * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ */
+jQuery.cookie = function (key, value, options) {
+
+ // key and at least value given, set cookie...
+ if (arguments.length > 1 && String(value) !== "[object Object]") {
+ options = jQuery.extend({}, options);
+
+ if (value === null || value === undefined) {
+ options.expires = -1;
+ }
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setDate(t.getDate() + days);
+ }
+
+ value = String(value);
+
+ return (document.cookie = [
+ encodeURIComponent(key), '=',
+ options.raw ? value : encodeURIComponent(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
+ }
+
+ // key and possibly options given, get cookie...
+ options = value || {};
+ var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
+ return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
+};
diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss
index c87751da6cd..0ee40f512ac 100644
--- a/app/assets/stylesheets/projects.css.scss
+++ b/app/assets/stylesheets/projects.css.scss
@@ -525,3 +525,17 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
#user_projects_limit{
width: 60px;
}
+
+.project_thumb {
+ margin:20px 0;
+ width: 250px;
+ float:left;
+ padding:20px;
+ text-align:center;
+ p, h4 {
+ text-align:left;
+ }
+ .lbutton {
+ float:left;
+ }
+}
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index e1192e4dc5d..2476b17ef90 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -1,2 +1,5 @@
class DashboardController < ApplicationController
+ def index
+ @projects = current_user.projects.all
+ end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index db5c5ce1a76..d570dff4639 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -1,2 +1,6 @@
module ProjectsHelper
+ def view_mode_style(type)
+ cookies["project_view"] ||= "tile"
+ cookies["project_view"] == type ? nil : "display:none"
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 104843a801e..0972f006dbd 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -33,6 +33,10 @@ class User < ActiveRecord::Base
def can_create_project?
projects_limit >= my_own_projects.count
end
+
+ def last_activity_project
+ projects.first
+ end
end
# == Schema Information
#
diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml
index e69de29bb2d..f4ce9a17d82 100644
--- a/app/views/dashboard/index.html.haml
+++ b/app/views/dashboard/index.html.haml
@@ -0,0 +1 @@
+timeline
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 8ac413a1f44..3eb99da61e5 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -21,6 +21,7 @@
= render :partial => "layouts/head_panel"
.top_bar.container
= render :partial => "projects/top_menu" if @project && !@project.new_record?
+ = render :partial => "projects/projects_top_menu" if (controller.controller_name == "projects" && ["index", "new", "create"].include?(controller.action_name)) && !admin_namespace?
= render :partial => "profile/top_menu" if ["keys", "profile"].include?(controller.controller_name)
= render :partial => "admin/top_menu" if admin_namespace?
#content-container.container
diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml
new file mode 100644
index 00000000000..82e1948c757
--- /dev/null
+++ b/app/views/projects/_list.html.haml
@@ -0,0 +1,26 @@
+-#- if current_user.can_create_project?
+ = link_to 'New Project', new_project_path, :class => "lbutton vm"
+
+%table.round-borders#projects-list
+ %tr
+ %th Name
+ %th Path
+ %th Code
+ %th Web
+ %th Git
+ %th Admin
+ %th Actions
+
+ - @projects.each do |project|
+ %tr{ :class => "project", :url => project_path(project) }
+ %td= project.name
+ %td= truncate project.url_to_repo
+ %td= project.code
+ %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled
+ %td= check_box_tag "commit", 1, project.writers.include?(current_user), :disabled => :disabled
+ %td= check_box_tag "admin", 1, project.admins.include?(current_user), :disabled => :disabled
+ %td
+ -if can? current_user, :admin_project, project
+ = link_to 'Edit', edit_project_path(project), :class => "lbutton positive"
+%br
+
diff --git a/app/views/projects/_projects_top_menu.html.haml b/app/views/projects/_projects_top_menu.html.haml
new file mode 100644
index 00000000000..be04c57e842
--- /dev/null
+++ b/app/views/projects/_projects_top_menu.html.haml
@@ -0,0 +1,16 @@
+%div.top_project_menu
+ %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil
+ %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil
+ %span.right
+ = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;")
+
+:javascript
+ function switchProjectView(){
+ $(".tile").toggle();
+ $(".list").toggle();
+ if($(".tile").is(":visible")){
+ $.cookie('project_view', 'tile', { expires: 14 });
+ } else {
+ $.cookie('project_view', 'list', { expires: 14 });
+ }
+ }
diff --git a/app/views/projects/_tile.html.haml b/app/views/projects/_tile.html.haml
new file mode 100644
index 00000000000..037aeccb228
--- /dev/null
+++ b/app/views/projects/_tile.html.haml
@@ -0,0 +1,16 @@
+- @projects.in_groups_of(3, false) do |projects|
+ - projects.each_with_index do |project, i|
+ %div{ :class => "project_thumb round-borders", :style => i == 2 ? "" : "margin-right:30px;" }
+ %div{ :class => "project", :url => project_path(project) }
+ %h2
+ = image_tag gravatar_icon(project.name), :class => "left", :width => 40, :style => "padding-right:5px;"
+ = "/" + project.code
+ %p= project.name
+ %p= project.url_to_repo
+ -#%p
+ Commit &ndash;
+ = last_commit(project)
+ %hr
+ = link_to "Browse Code", tree_project_path(project), :class => "lbutton"
+ = link_to "Commits", project_commits_path(project), :class => "lbutton", :style => "float:right;width:80px;"
+ .clear
diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml
index 25575283993..7179368a0c3 100644
--- a/app/views/projects/_tree_item.html.haml
+++ b/app/views/projects/_tree_item.html.haml
@@ -1,5 +1,5 @@
- file = params[:path] ? File.join(params[:path], content.name) : content.name
-- content_commit = @repo.log(@branch, file, :max_count => 1).last
+- content_commit = @project.repo.log(@branch, file, :max_count => 1).last
- return unless content_commit
%tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
%td.tree-item-file-name
diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml
index a33b4f57a82..22af6b7551a 100644
--- a/app/views/projects/index.html.haml
+++ b/app/views/projects/index.html.haml
@@ -1,26 +1,4 @@
-- if current_user.can_create_project?
- = link_to 'New Project', new_project_path, :class => "lbutton vm"
-
-%table.round-borders#projects-list
- %tr
- %th Name
- %th Path
- %th Code
- %th Web
- %th Git
- %th Admin
- %th Actions
-
- - @projects.each do |project|
- %tr{ :class => "project", :url => project_path(project) }
- %td= project.name
- %td= truncate project.url_to_repo
- %td= project.code
- %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled
- %td= check_box_tag "commit", 1, project.writers.include?(current_user), :disabled => :disabled
- %td= check_box_tag "admin", 1, project.admins.include?(current_user), :disabled => :disabled
- %td
- -if can? current_user, :admin_project, project
- = link_to 'Edit', edit_project_path(project), :class => "lbutton positive"
-%br
-
+%div{:class => "tile", :style => view_mode_style("tile")}
+ = render "tile"
+%div{:class => "list", :style => view_mode_style("list")}
+ = render "list"