Commit 6b030fd41d697e327d2935b406cba70b6a460504
1 parent
3a2b2733
Exists in
master
and in
4 other branches
1.1pre1
Showing
83 changed files
with
1090 additions
and
137 deletions
Show diff stats
CHANGELOG
1 | +v 1.1.0 | ||
2 | + - project dashboard | ||
3 | + - wall redesigned | ||
4 | + - feature: code snippets | ||
5 | + - fixed horizontal scroll on file preview | ||
6 | + - fixed app crash if commit message has invalid chars | ||
7 | + - bugfix & code cleaning | ||
8 | + | ||
9 | +v 1.0.2 | ||
10 | + - fixed bug with empty project | ||
11 | + - added adv validation for project path & code | ||
12 | + - feature: issues can be sortable | ||
13 | + - bugfix | ||
14 | + - username dispalyed on top panel | ||
15 | + | ||
1 | v 1.0.1 | 16 | v 1.0.1 |
2 | - fixed: with invalid source code for commit | 17 | - fixed: with invalid source code for commit |
3 | - fixed: lose branch/tag selection when use tree navigateion | 18 | - fixed: lose branch/tag selection when use tree navigateion |
4 | - when history clicked - display path | 19 | - when history clicked - display path |
5 | - bug fix & code cleaning | 20 | - bug fix & code cleaning |
21 | + | ||
6 | v 1.0.0 | 22 | v 1.0.0 |
7 | - bug fix | 23 | - bug fix |
8 | - projects preview mode | 24 | - projects preview mode |
25 | + | ||
9 | v 0.9.6 | 26 | v 0.9.6 |
10 | - css fix | 27 | - css fix |
11 | - new repo empty tree until restart server - fixed | 28 | - new repo empty tree until restart server - fixed |
29 | + | ||
12 | v 0.9.4 | 30 | v 0.9.4 |
13 | - security improved | 31 | - security improved |
14 | - authorization improved | 32 | - authorization improved |
@@ -24,6 +42,7 @@ v 0.9.1 | @@ -24,6 +42,7 @@ v 0.9.1 | ||
24 | - updated app name | 42 | - updated app name |
25 | - issue redesigned | 43 | - issue redesigned |
26 | - issue can be edit | 44 | - issue can be edit |
45 | + | ||
27 | v 0.8.0 | 46 | v 0.8.0 |
28 | - sytax highlight for main file types | 47 | - sytax highlight for main file types |
29 | - redesign | 48 | - redesign |
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 |
VERSION
271 Bytes
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/highlight.css.scss
@@ -22,8 +22,8 @@ td.linenos{ | @@ -22,8 +22,8 @@ td.linenos{ | ||
22 | 22 | ||
23 | .highlight{ | 23 | .highlight{ |
24 | background:none; | 24 | background:none; |
25 | - padding:10px 0px 0px 0; | ||
26 | - margin-left:10px; | 25 | + padding:10px 0px 0px 10px; |
26 | + margin-left:0px; | ||
27 | } | 27 | } |
28 | .highlight pre{ | 28 | .highlight pre{ |
29 | } | 29 | } |
@@ -43,7 +43,7 @@ td.linenos { | @@ -43,7 +43,7 @@ td.linenos { | ||
43 | } | 43 | } |
44 | 44 | ||
45 | td.code .highlight { | 45 | td.code .highlight { |
46 | - overflow-x: scroll; | 46 | + overflow: auto; |
47 | } | 47 | } |
48 | table.highlighttable pre{ | 48 | table.highlighttable pre{ |
49 | padding:0; | 49 | padding:0; |
app/assets/stylesheets/projects.css.scss
@@ -310,6 +310,7 @@ input.ssh_project_url { | @@ -310,6 +310,7 @@ input.ssh_project_url { | ||
310 | } | 310 | } |
311 | 311 | ||
312 | #projects-list .project, | 312 | #projects-list .project, |
313 | +#snippets-table .snippet, | ||
313 | #issues-table .issue{ | 314 | #issues-table .issue{ |
314 | cursor:pointer; | 315 | cursor:pointer; |
315 | 316 | ||
@@ -360,6 +361,8 @@ input.ssh_project_url { | @@ -360,6 +361,8 @@ input.ssh_project_url { | ||
360 | .user_new, | 361 | .user_new, |
361 | .edit_user, | 362 | .edit_user, |
362 | .new_project, | 363 | .new_project, |
364 | +.new_snippet, | ||
365 | +.edit_snippet, | ||
363 | .edit_project { | 366 | .edit_project { |
364 | input[type='text'], | 367 | input[type='text'], |
365 | input[type='email'], | 368 | input[type='email'], |
@@ -488,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -488,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
488 | background: white; | 491 | background: white; |
489 | } | 492 | } |
490 | p { | 493 | p { |
491 | - margin-bottom: 3px; | ||
492 | - font-size: 12px; | 494 | + margin-bottom: 4px; |
495 | + font-size: 13px; | ||
496 | + color:#111; | ||
497 | + } | ||
498 | + } | ||
499 | + cite { | ||
500 | + &.ago { | ||
501 | + color:#666; | ||
493 | } | 502 | } |
494 | } | 503 | } |
495 | } | 504 | } |
@@ -512,7 +521,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -512,7 +521,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
512 | } | 521 | } |
513 | .note_content { | 522 | .note_content { |
514 | float:left; | 523 | float:left; |
515 | - width:750px; | 524 | + width:650px; |
516 | } | 525 | } |
517 | 526 | ||
518 | .issue_notes { | 527 | .issue_notes { |
@@ -549,3 +558,83 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -549,3 +558,83 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
549 | height: 12px; | 558 | height: 12px; |
550 | padding: 10px; | 559 | padding: 10px; |
551 | } | 560 | } |
561 | + | ||
562 | +.recent_message_parent { | ||
563 | + img { | ||
564 | + padding-right:10px; | ||
565 | + } | ||
566 | + | ||
567 | + float: left; | ||
568 | + margin: 0 20px 20px 0px; | ||
569 | + padding: 5px 0px;; | ||
570 | + width: 420px; | ||
571 | + | ||
572 | + &.dash_wall{ | ||
573 | + border-bottom: 2px solid orange; | ||
574 | + span { | ||
575 | + background: orange; | ||
576 | + color:black; | ||
577 | + } | ||
578 | + } | ||
579 | + | ||
580 | + &.dash_issue{ | ||
581 | + border-bottom: 2px solid #ffbbbb; | ||
582 | + span { | ||
583 | + background: #ffbbbb; | ||
584 | + } | ||
585 | + } | ||
586 | + &.dash_commit{ | ||
587 | + border-bottom: 2px solid #bbbbff; | ||
588 | + | ||
589 | + span{ | ||
590 | + background: #bbbbff; | ||
591 | + } | ||
592 | + } | ||
593 | + | ||
594 | + &.dash_snippet{ | ||
595 | + border-bottom: 2px solid #bbffbb; | ||
596 | + | ||
597 | + span{ | ||
598 | + background: #bbffbb; | ||
599 | + } | ||
600 | + } | ||
601 | + | ||
602 | + | ||
603 | + span{ | ||
604 | + border: 1px solid #aaa; | ||
605 | + color:black; | ||
606 | + padding:1px 4px; | ||
607 | + } | ||
608 | + | ||
609 | + h4 { | ||
610 | + margin-bottom:3px; | ||
611 | + } | ||
612 | + | ||
613 | +} | ||
614 | +.commit, | ||
615 | +.message, | ||
616 | +#notes-list{ | ||
617 | + .author { | ||
618 | + background: #eaeaea; | ||
619 | + color: #333; | ||
620 | + border: 1px solid #aaa; | ||
621 | + padding:1px 2px; | ||
622 | + margin-right:5px; | ||
623 | + } | ||
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 | +} |
app/controllers/application_controller.rb
@@ -27,11 +27,15 @@ class ApplicationController < ActionController::Base | @@ -27,11 +27,15 @@ class ApplicationController < ActionController::Base | ||
27 | end | 27 | end |
28 | 28 | ||
29 | def authenticate_admin! | 29 | def authenticate_admin! |
30 | - return redirect_to(new_user_session_path) unless current_user.is_admin? | 30 | + return render_404 unless current_user.is_admin? |
31 | end | 31 | end |
32 | 32 | ||
33 | def authorize_project!(action) | 33 | def authorize_project!(action) |
34 | - return redirect_to(new_user_session_path) unless can?(current_user, action, project) | 34 | + return render_404 unless can?(current_user, action, project) |
35 | + end | ||
36 | + | ||
37 | + def access_denied! | ||
38 | + render_404 | ||
35 | end | 39 | end |
36 | 40 | ||
37 | def method_missing(method_sym, *arguments, &block) | 41 | def method_missing(method_sym, *arguments, &block) |
app/controllers/issues_controller.rb
1 | class IssuesController < ApplicationController | 1 | class IssuesController < ApplicationController |
2 | before_filter :authenticate_user! | 2 | before_filter :authenticate_user! |
3 | before_filter :project | 3 | before_filter :project |
4 | + before_filter :issue, :only => [:edit, :update, :destroy, :show] | ||
4 | 5 | ||
5 | # Authorize | 6 | # Authorize |
6 | before_filter :add_project_abilities | 7 | before_filter :add_project_abilities |
7 | before_filter :authorize_read_issue! | 8 | before_filter :authorize_read_issue! |
8 | before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort] | 9 | before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort] |
9 | - before_filter :authorize_admin_issue!, :only => [:destroy] | ||
10 | 10 | ||
11 | respond_to :js | 11 | respond_to :js |
12 | 12 | ||
@@ -30,12 +30,10 @@ class IssuesController < ApplicationController | @@ -30,12 +30,10 @@ class IssuesController < ApplicationController | ||
30 | end | 30 | end |
31 | 31 | ||
32 | def edit | 32 | def edit |
33 | - @issue = @project.issues.find(params[:id]) | ||
34 | respond_with(@issue) | 33 | respond_with(@issue) |
35 | end | 34 | end |
36 | 35 | ||
37 | def show | 36 | def show |
38 | - @issue = @project.issues.find(params[:id]) | ||
39 | @notes = @issue.notes | 37 | @notes = @issue.notes |
40 | @note = @project.notes.new(:noteable => @issue) | 38 | @note = @project.notes.new(:noteable => @issue) |
41 | end | 39 | end |
@@ -51,7 +49,6 @@ class IssuesController < ApplicationController | @@ -51,7 +49,6 @@ class IssuesController < ApplicationController | ||
51 | end | 49 | end |
52 | 50 | ||
53 | def update | 51 | def update |
54 | - @issue = @project.issues.find(params[:id]) | ||
55 | @issue.update_attributes(params[:issue]) | 52 | @issue.update_attributes(params[:issue]) |
56 | 53 | ||
57 | respond_to do |format| | 54 | respond_to do |format| |
@@ -62,7 +59,8 @@ class IssuesController < ApplicationController | @@ -62,7 +59,8 @@ class IssuesController < ApplicationController | ||
62 | 59 | ||
63 | 60 | ||
64 | def destroy | 61 | def destroy |
65 | - @issue = @project.issues.find(params[:id]) | 62 | + return access_denied! unless can?(current_user, :admin_issue, @issue) |
63 | + | ||
66 | @issue.destroy | 64 | @issue.destroy |
67 | 65 | ||
68 | respond_to do |format| | 66 | respond_to do |format| |
@@ -79,4 +77,10 @@ class IssuesController < ApplicationController | @@ -79,4 +77,10 @@ class IssuesController < ApplicationController | ||
79 | 77 | ||
80 | render :nothing => true | 78 | render :nothing => true |
81 | end | 79 | end |
80 | + | ||
81 | + protected | ||
82 | + | ||
83 | + def issue | ||
84 | + @issue ||= @project.issues.find(params[:id]) | ||
85 | + end | ||
82 | end | 86 | end |
app/controllers/notes_controller.rb
@@ -4,7 +4,6 @@ class NotesController < ApplicationController | @@ -4,7 +4,6 @@ class NotesController < ApplicationController | ||
4 | # Authorize | 4 | # Authorize |
5 | before_filter :add_project_abilities | 5 | before_filter :add_project_abilities |
6 | before_filter :authorize_write_note!, :only => [:create] | 6 | before_filter :authorize_write_note!, :only => [:create] |
7 | - before_filter :authorize_admin_note!, :only => [:destroy] | ||
8 | 7 | ||
9 | respond_to :js | 8 | respond_to :js |
10 | 9 | ||
@@ -25,6 +24,9 @@ class NotesController < ApplicationController | @@ -25,6 +24,9 @@ class NotesController < ApplicationController | ||
25 | 24 | ||
26 | def destroy | 25 | def destroy |
27 | @note = @project.notes.find(params[:id]) | 26 | @note = @project.notes.find(params[:id]) |
27 | + | ||
28 | + return access_denied! unless can?(current_user, :admin_note, @note) | ||
29 | + | ||
28 | @note.destroy | 30 | @note.destroy |
29 | 31 | ||
30 | respond_to do |format| | 32 | respond_to do |format| |
@@ -41,6 +43,8 @@ class NotesController < ApplicationController | @@ -41,6 +43,8 @@ class NotesController < ApplicationController | ||
41 | Notify.note_commit_email(u, @note).deliver | 43 | Notify.note_commit_email(u, @note).deliver |
42 | when "Issue" then | 44 | when "Issue" then |
43 | Notify.note_issue_email(u, @note).deliver | 45 | Notify.note_issue_email(u, @note).deliver |
46 | + when "Snippet" | ||
47 | + true | ||
44 | else | 48 | else |
45 | Notify.note_wall_email(u, @note).deliver | 49 | Notify.note_wall_email(u, @note).deliver |
46 | end | 50 | end |
app/controllers/profile_controller.rb
@@ -3,6 +3,12 @@ class ProfileController < ApplicationController | @@ -3,6 +3,12 @@ class ProfileController < ApplicationController | ||
3 | @user = current_user | 3 | @user = current_user |
4 | end | 4 | end |
5 | 5 | ||
6 | + def social_update | ||
7 | + @user = current_user | ||
8 | + @user.update_attributes(params[:user]) | ||
9 | + redirect_to [:profile] | ||
10 | + end | ||
11 | + | ||
6 | def password | 12 | def password |
7 | @user = current_user | 13 | @user = current_user |
8 | end | 14 | end |
app/controllers/projects_controller.rb
@@ -60,14 +60,21 @@ class ProjectsController < ApplicationController | @@ -60,14 +60,21 @@ class ProjectsController < ApplicationController | ||
60 | end | 60 | end |
61 | 61 | ||
62 | def show | 62 | def show |
63 | - @repo = project.repo | ||
64 | - @commit = @repo.commits.first | ||
65 | - @tree = @commit.tree | ||
66 | - @tree = @tree / params[:path] if params[:path] | ||
67 | - | ||
68 | - rescue Grit::NoSuchPathError => ex | ||
69 | - respond_to do |format| | ||
70 | - format.html {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) | ||
71 | end | 78 | end |
72 | end | 79 | end |
73 | 80 | ||
@@ -76,8 +83,15 @@ class ProjectsController < ApplicationController | @@ -76,8 +83,15 @@ class ProjectsController < ApplicationController | ||
76 | # | 83 | # |
77 | 84 | ||
78 | def wall | 85 | def wall |
79 | - @notes = @project.common_notes | ||
80 | @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 | ||
81 | end | 95 | end |
82 | 96 | ||
83 | # | 97 | # |
@@ -0,0 +1,62 @@ | @@ -0,0 +1,62 @@ | ||
1 | +class SnippetsController < ApplicationController | ||
2 | + before_filter :authenticate_user! | ||
3 | + before_filter :project | ||
4 | + | ||
5 | + # Authorize | ||
6 | + before_filter :add_project_abilities | ||
7 | + before_filter :authorize_read_snippet! | ||
8 | + before_filter :authorize_write_snippet!, :only => [:new, :create, :close, :edit, :update, :sort] | ||
9 | + | ||
10 | + respond_to :html | ||
11 | + | ||
12 | + def index | ||
13 | + @snippets = @project.snippets | ||
14 | + end | ||
15 | + | ||
16 | + def new | ||
17 | + @snippet = @project.snippets.new | ||
18 | + end | ||
19 | + | ||
20 | + def create | ||
21 | + @snippet = @project.snippets.new(params[:snippet]) | ||
22 | + @snippet.author = current_user | ||
23 | + @snippet.save | ||
24 | + | ||
25 | + if @snippet.valid? | ||
26 | + redirect_to [@project, @snippet] | ||
27 | + else | ||
28 | + respond_with(@snippet) | ||
29 | + end | ||
30 | + end | ||
31 | + | ||
32 | + def edit | ||
33 | + @snippet = @project.snippets.find(params[:id]) | ||
34 | + end | ||
35 | + | ||
36 | + def update | ||
37 | + @snippet = @project.snippets.find(params[:id]) | ||
38 | + @snippet.update_attributes(params[:snippet]) | ||
39 | + | ||
40 | + if @snippet.valid? | ||
41 | + redirect_to [@project, @snippet] | ||
42 | + else | ||
43 | + respond_with(@snippet) | ||
44 | + end | ||
45 | + end | ||
46 | + | ||
47 | + def show | ||
48 | + @snippet = @project.snippets.find(params[:id]) | ||
49 | + @notes = @snippet.notes | ||
50 | + @note = @project.notes.new(:noteable => @snippet) | ||
51 | + end | ||
52 | + | ||
53 | + def destroy | ||
54 | + @snippet = @project.snippets.find(params[:id]) | ||
55 | + | ||
56 | + return access_denied! unless can?(current_user, :admin_snippet, @snippet) | ||
57 | + | ||
58 | + @snippet.destroy | ||
59 | + | ||
60 | + redirect_to project_snippets_path(@project) | ||
61 | + end | ||
62 | +end |
app/controllers/team_members_controller.rb
@@ -3,8 +3,8 @@ class TeamMembersController < ApplicationController | @@ -3,8 +3,8 @@ class TeamMembersController < ApplicationController | ||
3 | 3 | ||
4 | # Authorize | 4 | # Authorize |
5 | before_filter :add_project_abilities | 5 | before_filter :add_project_abilities |
6 | - before_filter :authorize_read_team_member! | ||
7 | - before_filter :authorize_admin_team_member!, :only => [:new, :create, :destroy, :update] | 6 | + before_filter :authorize_read_project! |
7 | + before_filter :authorize_admin_project!, :only => [:new, :create, :destroy, :update] | ||
8 | 8 | ||
9 | def show | 9 | def show |
10 | @team_member = project.users_projects.find(params[:id]) | 10 | @team_member = project.users_projects.find(params[:id]) |
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) | ||
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/helpers/commits_helper.rb
@@ -21,4 +21,13 @@ module CommitsHelper | @@ -21,4 +21,13 @@ module CommitsHelper | ||
21 | link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), | 21 | link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), |
22 | :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" | 22 | :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" |
23 | end | 23 | end |
24 | + | ||
25 | + # Cause some errors with trucate & encoding use this method | ||
26 | + def truncate_commit_message(commit, size = 60) | ||
27 | + message = commit.message | ||
28 | + message.length > size ? (message[0..(size - 1)] + "...") : message | ||
29 | + # if special characters occurs | ||
30 | + rescue | ||
31 | + commit.message | ||
32 | + end | ||
24 | end | 33 | end |
app/helpers/projects_helper.rb
@@ -3,4 +3,16 @@ module ProjectsHelper | @@ -3,4 +3,16 @@ module ProjectsHelper | ||
3 | cookies["project_view"] ||= "tile" | 3 | cookies["project_view"] ||= "tile" |
4 | cookies["project_view"] == type ? nil : "display:none" | 4 | cookies["project_view"] == type ? nil : "display:none" |
5 | end | 5 | end |
6 | + | ||
7 | + def load_note_parent(id, type, project) | ||
8 | + case type | ||
9 | + when "Issue" then @project.issues.find(id) | ||
10 | + when "Commit" then @project.repo.commits(id).first | ||
11 | + when "Snippet" then @project.snippets.find(id) | ||
12 | + else | ||
13 | + true | ||
14 | + end | ||
15 | + rescue | ||
16 | + nil | ||
17 | + end | ||
6 | end | 18 | end |
app/models/ability.rb
@@ -2,6 +2,9 @@ class Ability | @@ -2,6 +2,9 @@ class Ability | ||
2 | def self.allowed(object, subject) | 2 | def self.allowed(object, subject) |
3 | case subject.class.name | 3 | case subject.class.name |
4 | when "Project" then project_abilities(object, subject) | 4 | when "Project" then project_abilities(object, subject) |
5 | + when "Issue" then issue_abilities(object, subject) | ||
6 | + when "Note" then note_abilities(object, subject) | ||
7 | + when "Snippet" then snippet_abilities(object, subject) | ||
5 | else [] | 8 | else [] |
6 | end | 9 | end |
7 | end | 10 | end |
@@ -12,6 +15,7 @@ class Ability | @@ -12,6 +15,7 @@ class Ability | ||
12 | rules << [ | 15 | rules << [ |
13 | :read_project, | 16 | :read_project, |
14 | :read_issue, | 17 | :read_issue, |
18 | + :read_snippet, | ||
15 | :read_team_member, | 19 | :read_team_member, |
16 | :read_note | 20 | :read_note |
17 | ] if project.readers.include?(user) | 21 | ] if project.readers.include?(user) |
@@ -19,16 +23,35 @@ class Ability | @@ -19,16 +23,35 @@ class Ability | ||
19 | rules << [ | 23 | rules << [ |
20 | :write_project, | 24 | :write_project, |
21 | :write_issue, | 25 | :write_issue, |
26 | + :write_snippet, | ||
22 | :write_note | 27 | :write_note |
23 | ] if project.writers.include?(user) | 28 | ] if project.writers.include?(user) |
24 | 29 | ||
25 | rules << [ | 30 | rules << [ |
26 | :admin_project, | 31 | :admin_project, |
27 | :admin_issue, | 32 | :admin_issue, |
33 | + :admin_snippet, | ||
28 | :admin_team_member, | 34 | :admin_team_member, |
29 | :admin_note | 35 | :admin_note |
30 | ] if project.admins.include?(user) | 36 | ] if project.admins.include?(user) |
31 | 37 | ||
32 | rules.flatten | 38 | rules.flatten |
33 | end | 39 | end |
40 | + | ||
41 | + class << self | ||
42 | + [:issue, :note, :snippet].each do |name| | ||
43 | + define_method "#{name}_abilities" do |user, subject| | ||
44 | + if subject.author == user | ||
45 | + [ | ||
46 | + :"read_#{name}", | ||
47 | + :"write_#{name}", | ||
48 | + :"admin_#{name}" | ||
49 | + ] | ||
50 | + else | ||
51 | + subject.respond_to?(:project) ? | ||
52 | + project_abilities(user, subject.project) : [] | ||
53 | + end | ||
54 | + end | ||
55 | + end | ||
56 | + end | ||
34 | end | 57 | end |
app/models/issue.rb
app/models/note.rb
@@ -22,6 +22,10 @@ class Note < ActiveRecord::Base | @@ -22,6 +22,10 @@ class Note < ActiveRecord::Base | ||
22 | 22 | ||
23 | scope :common, where(:noteable_id => nil) | 23 | scope :common, where(:noteable_id => nil) |
24 | 24 | ||
25 | + scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) | ||
26 | + scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } | ||
27 | + scope :fresh, order("created_at DESC") | ||
28 | + | ||
25 | mount_uploader :attachment, AttachmentUploader | 29 | mount_uploader :attachment, AttachmentUploader |
26 | end | 30 | end |
27 | # == Schema Information | 31 | # == Schema Information |
app/models/project.rb
@@ -7,6 +7,7 @@ class Project < ActiveRecord::Base | @@ -7,6 +7,7 @@ class Project < ActiveRecord::Base | ||
7 | has_many :users_projects, :dependent => :destroy | 7 | has_many :users_projects, :dependent => :destroy |
8 | has_many :users, :through => :users_projects | 8 | has_many :users, :through => :users_projects |
9 | has_many :notes, :dependent => :destroy | 9 | has_many :notes, :dependent => :destroy |
10 | + has_many :snippets, :dependent => :destroy | ||
10 | 11 | ||
11 | validates :name, | 12 | validates :name, |
12 | :uniqueness => true, | 13 | :uniqueness => true, |
@@ -125,6 +126,34 @@ class Project < ActiveRecord::Base | @@ -125,6 +126,34 @@ class Project < ActiveRecord::Base | ||
125 | end | 126 | end |
126 | end | 127 | end |
127 | 128 | ||
129 | + def heads | ||
130 | + @heads ||= repo.heads | ||
131 | + end | ||
132 | + | ||
133 | + def fresh_commits | ||
134 | + commits = heads.map do |h| | ||
135 | + repo.commits(h.name, 10) | ||
136 | + end.flatten.uniq { |c| c.id } | ||
137 | + | ||
138 | + commits.sort! do |x, y| | ||
139 | + y.committed_date <=> x.committed_date | ||
140 | + end | ||
141 | + | ||
142 | + commits[0..10] | ||
143 | + end | ||
144 | + | ||
145 | + def commits_since(date) | ||
146 | + commits = heads.map do |h| | ||
147 | + repo.log(h.name, nil, :since => date) | ||
148 | + end.flatten.uniq { |c| c.id } | ||
149 | + | ||
150 | + commits.sort! do |x, y| | ||
151 | + y.committed_date <=> x.committed_date | ||
152 | + end | ||
153 | + | ||
154 | + commits | ||
155 | + end | ||
156 | + | ||
128 | def tree(fcommit, path = nil) | 157 | def tree(fcommit, path = nil) |
129 | fcommit = commit if fcommit == :head | 158 | fcommit = commit if fcommit == :head |
130 | tree = fcommit.tree | 159 | tree = fcommit.tree |
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +class Snippet < ActiveRecord::Base | ||
2 | + include Utils::Colorize | ||
3 | + | ||
4 | + belongs_to :project | ||
5 | + belongs_to :author, :class_name => "User" | ||
6 | + has_many :notes, :as => :noteable | ||
7 | + | ||
8 | + attr_protected :author, :author_id, :project, :project_id | ||
9 | + | ||
10 | + validates_presence_of :project_id | ||
11 | + validates_presence_of :author_id | ||
12 | + | ||
13 | + validates :title, | ||
14 | + :presence => true, | ||
15 | + :length => { :within => 0..255 } | ||
16 | + | ||
17 | + validates :file_name, | ||
18 | + :presence => true, | ||
19 | + :length => { :within => 0..255 } | ||
20 | + | ||
21 | + validates :content, | ||
22 | + :presence => true, | ||
23 | + :length => { :within => 0..10000 } | ||
24 | + | ||
25 | + | ||
26 | + def self.content_types | ||
27 | + [ | ||
28 | + ".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java", | ||
29 | + ".haml", ".html", ".sass", ".scss", ".xml", ".php", ".erb", | ||
30 | + ".js", ".sh", ".coffee", ".yml", ".md" | ||
31 | + ] | ||
32 | + end | ||
33 | + | ||
34 | + def colorize | ||
35 | + system_colorize(content, file_name) | ||
36 | + end | ||
37 | +end | ||
38 | +# == Schema Information | ||
39 | +# | ||
40 | +# Table name: snippets | ||
41 | +# | ||
42 | +# id :integer not null, primary key | ||
43 | +# title :string(255) | ||
44 | +# content :text | ||
45 | +# author_id :integer not null | ||
46 | +# project_id :integer not null | ||
47 | +# created_at :datetime | ||
48 | +# updated_at :datetime | ||
49 | +# file_name :string(255) | ||
50 | +# | ||
51 | + |
app/models/user.rb
@@ -5,7 +5,8 @@ class User < ActiveRecord::Base | @@ -5,7 +5,8 @@ class User < ActiveRecord::Base | ||
5 | :recoverable, :rememberable, :trackable, :validatable | 5 | :recoverable, :rememberable, :trackable, :validatable |
6 | 6 | ||
7 | # Setup accessible (or protected) attributes for your model | 7 | # Setup accessible (or protected) attributes for your model |
8 | - attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :projects_limit | 8 | + attr_accessible :email, :password, :password_confirmation, :remember_me, |
9 | + :name, :projects_limit, :skype, :linkedin, :twitter | ||
9 | 10 | ||
10 | has_many :users_projects, :dependent => :destroy | 11 | has_many :users_projects, :dependent => :destroy |
11 | has_many :projects, :through => :users_projects | 12 | has_many :projects, :through => :users_projects |
@@ -58,5 +59,8 @@ end | @@ -58,5 +59,8 @@ end | ||
58 | # name :string(255) | 59 | # name :string(255) |
59 | # admin :boolean default(FALSE), not null | 60 | # admin :boolean default(FALSE), not null |
60 | # projects_limit :integer | 61 | # projects_limit :integer |
62 | +# skype :string | ||
63 | +# linkedin :string | ||
64 | +# twitter :string | ||
61 | # | 65 | # |
62 | 66 |
app/views/admin/users/_form.html.haml
@@ -25,13 +25,26 @@ | @@ -25,13 +25,26 @@ | ||
25 | = f.label :password_confirmation | 25 | = f.label :password_confirmation |
26 | %br | 26 | %br |
27 | = f.password_field :password_confirmation | 27 | = f.password_field :password_confirmation |
28 | - .span-11 | ||
29 | - .field.prepend-top.append-bottom | 28 | + .field.prepend-top |
30 | = f.check_box :admin | 29 | = f.check_box :admin |
31 | = f.label :admin | 30 | = f.label :admin |
31 | + .span-11 | ||
32 | .field.prepend-top | 32 | .field.prepend-top |
33 | = f.text_field :projects_limit, :class => "small_input" | 33 | = f.text_field :projects_limit, :class => "small_input" |
34 | = f.label :projects_limit | 34 | = f.label :projects_limit |
35 | + | ||
36 | + .field | ||
37 | + = f.label :skype | ||
38 | + %br | ||
39 | + = f.text_field :skype | ||
40 | + .field | ||
41 | + = f.label :linkedin | ||
42 | + %br | ||
43 | + = f.text_field :linkedin | ||
44 | + .field | ||
45 | + = f.label :twitter | ||
46 | + %br | ||
47 | + = f.text_field :twitter | ||
35 | .clear | 48 | .clear |
36 | %br | 49 | %br |
37 | .actions | 50 | .actions |
app/views/admin/users/show.html.haml
@@ -14,6 +14,17 @@ | @@ -14,6 +14,17 @@ | ||
14 | %b Projects limit: | 14 | %b Projects limit: |
15 | = @admin_user.projects_limit | 15 | = @admin_user.projects_limit |
16 | 16 | ||
17 | + %p | ||
18 | + %b Skype: | ||
19 | + = @admin_user.skype | ||
20 | + %p | ||
21 | + %b LinkedIn: | ||
22 | + = @admin_user.linkedin | ||
23 | + %p | ||
24 | + %b Twitter: | ||
25 | + = @admin_user.twitter | ||
26 | + | ||
27 | + | ||
17 | .clear | 28 | .clear |
18 | = link_to 'Edit', edit_admin_user_path(@admin_user) | 29 | = link_to 'Edit', edit_admin_user_path(@admin_user) |
19 | \| | 30 | \| |
app/views/commits/_commits.html.haml
@@ -11,12 +11,12 @@ | @@ -11,12 +11,12 @@ | ||
11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | 11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" |
12 | %p | 12 | %p |
13 | %strong | 13 | %strong |
14 | - = commit.message.length > 60 ? (commit.message[0..59] + "...") : commit.message | 14 | + = truncate_commit_message(commit) |
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 | 1 | .file_stats |
3 | - @commit.diffs.each do |diff| | 2 | - @commit.diffs.each do |diff| |
4 | - if diff.deleted_file | 3 | - if diff.deleted_file |
@@ -35,7 +34,7 @@ | @@ -35,7 +34,7 @@ | ||
35 | %strong{:id => "#{diff.b_path}"}= diff.b_path | 34 | %strong{:id => "#{diff.b_path}"}= diff.b_path |
36 | %br/ | 35 | %br/ |
37 | .diff_file_content | 36 | .diff_file_content |
38 | - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) | 37 | + - if file.text? |
39 | - lines_arr = diff.diff.lines.to_a | 38 | - lines_arr = diff.diff.lines.to_a |
40 | - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 | 39 | - 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 | 40 | - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 |
@@ -50,9 +49,9 @@ | @@ -50,9 +49,9 @@ | ||
50 | - else | 49 | - else |
51 | - line_new += 1 | 50 | - line_new += 1 |
52 | - line_old += 1 | 51 | - line_old += 1 |
53 | - - elsif file.mime_type =~ /image/ | 52 | + - elsif file.image? |
54 | .diff_file_content_image | 53 | .diff_file_content_image |
55 | - %img{:src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"} | 54 | + %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} |
56 | - else | 55 | - else |
57 | %p | 56 | %p |
58 | %center No preview for this file type | 57 | %center No preview for this file type |
app/views/commits/show.html.haml
1 | %h3 | 1 | %h3 |
2 | - = "[ #{@commit.committer} ] #{truncate @commit.message, :length => 80}" | 2 | + = "[ #{@commit.committer} ] #{truncate_commit_message(@commit, 80)}" |
3 | -#= link_to 'Back', project_commits_path(@project), :class => "button" | 3 | -#= link_to 'Back', project_commits_path(@project), :class => "button" |
4 | %table.round-borders | 4 | %table.round-borders |
5 | %tr | 5 | %tr |
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 |
@@ -25,4 +25,4 @@ | @@ -25,4 +25,4 @@ | ||
25 | 25 | ||
26 | .clear | 26 | .clear |
27 | %br | 27 | %br |
28 | - = f.submit 'Add note', :class => "lbutton vm" | 28 | + = f.submit 'Add note', :class => "lbutton vm", :id => "submit_note" |
app/views/notes/_notes.html.haml
1 | -%ul#notes-list | ||
2 | - - @notes.each do |note| | ||
3 | - - next unless note.author | ||
4 | - = render :partial => "notes/show", :locals => {:note => note} | 1 | +- if controller.action_name == "wall" |
2 | + %ul#notes-list= render "notes/notes_list" | ||
5 | 3 | ||
6 | -%br | ||
7 | -%br | ||
8 | -- if can? current_user, :write_note, @project | ||
9 | - = 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" | ||
10 | 10 | ||
11 | :javascript | 11 | :javascript |
12 | $('.delete-note').live('ajax:success', function() { | 12 | $('.delete-note').live('ajax:success', function() { |
13 | $(this).closest('li').fadeOut(); }); | 13 | $(this).closest('li').fadeOut(); }); |
14 | 14 | ||
15 | + $("#new_note").live("ajax:before", function(){ | ||
16 | + $("#submit_note").attr("disabled", "disabled"); | ||
17 | + }) | ||
15 | 18 | ||
19 | + $("#new_note").live("ajax:complete", function(){ | ||
20 | + $("#submit_note").removeAttr("disabled"); | ||
21 | + }) | ||
22 | + | ||
23 | + | ||
24 | +- if ["issues", "projects"].include?(controller.controller_name) | ||
25 | + :javascript | ||
26 | + $(function(){ | ||
27 | + var int =self.setInterval("updatePage()", 20000); | ||
28 | + }); |
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 |
8 | $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); | 8 | $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); |
9 | + | ||
10 | +:plain | ||
11 | + $("#submit_note").removeAttr("disabled"); |
app/views/profile/show.html.haml
@@ -6,3 +6,28 @@ | @@ -6,3 +6,28 @@ | ||
6 | %p | 6 | %p |
7 | %b Email: | 7 | %b Email: |
8 | = @user.email | 8 | = @user.email |
9 | + | ||
10 | +%br | ||
11 | + | ||
12 | += form_for @user, :url => profile_edit_path, :method => :put do |f| | ||
13 | + -if @user.errors.any? | ||
14 | + #error_explanation | ||
15 | + %ul | ||
16 | + - @user.errors.full_messages.each do |msg| | ||
17 | + %li= msg | ||
18 | + | ||
19 | + .div | ||
20 | + = f.label :skype | ||
21 | + %br | ||
22 | + = f.text_field :skype | ||
23 | + .div | ||
24 | + = f.label :linkedin | ||
25 | + %br | ||
26 | + = f.text_field :linkedin | ||
27 | + .div | ||
28 | + = f.label :twitter | ||
29 | + %br | ||
30 | + = f.text_field :twitter | ||
31 | + .actions | ||
32 | + = f.submit 'Save', :class => "lbutton vm" | ||
33 | + |
app/views/projects/_form.html.haml
1 | = form_for(@project, :remote => true) do |f| | 1 | = form_for(@project, :remote => true) do |f| |
2 | %div.form_content | 2 | %div.form_content |
3 | - - if @project.new_record? | ||
4 | - %h1 New Project | ||
5 | - - else | 3 | + - unless @project.new_record? |
6 | %h1 Edit Project | 4 | %h1 Edit Project |
7 | - if @project.errors.any? | 5 | - if @project.errors.any? |
8 | #error_explanation | 6 | #error_explanation |
@@ -26,7 +24,7 @@ | @@ -26,7 +24,7 @@ | ||
26 | %td | 24 | %td |
27 | .left= f.label :code | 25 | .left= f.label :code |
28 | %cite.right http://yourserver/ | 26 | %cite.right http://yourserver/ |
29 | - %td= f.text_field :code, :placeholder => "example (3..12 symbols only)" | 27 | + %td= f.text_field :code, :placeholder => "example" |
30 | .field | 28 | .field |
31 | = f.label :description | 29 | = f.label :description |
32 | %br/ | 30 | %br/ |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +- @commits.each do |commit| | ||
2 | + %div.commit | ||
3 | + - if commit.author.email | ||
4 | + = image_tag gravatar_icon(commit.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" | ||
5 | + - else | ||
6 | + = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | ||
7 | + %p{:style => "margin-bottom: 3px;"} | ||
8 | + %strong | ||
9 | + = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) | ||
10 | + | ||
11 | + %span | ||
12 | + %span.author | ||
13 | + = commit.author.name.force_encoding("UTF-8") | ||
14 | + %cite | ||
15 | + = time_ago_in_words(commit.committed_date) | ||
16 | + ago | ||
17 | + %br | ||
18 | + |
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +- @messages.group_by{ |x| [x.noteable_id, x.noteable_type]}.each do |item, notes| | ||
2 | + - id, type = item[0], item[1] | ||
3 | + - parent = load_note_parent(id, type, @project) | ||
4 | + - next unless parent | ||
5 | + | ||
6 | + - case type | ||
7 | + - when "Issue" | ||
8 | + - css_class = "dash_issue" | ||
9 | + - issue = parent | ||
10 | + - item_code = issue.author.email | ||
11 | + - link_item_name = truncate(issue.title, :length => 50) | ||
12 | + - link_to_item = project_issue_path(@project, issue) | ||
13 | + - when "Snippet" | ||
14 | + - css_class = "dash_snippet" | ||
15 | + - item_code = parent.author.email | ||
16 | + - link_item_name = parent.title | ||
17 | + - link_to_item = project_snippet_path(@project, parent) | ||
18 | + - when "Commit" | ||
19 | + - css_class = "dash_commit" | ||
20 | + - commit = parent | ||
21 | + - item_code = commit.author.email | ||
22 | + - link_item_name = truncate_commit_message(commit, 50) | ||
23 | + - link_to_item = project_commit_path(@project, :id => commit.id) | ||
24 | + - else | ||
25 | + - css_class = "dash_wall" | ||
26 | + - item_code = @project.name | ||
27 | + - link_item_name = "Project Wall" | ||
28 | + - link_to_item = wall_project_path(@project) | ||
29 | + | ||
30 | + %div{ :class => "recent_message_parent #{css_class}"} | ||
31 | + = image_tag gravatar_icon(item_code), :class => "left", :width => 40 | ||
32 | + %h4 | ||
33 | + = link_to(link_item_name, link_to_item) | ||
34 | + %span | ||
35 | + = type | ||
36 | + .clear | ||
37 | + - notes.sort {|x,y| x.updated_at <=> y.updated_at }.each do |note| | ||
38 | + %div.message | ||
39 | + = image_tag gravatar_icon(note.author.email), :class => "left", :width => 24, :style => "padding-right:5px;" | ||
40 | + %p{:style => "margin-bottom: 3px;"} | ||
41 | + %span.author | ||
42 | + = note.author.name | ||
43 | + = link_to truncate(note.note, :length => 200), link_to_item + "#note_#{note.id}" | ||
44 | + - if note.attachment.url | ||
45 | + %br | ||
46 | + Attachment: | ||
47 | + = link_to note.attachment_identifier, note.attachment.url | ||
48 | + %br | ||
49 | + %br | ||
50 | + .append-bottom | ||
51 | + | ||
52 | + .clear |
app/views/projects/_tile.html.haml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | %div{ :class => "project", :url => project_path(project) } | 4 | %div{ :class => "project", :url => project_path(project) } |
5 | %h2 | 5 | %h2 |
6 | = image_tag gravatar_icon(project.name), :class => "left", :width => 40, :style => "padding-right:5px;" | 6 | = image_tag gravatar_icon(project.name), :class => "left", :width => 40, :style => "padding-right:5px;" |
7 | - = "/" + project.code | 7 | + = link_to ("/" + project.code), project_path(project), :style => "text-decoration:none" |
8 | %p= project.name | 8 | %p= project.name |
9 | %p= project.url_to_repo | 9 | %p= project.url_to_repo |
10 | -#%p | 10 | -#%p |
app/views/projects/_top_menu.html.haml
1 | %div.top_project_menu | 1 | %div.top_project_menu |
2 | -#%span= link_to @project.code.capitalize, @project, :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil | 2 | -#%span= link_to @project.code.capitalize, @project, :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil |
3 | - if @project.repo_exists? | 3 | - if @project.repo_exists? |
4 | - %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) || current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil | 4 | + %span= link_to image_tag("home.png", :width => 20), project_path(@project), :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil |
5 | + %span= link_to "Tree", tree_project_path(@project), :class => current_page?(:controller => "projects", :action => "tree", :id => @project) ? "current" : nil | ||
5 | %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 |
6 | %span | 7 | %span |
7 | - = 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 |
8 | Team | 9 | Team |
9 | - if @project.users_projects.count > 0 | 10 | - if @project.users_projects.count > 0 |
10 | %span{ :class => "top_menu_count" }= @project.users_projects.count | 11 | %span{ :class => "top_menu_count" }= @project.users_projects.count |
@@ -18,6 +19,11 @@ | @@ -18,6 +19,11 @@ | ||
18 | Wall | 19 | Wall |
19 | - if @project.common_notes.count > 0 | 20 | - if @project.common_notes.count > 0 |
20 | %span{ :class => "top_menu_count" }= @project.common_notes.count | 21 | %span{ :class => "top_menu_count" }= @project.common_notes.count |
22 | + %span | ||
23 | + = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do | ||
24 | + Snippets | ||
25 | + - if @project.snippets.count > 0 | ||
26 | + %span{ :class => "top_menu_count" }= @project.snippets.count | ||
21 | 27 | ||
22 | - if @commit | 28 | - if @commit |
23 | %span= link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil | 29 | %span= link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil |
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/_tree_item.html.haml
@@ -12,4 +12,4 @@ | @@ -12,4 +12,4 @@ | ||
12 | = time_ago_in_words(content_commit.committed_date) | 12 | = time_ago_in_words(content_commit.committed_date) |
13 | ago | 13 | ago |
14 | %td | 14 | %td |
15 | - = link_to truncate(content_commit.message, :length => 40), project_commit_path(@project, content_commit) | 15 | + = link_to truncate_commit_message(content_commit, 40), project_commit_path(@project, content_commit) |
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 | - %div#tree-holder | ||
3 | - = render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @commit.tree} | 2 | + %h2.left History |
3 | + .right | ||
4 | + = form_tag project_path(@project), :method => :get do | ||
5 | + .span-2 | ||
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" | ||
10 | + = label_tag "day_view","Today" | ||
11 | + .span-2 | ||
12 | + = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view" | ||
13 | + = label_tag "week_view","Week" | ||
14 | + .clear | ||
15 | + %hr | ||
16 | +.span-11 | ||
17 | + %h3 Commits | ||
18 | + =render "projects/recent_commits" | ||
19 | + | ||
20 | +.span-11.right | ||
21 | + %h3 Talk | ||
22 | + =render "projects/recent_messages" | ||
23 | + |
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 | + }); |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +%div | ||
2 | + = form_for [@project, @snippet] do |f| | ||
3 | + -if @snippet.errors.any? | ||
4 | + %ul | ||
5 | + - @snippet.errors.full_messages.each do |msg| | ||
6 | + %li= msg | ||
7 | + | ||
8 | + %table.round-borders | ||
9 | + %tr | ||
10 | + %td= f.label :title | ||
11 | + %td= f.text_field :title, :placeholder => "Example Snippet" | ||
12 | + %tr | ||
13 | + %td= f.label :file_name | ||
14 | + %td= f.text_field :file_name, :placeholder => "example.rb" | ||
15 | + %tr | ||
16 | + %td{:colspan => 2} | ||
17 | + = f.label :content, "Code" | ||
18 | + %br | ||
19 | + = f.text_area :content, :style => "height:240px;width:932px;" | ||
20 | + | ||
21 | + .actions.prepend-top | ||
22 | + = f.submit 'Save', :class => "lbutton vm" |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +%tr{ :id => dom_id(snippet), :class => "snippet", :url => project_snippet_path(@project, snippet) } | ||
2 | + %td | ||
3 | + = image_tag gravatar_icon(snippet.author.email), :class => "left", :width => 40, :style => "padding:0 5px;" | ||
4 | + = truncate snippet.author.name, :lenght => 20 | ||
5 | + %td= html_escape snippet.title | ||
6 | + %td= html_escape snippet.file_name | ||
7 | + %td | ||
8 | + - if can?(current_user, :admin_snippet, @project) || snippet.author == current_user | ||
9 | + = link_to 'Edit', edit_project_snippet_path(@project, snippet), :class => "lbutton positive" | ||
10 | + - if can?(current_user, :admin_snippet, @project) || snippet.author == current_user | ||
11 | + = link_to 'Destroy', [@project, snippet], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-snippet negative", :id => "destroy_snippet_#{snippet.id}" |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | += render "snippets/form" |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +%div | ||
2 | + - if can? current_user, :write_snippet, @project | ||
3 | + .left= link_to 'New Snippet', new_project_snippet_path(@project), :class => "lbutton vm" | ||
4 | + | ||
5 | + %table.round-borders#snippets-table | ||
6 | + %tr | ||
7 | + %th Author | ||
8 | + %th Title | ||
9 | + %th File name | ||
10 | + %th | ||
11 | + = render @snippets | ||
12 | +:javascript | ||
13 | + $('.delete-snippet').live('ajax:success', function() { | ||
14 | + $(this).closest('tr').fadeOut(); }); |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | += render "snippets/form" |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +%h2 | ||
2 | + = "Snippet ##{@snippet.id} - #{@snippet.title}" | ||
3 | + | ||
4 | +.view_file | ||
5 | + .view_file_header | ||
6 | + %strong | ||
7 | + = @snippet.file_name | ||
8 | + %br/ | ||
9 | + .view_file_content | ||
10 | + :erb | ||
11 | + <%= raw @snippet.colorize %> | ||
12 | + | ||
13 | +- if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user | ||
14 | + = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive" | ||
15 | +- if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user | ||
16 | + = link_to 'Destroy', [@project, @snippet], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-snippet negative", :id => "destroy_snippet_#{@snippet.id}" | ||
17 | +.clear | ||
18 | +%br | ||
19 | +.snippet_notes= render "notes/notes" | ||
20 | + | ||
21 | +.clear | ||
22 | + |
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 | + |
config/routes.rb
@@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do | @@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do | ||
13 | get "errors/gitosis" | 13 | get "errors/gitosis" |
14 | get "profile/password", :to => "profile#password" | 14 | get "profile/password", :to => "profile#password" |
15 | put "profile/password", :to => "profile#password_update" | 15 | put "profile/password", :to => "profile#password_update" |
16 | + put "profile/edit", :to => "profile#social_update" | ||
16 | get "profile", :to => "profile#show" | 17 | get "profile", :to => "profile#show" |
17 | #get "profile/:id", :to => "profile#show" | 18 | #get "profile/:id", :to => "profile#show" |
18 | 19 | ||
@@ -38,6 +39,8 @@ Gitlab::Application.routes.draw do | @@ -38,6 +39,8 @@ Gitlab::Application.routes.draw do | ||
38 | } | 39 | } |
39 | 40 | ||
40 | end | 41 | end |
42 | + | ||
43 | + resources :snippets | ||
41 | resources :commits | 44 | resources :commits |
42 | resources :team_members | 45 | resources :team_members |
43 | resources :issues do | 46 | resources :issues do |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +class CreateSnippets < ActiveRecord::Migration | ||
2 | + def change | ||
3 | + create_table :snippets do |t| | ||
4 | + t.string :title | ||
5 | + t.text :content | ||
6 | + t.integer :author_id, :null => false | ||
7 | + t.integer :project_id, :null => false | ||
8 | + | ||
9 | + t.timestamps | ||
10 | + end | ||
11 | + end | ||
12 | +end |
db/migrate/20111016193417_add_content_type_to_snippets.rb
0 → 100644
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 => 20111015154310) 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" |
@@ -56,6 +56,16 @@ ActiveRecord::Schema.define(:version => 20111015154310) do | @@ -56,6 +56,16 @@ ActiveRecord::Schema.define(:version => 20111015154310) do | ||
56 | t.integer "owner_id" | 56 | t.integer "owner_id" |
57 | end | 57 | end |
58 | 58 | ||
59 | + create_table "snippets", :force => true do |t| | ||
60 | + t.string "title" | ||
61 | + t.text "content" | ||
62 | + t.integer "author_id", :null => false | ||
63 | + t.integer "project_id", :null => false | ||
64 | + t.datetime "created_at" | ||
65 | + t.datetime "updated_at" | ||
66 | + t.string "file_name" | ||
67 | + end | ||
68 | + | ||
59 | create_table "users", :force => true do |t| | 69 | create_table "users", :force => true do |t| |
60 | t.string "email", :default => "", :null => false | 70 | t.string "email", :default => "", :null => false |
61 | t.string "encrypted_password", :limit => 128, :default => "", :null => false | 71 | t.string "encrypted_password", :limit => 128, :default => "", :null => false |
@@ -72,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111015154310) do | @@ -72,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111015154310) do | ||
72 | t.string "name" | 82 | t.string "name" |
73 | t.boolean "admin", :default => false, :null => false | 83 | t.boolean "admin", :default => false, :null => false |
74 | t.integer "projects_limit", :default => 10 | 84 | t.integer "projects_limit", :default => 10 |
85 | + t.string "skype", :default => "", :null => false | ||
86 | + t.string "linkedin", :default => "", :null => false | ||
87 | + t.string "twitter", :default => "", :null => false | ||
75 | end | 88 | end |
76 | 89 | ||
77 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true | 90 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true |
lib/color.rb
@@ -11,6 +11,10 @@ module Color | @@ -11,6 +11,10 @@ module Color | ||
11 | colorize(text, "32m") | 11 | colorize(text, "32m") |
12 | end | 12 | end |
13 | 13 | ||
14 | + def yellow(text) | ||
15 | + colorize(text, "93m") | ||
16 | + end | ||
17 | + | ||
14 | def command(string) | 18 | def command(string) |
15 | `#{string}` | 19 | `#{string}` |
16 | if $?.to_i > 0 | 20 | if $?.to_i > 0 |
lib/gitosis.rb
@@ -27,13 +27,11 @@ class Gitosis | @@ -27,13 +27,11 @@ class Gitosis | ||
27 | def configure | 27 | def configure |
28 | status = Timeout::timeout(20) do | 28 | status = Timeout::timeout(20) do |
29 | File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f| | 29 | File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f| |
30 | - begin | 30 | + begin |
31 | f.flock(File::LOCK_EX) | 31 | f.flock(File::LOCK_EX) |
32 | - | ||
33 | pull | 32 | pull |
34 | yield(self) | 33 | yield(self) |
35 | push | 34 | push |
36 | - | ||
37 | ensure | 35 | ensure |
38 | f.flock(File::LOCK_UN) | 36 | f.flock(File::LOCK_UN) |
39 | end | 37 | end |
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/factories.rb
@@ -35,6 +35,12 @@ Factory.add(:issue, Issue) do |obj| | @@ -35,6 +35,12 @@ Factory.add(:issue, Issue) do |obj| | ||
35 | obj.content = Faker::Lorem.sentences | 35 | obj.content = Faker::Lorem.sentences |
36 | end | 36 | end |
37 | 37 | ||
38 | +Factory.add(:snippet, Snippet) do |obj| | ||
39 | + obj.title = Faker::Lorem.sentence | ||
40 | + obj.file_name = Faker::Lorem.sentence | ||
41 | + obj.content = Faker::Lorem.sentences | ||
42 | +end | ||
43 | + | ||
38 | Factory.add(:note, Note) do |obj| | 44 | Factory.add(:note, Note) do |obj| |
39 | obj.note = Faker::Lorem.sentence | 45 | obj.note = Faker::Lorem.sentence |
40 | end | 46 | end |
spec/models/issue_spec.rb
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe Snippet do | ||
4 | + describe "Associations" do | ||
5 | + it { should belong_to(:project) } | ||
6 | + it { should belong_to(:author) } | ||
7 | + end | ||
8 | + | ||
9 | + describe "Validation" do | ||
10 | + it { should validate_presence_of(:title) } | ||
11 | + it { should validate_presence_of(:author_id) } | ||
12 | + it { should validate_presence_of(:project_id) } | ||
13 | + it { should validate_presence_of(:file_name) } | ||
14 | + it { should validate_presence_of(:content) } | ||
15 | + end | ||
16 | +end | ||
17 | +# == Schema Information | ||
18 | +# | ||
19 | +# Table name: snippets | ||
20 | +# | ||
21 | +# id :integer not null, primary key | ||
22 | +# title :string(255) | ||
23 | +# content :text | ||
24 | +# author_id :integer not null | ||
25 | +# project_id :integer not null | ||
26 | +# created_at :datetime | ||
27 | +# updated_at :datetime | ||
28 | +# file_name :string(255) | ||
29 | +# | ||
30 | + |
spec/models/user_spec.rb
@@ -39,5 +39,8 @@ end | @@ -39,5 +39,8 @@ end | ||
39 | # name :string(255) | 39 | # name :string(255) |
40 | # admin :boolean default(FALSE), not null | 40 | # admin :boolean default(FALSE), not null |
41 | # projects_limit :integer | 41 | # projects_limit :integer |
42 | +# skype :string | ||
43 | +# linkedin :string | ||
44 | +# twitter :string | ||
42 | # | 45 | # |
43 | 46 |
spec/requests/profile_spec.rb
@@ -14,6 +14,22 @@ describe "Profile" do | @@ -14,6 +14,22 @@ describe "Profile" do | ||
14 | it { page.should have_content(@user.email) } | 14 | it { page.should have_content(@user.email) } |
15 | end | 15 | end |
16 | 16 | ||
17 | + describe "Profile update" do | ||
18 | + before do | ||
19 | + visit profile_path | ||
20 | + fill_in "user_skype", :with => "testskype" | ||
21 | + fill_in "user_linkedin", :with => "testlinkedin" | ||
22 | + fill_in "user_twitter", :with => "testtwitter" | ||
23 | + click_button "Save" | ||
24 | + @user.reload | ||
25 | + end | ||
26 | + | ||
27 | + it { @user.skype.should == 'testskype' } | ||
28 | + it { @user.linkedin.should == 'testlinkedin' } | ||
29 | + it { @user.twitter.should == 'testtwitter' } | ||
30 | + end | ||
31 | + | ||
32 | + | ||
17 | describe "Password update" do | 33 | describe "Password update" do |
18 | before do | 34 | before do |
19 | visit profile_password_path | 35 | visit profile_password_path |
spec/requests/projects_security_spec.rb
@@ -82,12 +82,18 @@ describe "Projects" do | @@ -82,12 +82,18 @@ describe "Projects" do | ||
82 | end | 82 | end |
83 | 83 | ||
84 | describe "GET /project_code/blob" do | 84 | describe "GET /project_code/blob" do |
85 | - it { blob_project_path(@project).should be_allowed_for @u1 } | ||
86 | - it { blob_project_path(@project).should be_allowed_for @u3 } | ||
87 | - it { blob_project_path(@project).should be_denied_for :admin } | ||
88 | - it { blob_project_path(@project).should be_denied_for @u2 } | ||
89 | - it { blob_project_path(@project).should be_denied_for :user } | ||
90 | - it { blob_project_path(@project).should be_denied_for :visitor } | 85 | + before do |
86 | + @commit = @project.commit | ||
87 | + @path = @commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name | ||
88 | + @blob_path = blob_project_path(@project, :commit_id => @commit.id, :path => @path) | ||
89 | + end | ||
90 | + | ||
91 | + it { @blob_path.should be_allowed_for @u1 } | ||
92 | + it { @blob_path.should be_allowed_for @u3 } | ||
93 | + it { @blob_path.should be_denied_for :admin } | ||
94 | + it { @blob_path.should be_denied_for @u2 } | ||
95 | + it { @blob_path.should be_denied_for :user } | ||
96 | + it { @blob_path.should be_denied_for :visitor } | ||
91 | end | 97 | end |
92 | 98 | ||
93 | describe "GET /project_code/edit" do | 99 | describe "GET /project_code/edit" do |
@@ -107,5 +113,14 @@ describe "Projects" do | @@ -107,5 +113,14 @@ describe "Projects" do | ||
107 | it { project_issues_path(@project).should be_denied_for :user } | 113 | it { project_issues_path(@project).should be_denied_for :user } |
108 | it { project_issues_path(@project).should be_denied_for :visitor } | 114 | it { project_issues_path(@project).should be_denied_for :visitor } |
109 | end | 115 | end |
116 | + | ||
117 | + describe "GET /project_code/snippets" do | ||
118 | + it { project_snippets_path(@project).should be_allowed_for @u1 } | ||
119 | + it { project_snippets_path(@project).should be_allowed_for @u3 } | ||
120 | + it { project_snippets_path(@project).should be_denied_for :admin } | ||
121 | + it { project_snippets_path(@project).should be_denied_for @u2 } | ||
122 | + it { project_snippets_path(@project).should be_denied_for :user } | ||
123 | + it { project_snippets_path(@project).should be_denied_for :visitor } | ||
124 | + end | ||
110 | end | 125 | end |
111 | end | 126 | end |
spec/requests/projects_spec.rb
@@ -72,7 +72,10 @@ describe "Projects" do | @@ -72,7 +72,10 @@ describe "Projects" do | ||
72 | current_path.should == project_path(@project) | 72 | current_path.should == project_path(@project) |
73 | end | 73 | end |
74 | 74 | ||
75 | - it_behaves_like :tree_view | 75 | + it "should beahave like dashboard" do |
76 | + page.should have_content("History") | ||
77 | + end | ||
78 | + | ||
76 | end | 79 | end |
77 | 80 | ||
78 | describe "GET /projects/team" do | 81 | describe "GET /projects/team" do |
@@ -134,8 +137,6 @@ describe "Projects" do | @@ -134,8 +137,6 @@ describe "Projects" do | ||
134 | it "should show project" do | 137 | it "should show project" do |
135 | page.should have_content("Awesome") | 138 | page.should have_content("Awesome") |
136 | end | 139 | end |
137 | - | ||
138 | - it_behaves_like :tree_view | ||
139 | end | 140 | end |
140 | 141 | ||
141 | #describe "DELETE /projects/:id", :js => true do | 142 | #describe "DELETE /projects/:id", :js => true do |
@@ -0,0 +1,101 @@ | @@ -0,0 +1,101 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe "Snippets" do | ||
4 | + let(:project) { Factory :project } | ||
5 | + | ||
6 | + before do | ||
7 | + login_as :user | ||
8 | + project.add_access(@user, :read, :write) | ||
9 | + end | ||
10 | + | ||
11 | + describe "GET /snippets" do | ||
12 | + before do | ||
13 | + @snippet = Factory :snippet, | ||
14 | + :author => @user, | ||
15 | + :project => project | ||
16 | + | ||
17 | + visit project_snippets_path(project) | ||
18 | + end | ||
19 | + | ||
20 | + subject { page } | ||
21 | + | ||
22 | + it { should have_content(@snippet.title) } | ||
23 | + it { should have_content(@snippet.project.name) } | ||
24 | + it { should have_content(@snippet.author.name) } | ||
25 | + | ||
26 | + describe "Destroy" do | ||
27 | + before do | ||
28 | + # admin access to remove snippet | ||
29 | + @user.users_projects.destroy_all | ||
30 | + project.add_access(@user, :read, :write, :admin) | ||
31 | + visit project_snippets_path(project) | ||
32 | + end | ||
33 | + | ||
34 | + it "should remove entry" do | ||
35 | + expect { | ||
36 | + click_link "destroy_snippet_#{@snippet.id}" | ||
37 | + }.to change { Snippet.count }.by(-1) | ||
38 | + end | ||
39 | + end | ||
40 | + end | ||
41 | + | ||
42 | + describe "New snippet" do | ||
43 | + before do | ||
44 | + visit project_snippets_path(project) | ||
45 | + click_link "New Snippet" | ||
46 | + end | ||
47 | + | ||
48 | + it "should open new snippet popup" do | ||
49 | + page.current_path.should == new_project_snippet_path(project) | ||
50 | + end | ||
51 | + | ||
52 | + describe "fill in" do | ||
53 | + before do | ||
54 | + fill_in "snippet_title", :with => "login function" | ||
55 | + fill_in "snippet_file_name", :with => "test.rb" | ||
56 | + fill_in "snippet_content", :with => "def login; end" | ||
57 | + end | ||
58 | + | ||
59 | + it { expect { click_button "Save" }.to change {Snippet.count}.by(1) } | ||
60 | + | ||
61 | + it "should add new snippet to table" do | ||
62 | + click_button "Save" | ||
63 | + page.current_path.should == project_snippet_path(project, Snippet.last) | ||
64 | + page.should have_content "login function" | ||
65 | + page.should have_content "test.rb" | ||
66 | + end | ||
67 | + end | ||
68 | + end | ||
69 | + | ||
70 | + describe "Edit snippet" do | ||
71 | + before do | ||
72 | + @snippet = Factory :snippet, | ||
73 | + :author => @user, | ||
74 | + :project => project | ||
75 | + visit project_snippets_path(project) | ||
76 | + click_link "Edit" | ||
77 | + end | ||
78 | + | ||
79 | + it "should open edit page" do | ||
80 | + page.current_path.should == edit_project_snippet_path(project, @snippet) | ||
81 | + end | ||
82 | + | ||
83 | + describe "fill in" do | ||
84 | + before do | ||
85 | + fill_in "snippet_title", :with => "login function" | ||
86 | + fill_in "snippet_file_name", :with => "test.rb" | ||
87 | + fill_in "snippet_content", :with => "def login; end" | ||
88 | + end | ||
89 | + | ||
90 | + it { expect { click_button "Save" }.to_not change {Snippet.count} } | ||
91 | + | ||
92 | + it "should update snippet fields" do | ||
93 | + click_button "Save" | ||
94 | + | ||
95 | + page.current_path.should == project_snippet_path(project, @snippet) | ||
96 | + page.should have_content "login function" | ||
97 | + page.should have_content "test.rb" | ||
98 | + end | ||
99 | + end | ||
100 | + end | ||
101 | +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/requests/user_security_spec.rb
@@ -7,10 +7,10 @@ describe "Users Security" do | @@ -7,10 +7,10 @@ describe "Users Security" do | ||
7 | end | 7 | end |
8 | 8 | ||
9 | describe "GET /login" do | 9 | describe "GET /login" do |
10 | - it { new_user_session_path.should be_denied_for @u1 } | ||
11 | - it { new_user_session_path.should be_denied_for :admin } | ||
12 | - it { new_user_session_path.should be_denied_for :user } | ||
13 | - it { new_user_session_path.should be_allowed_for :visitor } | 10 | + #it { new_user_session_path.should be_denied_for @u1 } |
11 | + #it { new_user_session_path.should be_denied_for :admin } | ||
12 | + #it { new_user_session_path.should be_denied_for :user } | ||
13 | + it { new_user_session_path.should_not be_404_for :visitor } | ||
14 | end | 14 | end |
15 | 15 | ||
16 | describe "GET /keys" do | 16 | describe "GET /keys" do |
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 |
spec/support/matchers.rb
@@ -21,17 +21,30 @@ RSpec::Matchers.define :be_denied_for do |user| | @@ -21,17 +21,30 @@ RSpec::Matchers.define :be_denied_for do |user| | ||
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 | ||
24 | +RSpec::Matchers.define :be_404_for do |user| | ||
25 | + match do |url| | ||
26 | + include UrlAccess | ||
27 | + url_404?(user, url) | ||
28 | + end | ||
29 | +end | ||
30 | + | ||
24 | module UrlAccess | 31 | module UrlAccess |
25 | def url_allowed?(user, url) | 32 | def url_allowed?(user, url) |
26 | emulate_user(user) | 33 | emulate_user(user) |
27 | visit url | 34 | visit url |
28 | - result = (current_path == url) | 35 | + (page.status_code != 404 && current_path != new_user_session_path) |
29 | end | 36 | end |
30 | 37 | ||
31 | def url_denied?(user, url) | 38 | def url_denied?(user, url) |
32 | emulate_user(user) | 39 | emulate_user(user) |
33 | visit url | 40 | visit url |
34 | - result = (current_path != url) | 41 | + (page.status_code == 404 || current_path == new_user_session_path) |
42 | + end | ||
43 | + | ||
44 | + def url_404?(user, url) | ||
45 | + emulate_user(user) | ||
46 | + visit url | ||
47 | + page.status_code == 404 | ||
35 | end | 48 | end |
36 | 49 | ||
37 | def emulate_user(user) | 50 | def emulate_user(user) |
update.rb
@@ -2,6 +2,10 @@ root_path = File.expand_path(File.dirname(__FILE__)) | @@ -2,6 +2,10 @@ root_path = File.expand_path(File.dirname(__FILE__)) | ||
2 | require File.join(root_path, "lib", "color") | 2 | require File.join(root_path, "lib", "color") |
3 | include Color | 3 | include Color |
4 | 4 | ||
5 | +def version | ||
6 | + File.read("VERSION") | ||
7 | +end | ||
8 | + | ||
5 | # | 9 | # |
6 | # ruby ./update.rb development # or test or production (default) | 10 | # ruby ./update.rb development # or test or production (default) |
7 | # | 11 | # |
@@ -12,15 +16,29 @@ env = if envs.include?(ARGV[0]) | @@ -12,15 +16,29 @@ env = if envs.include?(ARGV[0]) | ||
12 | "production" | 16 | "production" |
13 | end | 17 | end |
14 | 18 | ||
15 | -puts green " == Update for ENV=#{env}" | 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 1x" | ||
23 | +`git pull origin 1x` # pull from origin | ||
16 | 24 | ||
17 | -# pull from github | ||
18 | -`git pull` | 25 | +# latest version |
26 | +if version == current_version | ||
27 | + puts yellow "You have a latest version" | ||
28 | +else | ||
29 | + puts green "Update to #{version}" | ||
19 | 30 | ||
20 | `bundle install` | 31 | `bundle install` |
21 | 32 | ||
22 | -# migrate db | 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 | ||
23 | `bundle exec rake db:migrate RAILS_ENV=#{env}` | 38 | `bundle exec rake db:migrate RAILS_ENV=#{env}` |
39 | +end | ||
40 | + | ||
41 | + puts green "== Done! Now you can start/restart server" | ||
42 | +end | ||
24 | 43 | ||
25 | 44 | ||
26 | -puts green " == Done! Now you can start/restart server" |