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 | 16 | v 1.0.1 |
| 2 | 17 | - fixed: with invalid source code for commit |
| 3 | 18 | - fixed: lose branch/tag selection when use tree navigateion |
| 4 | 19 | - when history clicked - display path |
| 5 | 20 | - bug fix & code cleaning |
| 21 | + | |
| 6 | 22 | v 1.0.0 |
| 7 | 23 | - bug fix |
| 8 | 24 | - projects preview mode |
| 25 | + | |
| 9 | 26 | v 0.9.6 |
| 10 | 27 | - css fix |
| 11 | 28 | - new repo empty tree until restart server - fixed |
| 29 | + | |
| 12 | 30 | v 0.9.4 |
| 13 | 31 | - security improved |
| 14 | 32 | - authorization improved |
| ... | ... | @@ -24,6 +42,7 @@ v 0.9.1 |
| 24 | 42 | - updated app name |
| 25 | 43 | - issue redesigned |
| 26 | 44 | - issue can be edit |
| 45 | + | |
| 27 | 46 | v 0.8.0 |
| 28 | 47 | - sytax highlight for main file types |
| 29 | 48 | - redesign | ... | ... |
Gemfile
| ... | ... | @@ -15,7 +15,7 @@ gem 'therubyracer' |
| 15 | 15 | gem 'faker' |
| 16 | 16 | gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' |
| 17 | 17 | gem "inifile" |
| 18 | -gem "albino", :git => "git://github.com/gitlabhq/albino.git" | |
| 18 | +gem "pygments.rb", "0.2.3" | |
| 19 | 19 | gem "kaminari" |
| 20 | 20 | gem "thin" |
| 21 | 21 | gem "git" | ... | ... |
Gemfile.lock
| ... | ... | @@ -5,13 +5,6 @@ GIT |
| 5 | 5 | annotate (2.4.1.beta1) |
| 6 | 6 | |
| 7 | 7 | GIT |
| 8 | - remote: git://github.com/gitlabhq/albino.git | |
| 9 | - revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1 | |
| 10 | - specs: | |
| 11 | - albino (1.3.3) | |
| 12 | - posix-spawn (>= 0.3.6) | |
| 13 | - | |
| 14 | -GIT | |
| 15 | 8 | remote: git://github.com/gitlabhq/grit.git |
| 16 | 9 | revision: ff015074ef35bd94cba943f9c0f98e161ab5851c |
| 17 | 10 | specs: |
| ... | ... | @@ -72,6 +65,7 @@ GEM |
| 72 | 65 | ZenTest (= 4.5) |
| 73 | 66 | awesome_print (0.4.0) |
| 74 | 67 | bcrypt-ruby (3.0.1) |
| 68 | + blankslate (2.1.2.4) | |
| 75 | 69 | builder (3.0.0) |
| 76 | 70 | capybara (1.0.1) |
| 77 | 71 | mime-types (>= 1.16) |
| ... | ... | @@ -138,6 +132,8 @@ GEM |
| 138 | 132 | orm_adapter (0.0.5) |
| 139 | 133 | polyglot (0.3.2) |
| 140 | 134 | posix-spawn (0.3.6) |
| 135 | + pygments.rb (0.2.3) | |
| 136 | + rubypython (>= 0.5.1) | |
| 141 | 137 | rack (1.3.2) |
| 142 | 138 | rack-cache (1.0.3) |
| 143 | 139 | rack (>= 0.4) |
| ... | ... | @@ -189,6 +185,9 @@ GEM |
| 189 | 185 | ruby-debug-base19 (>= 0.11.19) |
| 190 | 186 | ruby_core_source (0.1.5) |
| 191 | 187 | archive-tar-minitar (>= 0.5.2) |
| 188 | + rubypython (0.5.1) | |
| 189 | + blankslate (>= 2.1.2.3) | |
| 190 | + ffi (~> 1.0.7) | |
| 192 | 191 | rubyzip (0.9.4) |
| 193 | 192 | sass (3.1.7) |
| 194 | 193 | sass-rails (3.1.1) |
| ... | ... | @@ -242,7 +241,6 @@ PLATFORMS |
| 242 | 241 | |
| 243 | 242 | DEPENDENCIES |
| 244 | 243 | acts_as_list |
| 245 | - albino! | |
| 246 | 244 | annotate! |
| 247 | 245 | autotest |
| 248 | 246 | autotest-rails |
| ... | ... | @@ -260,6 +258,7 @@ DEPENDENCIES |
| 260 | 258 | jquery-rails |
| 261 | 259 | kaminari |
| 262 | 260 | launchy |
| 261 | + pygments.rb (= 0.2.3) | |
| 263 | 262 | rails (= 3.1.0) |
| 264 | 263 | rails-footnotes (>= 3.7.5.rc4) |
| 265 | 264 | rspec-rails | ... | ... |
VERSION
271 Bytes
app/assets/javascripts/application.js
app/assets/stylesheets/highlight.css.scss
| ... | ... | @@ -22,8 +22,8 @@ td.linenos{ |
| 22 | 22 | |
| 23 | 23 | .highlight{ |
| 24 | 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 | 28 | .highlight pre{ |
| 29 | 29 | } |
| ... | ... | @@ -43,7 +43,7 @@ td.linenos { |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | td.code .highlight { |
| 46 | - overflow-x: scroll; | |
| 46 | + overflow: auto; | |
| 47 | 47 | } |
| 48 | 48 | table.highlighttable pre{ |
| 49 | 49 | padding:0; | ... | ... |
app/assets/stylesheets/projects.css.scss
| ... | ... | @@ -310,6 +310,7 @@ input.ssh_project_url { |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | #projects-list .project, |
| 313 | +#snippets-table .snippet, | |
| 313 | 314 | #issues-table .issue{ |
| 314 | 315 | cursor:pointer; |
| 315 | 316 | |
| ... | ... | @@ -360,6 +361,8 @@ input.ssh_project_url { |
| 360 | 361 | .user_new, |
| 361 | 362 | .edit_user, |
| 362 | 363 | .new_project, |
| 364 | +.new_snippet, | |
| 365 | +.edit_snippet, | |
| 363 | 366 | .edit_project { |
| 364 | 367 | input[type='text'], |
| 365 | 368 | input[type='email'], |
| ... | ... | @@ -488,8 +491,14 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
| 488 | 491 | background: white; |
| 489 | 492 | } |
| 490 | 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 | 521 | } |
| 513 | 522 | .note_content { |
| 514 | 523 | float:left; |
| 515 | - width:750px; | |
| 524 | + width:650px; | |
| 516 | 525 | } |
| 517 | 526 | |
| 518 | 527 | .issue_notes { |
| ... | ... | @@ -549,3 +558,83 @@ tbody tr:nth-child(2n) td, tbody tr.even td { |
| 549 | 558 | height: 12px; |
| 550 | 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 | 27 | end |
| 28 | 28 | |
| 29 | 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 | 31 | end |
| 32 | 32 | |
| 33 | 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 | 39 | end |
| 36 | 40 | |
| 37 | 41 | def method_missing(method_sym, *arguments, &block) | ... | ... |
app/controllers/issues_controller.rb
| 1 | 1 | class IssuesController < ApplicationController |
| 2 | 2 | before_filter :authenticate_user! |
| 3 | 3 | before_filter :project |
| 4 | + before_filter :issue, :only => [:edit, :update, :destroy, :show] | |
| 4 | 5 | |
| 5 | 6 | # Authorize |
| 6 | 7 | before_filter :add_project_abilities |
| 7 | 8 | before_filter :authorize_read_issue! |
| 8 | 9 | before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort] |
| 9 | - before_filter :authorize_admin_issue!, :only => [:destroy] | |
| 10 | 10 | |
| 11 | 11 | respond_to :js |
| 12 | 12 | |
| ... | ... | @@ -30,12 +30,10 @@ class IssuesController < ApplicationController |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | def edit |
| 33 | - @issue = @project.issues.find(params[:id]) | |
| 34 | 33 | respond_with(@issue) |
| 35 | 34 | end |
| 36 | 35 | |
| 37 | 36 | def show |
| 38 | - @issue = @project.issues.find(params[:id]) | |
| 39 | 37 | @notes = @issue.notes |
| 40 | 38 | @note = @project.notes.new(:noteable => @issue) |
| 41 | 39 | end |
| ... | ... | @@ -51,7 +49,6 @@ class IssuesController < ApplicationController |
| 51 | 49 | end |
| 52 | 50 | |
| 53 | 51 | def update |
| 54 | - @issue = @project.issues.find(params[:id]) | |
| 55 | 52 | @issue.update_attributes(params[:issue]) |
| 56 | 53 | |
| 57 | 54 | respond_to do |format| |
| ... | ... | @@ -62,7 +59,8 @@ class IssuesController < ApplicationController |
| 62 | 59 | |
| 63 | 60 | |
| 64 | 61 | def destroy |
| 65 | - @issue = @project.issues.find(params[:id]) | |
| 62 | + return access_denied! unless can?(current_user, :admin_issue, @issue) | |
| 63 | + | |
| 66 | 64 | @issue.destroy |
| 67 | 65 | |
| 68 | 66 | respond_to do |format| |
| ... | ... | @@ -79,4 +77,10 @@ class IssuesController < ApplicationController |
| 79 | 77 | |
| 80 | 78 | render :nothing => true |
| 81 | 79 | end |
| 80 | + | |
| 81 | + protected | |
| 82 | + | |
| 83 | + def issue | |
| 84 | + @issue ||= @project.issues.find(params[:id]) | |
| 85 | + end | |
| 82 | 86 | end | ... | ... |
app/controllers/notes_controller.rb
| ... | ... | @@ -4,7 +4,6 @@ class NotesController < ApplicationController |
| 4 | 4 | # Authorize |
| 5 | 5 | before_filter :add_project_abilities |
| 6 | 6 | before_filter :authorize_write_note!, :only => [:create] |
| 7 | - before_filter :authorize_admin_note!, :only => [:destroy] | |
| 8 | 7 | |
| 9 | 8 | respond_to :js |
| 10 | 9 | |
| ... | ... | @@ -25,6 +24,9 @@ class NotesController < ApplicationController |
| 25 | 24 | |
| 26 | 25 | def destroy |
| 27 | 26 | @note = @project.notes.find(params[:id]) |
| 27 | + | |
| 28 | + return access_denied! unless can?(current_user, :admin_note, @note) | |
| 29 | + | |
| 28 | 30 | @note.destroy |
| 29 | 31 | |
| 30 | 32 | respond_to do |format| |
| ... | ... | @@ -41,6 +43,8 @@ class NotesController < ApplicationController |
| 41 | 43 | Notify.note_commit_email(u, @note).deliver |
| 42 | 44 | when "Issue" then |
| 43 | 45 | Notify.note_issue_email(u, @note).deliver |
| 46 | + when "Snippet" | |
| 47 | + true | |
| 44 | 48 | else |
| 45 | 49 | Notify.note_wall_email(u, @note).deliver |
| 46 | 50 | end | ... | ... |
app/controllers/profile_controller.rb
| ... | ... | @@ -3,6 +3,12 @@ class ProfileController < ApplicationController |
| 3 | 3 | @user = current_user |
| 4 | 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 | 12 | def password |
| 7 | 13 | @user = current_user |
| 8 | 14 | end | ... | ... |
app/controllers/projects_controller.rb
| ... | ... | @@ -60,14 +60,21 @@ class ProjectsController < ApplicationController |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 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 | 78 | end |
| 72 | 79 | end |
| 73 | 80 | |
| ... | ... | @@ -76,8 +83,15 @@ class ProjectsController < ApplicationController |
| 76 | 83 | # |
| 77 | 84 | |
| 78 | 85 | def wall |
| 79 | - @notes = @project.common_notes | |
| 80 | 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 | 95 | end |
| 82 | 96 | |
| 83 | 97 | # | ... | ... |
| ... | ... | @@ -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 | 3 | |
| 4 | 4 | # Authorize |
| 5 | 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 | 9 | def show |
| 10 | 10 | @team_member = project.users_projects.find(params[:id]) | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -53,25 +53,4 @@ module ApplicationHelper |
| 53 | 53 | [projects, default_nav, project_nav].flatten.to_json |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | - def handle_file_type(file_name, mime_type) | |
| 57 | - if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ | |
| 58 | - :ruby | |
| 59 | - elsif file_name =~ /\.py$/ | |
| 60 | - :python | |
| 61 | - elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ | |
| 62 | - $1[1..-1].to_sym | |
| 63 | - elsif file_name =~ /\.js$/ | |
| 64 | - :javascript | |
| 65 | - elsif file_name =~ /\.sh$/ | |
| 66 | - :bash | |
| 67 | - elsif file_name =~ /\.coffee$/ | |
| 68 | - :coffeescript | |
| 69 | - elsif file_name =~ /\.yml$/ | |
| 70 | - :yaml | |
| 71 | - elsif file_name =~ /\.md$/ | |
| 72 | - :minid | |
| 73 | - else | |
| 74 | - :text | |
| 75 | - end | |
| 76 | - end | |
| 77 | 56 | end | ... | ... |
app/helpers/commits_helper.rb
| ... | ... | @@ -21,4 +21,13 @@ module CommitsHelper |
| 21 | 21 | link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), |
| 22 | 22 | :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" |
| 23 | 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 | 33 | end | ... | ... |
app/helpers/projects_helper.rb
| ... | ... | @@ -3,4 +3,16 @@ module ProjectsHelper |
| 3 | 3 | cookies["project_view"] ||= "tile" |
| 4 | 4 | cookies["project_view"] == type ? nil : "display:none" |
| 5 | 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 | 18 | end | ... | ... |
app/models/ability.rb
| ... | ... | @@ -2,6 +2,9 @@ class Ability |
| 2 | 2 | def self.allowed(object, subject) |
| 3 | 3 | case subject.class.name |
| 4 | 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 | 8 | else [] |
| 6 | 9 | end |
| 7 | 10 | end |
| ... | ... | @@ -12,6 +15,7 @@ class Ability |
| 12 | 15 | rules << [ |
| 13 | 16 | :read_project, |
| 14 | 17 | :read_issue, |
| 18 | + :read_snippet, | |
| 15 | 19 | :read_team_member, |
| 16 | 20 | :read_note |
| 17 | 21 | ] if project.readers.include?(user) |
| ... | ... | @@ -19,16 +23,35 @@ class Ability |
| 19 | 23 | rules << [ |
| 20 | 24 | :write_project, |
| 21 | 25 | :write_issue, |
| 26 | + :write_snippet, | |
| 22 | 27 | :write_note |
| 23 | 28 | ] if project.writers.include?(user) |
| 24 | 29 | |
| 25 | 30 | rules << [ |
| 26 | 31 | :admin_project, |
| 27 | 32 | :admin_issue, |
| 33 | + :admin_snippet, | |
| 28 | 34 | :admin_team_member, |
| 29 | 35 | :admin_note |
| 30 | 36 | ] if project.admins.include?(user) |
| 31 | 37 | |
| 32 | 38 | rules.flatten |
| 33 | 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 | 57 | end | ... | ... |
app/models/issue.rb
app/models/note.rb
| ... | ... | @@ -22,6 +22,10 @@ class Note < ActiveRecord::Base |
| 22 | 22 | |
| 23 | 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 | 29 | mount_uploader :attachment, AttachmentUploader |
| 26 | 30 | end |
| 27 | 31 | # == Schema Information | ... | ... |
app/models/project.rb
| ... | ... | @@ -7,6 +7,7 @@ class Project < ActiveRecord::Base |
| 7 | 7 | has_many :users_projects, :dependent => :destroy |
| 8 | 8 | has_many :users, :through => :users_projects |
| 9 | 9 | has_many :notes, :dependent => :destroy |
| 10 | + has_many :snippets, :dependent => :destroy | |
| 10 | 11 | |
| 11 | 12 | validates :name, |
| 12 | 13 | :uniqueness => true, |
| ... | ... | @@ -125,6 +126,34 @@ class Project < ActiveRecord::Base |
| 125 | 126 | end |
| 126 | 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 | 157 | def tree(fcommit, path = nil) |
| 129 | 158 | fcommit = commit if fcommit == :head |
| 130 | 159 | tree = fcommit.tree | ... | ... |
| ... | ... | @@ -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 | 5 | :recoverable, :rememberable, :trackable, :validatable |
| 6 | 6 | |
| 7 | 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 | 11 | has_many :users_projects, :dependent => :destroy |
| 11 | 12 | has_many :projects, :through => :users_projects |
| ... | ... | @@ -58,5 +59,8 @@ end |
| 58 | 59 | # name :string(255) |
| 59 | 60 | # admin :boolean default(FALSE), not null |
| 60 | 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 | 25 | = f.label :password_confirmation |
| 26 | 26 | %br |
| 27 | 27 | = f.password_field :password_confirmation |
| 28 | - .span-11 | |
| 29 | - .field.prepend-top.append-bottom | |
| 28 | + .field.prepend-top | |
| 30 | 29 | = f.check_box :admin |
| 31 | 30 | = f.label :admin |
| 31 | + .span-11 | |
| 32 | 32 | .field.prepend-top |
| 33 | 33 | = f.text_field :projects_limit, :class => "small_input" |
| 34 | 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 | 48 | .clear |
| 36 | 49 | %br |
| 37 | 50 | .actions | ... | ... |
app/views/admin/users/show.html.haml
| ... | ... | @@ -14,6 +14,17 @@ |
| 14 | 14 | %b Projects limit: |
| 15 | 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 | 28 | .clear |
| 18 | 29 | = link_to 'Edit', edit_admin_user_path(@admin_user) |
| 19 | 30 | \| | ... | ... |
app/views/commits/_commits.html.haml
| ... | ... | @@ -11,12 +11,12 @@ |
| 11 | 11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" |
| 12 | 12 | %p |
| 13 | 13 | %strong |
| 14 | - = commit.message.length > 60 ? (commit.message[0..59] + "...") : commit.message | |
| 14 | + = truncate_commit_message(commit) | |
| 15 | 15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" |
| 16 | 16 | = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" |
| 17 | 17 | %span |
| 18 | - %span | |
| 19 | - [ #{commit.author} ] | |
| 18 | + %span.author | |
| 19 | + = commit.author | |
| 20 | 20 | = time_ago_in_words(commit.committed_date) |
| 21 | 21 | ago |
| 22 | 22 | = more_commits_link if @commits.size > 99 | ... | ... |
app/views/commits/_diff.html.haml
| 1 | -- require "utils" | |
| 2 | 1 | .file_stats |
| 3 | 2 | - @commit.diffs.each do |diff| |
| 4 | 3 | - if diff.deleted_file |
| ... | ... | @@ -35,7 +34,7 @@ |
| 35 | 34 | %strong{:id => "#{diff.b_path}"}= diff.b_path |
| 36 | 35 | %br/ |
| 37 | 36 | .diff_file_content |
| 38 | - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) | |
| 37 | + - if file.text? | |
| 39 | 38 | - lines_arr = diff.diff.lines.to_a |
| 40 | 39 | - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0 |
| 41 | 40 | - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0 |
| ... | ... | @@ -50,9 +49,9 @@ |
| 50 | 49 | - else |
| 51 | 50 | - line_new += 1 |
| 52 | 51 | - line_old += 1 |
| 53 | - - elsif file.mime_type =~ /image/ | |
| 52 | + - elsif file.image? | |
| 54 | 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 | 55 | - else |
| 57 | 56 | %p |
| 58 | 57 | %center No preview for this file type | ... | ... |
app/views/commits/show.html.haml
app/views/commits/show.js.haml
| 1 | -:plain | |
| 1 | +-#:plain | |
| 2 | 2 | $("#side-commit-preview").remove(); |
| 3 | 3 | var side = $("<div id='side-commit-preview'></div>"); |
| 4 | 4 | side.html("#{escape_javascript(render "commits/show")}"); |
| 5 | 5 | $("##{dom_id(@project)}").parent().append(side); |
| 6 | 6 | $("##{dom_id(@project)}").addClass("span-14"); |
| 7 | +:plain | |
| 8 | + $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | ... | ... |
app/views/notes/_form.html.haml
| ... | ... | @@ -12,9 +12,9 @@ |
| 12 | 12 | = f.label :note |
| 13 | 13 | %cite (255 symbols only) |
| 14 | 14 | %br |
| 15 | - = f.text_area :note, :style => "width:97%;height:100px", :size => 255 | |
| 15 | + = f.text_area :note, :size => 255 | |
| 16 | 16 | |
| 17 | - %div | |
| 17 | + %div.attach_holder | |
| 18 | 18 | = f.label :attachment |
| 19 | 19 | %cite (less than 10 MB) |
| 20 | 20 | %br |
| ... | ... | @@ -25,4 +25,4 @@ |
| 25 | 25 | |
| 26 | 26 | .clear |
| 27 | 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 | 11 | :javascript |
| 12 | 12 | $('.delete-note').live('ajax:success', function() { |
| 13 | 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 | 1 | %li{:id => dom_id(note)} |
| 2 | 2 | %div.note_author |
| 3 | 3 | = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" |
| 4 | - %div.note_content | |
| 4 | + %div.note_content.left | |
| 5 | 5 | = simple_format(html_escape(note.note)) |
| 6 | 6 | - if note.attachment.url |
| 7 | 7 | Attachment: |
| 8 | - = link_to note.attachment_identifier, note.attachment.url | |
| 8 | + = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" | |
| 9 | 9 | %br |
| 10 | - %span | |
| 11 | - %span | |
| 12 | - [ #{note.author.name} ] | |
| 13 | - | |
| 10 | + %span.author= note.author.name | |
| 11 | + %cite.ago | |
| 14 | 12 | = time_ago_in_words(note.updated_at) |
| 15 | 13 | ago |
| 16 | - %br | |
| 14 | + %br | |
| 17 | 15 | - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) |
| 18 | 16 | = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative" |
| 19 | 17 | .clear | ... | ... |
app/views/notes/create.js.haml
| 1 | 1 | - if @note.valid? |
| 2 | 2 | :plain |
| 3 | 3 | $("#new_note .errors").remove(); |
| 4 | - $("#notes-list").append("#{escape_javascript(render(:partial => 'show', :locals => {:note => @note} ))}"); | |
| 4 | + updatePage(); | |
| 5 | 5 | $('#note_note').val(""); |
| 6 | 6 | - else |
| 7 | 7 | :plain |
| 8 | 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 | 6 | %p |
| 7 | 7 | %b Email: |
| 8 | 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 | 1 | = form_for(@project, :remote => true) do |f| |
| 2 | 2 | %div.form_content |
| 3 | - - if @project.new_record? | |
| 4 | - %h1 New Project | |
| 5 | - - else | |
| 3 | + - unless @project.new_record? | |
| 6 | 4 | %h1 Edit Project |
| 7 | 5 | - if @project.errors.any? |
| 8 | 6 | #error_explanation |
| ... | ... | @@ -26,7 +24,7 @@ |
| 26 | 24 | %td |
| 27 | 25 | .left= f.label :code |
| 28 | 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 | 28 | .field |
| 31 | 29 | = f.label :description |
| 32 | 30 | %br/ | ... | ... |
| ... | ... | @@ -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 @@ |
| 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 | 4 | %div{ :class => "project", :url => project_path(project) } |
| 5 | 5 | %h2 |
| 6 | 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 | 8 | %p= project.name |
| 9 | 9 | %p= project.url_to_repo |
| 10 | 10 | -#%p | ... | ... |
app/views/projects/_top_menu.html.haml
| 1 | 1 | %div.top_project_menu |
| 2 | 2 | -#%span= link_to @project.code.capitalize, @project, :class => current_page?(:controller => "projects", :action => "show", :id => @project) ? "current" : nil |
| 3 | 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 | 6 | %span= link_to "Commits", project_commits_path(@project), :class => current_page?(:controller => "commits", :action => "index", :project_id => @project) ? "current" : nil |
| 6 | 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 | 9 | Team |
| 9 | 10 | - if @project.users_projects.count > 0 |
| 10 | 11 | %span{ :class => "top_menu_count" }= @project.users_projects.count |
| ... | ... | @@ -18,6 +19,11 @@ |
| 18 | 19 | Wall |
| 19 | 20 | - if @project.common_notes.count > 0 |
| 20 | 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 | 28 | - if @commit |
| 23 | 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 | 2 | .view_file |
| 3 | 3 | .view_file_header |
| 4 | 4 | %strong |
| ... | ... | @@ -6,14 +6,13 @@ |
| 6 | 6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" |
| 7 | 7 | = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" |
| 8 | 8 | %br/ |
| 9 | - - if file.mime_type =~ /application|text/ && !Utils.binary?(file.data) | |
| 9 | + - if file.text? | |
| 10 | 10 | .view_file_content |
| 11 | - - ft = handle_file_type(file.name, file.mime_type) | |
| 12 | 11 | :erb |
| 13 | - <%= raw Albino.colorize(content, ft, :html, 'utf-8', "linenos=True") %> | |
| 14 | - - elsif file.mime_type =~ /image/ | |
| 12 | + <%= raw file.colorize %> | |
| 13 | + - elsif file.image? | |
| 15 | 14 | .view_file_content_image |
| 16 | - %img{ :src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"} | |
| 15 | + %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | |
| 17 | 16 | - else |
| 18 | 17 | %p |
| 19 | 18 | %center No preview for this file type | ... | ... |
app/views/projects/_tree_item.html.haml
| ... | ... | @@ -12,4 +12,4 @@ |
| 12 | 12 | = time_ago_in_words(content_commit.committed_date) |
| 13 | 13 | ago |
| 14 | 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 | 2 | <div class=""> |
| 2 | 3 | <div class="git-empty"> |
| 3 | 4 | <h2>Git global setup:</h2> |
| ... | ... | @@ -6,7 +7,7 @@ git config --global user.name "#{current_user.name}" |
| 6 | 7 | git config --global user.email "#{current_user.email}" |
| 7 | 8 | eos |
| 8 | 9 | %> |
| 9 | - <%= raw Albino.colorize(setup_str, :bash) %> | |
| 10 | + <%= raw bash_lexer.highlight(setup_str) %> | |
| 10 | 11 | <br /> |
| 11 | 12 | <br /> |
| 12 | 13 | <h2>Next steps:</h2> |
| ... | ... | @@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo} |
| 21 | 22 | git push -u origin master |
| 22 | 23 | eos |
| 23 | 24 | %> |
| 24 | - <%= raw Albino.colorize(repo_setup_str, :bash) %> | |
| 25 | + <%= raw bash_lexer.highlight(repo_setup_str) %> | |
| 25 | 26 | |
| 26 | 27 | <br /><br /> |
| 27 | 28 | <h2>Existing Git Repo?</h2> |
| ... | ... | @@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo} |
| 31 | 32 | git push -u origin master |
| 32 | 33 | eos |
| 33 | 34 | %> |
| 34 | - <%= raw Albino.colorize(exist_repo_setup_str, :bash) %> | |
| 35 | + <%= raw bash_lexer.highlight(exist_repo_setup_str) %> | |
| 35 | 36 | |
| 36 | 37 | <br /><br /> |
| 37 | 38 | <h2>Remove this project?</h2> | ... | ... |
app/views/projects/show.html.haml
| 1 | 1 | %div |
| 2 | - %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 | 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 @@ |
| 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 @@ |
| 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 @@ |
| 1 | += render "snippets/form" | ... | ... |
| ... | ... | @@ -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 @@ |
| 1 | += render "snippets/form" | ... | ... |
| ... | ... | @@ -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 | 1 | - user = member.user |
| 2 | 2 | %tr{:id => dom_id(member)} |
| 3 | 3 | %td |
| 4 | - = image_tag gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;" | |
| 5 | - = truncate user.name, :lenght => 16 | |
| 4 | + = link_to image_tag(gravatar_icon(user.email), :class => "left", :width => 40, :style => "padding:0 5px;"), project_team_member_path(@project, member) | |
| 5 | + | |
| 6 | + = link_to truncate(user.name, :lenght => 16), project_team_member_path(@project, member) | |
| 7 | + | |
| 6 | 8 | %td= truncate user.email, :lenght => 16 |
| 7 | 9 | - if can? current_user, :admin_project, @project |
| 8 | 10 | = form_for(member, :as => :team_member, :url => project_team_member_path(@project, member)) do |f| | ... | ... |
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +- user = @team_member.user | |
| 2 | +.span-2 | |
| 3 | + = image_tag gravatar_icon(user.email), :class => "left", :width => 60, :style => "padding-right:5px;" | |
| 4 | +%p | |
| 5 | + %b Name: | |
| 6 | + = user.name | |
| 7 | +%p | |
| 8 | + %b Email: | |
| 9 | + = user.email | |
| 10 | + | |
| 11 | +%br | |
| 12 | + | |
| 13 | +- unless user.skype.empty? | |
| 14 | + .div | |
| 15 | + %b Skype: | |
| 16 | + = user.skype | |
| 17 | + | |
| 18 | +- unless user.linkedin.empty? | |
| 19 | + .div | |
| 20 | + %b LinkedIn: | |
| 21 | + = user.linkedin | |
| 22 | + | |
| 23 | +- unless user.twitter.empty? | |
| 24 | + .div | |
| 25 | + %b Twitter: | |
| 26 | + = user.twitter | |
| 27 | + | |
| 28 | + | ... | ... |
config/routes.rb
| ... | ... | @@ -13,6 +13,7 @@ Gitlab::Application.routes.draw do |
| 13 | 13 | get "errors/gitosis" |
| 14 | 14 | get "profile/password", :to => "profile#password" |
| 15 | 15 | put "profile/password", :to => "profile#password_update" |
| 16 | + put "profile/edit", :to => "profile#social_update" | |
| 16 | 17 | get "profile", :to => "profile#show" |
| 17 | 18 | #get "profile/:id", :to => "profile#show" |
| 18 | 19 | |
| ... | ... | @@ -38,6 +39,8 @@ Gitlab::Application.routes.draw do |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | end |
| 42 | + | |
| 43 | + resources :snippets | |
| 41 | 44 | resources :commits |
| 42 | 45 | resources :team_members |
| 43 | 46 | resources :issues do | ... | ... |
| ... | ... | @@ -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 @@ |
| 1 | +class ChangeSocialFieldsInUsers < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + remove_column :users, :skype | |
| 4 | + remove_column :users, :linkedin | |
| 5 | + remove_column :users, :twitter | |
| 6 | + | |
| 7 | + add_column :users, :skype, :string, {:null => false, :default => ''} | |
| 8 | + add_column :users, :linkedin, :string, {:null => false, :default => ''} | |
| 9 | + add_column :users, :twitter, :string, {:null => false, :default => ''} | |
| 10 | + end | |
| 11 | + | |
| 12 | + def down | |
| 13 | + end | |
| 14 | +end | ... | ... |
db/schema.rb
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | # |
| 12 | 12 | # It's strongly recommended to check this file into your version control system. |
| 13 | 13 | |
| 14 | -ActiveRecord::Schema.define(:version => 20111015154310) do | |
| 14 | +ActiveRecord::Schema.define(:version => 20111021101550) do | |
| 15 | 15 | |
| 16 | 16 | create_table "issues", :force => true do |t| |
| 17 | 17 | t.string "title" |
| ... | ... | @@ -56,6 +56,16 @@ ActiveRecord::Schema.define(:version => 20111015154310) do |
| 56 | 56 | t.integer "owner_id" |
| 57 | 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 | 69 | create_table "users", :force => true do |t| |
| 60 | 70 | t.string "email", :default => "", :null => false |
| 61 | 71 | t.string "encrypted_password", :limit => 128, :default => "", :null => false |
| ... | ... | @@ -72,6 +82,9 @@ ActiveRecord::Schema.define(:version => 20111015154310) do |
| 72 | 82 | t.string "name" |
| 73 | 83 | t.boolean "admin", :default => false, :null => false |
| 74 | 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 | 88 | end |
| 76 | 89 | |
| 77 | 90 | add_index "users", ["email"], :name => "index_users_on_email", :unique => true | ... | ... |
lib/color.rb
lib/gitosis.rb
| ... | ... | @@ -27,13 +27,11 @@ class Gitosis |
| 27 | 27 | def configure |
| 28 | 28 | status = Timeout::timeout(20) do |
| 29 | 29 | File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f| |
| 30 | - begin | |
| 30 | + begin | |
| 31 | 31 | f.flock(File::LOCK_EX) |
| 32 | - | |
| 33 | 32 | pull |
| 34 | 33 | yield(self) |
| 35 | 34 | push |
| 36 | - | |
| 37 | 35 | ensure |
| 38 | 36 | f.flock(File::LOCK_UN) |
| 39 | 37 | end | ... | ... |
lib/utils.rb
| 1 | 1 | module Utils |
| 2 | - def self.binary?(string) | |
| 3 | - string.each_byte do |x| | |
| 4 | - x.nonzero? or return true | |
| 2 | + module FileHelper | |
| 3 | + def binary?(string) | |
| 4 | + string.each_byte do |x| | |
| 5 | + x.nonzero? or return true | |
| 6 | + end | |
| 7 | + false | |
| 8 | + end | |
| 9 | + | |
| 10 | + def image? | |
| 11 | + mime_type =~ /image/ | |
| 12 | + end | |
| 13 | + | |
| 14 | + def text? | |
| 15 | + mime_type =~ /application|text/ && !binary?(data) | |
| 16 | + end | |
| 17 | + end | |
| 18 | + | |
| 19 | + module Colorize | |
| 20 | + def colorize | |
| 21 | + system_colorize(data, name) | |
| 22 | + end | |
| 23 | + | |
| 24 | + def system_colorize(data, file_name) | |
| 25 | + ft = handle_file_type(file_name) | |
| 26 | + Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' }) | |
| 27 | + end | |
| 28 | + | |
| 29 | + def handle_file_type(file_name, mime_type = nil) | |
| 30 | + if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ | |
| 31 | + :ruby | |
| 32 | + elsif file_name =~ /\.py$/ | |
| 33 | + :python | |
| 34 | + elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ | |
| 35 | + $1[1..-1].to_sym | |
| 36 | + elsif file_name =~ /\.js$/ | |
| 37 | + :javascript | |
| 38 | + elsif file_name =~ /\.sh$/ | |
| 39 | + :bash | |
| 40 | + elsif file_name =~ /\.coffee$/ | |
| 41 | + :coffeescript | |
| 42 | + elsif file_name =~ /\.yml$/ | |
| 43 | + :yaml | |
| 44 | + elsif file_name =~ /\.md$/ | |
| 45 | + :minid | |
| 46 | + else | |
| 47 | + :text | |
| 48 | + end | |
| 5 | 49 | end |
| 6 | - false | |
| 7 | 50 | end |
| 8 | 51 | end | ... | ... |
spec/factories.rb
| ... | ... | @@ -35,6 +35,12 @@ Factory.add(:issue, Issue) do |obj| |
| 35 | 35 | obj.content = Faker::Lorem.sentences |
| 36 | 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 | 44 | Factory.add(:note, Note) do |obj| |
| 39 | 45 | obj.note = Faker::Lorem.sentence |
| 40 | 46 | end | ... | ... |
spec/models/issue_spec.rb
| ... | ... | @@ -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
spec/requests/profile_spec.rb
| ... | ... | @@ -14,6 +14,22 @@ describe "Profile" do |
| 14 | 14 | it { page.should have_content(@user.email) } |
| 15 | 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 | 33 | describe "Password update" do |
| 18 | 34 | before do |
| 19 | 35 | visit profile_password_path | ... | ... |
spec/requests/projects_security_spec.rb
| ... | ... | @@ -82,12 +82,18 @@ describe "Projects" do |
| 82 | 82 | end |
| 83 | 83 | |
| 84 | 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 | 97 | end |
| 92 | 98 | |
| 93 | 99 | describe "GET /project_code/edit" do |
| ... | ... | @@ -107,5 +113,14 @@ describe "Projects" do |
| 107 | 113 | it { project_issues_path(@project).should be_denied_for :user } |
| 108 | 114 | it { project_issues_path(@project).should be_denied_for :visitor } |
| 109 | 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 | 125 | end |
| 111 | 126 | end | ... | ... |
spec/requests/projects_spec.rb
| ... | ... | @@ -72,7 +72,10 @@ describe "Projects" do |
| 72 | 72 | current_path.should == project_path(@project) |
| 73 | 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 | 79 | end |
| 77 | 80 | |
| 78 | 81 | describe "GET /projects/team" do |
| ... | ... | @@ -134,8 +137,6 @@ describe "Projects" do |
| 134 | 137 | it "should show project" do |
| 135 | 138 | page.should have_content("Awesome") |
| 136 | 139 | end |
| 137 | - | |
| 138 | - it_behaves_like :tree_view | |
| 139 | 140 | end |
| 140 | 141 | |
| 141 | 142 | #describe "DELETE /projects/:id", :js => true do | ... | ... |
| ... | ... | @@ -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 | 7 | @project.add_access(@user, :read, :admin) |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | + describe "View profile" do | |
| 11 | + it "should be available" do | |
| 12 | + visit(team_project_path(@project)) | |
| 13 | + find(:xpath, "//table[@id='team-table']//a[1]").click | |
| 14 | + page.should have_content @user.skype | |
| 15 | + page.should_not have_content 'Twitter' | |
| 16 | + end | |
| 17 | + end | |
| 18 | + | |
| 10 | 19 | describe "New Team member", :js => true do |
| 11 | 20 | before do |
| 12 | 21 | @user_1 = Factory :user | ... | ... |
spec/requests/user_security_spec.rb
| ... | ... | @@ -7,10 +7,10 @@ describe "Users Security" do |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 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 | 14 | end |
| 15 | 15 | |
| 16 | 16 | describe "GET /keys" do | ... | ... |
spec/support/login.rb
| ... | ... | @@ -3,7 +3,8 @@ module LoginMacros |
| 3 | 3 | @user = User.create(:email => "user#{User.count}@mail.com", |
| 4 | 4 | :name => "John Smith", |
| 5 | 5 | :password => "123456", |
| 6 | - :password_confirmation => "123456") | |
| 6 | + :password_confirmation => "123456", | |
| 7 | + :skype => 'user_skype') | |
| 7 | 8 | |
| 8 | 9 | if role == :admin |
| 9 | 10 | @user.admin = true | ... | ... |
spec/support/matchers.rb
| ... | ... | @@ -21,17 +21,30 @@ RSpec::Matchers.define :be_denied_for do |user| |
| 21 | 21 | end |
| 22 | 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 | 31 | module UrlAccess |
| 25 | 32 | def url_allowed?(user, url) |
| 26 | 33 | emulate_user(user) |
| 27 | 34 | visit url |
| 28 | - result = (current_path == url) | |
| 35 | + (page.status_code != 404 && current_path != new_user_session_path) | |
| 29 | 36 | end |
| 30 | 37 | |
| 31 | 38 | def url_denied?(user, url) |
| 32 | 39 | emulate_user(user) |
| 33 | 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 | 48 | end |
| 36 | 49 | |
| 37 | 50 | def emulate_user(user) | ... | ... |
update.rb
| ... | ... | @@ -2,6 +2,10 @@ root_path = File.expand_path(File.dirname(__FILE__)) |
| 2 | 2 | require File.join(root_path, "lib", "color") |
| 3 | 3 | include Color |
| 4 | 4 | |
| 5 | +def version | |
| 6 | + File.read("VERSION") | |
| 7 | +end | |
| 8 | + | |
| 5 | 9 | # |
| 6 | 10 | # ruby ./update.rb development # or test or production (default) |
| 7 | 11 | # |
| ... | ... | @@ -12,15 +16,29 @@ env = if envs.include?(ARGV[0]) |
| 12 | 16 | "production" |
| 13 | 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 | 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 | 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" | ... | ... |