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
1 | v 1.1.0 | 1 | v 1.1.0 |
2 | + - project dashboard | ||
3 | + - wall redesigned | ||
2 | - feature: code snippets | 4 | - feature: code snippets |
3 | - fixed horizontal scroll on file preview | 5 | - fixed horizontal scroll on file preview |
4 | - fixed app crash if commit message has invalid chars | 6 | - fixed app crash if commit message has invalid chars |
Gemfile
@@ -15,7 +15,7 @@ gem 'therubyracer' | @@ -15,7 +15,7 @@ gem 'therubyracer' | ||
15 | gem 'faker' | 15 | gem 'faker' |
16 | gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' | 16 | gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' |
17 | gem "inifile" | 17 | gem "inifile" |
18 | -gem "albino", :git => "git://github.com/gitlabhq/albino.git" | 18 | +gem "pygments.rb", "0.2.3" |
19 | gem "kaminari" | 19 | gem "kaminari" |
20 | gem "thin" | 20 | gem "thin" |
21 | gem "git" | 21 | gem "git" |
Gemfile.lock
@@ -5,13 +5,6 @@ GIT | @@ -5,13 +5,6 @@ GIT | ||
5 | annotate (2.4.1.beta1) | 5 | annotate (2.4.1.beta1) |
6 | 6 | ||
7 | GIT | 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 | remote: git://github.com/gitlabhq/grit.git | 8 | remote: git://github.com/gitlabhq/grit.git |
16 | revision: ff015074ef35bd94cba943f9c0f98e161ab5851c | 9 | revision: ff015074ef35bd94cba943f9c0f98e161ab5851c |
17 | specs: | 10 | specs: |
@@ -72,6 +65,7 @@ GEM | @@ -72,6 +65,7 @@ GEM | ||
72 | ZenTest (= 4.5) | 65 | ZenTest (= 4.5) |
73 | awesome_print (0.4.0) | 66 | awesome_print (0.4.0) |
74 | bcrypt-ruby (3.0.1) | 67 | bcrypt-ruby (3.0.1) |
68 | + blankslate (2.1.2.4) | ||
75 | builder (3.0.0) | 69 | builder (3.0.0) |
76 | capybara (1.0.1) | 70 | capybara (1.0.1) |
77 | mime-types (>= 1.16) | 71 | mime-types (>= 1.16) |
@@ -138,6 +132,8 @@ GEM | @@ -138,6 +132,8 @@ GEM | ||
138 | orm_adapter (0.0.5) | 132 | orm_adapter (0.0.5) |
139 | polyglot (0.3.2) | 133 | polyglot (0.3.2) |
140 | posix-spawn (0.3.6) | 134 | posix-spawn (0.3.6) |
135 | + pygments.rb (0.2.3) | ||
136 | + rubypython (>= 0.5.1) | ||
141 | rack (1.3.2) | 137 | rack (1.3.2) |
142 | rack-cache (1.0.3) | 138 | rack-cache (1.0.3) |
143 | rack (>= 0.4) | 139 | rack (>= 0.4) |
@@ -189,6 +185,9 @@ GEM | @@ -189,6 +185,9 @@ GEM | ||
189 | ruby-debug-base19 (>= 0.11.19) | 185 | ruby-debug-base19 (>= 0.11.19) |
190 | ruby_core_source (0.1.5) | 186 | ruby_core_source (0.1.5) |
191 | archive-tar-minitar (>= 0.5.2) | 187 | archive-tar-minitar (>= 0.5.2) |
188 | + rubypython (0.5.1) | ||
189 | + blankslate (>= 2.1.2.3) | ||
190 | + ffi (~> 1.0.7) | ||
192 | rubyzip (0.9.4) | 191 | rubyzip (0.9.4) |
193 | sass (3.1.7) | 192 | sass (3.1.7) |
194 | sass-rails (3.1.1) | 193 | sass-rails (3.1.1) |
@@ -242,7 +241,6 @@ PLATFORMS | @@ -242,7 +241,6 @@ PLATFORMS | ||
242 | 241 | ||
243 | DEPENDENCIES | 242 | DEPENDENCIES |
244 | acts_as_list | 243 | acts_as_list |
245 | - albino! | ||
246 | annotate! | 244 | annotate! |
247 | autotest | 245 | autotest |
248 | autotest-rails | 246 | autotest-rails |
@@ -260,6 +258,7 @@ DEPENDENCIES | @@ -260,6 +258,7 @@ DEPENDENCIES | ||
260 | jquery-rails | 258 | jquery-rails |
261 | kaminari | 259 | kaminari |
262 | launchy | 260 | launchy |
261 | + pygments.rb (= 0.2.3) | ||
263 | rails (= 3.1.0) | 262 | rails (= 3.1.0) |
264 | rails-footnotes (>= 3.7.5.rc4) | 263 | rails-footnotes (>= 3.7.5.rc4) |
265 | rspec-rails | 264 | rspec-rails |
README.rdoc
@@ -34,18 +34,19 @@ sqlite as default db | @@ -34,18 +34,19 @@ sqlite as default db | ||
34 | sudo easy_install pygments | 34 | sudo easy_install pygments |
35 | 35 | ||
36 | sudo gem install bundler | 36 | sudo gem install bundler |
37 | + | ||
37 | bundle | 38 | bundle |
38 | 39 | ||
39 | - RAILS_ENV=production rake db:setup | 40 | + bundle exec rake db:setup RAILS_ENV=production |
40 | 41 | ||
41 | # create admin user | 42 | # create admin user |
42 | # login....admin@local.host | 43 | # login....admin@local.host |
43 | # pass.....5iveL!fe | 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 | Install gitosis, edit conf/gitosis.yml & start server | 47 | Install gitosis, edit conf/gitosis.yml & start server |
47 | 48 | ||
48 | - rails s | 49 | + rails s -e production |
49 | 50 | ||
50 | == Install Gitosis | 51 | == Install Gitosis |
51 | sudo aptitude install gitosis | 52 | sudo aptitude install gitosis |
@@ -63,6 +64,7 @@ Install gitosis, edit conf/gitosis.yml & start server | @@ -63,6 +64,7 @@ Install gitosis, edit conf/gitosis.yml & start server | ||
63 | ssh-keygen -t rsa | 64 | ssh-keygen -t rsa |
64 | 65 | ||
65 | sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub | 66 | sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub |
67 | + | ||
66 | sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update | 68 | sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update |
67 | 69 | ||
68 | 70 |
VERSION
app/assets/javascripts/application.js
@@ -16,3 +16,7 @@ $(function(){ | @@ -16,3 +16,7 @@ $(function(){ | ||
16 | $('select#branch').selectmenu({style:'popup', width:200}); | 16 | $('select#branch').selectmenu({style:'popup', width:200}); |
17 | $('select#tag').selectmenu({style:'popup', width:200}); | 17 | $('select#tag').selectmenu({style:'popup', width:200}); |
18 | }); | 18 | }); |
19 | + | ||
20 | +function updatePage(){ | ||
21 | + $.ajax({type: "GET", url: location.href, dataType: "script"}); | ||
22 | +} |
app/assets/stylesheets/projects.css.scss
@@ -491,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -491,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
491 | background: white; | 491 | background: white; |
492 | } | 492 | } |
493 | p { | 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,7 +521,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
515 | } | 521 | } |
516 | .note_content { | 522 | .note_content { |
517 | float:left; | 523 | float:left; |
518 | - width:750px; | 524 | + width:650px; |
519 | } | 525 | } |
520 | 526 | ||
521 | .issue_notes { | 527 | .issue_notes { |
@@ -605,7 +611,9 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -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 | .author { | 617 | .author { |
610 | background: #eaeaea; | 618 | background: #eaeaea; |
611 | color: #333; | 619 | color: #333; |
@@ -614,3 +622,28 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -614,3 +622,28 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
614 | margin-right:5px; | 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,24 +60,21 @@ class ProjectsController < ApplicationController | ||
60 | end | 60 | end |
61 | 61 | ||
62 | def show | 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 | end | 78 | end |
82 | end | 79 | end |
83 | 80 | ||
@@ -86,8 +83,15 @@ class ProjectsController < ApplicationController | @@ -86,8 +83,15 @@ class ProjectsController < ApplicationController | ||
86 | # | 83 | # |
87 | 84 | ||
88 | def wall | 85 | def wall |
89 | - @notes = @project.common_notes | ||
90 | @note = Note.new | 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 | end | 95 | end |
92 | 96 | ||
93 | # | 97 | # |
app/helpers/application_helper.rb
@@ -53,25 +53,4 @@ module ApplicationHelper | @@ -53,25 +53,4 @@ module ApplicationHelper | ||
53 | [projects, default_nav, project_nav].flatten.to_json | 53 | [projects, default_nav, project_nav].flatten.to_json |
54 | end | 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 | end | 56 | end |
app/models/note.rb
@@ -24,6 +24,7 @@ class Note < ActiveRecord::Base | @@ -24,6 +24,7 @@ class Note < ActiveRecord::Base | ||
24 | 24 | ||
25 | scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) | 25 | scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) |
26 | scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } | 26 | scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } |
27 | + scope :fresh, order("created_at DESC") | ||
27 | 28 | ||
28 | mount_uploader :attachment, AttachmentUploader | 29 | mount_uploader :attachment, AttachmentUploader |
29 | end | 30 | end |
app/models/project.rb
@@ -35,7 +35,8 @@ class Project < ActiveRecord::Base | @@ -35,7 +35,8 @@ class Project < ActiveRecord::Base | ||
35 | :presence => true | 35 | :presence => true |
36 | 36 | ||
37 | validate :check_limit | 37 | validate :check_limit |
38 | - | 38 | + validate :repo_name |
39 | + | ||
39 | after_destroy :destroy_gitosis_project | 40 | after_destroy :destroy_gitosis_project |
40 | after_save :update_gitosis_project | 41 | after_save :update_gitosis_project |
41 | 42 | ||
@@ -126,6 +127,34 @@ class Project < ActiveRecord::Base | @@ -126,6 +127,34 @@ class Project < ActiveRecord::Base | ||
126 | end | 127 | end |
127 | end | 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 | def tree(fcommit, path = nil) | 158 | def tree(fcommit, path = nil) |
130 | fcommit = commit if fcommit == :head | 159 | fcommit = commit if fcommit == :head |
131 | tree = fcommit.tree | 160 | tree = fcommit.tree |
@@ -140,6 +169,12 @@ class Project < ActiveRecord::Base | @@ -140,6 +169,12 @@ class Project < ActiveRecord::Base | ||
140 | errors[:base] << ("Cant check your ability to create project") | 169 | errors[:base] << ("Cant check your ability to create project") |
141 | end | 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 | def valid_repo? | 178 | def valid_repo? |
144 | repo | 179 | repo |
145 | rescue | 180 | rescue |
app/models/snippet.rb
1 | class Snippet < ActiveRecord::Base | 1 | class Snippet < ActiveRecord::Base |
2 | + include Utils::Colorize | ||
3 | + | ||
2 | belongs_to :project | 4 | belongs_to :project |
3 | belongs_to :author, :class_name => "User" | 5 | belongs_to :author, :class_name => "User" |
4 | has_many :notes, :as => :noteable | 6 | has_many :notes, :as => :noteable |
@@ -28,6 +30,10 @@ class Snippet < ActiveRecord::Base | @@ -28,6 +30,10 @@ class Snippet < ActiveRecord::Base | ||
28 | ".js", ".sh", ".coffee", ".yml", ".md" | 30 | ".js", ".sh", ".coffee", ".yml", ".md" |
29 | ] | 31 | ] |
30 | end | 32 | end |
33 | + | ||
34 | + def colorize | ||
35 | + system_colorize(content, file_name) | ||
36 | + end | ||
31 | end | 37 | end |
32 | # == Schema Information | 38 | # == Schema Information |
33 | # | 39 | # |
app/views/commits/_commits.html.haml
@@ -15,8 +15,8 @@ | @@ -15,8 +15,8 @@ | ||
15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" | 15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" |
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" | 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 | %span | 17 | %span |
18 | - %span | ||
19 | - [ #{commit.author} ] | 18 | + %span.author |
19 | + = commit.author | ||
20 | = time_ago_in_words(commit.committed_date) | 20 | = time_ago_in_words(commit.committed_date) |
21 | ago | 21 | ago |
22 | = more_commits_link if @commits.size > 99 | 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 | - @commit.diffs.each do |diff| | 3 | - @commit.diffs.each do |diff| |
27 | - next if diff.diff.empty? | 4 | - next if diff.diff.empty? |
28 | - file = (@commit.tree / diff.b_path) | 5 | - file = (@commit.tree / diff.b_path) |
@@ -32,27 +9,15 @@ | @@ -32,27 +9,15 @@ | ||
32 | - if diff.deleted_file | 9 | - if diff.deleted_file |
33 | %strong{:id => "#{diff.b_path}"}= diff.a_path | 10 | %strong{:id => "#{diff.b_path}"}= diff.a_path |
34 | - else | 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 | %br/ | 14 | %br/ |
37 | .diff_file_content | 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 | .diff_file_content_image | 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 | - else | 21 | - else |
57 | %p | 22 | %p |
58 | %center No preview for this file type | 23 | %center No preview for this file type |
@@ -0,0 +1,24 @@ | @@ -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 @@ | @@ -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 | $("#side-commit-preview").remove(); | 2 | $("#side-commit-preview").remove(); |
3 | var side = $("<div id='side-commit-preview'></div>"); | 3 | var side = $("<div id='side-commit-preview'></div>"); |
4 | side.html("#{escape_javascript(render "commits/show")}"); | 4 | side.html("#{escape_javascript(render "commits/show")}"); |
5 | $("##{dom_id(@project)}").parent().append(side); | 5 | $("##{dom_id(@project)}").parent().append(side); |
6 | $("##{dom_id(@project)}").addClass("span-14"); | 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,9 +12,9 @@ | ||
12 | = f.label :note | 12 | = f.label :note |
13 | %cite (255 symbols only) | 13 | %cite (255 symbols only) |
14 | %br | 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 | = f.label :attachment | 18 | = f.label :attachment |
19 | %cite (less than 10 MB) | 19 | %cite (less than 10 MB) |
20 | %br | 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 | :javascript | 11 | :javascript |
9 | $('.delete-note').live('ajax:success', function() { | 12 | $('.delete-note').live('ajax:success', function() { |
@@ -23,7 +26,3 @@ | @@ -23,7 +26,3 @@ | ||
23 | $(function(){ | 26 | $(function(){ |
24 | var int =self.setInterval("updatePage()", 20000); | 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 | %li{:id => dom_id(note)} | 1 | %li{:id => dom_id(note)} |
2 | %div.note_author | 2 | %div.note_author |
3 | = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" | 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 | = simple_format(html_escape(note.note)) | 5 | = simple_format(html_escape(note.note)) |
6 | - if note.attachment.url | 6 | - if note.attachment.url |
7 | Attachment: | 7 | Attachment: |
8 | - = link_to note.attachment_identifier, note.attachment.url | 8 | + = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" |
9 | %br | 9 | %br |
10 | - %span | ||
11 | - %span | ||
12 | - [ #{note.author.name} ] | ||
13 | - | 10 | + %span.author= note.author.name |
11 | + %cite.ago | ||
14 | = time_ago_in_words(note.updated_at) | 12 | = time_ago_in_words(note.updated_at) |
15 | ago | 13 | ago |
16 | - %br | 14 | + %br |
17 | - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) | 15 | - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) |
18 | = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" | 16 | = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" |
19 | .clear | 17 | .clear |
app/views/notes/create.js.haml
1 | - if @note.valid? | 1 | - if @note.valid? |
2 | :plain | 2 | :plain |
3 | $("#new_note .errors").remove(); | 3 | $("#new_note .errors").remove(); |
4 | - $("#notes-list").append("#{escape_javascript(render(:partial => 'show', :locals => {:note => @note} ))}"); | 4 | + updatePage(); |
5 | $('#note_note').val(""); | 5 | $('#note_note').val(""); |
6 | - else | 6 | - else |
7 | :plain | 7 | :plain |
app/views/projects/_recent_commits.html.haml
@@ -9,8 +9,8 @@ | @@ -9,8 +9,8 @@ | ||
9 | = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) | 9 | = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) |
10 | 10 | ||
11 | %span | 11 | %span |
12 | - %span | ||
13 | - [ #{commit.author} ] | 12 | + %span.author |
13 | + = commit.author.name.force_encoding("UTF-8") | ||
14 | %cite | 14 | %cite |
15 | = time_ago_in_words(commit.committed_date) | 15 | = time_ago_in_words(commit.committed_date) |
16 | ago | 16 | ago |
app/views/projects/_recent_messages.html.haml
@@ -46,12 +46,6 @@ | @@ -46,12 +46,6 @@ | ||
46 | Attachment: | 46 | Attachment: |
47 | = link_to note.attachment_identifier, note.attachment.url | 47 | = link_to note.attachment_identifier, note.attachment.url |
48 | %br | 48 | %br |
49 | - -#%span | ||
50 | - %span | ||
51 | - [ #{note.author.name} ] | ||
52 | - %cite | ||
53 | - = time_ago_in_words(note.created_at) | ||
54 | - ago | ||
55 | %br | 49 | %br |
56 | .append-bottom | 50 | .append-bottom |
57 | | 51 | |
app/views/projects/_top_menu.html.haml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil | 5 | %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil |
6 | %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil | 6 | %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil |
7 | %span | 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 | Team | 9 | Team |
10 | - if @project.users_projects.count > 0 | 10 | - if @project.users_projects.count > 0 |
11 | %span{ :class => "top_menu_count" }= @project.users_projects.count | 11 | %span{ :class => "top_menu_count" }= @project.users_projects.count |
app/views/projects/_tree_file.html.haml
1 | -- require "utils" | 1 | +:css |
2 | .view_file | 2 | .view_file |
3 | .view_file_header | 3 | .view_file_header |
4 | %strong | 4 | %strong |
@@ -6,14 +6,13 @@ | @@ -6,14 +6,13 @@ | ||
6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" | 6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" |
7 | = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" | 7 | = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" |
8 | %br/ | 8 | %br/ |
9 | - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) | 9 | + - if file.text? |
10 | .view_file_content | 10 | .view_file_content |
11 | - - ft = handle_file_type(file.name, file.mime_type) | ||
12 | :erb | 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 | .view_file_content_image | 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 | - else | 16 | - else |
18 | %p | 17 | %p |
19 | %center No preview for this file type | 18 | %center No preview for this file type |
app/views/projects/empty.html.erb
1 | +<% bash_lexer = Pygments::Lexer[:bash] %> | ||
1 | <div class=""> | 2 | <div class=""> |
2 | <div class="git-empty"> | 3 | <div class="git-empty"> |
3 | <h2>Git global setup:</h2> | 4 | <h2>Git global setup:</h2> |
@@ -6,7 +7,7 @@ git config --global user.name "#{current_user.name}" | @@ -6,7 +7,7 @@ git config --global user.name "#{current_user.name}" | ||
6 | git config --global user.email "#{current_user.email}" | 7 | git config --global user.email "#{current_user.email}" |
7 | eos | 8 | eos |
8 | %> | 9 | %> |
9 | - <%= raw Albino.colorize(setup_str, :bash) %> | 10 | + <%= raw bash_lexer.highlight(setup_str) %> |
10 | <br /> | 11 | <br /> |
11 | <br /> | 12 | <br /> |
12 | <h2>Next steps:</h2> | 13 | <h2>Next steps:</h2> |
@@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo} | @@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo} | ||
21 | git push -u origin master | 22 | git push -u origin master |
22 | eos | 23 | eos |
23 | %> | 24 | %> |
24 | - <%= raw Albino.colorize(repo_setup_str, :bash) %> | 25 | + <%= raw bash_lexer.highlight(repo_setup_str) %> |
25 | 26 | ||
26 | <br /><br /> | 27 | <br /><br /> |
27 | <h2>Existing Git Repo?</h2> | 28 | <h2>Existing Git Repo?</h2> |
@@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo} | @@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo} | ||
31 | git push -u origin master | 32 | git push -u origin master |
32 | eos | 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 | <br /><br /> | 37 | <br /><br /> |
37 | <h2>Remove this project?</h2> | 38 | <h2>Remove this project?</h2> |
app/views/projects/show.html.haml
1 | %div | 1 | %div |
2 | - %h2.left Recent history | 2 | + %h2.left History |
3 | .right | 3 | .right |
4 | = form_tag project_path(@project), :method => :get do | 4 | = form_tag project_path(@project), :method => :get do |
5 | .span-2 | 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 | = label_tag "day_view","Today" | 10 | = label_tag "day_view","Today" |
8 | .span-2 | 11 | .span-2 |
9 | = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" | 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 | = render "notes/notes" | 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,9 +7,8 @@ | ||
7 | = @snippet.file_name | 7 | = @snippet.file_name |
8 | %br/ | 8 | %br/ |
9 | .view_file_content | 9 | .view_file_content |
10 | - - ft = handle_file_type(@snippet.file_name) | ||
11 | :erb | 10 | :erb |
12 | - <%= raw Albino.colorize(@snippet.content, ft, :html, 'utf-8', "linenos=True") %> | 11 | + <%= raw @snippet.colorize %> |
13 | 12 | ||
14 | - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user | 13 | - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user |
15 | = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive" | 14 | = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive" |
app/views/team_members/_show.html.haml
1 | - user = member.user | 1 | - user = member.user |
2 | %tr{:id => dom_id(member)} | 2 | %tr{:id => dom_id(member)} |
3 | %td | 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 | %td= truncate user.email, :lenght => 16 | 8 | %td= truncate user.email, :lenght => 16 |
7 | - if can? current_user, :admin_project, @project | 9 | - if can? current_user, :admin_project, @project |
8 | = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| | 10 | = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| |
@@ -0,0 +1,28 @@ | @@ -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 | admin = User.create( | 1 | admin = User.create( |
3 | :email => "admin@local.host", | 2 | :email => "admin@local.host", |
4 | :name => "Administrator", | 3 | :name => "Administrator", |
@@ -9,3 +8,12 @@ admin = User.create( | @@ -9,3 +8,12 @@ admin = User.create( | ||
9 | admin.projects_limit = 10000 | 8 | admin.projects_limit = 10000 |
10 | admin.admin = true | 9 | admin.admin = true |
11 | admin.save! | 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
@@ -8,3 +8,12 @@ admin = User.create( | @@ -8,3 +8,12 @@ admin = User.create( | ||
8 | admin.projects_limit = 10000 | 8 | admin.projects_limit = 10000 |
9 | admin.admin = true | 9 | admin.admin = true |
10 | admin.save! | 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/migrate/20111021101550_change_social_fields_in_users.rb
0 → 100644
@@ -0,0 +1,14 @@ | @@ -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,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 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 | create_table "issues", :force => true do |t| | 16 | create_table "issues", :force => true do |t| |
17 | t.string "title" | 17 | t.string "title" |
@@ -82,9 +82,9 @@ ActiveRecord::Schema.define(:version => 20111019212429) do | @@ -82,9 +82,9 @@ ActiveRecord::Schema.define(:version => 20111019212429) do | ||
82 | t.string "name" | 82 | t.string "name" |
83 | t.boolean "admin", :default => false, :null => false | 83 | t.boolean "admin", :default => false, :null => false |
84 | t.integer "projects_limit", :default => 10 | 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 | end | 88 | end |
89 | 89 | ||
90 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true | 90 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true |
install.rb
@@ -1,32 +0,0 @@ | @@ -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 | module Utils | 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 | end | 49 | end |
6 | - false | ||
7 | end | 50 | end |
8 | end | 51 | end |
spec/models/project_spec.rb
@@ -4,11 +4,15 @@ describe Project do | @@ -4,11 +4,15 @@ describe Project do | ||
4 | describe "Associations" do | 4 | describe "Associations" do |
5 | it { should have_many(:users) } | 5 | it { should have_many(:users) } |
6 | it { should have_many(:users_projects) } | 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 | end | 10 | end |
8 | 11 | ||
9 | describe "Validation" do | 12 | describe "Validation" do |
10 | it { should validate_presence_of(:name) } | 13 | it { should validate_presence_of(:name) } |
11 | it { should validate_presence_of(:path) } | 14 | it { should validate_presence_of(:path) } |
15 | + it { should validate_presence_of(:code) } | ||
12 | end | 16 | end |
13 | 17 | ||
14 | describe "Respond to" do | 18 | describe "Respond to" do |
@@ -31,6 +35,11 @@ describe Project do | @@ -31,6 +35,11 @@ describe Project do | ||
31 | it { should respond_to(:commit) } | 35 | it { should respond_to(:commit) } |
32 | end | 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 | it "should return valid url to repo" do | 43 | it "should return valid url to repo" do |
35 | project = Project.new(:path => "somewhere") | 44 | project = Project.new(:path => "somewhere") |
36 | project.url_to_repo.should == "git@localhost:somewhere.git" | 45 | project.url_to_repo.should == "git@localhost:somewhere.git" |
spec/requests/projects_spec.rb
@@ -73,7 +73,7 @@ describe "Projects" do | @@ -73,7 +73,7 @@ describe "Projects" do | ||
73 | end | 73 | end |
74 | 74 | ||
75 | it "should beahave like dashboard" do | 75 | it "should beahave like dashboard" do |
76 | - page.should have_content("Recent history") | 76 | + page.should have_content("History") |
77 | end | 77 | end |
78 | 78 | ||
79 | end | 79 | end |
spec/requests/team_members_spec.rb
@@ -7,6 +7,15 @@ describe "TeamMembers" do | @@ -7,6 +7,15 @@ describe "TeamMembers" do | ||
7 | @project.add_access(@user, :read, :admin) | 7 | @project.add_access(@user, :read, :admin) |
8 | end | 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 | describe "New Team member", :js => true do | 19 | describe "New Team member", :js => true do |
11 | before do | 20 | before do |
12 | @user_1 = Factory :user | 21 | @user_1 = Factory :user |
spec/support/login.rb
@@ -3,7 +3,8 @@ module LoginMacros | @@ -3,7 +3,8 @@ module LoginMacros | ||
3 | @user = User.create(:email => "user#{User.count}@mail.com", | 3 | @user = User.create(:email => "user#{User.count}@mail.com", |
4 | :name => "John Smith", | 4 | :name => "John Smith", |
5 | :password => "123456", | 5 | :password => "123456", |
6 | - :password_confirmation => "123456") | 6 | + :password_confirmation => "123456", |
7 | + :skype => 'user_skype') | ||
7 | 8 | ||
8 | if role == :admin | 9 | if role == :admin |
9 | @user.admin = true | 10 | @user.admin = true |
update.rb
@@ -1,44 +0,0 @@ | @@ -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 | - |