From 69e0ea626540a18866b58944ae230f4278e91ab6 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Wed, 19 Oct 2011 16:25:22 +0300 Subject: [PATCH 01/12] dashboard --- app/assets/stylesheets/projects.css.scss | 37 +++++++++++++++---- app/controllers/projects_controller.rb | 4 +- app/views/projects/_recent_messages.html.haml | 7 +++- app/views/projects/show.html.haml | 4 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 4739a469..8d545435 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -557,21 +557,44 @@ tbody tr:nth-child(2n) td, tbody tr.even td { img { padding-right:10px; } - background: #fff !important; - background: -webkit-gradient(linear,left top,left bottom,from(#fff),to(#EAEAEA)) !important; - background: -moz-linear-gradient(top,#fff,#EAEAEA) !important; - background: transparent 9 !important; float: left; margin: 0 20px 20px 0px; - padding: 5px 5px;; + padding: 5px 0px;; width: 420px; + &.dash_wall{ + border-bottom: 2px solid orange; + span { + background: orange; + color:black; + } + } + + &.dash_issue{ + border-bottom: 2px solid #ffbbbb; + span { + background: #ffbbbb; + color:black; + padding:2px; + } + } + &.dash_commit{ + border-bottom: 2px solid #bbbbff; + + span{ + background: #bbbbff; + color:black; + padding:2px; + } + } + h4 { margin-bottom:3px; } - span { - + .author { + background: #eaeaea; + color: #333; } } diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6bcc14b5..8ce3ca97 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -64,11 +64,11 @@ class ProjectsController < ApplicationController @date = case params[:view] when "week" then Date.today - 7.days else Date.today - end + end.at_beginning_of_day @heads = @project.repo.heads @commits = @heads.map do |h| - @project.repo.log(h.name, nil, :since => @date - 1.day) + @project.repo.log(h.name, nil, :since => @date) end.flatten.uniq { |c| c.id } @commits.sort! do |x, y| diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml index 2191ed95..16612350 100644 --- a/app/views/projects/_recent_messages.html.haml +++ b/app/views/projects/_recent_messages.html.haml @@ -5,21 +5,24 @@ - case type - when "Issue" + - css_class = "dash_issue" - issue = parent - item_code = issue.author.email - link_item_name = truncate(issue.title, :length => 50) - link_to_item = project_issue_path(@project, issue) - when "Commit" + - css_class = "dash_commit" - commit = parent - item_code = commit.author.email - link_item_name = truncate_commit_message(commit, 50) - link_to_item = project_commit_path(@project, :id => commit.id) - else + - css_class = "dash_wall" - item_code = @project.name - link_item_name = "Project Wall" - link_to_item = wall_project_path(@project) - %div.recent_message_parent + %div{ :class => "recent_message_parent #{css_class}"} = image_tag gravatar_icon(item_code), :class => "left", :width => 40 %h4 = link_to(link_item_name, link_to_item) @@ -30,7 +33,7 @@ %div.message = image_tag gravatar_icon(note.author.email), :class => "left", :width => 24, :style => "padding-right:5px;" %p{:style => "margin-bottom: 3px;"} - = link_to truncate(note.note, :length => 50), "#" + = link_to truncate(note.note, :length => 200), link_to_item + "#note_#{note.id}" - if note.attachment.url %br Attachment: diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 25cd7b94..ff6078c1 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -4,7 +4,7 @@ = form_tag project_path(@project), :method => :get do .span-2 = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" - = label_tag "day_view","Day" + = label_tag "day_view","Today" .span-2 = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" = label_tag "week_view","Week" @@ -15,6 +15,6 @@ =render "projects/recent_commits" .span-11.right - %h3 Messages + %h3 Talk =render "projects/recent_messages" From 9ad444f02efbeb30365cdf7f23f9b2f846b45a03 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Wed, 19 Oct 2011 20:41:14 +0300 Subject: [PATCH 02/12] dashboard updated, links from project to dasdhboard --- app/assets/stylesheets/projects.css.scss | 24 +++++++++++++++---- app/helpers/projects_helper.rb | 1 + app/views/projects/_recent_messages.html.haml | 9 ++++++- app/views/projects/_tile.html.haml | 2 +- app/views/snippets/show.html.haml | 1 + 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 8d545435..860523b0 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -575,8 +575,6 @@ tbody tr:nth-child(2n) td, tbody tr.even td { border-bottom: 2px solid #ffbbbb; span { background: #ffbbbb; - color:black; - padding:2px; } } &.dash_commit{ @@ -584,17 +582,35 @@ tbody tr:nth-child(2n) td, tbody tr.even td { span{ background: #bbbbff; - color:black; - padding:2px; } } + &.dash_snippet{ + border-bottom: 2px solid #bbffbb; + + span{ + background: #bbffbb; + } + } + + + span{ + border: 1px solid #aaa; + color:black; + padding:1px 4px; + } + h4 { margin-bottom:3px; } +} +.message{ .author { background: #eaeaea; color: #333; + border: 1px solid #aaa; + padding:1px 2px; + margin-right:5px; } } diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 02e1df5d..4a6923af 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -8,6 +8,7 @@ module ProjectsHelper case type when "Issue" then @project.issues.find(id) when "Commit" then @project.repo.commits(id).first + when "Snippet" then @project.snippets.find(id) else true end diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml index 16612350..03f723da 100644 --- a/app/views/projects/_recent_messages.html.haml +++ b/app/views/projects/_recent_messages.html.haml @@ -10,6 +10,11 @@ - item_code = issue.author.email - link_item_name = truncate(issue.title, :length => 50) - link_to_item = project_issue_path(@project, issue) + - when "Snippet" + - css_class = "dash_snippet" + - item_code = parent.author.email + - link_item_name = parent.title + - link_to_item = project_snippet_path(@project, parent) - when "Commit" - css_class = "dash_commit" - commit = parent @@ -33,13 +38,15 @@ %div.message = image_tag gravatar_icon(note.author.email), :class => "left", :width => 24, :style => "padding-right:5px;" %p{:style => "margin-bottom: 3px;"} + %span.author + = note.author.name = link_to truncate(note.note, :length => 200), link_to_item + "#note_#{note.id}" - if note.attachment.url %br Attachment: = link_to note.attachment_identifier, note.attachment.url %br - %span + -#%span %span [ #{note.author.name} ] %cite diff --git a/app/views/projects/_tile.html.haml b/app/views/projects/_tile.html.haml index 037aeccb..b2466d93 100644 --- a/app/views/projects/_tile.html.haml +++ b/app/views/projects/_tile.html.haml @@ -4,7 +4,7 @@ %div{ :class => "project", :url => project_path(project) } %h2 = image_tag gravatar_icon(project.name), :class => "left", :width => 40, :style => "padding-right:5px;" - = "/" + project.code + = link_to ("/" + project.code), project_path(project), :style => "text-decoration:none" %p= project.name %p= project.url_to_repo -#%p diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index d29e0f8c..bb444efe 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -15,6 +15,7 @@ = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive" - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user = link_to 'Destroy', [@project, @snippet], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-snippet negative", :id => "destroy_snippet_#{@snippet.id}" +.clear %br .snippet_notes= render "notes/notes" From 59704f481e742710fff32c733047eb84478e505e Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Thu, 20 Oct 2011 01:34:05 +0300 Subject: [PATCH 03/12] extended user profile with social fields --- app/controllers/profile_controller.rb | 6 +++++ app/models/user.rb | 6 ++++- app/views/admin/users/_form.html.haml | 17 +++++++++++-- app/views/admin/users/show.html.haml | 11 ++++++++ app/views/profile/show.html.haml | 25 +++++++++++++++++++ config/routes.rb | 1 + .../20111019212429_add_social_to_user.rb | 7 ++++++ db/schema.rb | 5 +++- spec/models/user_spec.rb | 3 +++ spec/requests/profile_spec.rb | 16 ++++++++++++ 10 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20111019212429_add_social_to_user.rb diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb index 666c6309..c8477729 100644 --- a/app/controllers/profile_controller.rb +++ b/app/controllers/profile_controller.rb @@ -3,6 +3,12 @@ class ProfileController < ApplicationController @user = current_user end + def social_update + @user = current_user + @user.update_attributes(params[:user]) + redirect_to [:profile] + end + def password @user = current_user end diff --git a/app/models/user.rb b/app/models/user.rb index 0972f006..7736599e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,7 +5,8 @@ class User < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :projects_limit + attr_accessible :email, :password, :password_confirmation, :remember_me, + :name, :projects_limit, :skype, :linkedin, :twitter has_many :users_projects, :dependent => :destroy has_many :projects, :through => :users_projects @@ -58,5 +59,8 @@ end # name :string(255) # admin :boolean default(FALSE), not null # projects_limit :integer +# skype :string +# linkedin :string +# twitter :string # diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml index 17be416f..aa9df298 100644 --- a/app/views/admin/users/_form.html.haml +++ b/app/views/admin/users/_form.html.haml @@ -25,13 +25,26 @@ = f.label :password_confirmation %br = f.password_field :password_confirmation - .span-11 - .field.prepend-top.append-bottom + .field.prepend-top = f.check_box :admin = f.label :admin + .span-11 .field.prepend-top = f.text_field :projects_limit, :class => "small_input" = f.label :projects_limit + + .field + = f.label :skype + %br + = f.text_field :skype + .field + = f.label :linkedin + %br + = f.text_field :linkedin + .field + = f.label :twitter + %br + = f.text_field :twitter .clear %br .actions diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index b1d110be..aee73c38 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -14,6 +14,17 @@ %b Projects limit: = @admin_user.projects_limit + %p + %b Skype: + = @admin_user.skype + %p + %b LinkedIn: + = @admin_user.linkedin + %p + %b Twitter: + = @admin_user.twitter + + .clear = link_to 'Edit', edit_admin_user_path(@admin_user) \| diff --git a/app/views/profile/show.html.haml b/app/views/profile/show.html.haml index 12737ba8..ef23a169 100644 --- a/app/views/profile/show.html.haml +++ b/app/views/profile/show.html.haml @@ -6,3 +6,28 @@ %p %b Email: = @user.email + +%br + += form_for @user, :url => profile_edit_path, :method => :put do |f| + -if @user.errors.any? + #error_explanation + %ul + - @user.errors.full_messages.each do |msg| + %li= msg + + .div + = f.label :skype + %br + = f.text_field :skype + .div + = f.label :linkedin + %br + = f.text_field :linkedin + .div + = f.label :twitter + %br + = f.text_field :twitter + .actions + = f.submit 'Save', :class => "lbutton vm" + diff --git a/config/routes.rb b/config/routes.rb index 9ee3f0d0..8a40a8fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do get "errors/gitosis" get "profile/password", :to => "profile#password" put "profile/password", :to => "profile#password_update" + put "profile/edit", :to => "profile#social_update" get "profile", :to => "profile#show" #get "profile/:id", :to => "profile#show" diff --git a/db/migrate/20111019212429_add_social_to_user.rb b/db/migrate/20111019212429_add_social_to_user.rb new file mode 100644 index 00000000..b0ffe536 --- /dev/null +++ b/db/migrate/20111019212429_add_social_to_user.rb @@ -0,0 +1,7 @@ +class AddSocialToUser < ActiveRecord::Migration + def change + add_column :users, :skype, :string + add_column :users, :linkedin, :string + add_column :users, :twitter, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index a8196976..6408792f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111016195506) do +ActiveRecord::Schema.define(:version => 20111019212429) do create_table "issues", :force => true do |t| t.string "title" @@ -82,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111016195506) do t.string "name" t.boolean "admin", :default => false, :null => false t.integer "projects_limit", :default => 10 + t.string "skype" + t.string "linkedin" + t.string "twitter" end add_index "users", ["email"], :name => "index_users_on_email", :unique => true diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 77abe2ca..32fb90a3 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -39,5 +39,8 @@ end # name :string(255) # admin :boolean default(FALSE), not null # projects_limit :integer +# skype :string +# linkedin :string +# twitter :string # diff --git a/spec/requests/profile_spec.rb b/spec/requests/profile_spec.rb index 07fdc4ab..5838f63b 100644 --- a/spec/requests/profile_spec.rb +++ b/spec/requests/profile_spec.rb @@ -14,6 +14,22 @@ describe "Profile" do it { page.should have_content(@user.email) } end + describe "Profile update" do + before do + visit profile_path + fill_in "user_skype", :with => "testskype" + fill_in "user_linkedin", :with => "testlinkedin" + fill_in "user_twitter", :with => "testtwitter" + click_button "Save" + @user.reload + end + + it { @user.skype.should == 'testskype' } + it { @user.linkedin.should == 'testlinkedin' } + it { @user.twitter.should == 'testtwitter' } + end + + describe "Password update" do before do visit profile_password_path From 48924dfeeafbe965ec06797b10010ebd8a5dcfcd Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 20 Oct 2011 19:21:58 +0300 Subject: [PATCH 04/12] Wall redesign --- app/assets/javascripts/application.js | 4 +++ app/assets/stylesheets/projects.css.scss | 32 ++++++++++++++++--- app/controllers/projects_controller.rb | 11 +++++-- app/views/commits/_commits.html.haml | 4 +-- app/views/commits/show.js.haml | 4 ++- app/views/notes/_form.html.haml | 4 +-- app/views/notes/_notes.html.haml | 17 +++++----- app/views/notes/_show.html.haml | 12 +++---- app/views/notes/create.js.haml | 2 +- app/views/projects/_recent_commits.html.haml | 4 +-- app/views/projects/_recent_messages.html.haml | 6 ---- app/views/projects/wall.html.haml | 25 +++++++++++++++ 12 files changed, 89 insertions(+), 36 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 01e3b416..024dfe11 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,3 +16,7 @@ $(function(){ $('select#branch').selectmenu({style:'popup', width:200}); $('select#tag').selectmenu({style:'popup', width:200}); }); + +function updatePage(){ + $.ajax({type: "GET", url: location.href, dataType: "script"}); +} diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 860523b0..51788672 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -491,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { background: white; } p { - margin-bottom: 3px; - font-size: 12px; + margin-bottom: 4px; + font-size: 13px; + color:#111; + } + } + cite { + &.ago { + color:#666; } } } @@ -515,7 +521,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td { } .note_content { float:left; - width:750px; + width:650px; } .issue_notes { @@ -605,7 +611,9 @@ tbody tr:nth-child(2n) td, tbody tr.even td { } } -.message{ +.commit, +.message, +#notes-list{ .author { background: #eaeaea; color: #333; @@ -614,3 +622,19 @@ tbody tr:nth-child(2n) td, tbody tr.even td { margin-right:5px; } } + +/* Note textare */ +#note_note { + height:100px; + width:97%; + font-size:14px; +} + +.wall_page { + #note_note { + height:25px; + } + .attach_holder { + display:none; + } +} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8ce3ca97..dc94bae2 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -75,7 +75,7 @@ class ProjectsController < ApplicationController y.committed_date <=> x.committed_date end - @messages = project.notes.since(@date).limit(40).order("created_at DESC") + @messages = project.notes.since(@date).order("created_at DESC") else return render "projects/empty" end @@ -86,7 +86,14 @@ class ProjectsController < ApplicationController # def wall - @notes = @project.common_notes + @date = case params[:view] + when "week" then Date.today - 7.days + when "all" then nil + else Date.today + end + + @notes = @project.common_notes.order("created_at DESC") + @notes = @notes.since(@date.at_beginning_of_day) if @date @note = Note.new end diff --git a/app/views/commits/_commits.html.haml b/app/views/commits/_commits.html.haml index 5a3ba3a7..94a1bd1b 100644 --- a/app/views/commits/_commits.html.haml +++ b/app/views/commits/_commits.html.haml @@ -15,8 +15,8 @@ = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" %span - %span - [ #{commit.author} ] + %span.author + = commit.author = time_ago_in_words(commit.committed_date) ago = more_commits_link if @commits.size > 99 diff --git a/app/views/commits/show.js.haml b/app/views/commits/show.js.haml index 2c46689b..cec1fe28 100644 --- a/app/views/commits/show.js.haml +++ b/app/views/commits/show.js.haml @@ -1,6 +1,8 @@ -:plain +-#:plain $("#side-commit-preview").remove(); var side = $("
"); side.html("#{escape_javascript(render "commits/show")}"); $("##{dom_id(@project)}").parent().append(side); $("##{dom_id(@project)}").addClass("span-14"); +:plain + $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); diff --git a/app/views/notes/_form.html.haml b/app/views/notes/_form.html.haml index 8eaf968c..ca56a245 100644 --- a/app/views/notes/_form.html.haml +++ b/app/views/notes/_form.html.haml @@ -12,9 +12,9 @@ = f.label :note %cite (255 symbols only) %br - = f.text_area :note, :style => "width:97%;height:100px", :size => 255 + = f.text_area :note, :size => 255 - %div + %div.attach_holder = f.label :attachment %cite (less than 10 MB) %br diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml index c93a4723..2d110162 100644 --- a/app/views/notes/_notes.html.haml +++ b/app/views/notes/_notes.html.haml @@ -1,9 +1,12 @@ -%ul#notes-list= render "notes/notes_list" +- if controller.action_name == "wall" + %ul#notes-list= render "notes/notes_list" -%br -%br -- if can? current_user, :write_note, @project - = render "notes/form" +- else + %ul#notes-list= render "notes/notes_list" + %br + %br + - if can? current_user, :write_note, @project + = render "notes/form" :javascript $('.delete-note').live('ajax:success', function() { @@ -23,7 +26,3 @@ $(function(){ var int =self.setInterval("updatePage()", 20000); }); - - function updatePage(){ - $.ajax({type: "GET", url: location.href, dataType: "script"}); - } diff --git a/app/views/notes/_show.html.haml b/app/views/notes/_show.html.haml index 2b0a6d2e..ee9f9ffa 100644 --- a/app/views/notes/_show.html.haml +++ b/app/views/notes/_show.html.haml @@ -1,19 +1,17 @@ %li{:id => dom_id(note)} %div.note_author = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" - %div.note_content + %div.note_content.left = simple_format(html_escape(note.note)) - if note.attachment.url Attachment: - = link_to note.attachment_identifier, note.attachment.url + = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" %br - %span - %span - [ #{note.author.name} ] -   + %span.author= note.author.name + %cite.ago = time_ago_in_words(note.updated_at) ago - %br + %br - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" .clear diff --git a/app/views/notes/create.js.haml b/app/views/notes/create.js.haml index 0af548ff..15371dbc 100644 --- a/app/views/notes/create.js.haml +++ b/app/views/notes/create.js.haml @@ -1,7 +1,7 @@ - if @note.valid? :plain $("#new_note .errors").remove(); - $("#notes-list").append("#{escape_javascript(render(:partial => 'show', :locals => {:note => @note} ))}"); + updatePage(); $('#note_note').val(""); - else :plain diff --git a/app/views/projects/_recent_commits.html.haml b/app/views/projects/_recent_commits.html.haml index 812be93c..e435ea30 100644 --- a/app/views/projects/_recent_commits.html.haml +++ b/app/views/projects/_recent_commits.html.haml @@ -9,8 +9,8 @@ = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) %span - %span - [ #{commit.author} ] + %span.author + = commit.author.name.force_encoding("UTF-8") %cite = time_ago_in_words(commit.committed_date) ago diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml index 03f723da..1af7fe3b 100644 --- a/app/views/projects/_recent_messages.html.haml +++ b/app/views/projects/_recent_messages.html.haml @@ -46,12 +46,6 @@ Attachment: = link_to note.attachment_identifier, note.attachment.url %br - -#%span - %span - [ #{note.author.name} ] - %cite - = time_ago_in_words(note.created_at) - ago %br .append-bottom   diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml index 479bb3cf..d3dcb353 100644 --- a/app/views/projects/wall.html.haml +++ b/app/views/projects/wall.html.haml @@ -1 +1,26 @@ +%div.wall_page + - if can? current_user, :write_note, @project + = render "notes/form" + .right + = form_tag wall_project_path(@project), :method => :get do + .span-2 + = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" + = label_tag "day_view","Today" + .span-2 + = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" + = label_tag "week_view","Week" + .span-2 + = radio_button_tag :view, "all", params[:view] == "all", :onclick => "this.form.submit()", :id => "all_view" + = label_tag "all_view","All" + .clear + %br + %hr = render "notes/notes" + +:javascript + $(function(){ + $("#note_note").live("click", function(){ + $(this).css("height", "100px"); + $('.attach_holder').show(); + }); + }); From c463eeb0908e5c00008073c07e71e06434393342 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 20 Oct 2011 22:00:00 +0300 Subject: [PATCH 05/12] refactoring --- app/helpers/application_helper.rb | 21 ----------- app/models/snippet.rb | 7 ++++ app/views/commits/_diff.html.haml | 7 ++-- app/views/projects/_tree_file.html.haml | 10 +++--- app/views/snippets/show.html.haml | 3 +- config/initializers/grit_ext.rb | 8 +++++ lib/utils.rb | 47 ++++++++++++++++++++++--- 7 files changed, 66 insertions(+), 37 deletions(-) create mode 100644 config/initializers/grit_ext.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c389fd4a..0895eb0d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -53,25 +53,4 @@ module ApplicationHelper [projects, default_nav, project_nav].flatten.to_json end - def handle_file_type(file_name, mime_type = nil) - if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ - :ruby - elsif file_name =~ /\.py$/ - :python - elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ - $1[1..-1].to_sym - elsif file_name =~ /\.js$/ - :javascript - elsif file_name =~ /\.sh$/ - :bash - elsif file_name =~ /\.coffee$/ - :coffeescript - elsif file_name =~ /\.yml$/ - :yaml - elsif file_name =~ /\.md$/ - :minid - else - :text - end - end end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 0a54fee7..119b69a4 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -1,4 +1,6 @@ class Snippet < ActiveRecord::Base + include Utils::Colorize + belongs_to :project belongs_to :author, :class_name => "User" has_many :notes, :as => :noteable @@ -28,6 +30,11 @@ class Snippet < ActiveRecord::Base ".js", ".sh", ".coffee", ".yml", ".md" ] end + + def colorize + ft = handle_file_type(file_name) + Albino.colorize(content, ft, :html, 'utf-8', "linenos=True") + end end # == Schema Information # diff --git a/app/views/commits/_diff.html.haml b/app/views/commits/_diff.html.haml index dff99bf1..73652aaf 100644 --- a/app/views/commits/_diff.html.haml +++ b/app/views/commits/_diff.html.haml @@ -1,4 +1,3 @@ -- require "utils" .file_stats - @commit.diffs.each do |diff| - if diff.deleted_file @@ -35,7 +34,7 @@ %strong{:id => "#{diff.b_path}"}= diff.b_path %br/ .diff_file_content - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) + - if file.text? - lines_arr = diff.diff.lines.to_a - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 @@ -50,9 +49,9 @@ - else - line_new += 1 - line_old += 1 - - elsif file.mime_type =~ /image/ + - elsif file.image? .diff_file_content_image - %img{:src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"} + %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - else %p %center No preview for this file type diff --git a/app/views/projects/_tree_file.html.haml b/app/views/projects/_tree_file.html.haml index 3463bfc5..ae95d483 100644 --- a/app/views/projects/_tree_file.html.haml +++ b/app/views/projects/_tree_file.html.haml @@ -1,4 +1,3 @@ -- require "utils" .view_file .view_file_header %strong @@ -6,14 +5,13 @@ = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" %br/ - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) + - if file.text? .view_file_content - - ft = handle_file_type(file.name, file.mime_type) :erb - <%= raw Albino.colorize(content, ft, :html, 'utf-8', "linenos=True") %> - - elsif file.mime_type =~ /image/ + <%= raw file.colorize %> + - elsif file.image? .view_file_content_image - %img{ :src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"} + %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - else %p %center No preview for this file type diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index bb444efe..899950b7 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -7,9 +7,8 @@ = @snippet.file_name %br/ .view_file_content - - ft = handle_file_type(@snippet.file_name) :erb - <%= raw Albino.colorize(@snippet.content, ft, :html, 'utf-8', "linenos=True") %> + <%= raw @snippet.colorize %> - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive" diff --git a/config/initializers/grit_ext.rb b/config/initializers/grit_ext.rb new file mode 100644 index 00000000..8f1329a6 --- /dev/null +++ b/config/initializers/grit_ext.rb @@ -0,0 +1,8 @@ +require 'grit' +require 'albino' +require "utils" + +Grit::Blob.class_eval do + include Utils::FileHelper + include Utils::Colorize +end diff --git a/lib/utils.rb b/lib/utils.rb index 6e7460ed..40bf2673 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -1,8 +1,47 @@ module Utils - def self.binary?(string) - string.each_byte do |x| - x.nonzero? or return true + module FileHelper + def binary?(string) + string.each_byte do |x| + x.nonzero? or return true + end + false + end + + def image? + mime_type =~ /image/ + end + + def text? + mime_type =~ /application|text/ && !binary?(data) + end + end + + module Colorize + def colorize + ft = handle_file_type(name, mime_type) + Albino.colorize(data, ft, :html, 'utf-8', "linenos=True") + end + + def handle_file_type(file_name, mime_type = nil) + if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ + :ruby + elsif file_name =~ /\.py$/ + :python + elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ + $1[1..-1].to_sym + elsif file_name =~ /\.js$/ + :javascript + elsif file_name =~ /\.sh$/ + :bash + elsif file_name =~ /\.coffee$/ + :coffeescript + elsif file_name =~ /\.yml$/ + :yaml + elsif file_name =~ /\.md$/ + :minid + else + :text + end end - false end end From b5a5e5a416a33147e99be2e8c07e2bcc7fb7ee6c Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 09:58:28 +0300 Subject: [PATCH 06/12] prepare for 1.1 --- CHANGELOG | 2 ++ VERSION | 2 +- update.rb | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index aa846166..96acfba1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ v 1.1.0 + - project dashboard + - wall redesigned - feature: code snippets - fixed horizontal scroll on file preview - fixed app crash if commit message has invalid chars diff --git a/VERSION b/VERSION index 6d7de6e6..9084fa2f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.2 +1.1.0 diff --git a/update.rb b/update.rb index dccb7df3..b81a4088 100644 --- a/update.rb +++ b/update.rb @@ -19,8 +19,8 @@ env = if envs.include?(ARGV[0]) puts yellow "== RAILS ENV | #{env}" current_version = version puts yellow "Your version is #{current_version}" -puts yellow "Check for new version: $ git pull origin" -`git pull origin` # pull from origin +puts yellow "Check for new version: $ git pull origin 1x" +`git pull origin 1x` # pull from origin # latest version if version == current_version From a07923a549d53527442967aac9c4baf9596f3c1f Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 14:03:34 +0300 Subject: [PATCH 07/12] recent radio button --- app/controllers/projects_controller.rb | 32 ++++++++++++-------------- app/models/note.rb | 1 + app/models/project.rb | 28 ++++++++++++++++++++++ app/views/projects/show.html.haml | 7 ++++-- app/views/projects/wall.html.haml | 5 +++- spec/requests/projects_spec.rb | 2 +- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index dc94bae2..5ccfe4bb 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -60,24 +60,21 @@ class ProjectsController < ApplicationController end def show - if @project.repo_exists? - @date = case params[:view] - when "week" then Date.today - 7.days - else Date.today - end.at_beginning_of_day + return render "projects/empty" unless @project.repo_exists? + @date = case params[:view] + when "week" then Date.today - 7.days + when "day" then Date.today + else nil + end - @heads = @project.repo.heads - @commits = @heads.map do |h| - @project.repo.log(h.name, nil, :since => @date) - end.flatten.uniq { |c| c.id } - - @commits.sort! do |x, y| - y.committed_date <=> x.committed_date - end + if @date + @date = @date.at_beginning_of_day + @commits = @project.commits_since(@date) @messages = project.notes.since(@date).order("created_at DESC") - else - return render "projects/empty" + else + @commits = @project.fresh_commits + @messages = project.notes.fresh.limit(10) end end @@ -89,11 +86,12 @@ class ProjectsController < ApplicationController @date = case params[:view] when "week" then Date.today - 7.days when "all" then nil - else Date.today + when "day" then Date.today + else nil end @notes = @project.common_notes.order("created_at DESC") - @notes = @notes.since(@date.at_beginning_of_day) if @date + @notes = @date ? @notes.since(@date.at_beginning_of_day) : @notes.fresh.limit(10) @note = Note.new end diff --git a/app/models/note.rb b/app/models/note.rb index 71fd9dcd..e3dabce4 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -24,6 +24,7 @@ class Note < ActiveRecord::Base scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } + scope :fresh, order("created_at DESC") mount_uploader :attachment, AttachmentUploader end diff --git a/app/models/project.rb b/app/models/project.rb index f51bd9b3..d70b18e7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -126,6 +126,34 @@ class Project < ActiveRecord::Base end end + def heads + @heads ||= repo.heads + end + + def fresh_commits + commits = heads.map do |h| + repo.commits(h.name, 10) + end.flatten.uniq { |c| c.id } + + commits.sort! do |x, y| + y.committed_date <=> x.committed_date + end + + commits[0..10] + end + + def commits_since(date) + commits = heads.map do |h| + repo.log(h.name, nil, :since => date) + end.flatten.uniq { |c| c.id } + + commits.sort! do |x, y| + y.committed_date <=> x.committed_date + end + + commits + end + def tree(fcommit, path = nil) fcommit = commit if fcommit == :head tree = fcommit.tree diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index ff6078c1..85019ecb 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -1,9 +1,12 @@ %div - %h2.left Recent history + %h2.left History .right = form_tag project_path(@project), :method => :get do .span-2 - = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" + = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" + = label_tag "recent_view","Recent" + .span-2 + = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" = label_tag "day_view","Today" .span-2 = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml index d3dcb353..ed22478c 100644 --- a/app/views/projects/wall.html.haml +++ b/app/views/projects/wall.html.haml @@ -4,7 +4,10 @@ .right = form_tag wall_project_path(@project), :method => :get do .span-2 - = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" + = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" + = label_tag "recent_view","Recent" + .span-2 + = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" = label_tag "day_view","Today" .span-2 = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index a1bac062..945c1ea2 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -73,7 +73,7 @@ describe "Projects" do end it "should beahave like dashboard" do - page.should have_content("Recent history") + page.should have_content("History") end end From f2808191893d2d3f158f569627ac6005509ea05b Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 14:25:42 +0300 Subject: [PATCH 08/12] fixed wall --all option --- app/controllers/projects_controller.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5ccfe4bb..54d19af7 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -83,16 +83,15 @@ class ProjectsController < ApplicationController # def wall - @date = case params[:view] - when "week" then Date.today - 7.days - when "all" then nil - when "day" then Date.today - else nil - end - - @notes = @project.common_notes.order("created_at DESC") - @notes = @date ? @notes.since(@date.at_beginning_of_day) : @notes.fresh.limit(10) @note = Note.new + @notes = @project.common_notes.order("created_at DESC") + + @notes = case params[:view] + when "week" then @notes.since((Date.today - 7.days).at_beginning_of_day) + when "all" then @notes.all + when "day" then @notes.since(Date.today.at_beginning_of_day) + else @notes.fresh.limit(10) + end end # From 1477a6c8aaecbde1f2b5903cccb267d632212ee4 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 21 Oct 2011 15:35:42 +0300 Subject: [PATCH 09/12] moved from albino -> pygments.rb --- Gemfile | 2 +- Gemfile.lock | 15 +++++++-------- app/models/snippet.rb | 3 +-- app/views/projects/_tree_file.html.haml | 1 + app/views/projects/empty.html.erb | 7 ++++--- config/initializers/grit_ext.rb | 2 +- lib/utils.rb | 8 ++++++-- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 523793e7..77a00659 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'therubyracer' gem 'faker' gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' gem "inifile" -gem "albino", :git => "git://github.com/gitlabhq/albino.git" +gem "pygments.rb", "0.2.3" gem "kaminari" gem "thin" gem "git" diff --git a/Gemfile.lock b/Gemfile.lock index 2aa894aa..5ba34459 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,13 +4,6 @@ GIT specs: annotate (2.4.1.beta1) -GIT - remote: git://github.com/gitlabhq/albino.git - revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1 - specs: - albino (1.3.3) - posix-spawn (>= 0.3.6) - GIT remote: git://github.com/gitlabhq/grit.git revision: ff015074ef35bd94cba943f9c0f98e161ab5851c @@ -72,6 +65,7 @@ GEM ZenTest (= 4.5) awesome_print (0.4.0) bcrypt-ruby (3.0.1) + blankslate (2.1.2.4) builder (3.0.0) capybara (1.0.1) mime-types (>= 1.16) @@ -138,6 +132,8 @@ GEM orm_adapter (0.0.5) polyglot (0.3.2) posix-spawn (0.3.6) + pygments.rb (0.2.3) + rubypython (>= 0.5.1) rack (1.3.2) rack-cache (1.0.3) rack (>= 0.4) @@ -189,6 +185,9 @@ GEM ruby-debug-base19 (>= 0.11.19) ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) + rubypython (0.5.1) + blankslate (>= 2.1.2.3) + ffi (~> 1.0.7) rubyzip (0.9.4) sass (3.1.7) sass-rails (3.1.1) @@ -242,7 +241,6 @@ PLATFORMS DEPENDENCIES acts_as_list - albino! annotate! autotest autotest-rails @@ -260,6 +258,7 @@ DEPENDENCIES jquery-rails kaminari launchy + pygments.rb (= 0.2.3) rails (= 3.1.0) rails-footnotes (>= 3.7.5.rc4) rspec-rails diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 119b69a4..95d6a07d 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -32,8 +32,7 @@ class Snippet < ActiveRecord::Base end def colorize - ft = handle_file_type(file_name) - Albino.colorize(content, ft, :html, 'utf-8', "linenos=True") + system_colorize(content, file_name) end end # == Schema Information diff --git a/app/views/projects/_tree_file.html.haml b/app/views/projects/_tree_file.html.haml index ae95d483..41a2287a 100644 --- a/app/views/projects/_tree_file.html.haml +++ b/app/views/projects/_tree_file.html.haml @@ -1,3 +1,4 @@ +:css .view_file .view_file_header %strong diff --git a/app/views/projects/empty.html.erb b/app/views/projects/empty.html.erb index a8917471..4c60facd 100644 --- a/app/views/projects/empty.html.erb +++ b/app/views/projects/empty.html.erb @@ -1,3 +1,4 @@ +<% bash_lexer = Pygments::Lexer[:bash] %>

Git global setup:

@@ -6,7 +7,7 @@ git config --global user.name "#{current_user.name}" git config --global user.email "#{current_user.email}" eos %> - <%= raw Albino.colorize(setup_str, :bash) %> + <%= raw bash_lexer.highlight(setup_str) %>

Next steps:

@@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo} git push -u origin master eos %> - <%= raw Albino.colorize(repo_setup_str, :bash) %> + <%= raw bash_lexer.highlight(repo_setup_str) %>

Existing Git Repo?

@@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo} git push -u origin master eos %> - <%= raw Albino.colorize(exist_repo_setup_str, :bash) %> + <%= raw bash_lexer.highlight(exist_repo_setup_str) %>

Remove this project?

diff --git a/config/initializers/grit_ext.rb b/config/initializers/grit_ext.rb index 8f1329a6..4bd71003 100644 --- a/config/initializers/grit_ext.rb +++ b/config/initializers/grit_ext.rb @@ -1,5 +1,5 @@ require 'grit' -require 'albino' +require 'pygments' require "utils" Grit::Blob.class_eval do diff --git a/lib/utils.rb b/lib/utils.rb index 40bf2673..e57121a3 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -18,8 +18,12 @@ module Utils module Colorize def colorize - ft = handle_file_type(name, mime_type) - Albino.colorize(data, ft, :html, 'utf-8', "linenos=True") + system_colorize(data, name) + end + + def system_colorize(data, file_name) + ft = handle_file_type(file_name) + Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' }) end def handle_file_type(file_name, mime_type = nil) From cee932500caf2d903e08f063772c570db4158925 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 21 Oct 2011 15:56:37 +0300 Subject: [PATCH 10/12] now you can view comrade profile info #134 --- app/views/projects/_top_menu.html.haml | 2 +- app/views/team_members/_show.html.haml | 6 ++-- app/views/team_members/show.html.haml | 28 +++++++++++++++++++ ...021101550_change_social_fields_in_users.rb | 10 +++++++ db/schema.rb | 8 +++--- spec/requests/team_members_spec.rb | 9 ++++++ spec/support/login.rb | 3 +- 7 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 app/views/team_members/show.html.haml create mode 100644 db/migrate/20111021101550_change_social_fields_in_users.rb diff --git a/app/views/projects/_top_menu.html.haml b/app/views/projects/_top_menu.html.haml index e281b93b..59f2533e 100644 --- a/app/views/projects/_top_menu.html.haml +++ b/app/views/projects/_top_menu.html.haml @@ -5,7 +5,7 @@ %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil %span - = link_to team_project_path(@project), :class => current_page?(:controller => "projects", :action => "team", :id => @project) ? "current" : nil do + = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do Team - if @project.users_projects.count > 0 %span{ :class => "top_menu_count" }= @project.users_projects.count diff --git a/app/views/team_members/_show.html.haml b/app/views/team_members/_show.html.haml index 6d310768..b9a68e6c 100644 --- a/app/views/team_members/_show.html.haml +++ b/app/views/team_members/_show.html.haml @@ -1,8 +1,10 @@ - user = member.user %tr{:id => dom_id(member)} %td - = image_tag gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;" - = truncate user.name, :lenght => 16 + = link_to image_tag(gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;"), project_team_member_path(@project, member) + + = link_to truncate(user.name, :lenght => 16), project_team_member_path(@project, member) + %td= truncate user.email, :lenght => 16 - if can? current_user, :admin_project, @project = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| diff --git a/app/views/team_members/show.html.haml b/app/views/team_members/show.html.haml new file mode 100644 index 00000000..d07c54f8 --- /dev/null +++ b/app/views/team_members/show.html.haml @@ -0,0 +1,28 @@ +- user = @team_member.user +.span-2 + = image_tag gravatar_icon(user.email), :class => "left", :width => 60, :style => "padding-right:5px;" +%p + %b Name: + = user.name +%p + %b Email: + = user.email + +%br + +- unless user.skype.empty? + .div + %b Skype: + = user.skype + +- unless user.linkedin.empty? + .div + %b LinkedIn: + = user.linkedin + +- unless user.twitter.empty? + .div + %b Twitter: + = user.twitter + + diff --git a/db/migrate/20111021101550_change_social_fields_in_users.rb b/db/migrate/20111021101550_change_social_fields_in_users.rb new file mode 100644 index 00000000..6f05c05d --- /dev/null +++ b/db/migrate/20111021101550_change_social_fields_in_users.rb @@ -0,0 +1,10 @@ +class ChangeSocialFieldsInUsers < ActiveRecord::Migration + def up + change_column(:users, :skype, :string, {:null => false, :default => ''}) + change_column(:users, :linkedin, :string, {:null => false, :default => ''}) + change_column(:users, :twitter, :string, {:null => false, :default => ''}) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 6408792f..cc805990 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111019212429) do +ActiveRecord::Schema.define(:version => 20111021101550) do create_table "issues", :force => true do |t| t.string "title" @@ -82,9 +82,9 @@ ActiveRecord::Schema.define(:version => 20111019212429) do t.string "name" t.boolean "admin", :default => false, :null => false t.integer "projects_limit", :default => 10 - t.string "skype" - t.string "linkedin" - t.string "twitter" + t.string "skype", :default => "", :null => false + t.string "linkedin", :default => "", :null => false + t.string "twitter", :default => "", :null => false end add_index "users", ["email"], :name => "index_users_on_email", :unique => true diff --git a/spec/requests/team_members_spec.rb b/spec/requests/team_members_spec.rb index db7513ae..dd92febf 100644 --- a/spec/requests/team_members_spec.rb +++ b/spec/requests/team_members_spec.rb @@ -7,6 +7,15 @@ describe "TeamMembers" do @project.add_access(@user, :read, :admin) end + describe "View profile" do + it "should be available" do + visit(team_project_path(@project)) + find(:xpath, "//table[@id='team-table']//a[1]").click + page.should have_content @user.skype + page.should_not have_content 'Twitter' + end + end + describe "New Team member", :js => true do before do @user_1 = Factory :user diff --git a/spec/support/login.rb b/spec/support/login.rb index 09f64f9e..462647ab 100644 --- a/spec/support/login.rb +++ b/spec/support/login.rb @@ -3,7 +3,8 @@ module LoginMacros @user = User.create(:email => "user#{User.count}@mail.com", :name => "John Smith", :password => "123456", - :password_confirmation => "123456") + :password_confirmation => "123456", + :skype => 'user_skype') if role == :admin @user.admin = true From 86021a7dc397923afaf09d7602c34182f8064efe Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 21 Oct 2011 16:36:33 +0300 Subject: [PATCH 11/12] corrected last migration --- .../20111021101550_change_social_fields_in_users.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db/migrate/20111021101550_change_social_fields_in_users.rb b/db/migrate/20111021101550_change_social_fields_in_users.rb index 6f05c05d..6e506c1c 100644 --- a/db/migrate/20111021101550_change_social_fields_in_users.rb +++ b/db/migrate/20111021101550_change_social_fields_in_users.rb @@ -1,8 +1,12 @@ class ChangeSocialFieldsInUsers < ActiveRecord::Migration def up - change_column(:users, :skype, :string, {:null => false, :default => ''}) - change_column(:users, :linkedin, :string, {:null => false, :default => ''}) - change_column(:users, :twitter, :string, {:null => false, :default => ''}) + remove_column :users, :skype + remove_column :users, :linkedin + remove_column :users, :twitter + + add_column :users, :skype, :string, {:null => false, :default => ''} + add_column :users, :linkedin, :string, {:null => false, :default => ''} + add_column :users, :twitter, :string, {:null => false, :default => ''} end def down From 5b284f6adf4cf17ffb66b32a5afdb2f754d5ad5f Mon Sep 17 00:00:00 2001 From: Adam Leonard Date: Sat, 22 Oct 2011 00:06:38 -0400 Subject: [PATCH 12/12] Add ability to Search issues --- Gemfile | 1 + Gemfile.lock | 2 ++ app/controllers/issues_controller.rb | 7 +++++++ app/views/issues/index.html.haml | 18 +++++++++++++++++- config/database.yml | 19 +++++++++---------- config/routes.rb | 3 +++ spec/requests/issues_spec.rb | 22 ++++++++++++++++++++++ 7 files changed, 61 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 77a00659..ad15fc83 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ gem "kaminari" gem "thin" gem "git" gem "acts_as_list" +gem "mysql2" group :assets do gem 'sass-rails', " ~> 3.1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 5ba34459..a881b05e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -128,6 +128,7 @@ GEM treetop (~> 1.4.8) mime-types (1.16) multi_json (1.0.3) + mysql2 (0.3.7) nokogiri (1.5.0) orm_adapter (0.0.5) polyglot (0.3.2) @@ -258,6 +259,7 @@ DEPENDENCIES jquery-rails kaminari launchy + mysql2 pygments.rb (= 0.2.3) rails (= 3.1.0) rails-footnotes (>= 3.7.5.rc4) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index cf8e1ebe..7b8c7cb5 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -78,6 +78,13 @@ class IssuesController < ApplicationController render :nothing => true end + def search + @project = Project.find(params['project']) + @issues = @project.issues.where("title LIKE ? OR content LIKE ?", "%#{params['terms']}%", "%#{params['terms']}%") + + render :partial => 'issues' + end + protected def issue diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index 6f4548a8..53c4fe66 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -1,6 +1,10 @@ %div - if can? current_user, :write_issue, @project - .left= link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm" + .left + = form_tag search_project_issues_path(@project), :method => :get, :remote => true do + = search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' } + = link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm" + .right = form_tag project_issues_path(@project), :method => :get do .span-2 @@ -20,6 +24,18 @@ #issues-table-holder= render "issues" %br :javascript + $('.issue_search').keyup(function() { + var terms = $(this).val(); + var project_id = 1; + + if (terms.length >= 2) { + $.get($(this).parent().attr('action'), { 'terms': terms, project: project_id }, function(response) { + $('#issues-table').html(response); + setSortable(); + }); + } + }); + $('.delete-issue').live('ajax:success', function() { $(this).closest('tr').fadeOut(); }); diff --git a/config/database.yml b/config/database.yml index 51a4dd45..59e1f12c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -4,8 +4,9 @@ # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' development: - adapter: sqlite3 - database: db/development.sqlite3 + adapter: mysql2 + database: gitlab_development + username: root pool: 5 timeout: 5000 @@ -13,13 +14,11 @@ development: # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 + adapter: mysql2 + database: gitlab_development + username: root production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 + adatper: mysql2 + database: gitlab_test + username: root diff --git a/config/routes.rb b/config/routes.rb index 8a40a8fe..57879224 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,6 +47,9 @@ Gitlab::Application.routes.draw do collection do post :sort end + collection do + get :search + end end resources :notes, :only => [:create, :destroy] end diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index 79fdf5ef..d3582d16 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -144,4 +144,26 @@ describe "Issues" do end end end + + describe "Search issue", :js => true do + before do + ['foobar', 'foobar2', 'gitlab'].each do |title| + @issue = Factory :issue, + :author => @user, + :assignee => @user, + :project => project, + :title => title + @issue.save + end + end + + it "should search and return the correct results" do + visit project_issues_path(project) + fill_in "issue_search", :with => "foobar" + page.should have_content 'foobar' + page.should have_content 'foobar2' + page.should_not have_content 'gitlab' + end + end + end