Commit ce9b8e7b12c61732cc181894e9b4f7dbab1f22a5
Exists in
master
and in
4 other branches
Merge branch 'dev' into feature/team_member_role_validation
Showing
43 changed files
with
381 additions
and
234 deletions
Show diff stats
CHANGELOG
Gemfile
... | ... | @@ -15,7 +15,7 @@ gem 'therubyracer' |
15 | 15 | gem 'faker' |
16 | 16 | gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' |
17 | 17 | gem "inifile" |
18 | -gem "albino", :git => "git://github.com/gitlabhq/albino.git" | |
18 | +gem "pygments.rb", "0.2.3" | |
19 | 19 | gem "kaminari" |
20 | 20 | gem "thin" |
21 | 21 | gem "git" | ... | ... |
Gemfile.lock
... | ... | @@ -5,13 +5,6 @@ GIT |
5 | 5 | annotate (2.4.1.beta1) |
6 | 6 | |
7 | 7 | GIT |
8 | - remote: git://github.com/gitlabhq/albino.git | |
9 | - revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1 | |
10 | - specs: | |
11 | - albino (1.3.3) | |
12 | - posix-spawn (>= 0.3.6) | |
13 | - | |
14 | -GIT | |
15 | 8 | remote: git://github.com/gitlabhq/grit.git |
16 | 9 | revision: ff015074ef35bd94cba943f9c0f98e161ab5851c |
17 | 10 | specs: |
... | ... | @@ -72,6 +65,7 @@ GEM |
72 | 65 | ZenTest (= 4.5) |
73 | 66 | awesome_print (0.4.0) |
74 | 67 | bcrypt-ruby (3.0.1) |
68 | + blankslate (2.1.2.4) | |
75 | 69 | builder (3.0.0) |
76 | 70 | capybara (1.0.1) |
77 | 71 | mime-types (>= 1.16) |
... | ... | @@ -138,6 +132,8 @@ GEM |
138 | 132 | orm_adapter (0.0.5) |
139 | 133 | polyglot (0.3.2) |
140 | 134 | posix-spawn (0.3.6) |
135 | + pygments.rb (0.2.3) | |
136 | + rubypython (>= 0.5.1) | |
141 | 137 | rack (1.3.2) |
142 | 138 | rack-cache (1.0.3) |
143 | 139 | rack (>= 0.4) |
... | ... | @@ -189,6 +185,9 @@ GEM |
189 | 185 | ruby-debug-base19 (>= 0.11.19) |
190 | 186 | ruby_core_source (0.1.5) |
191 | 187 | archive-tar-minitar (>= 0.5.2) |
188 | + rubypython (0.5.1) | |
189 | + blankslate (>= 2.1.2.3) | |
190 | + ffi (~> 1.0.7) | |
192 | 191 | rubyzip (0.9.4) |
193 | 192 | sass (3.1.7) |
194 | 193 | sass-rails (3.1.1) |
... | ... | @@ -242,7 +241,6 @@ PLATFORMS |
242 | 241 | |
243 | 242 | DEPENDENCIES |
244 | 243 | acts_as_list |
245 | - albino! | |
246 | 244 | annotate! |
247 | 245 | autotest |
248 | 246 | autotest-rails |
... | ... | @@ -260,6 +258,7 @@ DEPENDENCIES |
260 | 258 | jquery-rails |
261 | 259 | kaminari |
262 | 260 | launchy |
261 | + pygments.rb (= 0.2.3) | |
263 | 262 | rails (= 3.1.0) |
264 | 263 | rails-footnotes (>= 3.7.5.rc4) |
265 | 264 | rspec-rails | ... | ... |
README.rdoc
... | ... | @@ -34,18 +34,19 @@ sqlite as default db |
34 | 34 | sudo easy_install pygments |
35 | 35 | |
36 | 36 | sudo gem install bundler |
37 | + | |
37 | 38 | bundle |
38 | 39 | |
39 | - RAILS_ENV=production rake db:setup | |
40 | + bundle exec rake db:setup RAILS_ENV=production | |
40 | 41 | |
41 | 42 | # create admin user |
42 | 43 | # login....admin@local.host |
43 | 44 | # pass.....5iveL!fe |
44 | - RAILS_ENV=production rake db:seed_fu | |
45 | + bundle exec rake db:seed_fu RAILS_ENV=production | |
45 | 46 | |
46 | 47 | Install gitosis, edit conf/gitosis.yml & start server |
47 | 48 | |
48 | - rails s | |
49 | + rails s -e production | |
49 | 50 | |
50 | 51 | == Install Gitosis |
51 | 52 | sudo aptitude install gitosis |
... | ... | @@ -63,6 +64,7 @@ Install gitosis, edit conf/gitosis.yml & start server |
63 | 64 | ssh-keygen -t rsa |
64 | 65 | |
65 | 66 | sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub |
67 | + | |
66 | 68 | sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update |
67 | 69 | |
68 | 70 | ... | ... |
VERSION
app/assets/javascripts/application.js
app/assets/stylesheets/projects.css.scss
... | ... | @@ -491,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
491 | 491 | background: white; |
492 | 492 | } |
493 | 493 | p { |
494 | - margin-bottom: 3px; | |
495 | - font-size: 12px; | |
494 | + margin-bottom: 4px; | |
495 | + font-size: 13px; | |
496 | + color:#111; | |
497 | + } | |
498 | + } | |
499 | + cite { | |
500 | + &.ago { | |
501 | + color:#666; | |
496 | 502 | } |
497 | 503 | } |
498 | 504 | } |
... | ... | @@ -515,7 +521,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
515 | 521 | } |
516 | 522 | .note_content { |
517 | 523 | float:left; |
518 | - width:750px; | |
524 | + width:650px; | |
519 | 525 | } |
520 | 526 | |
521 | 527 | .issue_notes { |
... | ... | @@ -605,7 +611,9 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
605 | 611 | } |
606 | 612 | |
607 | 613 | } |
608 | -.message{ | |
614 | +.commit, | |
615 | +.message, | |
616 | +#notes-list{ | |
609 | 617 | .author { |
610 | 618 | background: #eaeaea; |
611 | 619 | color: #333; |
... | ... | @@ -614,3 +622,28 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
614 | 622 | margin-right:5px; |
615 | 623 | } |
616 | 624 | } |
625 | + | |
626 | +/* Note textare */ | |
627 | +#note_note { | |
628 | + height:100px; | |
629 | + width:97%; | |
630 | + font-size:14px; | |
631 | +} | |
632 | + | |
633 | +.wall_page { | |
634 | + #note_note { | |
635 | + height:25px; | |
636 | + } | |
637 | + .attach_holder { | |
638 | + display:none; | |
639 | + } | |
640 | +} | |
641 | + | |
642 | +.field_with_errors { | |
643 | + input[type="text"], | |
644 | + input[type="password"], | |
645 | + textarea | |
646 | + { | |
647 | + background: none repeat scroll 0 0 #FFBBBB | |
648 | + } | |
649 | +} | ... | ... |
app/controllers/projects_controller.rb
... | ... | @@ -60,24 +60,21 @@ class ProjectsController < ApplicationController |
60 | 60 | end |
61 | 61 | |
62 | 62 | def show |
63 | - if @project.repo_exists? | |
64 | - @date = case params[:view] | |
65 | - when "week" then Date.today - 7.days | |
66 | - else Date.today | |
67 | - end.at_beginning_of_day | |
68 | - | |
69 | - @heads = @project.repo.heads | |
70 | - @commits = @heads.map do |h| | |
71 | - @project.repo.log(h.name, nil, :since => @date) | |
72 | - end.flatten.uniq { |c| c.id } | |
73 | - | |
74 | - @commits.sort! do |x, y| | |
75 | - y.committed_date <=> x.committed_date | |
76 | - end | |
77 | - | |
78 | - @messages = project.notes.since(@date).limit(40).order("created_at DESC") | |
79 | - else | |
80 | - return render "projects/empty" | |
63 | + return render "projects/empty" unless @project.repo_exists? | |
64 | + @date = case params[:view] | |
65 | + when "week" then Date.today - 7.days | |
66 | + when "day" then Date.today | |
67 | + else nil | |
68 | + end | |
69 | + | |
70 | + if @date | |
71 | + @date = @date.at_beginning_of_day | |
72 | + | |
73 | + @commits = @project.commits_since(@date) | |
74 | + @messages = project.notes.since(@date).order("created_at DESC") | |
75 | + else | |
76 | + @commits = @project.fresh_commits | |
77 | + @messages = project.notes.fresh.limit(10) | |
81 | 78 | end |
82 | 79 | end |
83 | 80 | |
... | ... | @@ -86,8 +83,15 @@ class ProjectsController < ApplicationController |
86 | 83 | # |
87 | 84 | |
88 | 85 | def wall |
89 | - @notes = @project.common_notes | |
90 | 86 | @note = Note.new |
87 | + @notes = @project.common_notes.order("created_at DESC") | |
88 | + | |
89 | + @notes = case params[:view] | |
90 | + when "week" then @notes.since((Date.today - 7.days).at_beginning_of_day) | |
91 | + when "all" then @notes.all | |
92 | + when "day" then @notes.since(Date.today.at_beginning_of_day) | |
93 | + else @notes.fresh.limit(10) | |
94 | + end | |
91 | 95 | end |
92 | 96 | |
93 | 97 | # | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -53,25 +53,4 @@ module ApplicationHelper |
53 | 53 | [projects, default_nav, project_nav].flatten.to_json |
54 | 54 | end |
55 | 55 | |
56 | - def handle_file_type(file_name, mime_type = nil) | |
57 | - if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ | |
58 | - :ruby | |
59 | - elsif file_name =~ /\.py$/ | |
60 | - :python | |
61 | - elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ | |
62 | - $1[1..-1].to_sym | |
63 | - elsif file_name =~ /\.js$/ | |
64 | - :javascript | |
65 | - elsif file_name =~ /\.sh$/ | |
66 | - :bash | |
67 | - elsif file_name =~ /\.coffee$/ | |
68 | - :coffeescript | |
69 | - elsif file_name =~ /\.yml$/ | |
70 | - :yaml | |
71 | - elsif file_name =~ /\.md$/ | |
72 | - :minid | |
73 | - else | |
74 | - :text | |
75 | - end | |
76 | - end | |
77 | 56 | end | ... | ... |
app/models/note.rb
... | ... | @@ -24,6 +24,7 @@ class Note < ActiveRecord::Base |
24 | 24 | |
25 | 25 | scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) |
26 | 26 | scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } |
27 | + scope :fresh, order("created_at DESC") | |
27 | 28 | |
28 | 29 | mount_uploader :attachment, AttachmentUploader |
29 | 30 | end | ... | ... |
app/models/project.rb
... | ... | @@ -35,7 +35,8 @@ class Project < ActiveRecord::Base |
35 | 35 | :presence => true |
36 | 36 | |
37 | 37 | validate :check_limit |
38 | - | |
38 | + validate :repo_name | |
39 | + | |
39 | 40 | after_destroy :destroy_gitosis_project |
40 | 41 | after_save :update_gitosis_project |
41 | 42 | |
... | ... | @@ -126,6 +127,34 @@ class Project < ActiveRecord::Base |
126 | 127 | end |
127 | 128 | end |
128 | 129 | |
130 | + def heads | |
131 | + @heads ||= repo.heads | |
132 | + end | |
133 | + | |
134 | + def fresh_commits | |
135 | + commits = heads.map do |h| | |
136 | + repo.commits(h.name, 10) | |
137 | + end.flatten.uniq { |c| c.id } | |
138 | + | |
139 | + commits.sort! do |x, y| | |
140 | + y.committed_date <=> x.committed_date | |
141 | + end | |
142 | + | |
143 | + commits[0..10] | |
144 | + end | |
145 | + | |
146 | + def commits_since(date) | |
147 | + commits = heads.map do |h| | |
148 | + repo.log(h.name, nil, :since => date) | |
149 | + end.flatten.uniq { |c| c.id } | |
150 | + | |
151 | + commits.sort! do |x, y| | |
152 | + y.committed_date <=> x.committed_date | |
153 | + end | |
154 | + | |
155 | + commits | |
156 | + end | |
157 | + | |
129 | 158 | def tree(fcommit, path = nil) |
130 | 159 | fcommit = commit if fcommit == :head |
131 | 160 | tree = fcommit.tree |
... | ... | @@ -140,6 +169,12 @@ class Project < ActiveRecord::Base |
140 | 169 | errors[:base] << ("Cant check your ability to create project") |
141 | 170 | end |
142 | 171 | |
172 | + def repo_name | |
173 | + if path == "gitosis-admin" | |
174 | + errors.add(:path, " like 'gitosis-admin' is not allowed") | |
175 | + end | |
176 | + end | |
177 | + | |
143 | 178 | def valid_repo? |
144 | 179 | repo |
145 | 180 | rescue | ... | ... |
app/models/snippet.rb
1 | 1 | class Snippet < ActiveRecord::Base |
2 | + include Utils::Colorize | |
3 | + | |
2 | 4 | belongs_to :project |
3 | 5 | belongs_to :author, :class_name => "User" |
4 | 6 | has_many :notes, :as => :noteable |
... | ... | @@ -28,6 +30,10 @@ class Snippet < ActiveRecord::Base |
28 | 30 | ".js", ".sh", ".coffee", ".yml", ".md" |
29 | 31 | ] |
30 | 32 | end |
33 | + | |
34 | + def colorize | |
35 | + system_colorize(content, file_name) | |
36 | + end | |
31 | 37 | end |
32 | 38 | # == Schema Information |
33 | 39 | # | ... | ... |
app/views/commits/_commits.html.haml
... | ... | @@ -15,8 +15,8 @@ |
15 | 15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" |
16 | 16 | = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" |
17 | 17 | %span |
18 | - %span | |
19 | - [ #{commit.author} ] | |
18 | + %span.author | |
19 | + = commit.author | |
20 | 20 | = time_ago_in_words(commit.committed_date) |
21 | 21 | ago |
22 | 22 | = more_commits_link if @commits.size > 99 | ... | ... |
app/views/commits/_diff.html.haml
1 | -- require "utils" | |
2 | -.file_stats | |
3 | - - @commit.diffs.each do |diff| | |
4 | - - if diff.deleted_file | |
5 | - %span.removed_file | |
6 | - %a{:href => "##{diff.a_path}"} | |
7 | - = diff.a_path | |
8 | - = image_tag "blueprint_delete.png" | |
9 | - - elsif diff.renamed_file | |
10 | - %span.moved_file | |
11 | - %a{:href => "##{diff.b_path}"} | |
12 | - = diff.a_path | |
13 | - = "->" | |
14 | - = diff.b_path | |
15 | - = image_tag "blueprint_notice.png" | |
16 | - - elsif diff.new_file | |
17 | - %span.new_file | |
18 | - %a{:href => "##{diff.b_path}"} | |
19 | - = diff.b_path | |
20 | - = image_tag "blueprint_add.png" | |
21 | - - else | |
22 | - %span.edit_file | |
23 | - %a{:href => "##{diff.b_path}"} | |
24 | - = diff.b_path | |
25 | - = image_tag "blueprint_info.png" | |
1 | +.file_stats= render "commits/diff_head" | |
2 | + | |
26 | 3 | - @commit.diffs.each do |diff| |
27 | 4 | - next if diff.diff.empty? |
28 | 5 | - file = (@commit.tree / diff.b_path) |
... | ... | @@ -32,27 +9,15 @@ |
32 | 9 | - if diff.deleted_file |
33 | 10 | %strong{:id => "#{diff.b_path}"}= diff.a_path |
34 | 11 | - else |
35 | - %strong{:id => "#{diff.b_path}"}= diff.b_path | |
12 | + = link_to tree_file_project_path(@project, @commit.id, diff.b_path) do | |
13 | + %strong{:id => "#{diff.b_path}"}= diff.b_path | |
36 | 14 | %br/ |
37 | 15 | .diff_file_content |
38 | - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) | |
39 | - - lines_arr = diff.diff.lines.to_a | |
40 | - - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 | |
41 | - - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 | |
42 | - - lines = lines_arr[3..-1].join | |
43 | - - lines.each_line do |line| | |
44 | - = diff_line(line, line_new, line_old) | |
45 | - - if line[0] == "+" | |
46 | - - line_new += 1 | |
47 | - - elsif | |
48 | - - line[0] == "-" | |
49 | - - line_old += 1 | |
50 | - - else | |
51 | - - line_new += 1 | |
52 | - - line_old += 1 | |
53 | - - elsif file.mime_type =~ /image/ | |
16 | + - if file.text? | |
17 | + = render :partial => "commits/text_file", :locals => { :diff => diff } | |
18 | + - elsif file.image? | |
54 | 19 | .diff_file_content_image |
55 | - %img{:src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"} | |
20 | + %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | |
56 | 21 | - else |
57 | 22 | %p |
58 | 23 | %center No preview for this file type | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +- @commit.diffs.each do |diff| | |
2 | + - if diff.deleted_file | |
3 | + %span.removed_file | |
4 | + %a{:href => "##{diff.a_path}"} | |
5 | + = diff.a_path | |
6 | + = image_tag "blueprint_delete.png" | |
7 | + - elsif diff.renamed_file | |
8 | + %span.moved_file | |
9 | + %a{:href => "##{diff.b_path}"} | |
10 | + = diff.a_path | |
11 | + = "->" | |
12 | + = diff.b_path | |
13 | + = image_tag "blueprint_notice.png" | |
14 | + - elsif diff.new_file | |
15 | + %span.new_file | |
16 | + %a{:href => "##{diff.b_path}"} | |
17 | + = diff.b_path | |
18 | + = image_tag "blueprint_add.png" | |
19 | + - else | |
20 | + %span.edit_file | |
21 | + %a{:href => "##{diff.b_path}"} | |
22 | + = diff.b_path | |
23 | + = image_tag "blueprint_info.png" | |
24 | + | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +- lines_arr = diff.diff.lines.to_a | |
2 | +- line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 | |
3 | +- line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 | |
4 | +- lines = lines_arr[3..-1].join | |
5 | +- lines.each_line do |line| | |
6 | + = diff_line(line, line_new, line_old) | |
7 | + - if line[0] == "+" | |
8 | + - line_new += 1 | |
9 | + - elsif | |
10 | + - line[0] == "-" | |
11 | + - line_old += 1 | |
12 | + - else | |
13 | + - line_new += 1 | |
14 | + - line_old += 1 | |
15 | + | ... | ... |
app/views/commits/show.js.haml
1 | -:plain | |
1 | +-#:plain | |
2 | 2 | $("#side-commit-preview").remove(); |
3 | 3 | var side = $("<div id='side-commit-preview'></div>"); |
4 | 4 | side.html("#{escape_javascript(render "commits/show")}"); |
5 | 5 | $("##{dom_id(@project)}").parent().append(side); |
6 | 6 | $("##{dom_id(@project)}").addClass("span-14"); |
7 | +:plain | |
8 | + $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | ... | ... |
app/views/notes/_form.html.haml
... | ... | @@ -12,9 +12,9 @@ |
12 | 12 | = f.label :note |
13 | 13 | %cite (255 symbols only) |
14 | 14 | %br |
15 | - = f.text_area :note, :style => "width:97%;height:100px", :size => 255 | |
15 | + = f.text_area :note, :size => 255 | |
16 | 16 | |
17 | - %div | |
17 | + %div.attach_holder | |
18 | 18 | = f.label :attachment |
19 | 19 | %cite (less than 10 MB) |
20 | 20 | %br | ... | ... |
app/views/notes/_notes.html.haml
1 | -%ul#notes-list= render "notes/notes_list" | |
1 | +- if controller.action_name == "wall" | |
2 | + %ul#notes-list= render "notes/notes_list" | |
2 | 3 | |
3 | -%br | |
4 | -%br | |
5 | -- if can? current_user, :write_note, @project | |
6 | - = render "notes/form" | |
4 | +- else | |
5 | + %ul#notes-list= render "notes/notes_list" | |
6 | + %br | |
7 | + %br | |
8 | + - if can? current_user, :write_note, @project | |
9 | + = render "notes/form" | |
7 | 10 | |
8 | 11 | :javascript |
9 | 12 | $('.delete-note').live('ajax:success', function() { |
... | ... | @@ -23,7 +26,3 @@ |
23 | 26 | $(function(){ |
24 | 27 | var int =self.setInterval("updatePage()", 20000); |
25 | 28 | }); |
26 | - | |
27 | - function updatePage(){ | |
28 | - $.ajax({type: "GET", url: location.href, dataType: "script"}); | |
29 | - } | ... | ... |
app/views/notes/_show.html.haml
1 | 1 | %li{:id => dom_id(note)} |
2 | 2 | %div.note_author |
3 | 3 | = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" |
4 | - %div.note_content | |
4 | + %div.note_content.left | |
5 | 5 | = simple_format(html_escape(note.note)) |
6 | 6 | - if note.attachment.url |
7 | 7 | Attachment: |
8 | - = link_to note.attachment_identifier, note.attachment.url | |
8 | + = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" | |
9 | 9 | %br |
10 | - %span | |
11 | - %span | |
12 | - [ #{note.author.name} ] | |
13 | - | |
10 | + %span.author= note.author.name | |
11 | + %cite.ago | |
14 | 12 | = time_ago_in_words(note.updated_at) |
15 | 13 | ago |
16 | - %br | |
14 | + %br | |
17 | 15 | - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) |
18 | 16 | = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" |
19 | 17 | .clear | ... | ... |
app/views/notes/create.js.haml
app/views/projects/_recent_commits.html.haml
... | ... | @@ -9,8 +9,8 @@ |
9 | 9 | = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) |
10 | 10 | |
11 | 11 | %span |
12 | - %span | |
13 | - [ #{commit.author} ] | |
12 | + %span.author | |
13 | + = commit.author.name.force_encoding("UTF-8") | |
14 | 14 | %cite |
15 | 15 | = time_ago_in_words(commit.committed_date) |
16 | 16 | ago | ... | ... |
app/views/projects/_recent_messages.html.haml
app/views/projects/_top_menu.html.haml
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil |
6 | 6 | %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil |
7 | 7 | %span |
8 | - = link_to team_project_path(@project), :class => current_page?(:controller => "projects", :action => "team", :id => @project) ? "current" : nil do | |
8 | + = link_to team_project_path(@project), :class => (current_page?(:controller => "projects", :action => "team", :id => @project) || controller.controller_name == "team_members") ? "current" : nil do | |
9 | 9 | Team |
10 | 10 | - if @project.users_projects.count > 0 |
11 | 11 | %span{ :class => "top_menu_count" }= @project.users_projects.count | ... | ... |
app/views/projects/_tree_file.html.haml
1 | -- require "utils" | |
1 | +:css | |
2 | 2 | .view_file |
3 | 3 | .view_file_header |
4 | 4 | %strong |
... | ... | @@ -6,14 +6,13 @@ |
6 | 6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" |
7 | 7 | = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" |
8 | 8 | %br/ |
9 | - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) | |
9 | + - if file.text? | |
10 | 10 | .view_file_content |
11 | - - ft = handle_file_type(file.name, file.mime_type) | |
12 | 11 | :erb |
13 | - <%= raw Albino.colorize(content, ft, :html, 'utf-8', "linenos=True") %> | |
14 | - - elsif file.mime_type =~ /image/ | |
12 | + <%= raw file.colorize %> | |
13 | + - elsif file.image? | |
15 | 14 | .view_file_content_image |
16 | - %img{ :src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"} | |
15 | + %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | |
17 | 16 | - else |
18 | 17 | %p |
19 | 18 | %center No preview for this file type | ... | ... |
app/views/projects/empty.html.erb
1 | +<% bash_lexer = Pygments::Lexer[:bash] %> | |
1 | 2 | <div class=""> |
2 | 3 | <div class="git-empty"> |
3 | 4 | <h2>Git global setup:</h2> |
... | ... | @@ -6,7 +7,7 @@ git config --global user.name "#{current_user.name}" |
6 | 7 | git config --global user.email "#{current_user.email}" |
7 | 8 | eos |
8 | 9 | %> |
9 | - <%= raw Albino.colorize(setup_str, :bash) %> | |
10 | + <%= raw bash_lexer.highlight(setup_str) %> | |
10 | 11 | <br /> |
11 | 12 | <br /> |
12 | 13 | <h2>Next steps:</h2> |
... | ... | @@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo} |
21 | 22 | git push -u origin master |
22 | 23 | eos |
23 | 24 | %> |
24 | - <%= raw Albino.colorize(repo_setup_str, :bash) %> | |
25 | + <%= raw bash_lexer.highlight(repo_setup_str) %> | |
25 | 26 | |
26 | 27 | <br /><br /> |
27 | 28 | <h2>Existing Git Repo?</h2> |
... | ... | @@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo} |
31 | 32 | git push -u origin master |
32 | 33 | eos |
33 | 34 | %> |
34 | - <%= raw Albino.colorize(exist_repo_setup_str, :bash) %> | |
35 | + <%= raw bash_lexer.highlight(exist_repo_setup_str) %> | |
35 | 36 | |
36 | 37 | <br /><br /> |
37 | 38 | <h2>Remove this project?</h2> | ... | ... |
app/views/projects/show.html.haml
1 | 1 | %div |
2 | - %h2.left Recent history | |
2 | + %h2.left History | |
3 | 3 | .right |
4 | 4 | = form_tag project_path(@project), :method => :get do |
5 | 5 | .span-2 |
6 | - = radio_button_tag :view, "day", (params[:view] || "day") == "day", :onclick => "this.form.submit()", :id => "day_view" | |
6 | + = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" | |
7 | + = label_tag "recent_view","Recent" | |
8 | + .span-2 | |
9 | + = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" | |
7 | 10 | = label_tag "day_view","Today" |
8 | 11 | .span-2 |
9 | 12 | = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" | ... | ... |
app/views/projects/wall.html.haml
1 | +%div.wall_page | |
2 | + - if can? current_user, :write_note, @project | |
3 | + = render "notes/form" | |
4 | + .right | |
5 | + = form_tag wall_project_path(@project), :method => :get do | |
6 | + .span-2 | |
7 | + = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view" | |
8 | + = label_tag "recent_view","Recent" | |
9 | + .span-2 | |
10 | + = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view" | |
11 | + = label_tag "day_view","Today" | |
12 | + .span-2 | |
13 | + = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" | |
14 | + = label_tag "week_view","Week" | |
15 | + .span-2 | |
16 | + = radio_button_tag :view, "all", params[:view] == "all", :onclick => "this.form.submit()", :id => "all_view" | |
17 | + = label_tag "all_view","All" | |
18 | + .clear | |
19 | + %br | |
20 | + %hr | |
1 | 21 | = render "notes/notes" |
22 | + | |
23 | +:javascript | |
24 | + $(function(){ | |
25 | + $("#note_note").live("click", function(){ | |
26 | + $(this).css("height", "100px"); | |
27 | + $('.attach_holder').show(); | |
28 | + }); | |
29 | + }); | ... | ... |
app/views/snippets/show.html.haml
... | ... | @@ -7,9 +7,8 @@ |
7 | 7 | = @snippet.file_name |
8 | 8 | %br/ |
9 | 9 | .view_file_content |
10 | - - ft = handle_file_type(@snippet.file_name) | |
11 | 10 | :erb |
12 | - <%= raw Albino.colorize(@snippet.content, ft, :html, 'utf-8', "linenos=True") %> | |
11 | + <%= raw @snippet.colorize %> | |
13 | 12 | |
14 | 13 | - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user |
15 | 14 | = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive" | ... | ... |
app/views/team_members/_show.html.haml
1 | 1 | - user = member.user |
2 | 2 | %tr{:id => dom_id(member)} |
3 | 3 | %td |
4 | - = image_tag gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;" | |
5 | - = truncate user.name, :lenght => 16 | |
4 | + = link_to image_tag(gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;"), project_team_member_path(@project, member) | |
5 | + | |
6 | + = link_to truncate(user.name, :lenght => 16), project_team_member_path(@project, member) | |
7 | + | |
6 | 8 | %td= truncate user.email, :lenght => 16 |
7 | 9 | - if can? current_user, :admin_project, @project |
8 | 10 | = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| | ... | ... |
... | ... | @@ -0,0 +1,28 @@ |
1 | +- user = @team_member.user | |
2 | +.span-2 | |
3 | + = image_tag gravatar_icon(user.email), :class => "left", :width => 60, :style => "padding-right:5px;" | |
4 | +%p | |
5 | + %b Name: | |
6 | + = user.name | |
7 | +%p | |
8 | + %b Email: | |
9 | + = user.email | |
10 | + | |
11 | +%br | |
12 | + | |
13 | +- unless user.skype.empty? | |
14 | + .div | |
15 | + %b Skype: | |
16 | + = user.skype | |
17 | + | |
18 | +- unless user.linkedin.empty? | |
19 | + .div | |
20 | + %b LinkedIn: | |
21 | + = user.linkedin | |
22 | + | |
23 | +- unless user.twitter.empty? | |
24 | + .div | |
25 | + %b Twitter: | |
26 | + = user.twitter | |
27 | + | |
28 | + | ... | ... |
db/fixtures/development/001_admin.rb
1 | -# Admin account | |
2 | 1 | admin = User.create( |
3 | 2 | :email => "admin@local.host", |
4 | 3 | :name => "Administrator", |
... | ... | @@ -9,3 +8,12 @@ admin = User.create( |
9 | 8 | admin.projects_limit = 10000 |
10 | 9 | admin.admin = true |
11 | 10 | admin.save! |
11 | + | |
12 | +if admin.valid? | |
13 | +puts %q[ | |
14 | +Administrator account created: | |
15 | + | |
16 | +login.........admin@local.host | |
17 | +password......5iveL!fe | |
18 | +] | |
19 | +end | ... | ... |
db/fixtures/production/001_admin.rb
db/migrate/20111021101550_change_social_fields_in_users.rb
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +class ChangeSocialFieldsInUsers < ActiveRecord::Migration | |
2 | + def up | |
3 | + remove_column :users, :skype | |
4 | + remove_column :users, :linkedin | |
5 | + remove_column :users, :twitter | |
6 | + | |
7 | + add_column :users, :skype, :string, {:null => false, :default => ''} | |
8 | + add_column :users, :linkedin, :string, {:null => false, :default => ''} | |
9 | + add_column :users, :twitter, :string, {:null => false, :default => ''} | |
10 | + end | |
11 | + | |
12 | + def down | |
13 | + end | |
14 | +end | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20111019212429) do | |
14 | +ActiveRecord::Schema.define(:version => 20111021101550) do | |
15 | 15 | |
16 | 16 | create_table "issues", :force => true do |t| |
17 | 17 | t.string "title" |
... | ... | @@ -82,9 +82,9 @@ ActiveRecord::Schema.define(:version => 20111019212429) do |
82 | 82 | t.string "name" |
83 | 83 | t.boolean "admin", :default => false, :null => false |
84 | 84 | t.integer "projects_limit", :default => 10 |
85 | - t.string "skype" | |
86 | - t.string "linkedin" | |
87 | - t.string "twitter" | |
85 | + t.string "skype", :default => "", :null => false | |
86 | + t.string "linkedin", :default => "", :null => false | |
87 | + t.string "twitter", :default => "", :null => false | |
88 | 88 | end |
89 | 89 | |
90 | 90 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true | ... | ... |
install.rb
... | ... | @@ -1,32 +0,0 @@ |
1 | -root_path = File.expand_path(File.dirname(__FILE__)) | |
2 | -require File.join(root_path, "lib", "color") | |
3 | -include Color | |
4 | - | |
5 | -# | |
6 | -# ruby ./update.rb development # or test or production (default) | |
7 | -# | |
8 | -envs = ["production", "test", "development"] | |
9 | -env = if envs.include?(ARGV[0]) | |
10 | - ARGV[0] | |
11 | - else | |
12 | - "production" | |
13 | - end | |
14 | - | |
15 | -puts green " == Install for ENV=#{env} ..." | |
16 | - | |
17 | -# bundle install | |
18 | -`bundle install` | |
19 | - | |
20 | -# migrate db | |
21 | -`bundle exec rake db:create RAILS_ENV=#{env}` | |
22 | -`bundle exec rake db:schema:load RAILS_ENV=#{env}` | |
23 | -`bundle exec rake db:seed_fu RAILS_ENV=#{env}` | |
24 | - | |
25 | -puts green %q[ | |
26 | -Administrator account created: | |
27 | - | |
28 | -login.........admin@local.host | |
29 | -password......5iveL!fe | |
30 | -] | |
31 | - | |
32 | -puts green " == Done! Now you can start server" |
lib/utils.rb
1 | 1 | module Utils |
2 | - def self.binary?(string) | |
3 | - string.each_byte do |x| | |
4 | - x.nonzero? or return true | |
2 | + module FileHelper | |
3 | + def binary?(string) | |
4 | + string.each_byte do |x| | |
5 | + x.nonzero? or return true | |
6 | + end | |
7 | + false | |
8 | + end | |
9 | + | |
10 | + def image? | |
11 | + mime_type =~ /image/ | |
12 | + end | |
13 | + | |
14 | + def text? | |
15 | + mime_type =~ /application|text/ && !binary?(data) | |
16 | + end | |
17 | + end | |
18 | + | |
19 | + module Colorize | |
20 | + def colorize | |
21 | + system_colorize(data, name) | |
22 | + end | |
23 | + | |
24 | + def system_colorize(data, file_name) | |
25 | + ft = handle_file_type(file_name) | |
26 | + Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' }) | |
27 | + end | |
28 | + | |
29 | + def handle_file_type(file_name, mime_type = nil) | |
30 | + if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ | |
31 | + :ruby | |
32 | + elsif file_name =~ /\.py$/ | |
33 | + :python | |
34 | + elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ | |
35 | + $1[1..-1].to_sym | |
36 | + elsif file_name =~ /\.js$/ | |
37 | + :javascript | |
38 | + elsif file_name =~ /\.sh$/ | |
39 | + :bash | |
40 | + elsif file_name =~ /\.coffee$/ | |
41 | + :coffeescript | |
42 | + elsif file_name =~ /\.yml$/ | |
43 | + :yaml | |
44 | + elsif file_name =~ /\.md$/ | |
45 | + :minid | |
46 | + else | |
47 | + :text | |
48 | + end | |
5 | 49 | end |
6 | - false | |
7 | 50 | end |
8 | 51 | end | ... | ... |
spec/models/project_spec.rb
... | ... | @@ -4,11 +4,15 @@ describe Project do |
4 | 4 | describe "Associations" do |
5 | 5 | it { should have_many(:users) } |
6 | 6 | it { should have_many(:users_projects) } |
7 | + it { should have_many(:issues) } | |
8 | + it { should have_many(:notes) } | |
9 | + it { should have_many(:snippets) } | |
7 | 10 | end |
8 | 11 | |
9 | 12 | describe "Validation" do |
10 | 13 | it { should validate_presence_of(:name) } |
11 | 14 | it { should validate_presence_of(:path) } |
15 | + it { should validate_presence_of(:code) } | |
12 | 16 | end |
13 | 17 | |
14 | 18 | describe "Respond to" do |
... | ... | @@ -31,6 +35,11 @@ describe Project do |
31 | 35 | it { should respond_to(:commit) } |
32 | 36 | end |
33 | 37 | |
38 | + it "should not allow 'gitosis-admin' as repo name" do | |
39 | + should allow_value("blah").for(:path) | |
40 | + should_not allow_value("gitosis-admin").for(:path) | |
41 | + end | |
42 | + | |
34 | 43 | it "should return valid url to repo" do |
35 | 44 | project = Project.new(:path => "somewhere") |
36 | 45 | project.url_to_repo.should == "git@localhost:somewhere.git" | ... | ... |
spec/requests/projects_spec.rb
spec/requests/team_members_spec.rb
... | ... | @@ -7,6 +7,15 @@ describe "TeamMembers" do |
7 | 7 | @project.add_access(@user, :read, :admin) |
8 | 8 | end |
9 | 9 | |
10 | + describe "View profile" do | |
11 | + it "should be available" do | |
12 | + visit(team_project_path(@project)) | |
13 | + find(:xpath, "//table[@id='team-table']//a[1]").click | |
14 | + page.should have_content @user.skype | |
15 | + page.should_not have_content 'Twitter' | |
16 | + end | |
17 | + end | |
18 | + | |
10 | 19 | describe "New Team member", :js => true do |
11 | 20 | before do |
12 | 21 | @user_1 = Factory :user | ... | ... |
spec/support/login.rb
... | ... | @@ -3,7 +3,8 @@ module LoginMacros |
3 | 3 | @user = User.create(:email => "user#{User.count}@mail.com", |
4 | 4 | :name => "John Smith", |
5 | 5 | :password => "123456", |
6 | - :password_confirmation => "123456") | |
6 | + :password_confirmation => "123456", | |
7 | + :skype => 'user_skype') | |
7 | 8 | |
8 | 9 | if role == :admin |
9 | 10 | @user.admin = true | ... | ... |
update.rb
... | ... | @@ -1,44 +0,0 @@ |
1 | -root_path = File.expand_path(File.dirname(__FILE__)) | |
2 | -require File.join(root_path, "lib", "color") | |
3 | -include Color | |
4 | - | |
5 | -def version | |
6 | - File.read("VERSION") | |
7 | -end | |
8 | - | |
9 | -# | |
10 | -# ruby ./update.rb development # or test or production (default) | |
11 | -# | |
12 | -envs = ["production", "test", "development"] | |
13 | -env = if envs.include?(ARGV[0]) | |
14 | - ARGV[0] | |
15 | - else | |
16 | - "production" | |
17 | - end | |
18 | - | |
19 | -puts yellow "== RAILS ENV | #{env}" | |
20 | -current_version = version | |
21 | -puts yellow "Your version is #{current_version}" | |
22 | -puts yellow "Check for new version: $ git pull origin" | |
23 | -`git pull origin` # pull from origin | |
24 | - | |
25 | -# latest version | |
26 | -if version == current_version | |
27 | - puts yellow "You have a latest version" | |
28 | -else | |
29 | - puts green "Update to #{version}" | |
30 | - | |
31 | -`bundle install` | |
32 | - | |
33 | - # migrate db | |
34 | -if env == "development" | |
35 | -`bundle exec rake db:migrate RAILS_ENV=development` | |
36 | -`bundle exec rake db:migrate RAILS_ENV=test` | |
37 | -else | |
38 | -`bundle exec rake db:migrate RAILS_ENV=#{env}` | |
39 | -end | |
40 | - | |
41 | - puts green "== Done! Now you can start/restart server" | |
42 | -end | |
43 | - | |
44 | - |