diff --git a/.rubocop.yml b/.rubocop.yml index 03b78d6884..0cc729d3b0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -954,7 +954,7 @@ Lint/Void: Rails/ActionFilter: Description: 'Enforces consistent use of action filter methods.' - Enabled: false + Enabled: true Rails/DefaultScope: Description: 'Checks if the argument passed to default_scope is a block.' diff --git a/CHANGELOG b/CHANGELOG index b2c783ef9d..d53429a5d4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,14 +3,20 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.11.0 (unreleased) - Fix clone URL field and X11 Primary selection (Dmitry Medvinsky) - Ignore invalid lines in .gitmodules + - Fix "Cannot move project" error message from popping up after a successful transfer (Stan Hu) + - Redirect to sign in page after signing out. + - + - Add "Reply quoting selected text" shortcut key (`r`) + - Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention. + - Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention. - - - - - - - - - - + - Move snippets UI to fluid layout + - Improve UI for sidebar. Increase separation between navigation and content - Improve new project command options (Ben Bodenmiller) + - Prevent sending empty messages to HipChat (Chulki Lee) v 7.10.0 (unreleased) - Ignore submodules that are defined in .gitmodules but are checked in as directories. @@ -38,7 +44,6 @@ v 7.10.0 (unreleased) - Allow HTML tags in Markdown input - Fix code unfold not working on Compare commits page (Stan Hu) - Fix generating SSH key fingerprints with OpenSSH 6.8. (Sašo Stanovnik) - - Include missing events and fix save functionality in admin service template settings form (Stan Hu) - Fix "Import projects from" button to show the correct instructions (Stan Hu) - Fix dots in Wiki slugs causing errors (Stan Hu) - Make maximum attachment size configurable via Application Settings (Stan Hu) diff --git a/Gemfile b/Gemfile index e26127a4ad..238337d773 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem "browser" gem "gitlab_git", '~> 7.1.10' # Ruby/Rack Git Smart-HTTP Server Handler -gem 'gitlab-grack', '~> 2.0.0.rc2', require: 'grack' +gem 'gitlab-grack', '~> 2.0.2', require: 'grack' # LDAP Auth gem 'gitlab_omniauth-ldap', '1.2.1', require: "omniauth-ldap" @@ -89,7 +89,7 @@ gem "six" gem "seed-fu" # Markup pipeline for GitLab -gem 'html-pipeline-gitlab', '~> 0.1' +gem 'html-pipeline', '~> 1.11.0' # Markdown to HTML gem "github-markup" @@ -144,7 +144,7 @@ gem "redis-rails" gem 'tinder', '~> 1.9.2' # HipChat integration -gem "hipchat", "~> 1.4.0" +gem 'hipchat', '~> 1.5.0' # Flowdock integration gem "gitlab-flowdock-git-hook", "~> 0.4.2" @@ -252,12 +252,13 @@ group :development, :test do # PhantomJS driver for Capybara gem 'poltergeist', '~> 1.5.1' - gem 'jasmine', '2.0.2' + gem 'jasmine', '~> 2.2.0' + gem 'jasmine-rails' gem "spring", '~> 1.3.1' gem "spring-commands-rspec", '1.0.4' gem "spring-commands-spinach", '1.0.0' - + gem "byebug" end diff --git a/Gemfile.lock b/Gemfile.lock index 3129c53515..9d17cd1128 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,7 +199,7 @@ GEM gitlab-flowdock-git-hook (0.4.2.2) gitlab-grit (>= 2.4.1) multi_json - gitlab-grack (2.0.0) + gitlab-grack (2.0.2) rack (~> 1.5.1) gitlab-grit (2.7.2) charlock_holmes (~> 0.6) @@ -271,20 +271,15 @@ GEM hashie (2.1.2) highline (1.6.21) hike (1.2.3) - hipchat (1.4.0) + hipchat (1.5.0) httparty + mimemagic hitimes (1.2.2) html-pipeline (1.11.0) activesupport (>= 2) nokogiri (~> 1.4) - html-pipeline-gitlab (0.2.0) - actionpack (~> 4) - gitlab_emoji (~> 0.1) - html-pipeline (~> 1.11.0) - mime-types - sanitize (~> 2.1) http_parser.rb (0.5.3) - httparty (0.13.0) + httparty (0.13.3) json (~> 1.8) multi_xml (>= 0.5.2) httpauth (0.2.1) @@ -292,12 +287,17 @@ GEM i18n (0.7.0) ice_cube (0.11.1) ice_nine (0.10.0) - jasmine (2.0.2) - jasmine-core (~> 2.0.0) + jasmine (2.2.0) + jasmine-core (~> 2.2) phantomjs rack (>= 1.2.1) rake - jasmine-core (2.0.0) + jasmine-core (2.2.0) + jasmine-rails (0.10.8) + jasmine-core (>= 1.3, < 3.0) + phantomjs (>= 1.9) + railties (>= 3.2.0) + sprockets-rails jquery-atwho-rails (0.3.3) jquery-rails (3.1.0) railties (>= 3.0, < 5.0) @@ -329,6 +329,7 @@ GEM mime-types (>= 1.16, < 3) method_source (0.8.2) mime-types (1.25.1) + mimemagic (0.3.0) mini_portile (0.6.1) minitest (5.3.5) mousetrap-rails (1.4.6) @@ -391,7 +392,7 @@ GEM parser (2.2.0.2) ast (>= 1.1, < 3.0) pg (0.15.1) - phantomjs (1.9.2.0) + phantomjs (1.9.8.0) poltergeist (1.5.1) capybara (~> 2.1) cliver (~> 0.3.1) @@ -700,7 +701,7 @@ DEPENDENCIES gemnasium-gitlab-service (~> 0.2) github-markup gitlab-flowdock-git-hook (~> 0.4.2) - gitlab-grack (~> 2.0.0.rc2) + gitlab-grack (~> 2.0.2) gitlab-linguist (~> 3.0.1) gitlab_emoji (~> 0.1) gitlab_git (~> 7.1.10) @@ -714,10 +715,11 @@ DEPENDENCIES guard-rspec guard-spinach haml-rails - hipchat (~> 1.4.0) - html-pipeline-gitlab (~> 0.1) + hipchat (~> 1.5.0) + html-pipeline (~> 1.11.0) httparty - jasmine (= 2.0.2) + jasmine (~> 2.2.0) + jasmine-rails jquery-atwho-rails (~> 0.3.3) jquery-rails jquery-scrollto-rails diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index bd52d3d4d7..020c103dbc 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -38,7 +38,7 @@ #= require shortcuts #= require shortcuts_navigation #= require shortcuts_dashboard_navigation -#= require shortcuts_issueable +#= require shortcuts_issuable #= require shortcuts_network #= require cal-heatmap #= require_tree . @@ -173,6 +173,7 @@ $ -> $(@).closest(".diff-file").find(".notes_holder").toggle() e.preventDefault() + $(document).off "click", '.js-confirm-danger' $(document).on "click", '.js-confirm-danger', (e) -> e.preventDefault() btn = $(e.target) diff --git a/app/assets/javascripts/confirm_danger_modal.js.coffee b/app/assets/javascripts/confirm_danger_modal.js.coffee index bb99edbd09..66e34dd4a0 100644 --- a/app/assets/javascripts/confirm_danger_modal.js.coffee +++ b/app/assets/javascripts/confirm_danger_modal.js.coffee @@ -8,11 +8,13 @@ class @ConfirmDangerModal submit = $('.js-confirm-danger-submit') submit.disable() + $('.js-confirm-danger-input').off 'input' $('.js-confirm-danger-input').on 'input', -> if rstrip($(@).val()) is project_path submit.enable() else submit.disable() + $('.js-confirm-danger-submit').off 'click' $('.js-confirm-danger-submit').on 'click', => @form.submit() diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 012acf2a19..3314507352 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -22,7 +22,7 @@ class Dispatcher shortcut_handler = new ShortcutsNavigation() when 'projects:issues:show' new Issue() - shortcut_handler = new ShortcutsIssueable() + shortcut_handler = new ShortcutsIssuable() new ZenMode() when 'projects:milestones:show' new Milestone() @@ -47,7 +47,7 @@ class Dispatcher new IssuableForm($('.merge-request-form')) when 'projects:merge_requests:show' new Diff() - shortcut_handler = new ShortcutsIssueable() + shortcut_handler = new ShortcutsIssuable() new ZenMode() when "projects:merge_requests:diffs" new Diff() diff --git a/app/assets/javascripts/shortcuts_issuable.coffee b/app/assets/javascripts/shortcuts_issuable.coffee new file mode 100644 index 0000000000..6b534f2921 --- /dev/null +++ b/app/assets/javascripts/shortcuts_issuable.coffee @@ -0,0 +1,48 @@ +#= require jquery +#= require mousetrap + +#= require shortcuts_navigation + +class @ShortcutsIssuable extends ShortcutsNavigation + constructor: (isMergeRequest) -> + super() + Mousetrap.bind('a', -> + $('.js-assignee').select2('open') + return false + ) + Mousetrap.bind('m', -> + $('.js-milestone').select2('open') + return false + ) + Mousetrap.bind('r', => + @replyWithSelectedText() + return false + ) + + if isMergeRequest + @enabledHelp.push('.hidden-shortcut.merge_requests') + else + @enabledHelp.push('.hidden-shortcut.issues') + + replyWithSelectedText: -> + if window.getSelection + selected = window.getSelection().toString() + replyField = $('.js-main-target-form #note_note') + + return if selected.trim() == "" + + # Put a '>' character before each non-empty line in the selection + quote = _.map selected.split("\n"), (val) -> + "> #{val}\n" if val.trim() != '' + + # If replyField already has some content, add a newline before our quote + separator = replyField.val().trim() != "" and "\n" or '' + + replyField.val (_, current) -> + current + separator + quote.join('') + "\n" + + # Trigger autosave for the added text + replyField.trigger('input') + + # Focus the input field + replyField.focus() diff --git a/app/assets/javascripts/shortcuts_issueable.coffee b/app/assets/javascripts/shortcuts_issueable.coffee deleted file mode 100644 index b8dae71e03..0000000000 --- a/app/assets/javascripts/shortcuts_issueable.coffee +++ /dev/null @@ -1,19 +0,0 @@ -#= require shortcuts_navigation - -class @ShortcutsIssueable extends ShortcutsNavigation - constructor: (isMergeRequest) -> - super() - Mousetrap.bind('a', -> - $('.js-assignee').select2('open') - return false - ) - Mousetrap.bind('m', -> - $('.js-milestone').select2('open') - return false - ) - - if isMergeRequest - @enabledHelp.push('.hidden-shortcut.merge_reuests') - else - @enabledHelp.push('.hidden-shortcut.issues') - diff --git a/app/assets/javascripts/sidebar.js.coffee b/app/assets/javascripts/sidebar.js.coffee index 2e3f560825..fb08016fba 100644 --- a/app/assets/javascripts/sidebar.js.coffee +++ b/app/assets/javascripts/sidebar.js.coffee @@ -4,6 +4,7 @@ $(document).on("click", '.toggle-nav-collapse', (e) -> expanded = 'page-sidebar-expanded' $('.page-with-sidebar').toggleClass("#{collapsed} #{expanded}") + $('header').toggleClass("header-collapsed header-expanded") $('.toggle-nav-collapse i').toggleClass("fa-angle-right fa-angle-left") $.cookie("collapsed_nav", $('.page-with-sidebar').hasClass(collapsed), { path: '/' }) ) diff --git a/app/assets/javascripts/stat_graph_contributors.js.coffee b/app/assets/javascripts/stat_graph_contributors.js.coffee index 27f0fd31d5..ed12bdcef2 100644 --- a/app/assets/javascripts/stat_graph_contributors.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors.js.coffee @@ -1,3 +1,7 @@ +#= require d3 +#= require jquery +#= require stat_graph_contributors_util + class @ContributorsStatGraph init: (log) -> @parsed_log = ContributorsStatGraphUtil.parse_log(log) diff --git a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee index 8b82d20c6c..0e6fbdef3b 100644 --- a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee @@ -1,3 +1,7 @@ +#= require d3 +#= require jquery +#= require underscore + class @ContributorsGraph MARGIN: top: 20 diff --git a/app/assets/stylesheets/base/mixins.scss b/app/assets/stylesheets/base/mixins.scss index 216f25cdcd..feff931156 100644 --- a/app/assets/stylesheets/base/mixins.scss +++ b/app/assets/stylesheets/base/mixins.scss @@ -50,13 +50,6 @@ @include box-shadow(0 0 0 3px #f1f1f1); } -@mixin header-font { - color: $style_color; - font-size: 16px; - line-height: 44px; - font-weight: normal; -} - @mixin md-typography { font-size: 15px; line-height: 1.5; diff --git a/app/assets/stylesheets/pages/header.scss b/app/assets/stylesheets/generic/header.scss similarity index 66% rename from app/assets/stylesheets/pages/header.scss rename to app/assets/stylesheets/generic/header.scss index dde19b801f..b861646191 100644 --- a/app/assets/stylesheets/pages/header.scss +++ b/app/assets/stylesheets/generic/header.scss @@ -11,9 +11,55 @@ header { width: 100%; .navbar-inner { + background: #FFF; + border-bottom: 1px solid #DDD; filter: none; + .title { + position: relative; + float: left; + margin: 0; + margin-left: 25px; + font-size: 18px; + line-height: 44px; + font-weight: normal; + color: #555; + + @include str-truncated(37%); + + a { + color: #555; + &:hover { + text-decoration: underline; + } + } + } + + .app_logo { + border-bottom: 1px solid transparent; + margin-bottom: -1px; + + a { + padding: 5px 8px; + + img { + float: left; + } + + h3 { + width: 158px; + float: left; + margin: 0; + margin-left: 20px; + font-size: 18px; + line-height: 34px; + font-weight: normal; + } + } + } + .nav > li > a { + color: #666; font-size: 14px; line-height: 32px; padding: 6px 10px; @@ -30,15 +76,10 @@ header { } .navbar-toggle { - color: $style_color; + color: #666; margin: 0; - padding: 10px; border-radius: 0; - button i { font-size: 22px; } - - &.collapsed { background-color: transparent !important;} - &:hover { background-color: #EEE; } @@ -60,8 +101,6 @@ header { .navbar-collapse { margin-top: 47px; - padding-right: 0; - padding-left: 0; } .navbar-nav { @@ -100,10 +139,8 @@ header { a { float: left; - padding: 5px 0; height: 46px; - width: 52px; - text-align: center; + width: 100%; img { width: 36px; @@ -115,20 +152,6 @@ header { } } - /** - * - * Project / Area name - * - */ - .title { - position: relative; - float: left; - margin: 0; - margin-left: 5px; - @include header-font; - @include str-truncated(37%); - } - .profile-pic { padding: 0px !important; width: 46px; @@ -164,9 +187,10 @@ header { padding-left: 25px; font-size: 13px; @include border-radius(3px); - border: 1px solid #c6c6c6; + border: 1px solid #DDD; box-shadow: none; @include transition(all 0.15s ease-in 0s); + background-color: #f5f5f5; } } } @@ -192,3 +216,26 @@ header { right: 35px !important; } } + +@media (max-width: $screen-md-max) { + .header-collapsed, .header-expanded { + width: 52px; + + h3 { + display: none; + } + } +} + +@media(min-width: $screen-md-max) { + .header-collapsed { + width: 52px; + + h3 { + display: none; + } + } + + .header-expanded { + } +} diff --git a/app/assets/stylesheets/generic/nav_sidebar.scss b/app/assets/stylesheets/generic/sidebar.scss similarity index 77% rename from app/assets/stylesheets/generic/nav_sidebar.scss rename to app/assets/stylesheets/generic/sidebar.scss index 3bcb7b8133..754c5b5302 100644 --- a/app/assets/stylesheets/generic/nav_sidebar.scss +++ b/app/assets/stylesheets/generic/sidebar.scss @@ -6,7 +6,6 @@ top: 0; left: 0; height: 100%; - border-right: 1px solid $border-color; } } @@ -38,28 +37,10 @@ } .nav-sidebar li { - &.active a { - color: $text-color; - background: #FFF !important; - font-weight: bold; - border: 1px solid #EEE; - border-right: 1px solid transparent; - border-left: 3px solid $style_color; - - &.no-highlight { - background: none !important; - border: none; - } - - i { - color: $text-color; - } - } } .nav-sidebar li { &.separate-item { - border-top: 1px solid $border-color; padding-top: 10px; margin-top: 10px; } @@ -71,12 +52,10 @@ padding: 8px 15px; font-size: 13px; line-height: 20px; - padding-left: 20px; + padding-left: 16px; &:hover { text-decoration: none; - color: $text-color; - background: $border-color; } &:active, &:focus { @@ -146,7 +125,7 @@ .collapse-nav a { left: 0px; - padding: 7px 23px 3px 22px; + width: 52px; } } } @@ -154,13 +133,13 @@ .collapse-nav a { position: fixed; top: 46px; - padding: 5px 13px 5px 13px; left: 198px; font-size: 13px; background: transparent; - color: black; - border-left: 1px solid $border-color; - border-bottom: 1px solid $border-color; + width: 32px; + height: 28px; + text-align: center; + line-height: 28px; } .collapse-nav a:hover { diff --git a/app/assets/stylesheets/pages/profile.scss b/app/assets/stylesheets/pages/profile.scss index 65655d4bfa..280e8b5717 100644 --- a/app/assets/stylesheets/pages/profile.scss +++ b/app/assets/stylesheets/pages/profile.scss @@ -37,7 +37,7 @@ } &.default { - background: #f1f1f1; + background: #888888; } &.modern { diff --git a/app/assets/stylesheets/themes/dark-theme.scss b/app/assets/stylesheets/themes/dark-theme.scss deleted file mode 100644 index b7b22a8724..0000000000 --- a/app/assets/stylesheets/themes/dark-theme.scss +++ /dev/null @@ -1,63 +0,0 @@ -@mixin dark-theme($color-light, $color, $color-darker, $color-dark) { - header { - &.navbar-gitlab { - .navbar-inner { - background: $color; - - .navbar-toggle { - color: #FFF; - } - - .app_logo, .navbar-toggle { - &:hover { - background-color: $color-darker; - } - } - - .app_logo { - background-color: $color-dark; - } - - .title { - color: #FFF; - - a { - color: #FFF; - &:hover { - text-decoration: underline; - } - } - } - - .search { - .search-input { - background-color: $color-light; - background-color: rgba(255, 255, 255, 0.5); - border: 1px solid $color-light; - - &:focus { - background-color: white; - } - } - } - - .search-input::-webkit-input-placeholder { - color: #666; - } - - .nav > li > a { - color: $color-light; - - &:hover, &:focus, &:active { - background: none; - color: #FFF; - } - } - - .search-input { - border-color: $color-light; - } - } - } - } -} diff --git a/app/assets/stylesheets/themes/gitlab-theme.scss b/app/assets/stylesheets/themes/gitlab-theme.scss new file mode 100644 index 0000000000..ee75fe6188 --- /dev/null +++ b/app/assets/stylesheets/themes/gitlab-theme.scss @@ -0,0 +1,72 @@ +@mixin gitlab-theme($color-light, $color, $color-darker, $color-dark) { + header { + &.navbar-gitlab { + .navbar-inner { + .app_logo { + background-color: $color-darker; + + a { + color: $color-light; + } + + &:hover { + background-color: $color-dark; + a { + color: #FFF; + } + } + } + } + } + } + + .page-with-sidebar { + background: $color-darker; + + .collapse-nav a { + color: #FFF; + background: $color; + } + + .sidebar-wrapper { + background: $color-darker; + border-right: 1px solid $color-darker; + } + + .nav-sidebar li { + a { + color: $color-light; + + &:hover, &:focus, &:active { + background: $color-dark; + } + + i { + color: $color-light; + } + + .count { + color: $color-light; + background: $color-dark; + } + } + + &.separate-item { + border-top: 1px solid $color; + } + + &.active a { + color: #FFF; + font-weight: bold; + + &.no-highlight { + border: none; + } + + i { + color: #FFF + } + } + } + } +} diff --git a/app/assets/stylesheets/themes/ui_basic.scss b/app/assets/stylesheets/themes/ui_basic.scss index 097d5c5b73..63e8dce1e9 100644 --- a/app/assets/stylesheets/themes/ui_basic.scss +++ b/app/assets/stylesheets/themes/ui_basic.scss @@ -4,27 +4,5 @@ * */ .ui_basic { - header { - &.navbar-gitlab { - .navbar-inner { - background: #F1F1F1; - border-bottom: 1px solid #DDD; - - .title { - color: #555; - - a { - color: #555; - &:hover { - text-decoration: underline; - } - } - } - - .nav > li > a { - color: $style_color; - } - } - } - } + @include gitlab-theme(#CCCCCC, #888888, #777777, #666666); } diff --git a/app/assets/stylesheets/themes/ui_blue.scss b/app/assets/stylesheets/themes/ui_blue.scss index e223058be8..cf995622b6 100644 --- a/app/assets/stylesheets/themes/ui_blue.scss +++ b/app/assets/stylesheets/themes/ui_blue.scss @@ -2,5 +2,5 @@ * Blue GitLab UI theme */ .ui_blue { - @include dark-theme(#BECDE9, #2980b9, #1970a9, #096099); + @include gitlab-theme(#BECDE9, #2980b9, #1970a9, #096099); } diff --git a/app/assets/stylesheets/themes/ui_color.scss b/app/assets/stylesheets/themes/ui_color.scss index 7ac6903b2e..6babccec0d 100644 --- a/app/assets/stylesheets/themes/ui_color.scss +++ b/app/assets/stylesheets/themes/ui_color.scss @@ -2,5 +2,5 @@ * Violet GitLab UI theme */ .ui_color { - @include dark-theme(#98C, #548, #436, #325); + @include gitlab-theme(#98C, #548, #436, #325); } diff --git a/app/assets/stylesheets/themes/ui_gray.scss b/app/assets/stylesheets/themes/ui_gray.scss index 9257e5f4d4..f8e4a6ea7d 100644 --- a/app/assets/stylesheets/themes/ui_gray.scss +++ b/app/assets/stylesheets/themes/ui_gray.scss @@ -2,5 +2,5 @@ * Gray GitLab UI theme */ .ui_gray { - @include dark-theme(#979797, #373737, #272727, #222222); + @include gitlab-theme(#979797, #373737, #272727, #222222); } diff --git a/app/assets/stylesheets/themes/ui_mars.scss b/app/assets/stylesheets/themes/ui_mars.scss index 4caf5843d9..fda96b64cd 100644 --- a/app/assets/stylesheets/themes/ui_mars.scss +++ b/app/assets/stylesheets/themes/ui_mars.scss @@ -2,5 +2,5 @@ * Classic GitLab UI theme */ .ui_mars { - @include dark-theme(#979DA7, #474D57, #373D47, #24272D); + @include gitlab-theme(#979DA7, #474D57, #373D47, #24272D); } diff --git a/app/assets/stylesheets/themes/ui_modern.scss b/app/assets/stylesheets/themes/ui_modern.scss index 7044988231..8261e80b35 100644 --- a/app/assets/stylesheets/themes/ui_modern.scss +++ b/app/assets/stylesheets/themes/ui_modern.scss @@ -2,5 +2,5 @@ * Modern GitLab UI theme */ .ui_modern { - @include dark-theme(#ADC, #019875, #018865, #017855); + @include gitlab-theme(#ADC, #019875, #018865, #017855); } diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index 6a8f20f604..fe5456f820 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -3,7 +3,7 @@ # Automatically sets the layout and ensures an administrator is logged in class Admin::ApplicationController < ApplicationController layout 'admin' - before_filter :authenticate_admin! + before_action :authenticate_admin! def authenticate_admin! return render_404 unless current_user.is_admin? diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 3f900956e7..6e19f97ce0 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -1,5 +1,5 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController - before_filter :set_application_setting + before_action :set_application_setting def show end diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb index e1643bb34b..0808024fc3 100644 --- a/app/controllers/admin/broadcast_messages_controller.rb +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -1,5 +1,5 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController - before_filter :broadcast_messages + before_action :broadcast_messages def index @broadcast_message = BroadcastMessage.new diff --git a/app/controllers/admin/deploy_keys_controller.rb b/app/controllers/admin/deploy_keys_controller.rb index e93603bef3..c301e61d1c 100644 --- a/app/controllers/admin/deploy_keys_controller.rb +++ b/app/controllers/admin/deploy_keys_controller.rb @@ -1,13 +1,13 @@ class Admin::DeployKeysController < Admin::ApplicationController - before_filter :deploy_keys, only: [:index] - before_filter :deploy_key, only: [:show, :destroy] + before_action :deploy_keys, only: [:index] + before_action :deploy_key, only: [:show, :destroy] def index end def show - + end def new diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 22d045fc38..2dfae13ac5 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -1,5 +1,5 @@ class Admin::GroupsController < Admin::ApplicationController - before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update] + before_action :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update] def index @groups = Group.all diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb index 21111bb44f..cb33fdd976 100644 --- a/app/controllers/admin/keys_controller.rb +++ b/app/controllers/admin/keys_controller.rb @@ -1,5 +1,5 @@ class Admin::KeysController < Admin::ApplicationController - before_filter :user, only: [:show, :destroy] + before_action :user, only: [:show, :destroy] def show @key = user.keys.find(params[:id]) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 5176a8399a..ee449badf5 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -1,7 +1,7 @@ class Admin::ProjectsController < Admin::ApplicationController - before_filter :project, only: [:show, :transfer] - before_filter :group, only: [:show, :transfer] - before_filter :repository, only: [:show, :transfer] + before_action :project, only: [:show, :transfer] + before_action :group, only: [:show, :transfer] + before_action :repository, only: [:show, :transfer] def index @projects = Project.all diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb index 76a938c5fe..c1fdcd7fab 100644 --- a/app/controllers/admin/services_controller.rb +++ b/app/controllers/admin/services_controller.rb @@ -1,5 +1,5 @@ class Admin::ServicesController < Admin::ApplicationController - before_filter :service, only: [:edit, :update] + before_action :service, only: [:edit, :update] def index @services = services_templates diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b4c011f213..adb83996f8 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,5 +1,5 @@ class Admin::UsersController < Admin::ApplicationController - before_filter :user, only: [:show, :edit, :update, :destroy] + before_action :user, only: [:show, :edit, :update, :destroy] def index @users = User.order_name_asc.filter(params[:filter]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 40f53c0766..5873aa8134 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,15 +6,15 @@ class ApplicationController < ActionController::Base PER_PAGE = 20 - before_filter :authenticate_user_from_token! - before_filter :authenticate_user! - before_filter :reject_blocked! - before_filter :check_password_expiration - before_filter :ldap_security_check - before_filter :default_headers - before_filter :add_gon_variables - before_filter :configure_permitted_parameters, if: :devise_controller? - before_filter :require_email, unless: :devise_controller? + before_action :authenticate_user_from_token! + before_action :authenticate_user! + before_action :reject_blocked! + before_action :check_password_expiration + before_action :ldap_security_check + before_action :default_headers + before_action :add_gon_variables + before_action :configure_permitted_parameters, if: :devise_controller? + before_action :require_email, unless: :devise_controller? protect_from_forgery with: :exception @@ -87,6 +87,10 @@ class ApplicationController < ActionController::Base end end + def after_sign_out_path_for(resource) + new_user_session_path + end + def abilities Ability.abilities end diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb index cb51792df1..33227e7f1d 100644 --- a/app/controllers/dashboard/milestones_controller.rb +++ b/app/controllers/dashboard/milestones_controller.rb @@ -1,5 +1,5 @@ class Dashboard::MilestonesController < ApplicationController - before_filter :load_projects + before_action :load_projects def index project_milestones = case params[:state] diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index 56e6fcc41c..426bc61541 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -1,5 +1,5 @@ class Dashboard::ProjectsController < ApplicationController - before_filter :event_filter + before_action :event_filter def starred @projects = current_user.starred_projects diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9bd853ed5c..40b5de1295 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,8 +1,8 @@ class DashboardController < ApplicationController respond_to :html - before_filter :load_projects, except: [:projects] - before_filter :event_filter, only: :show + before_action :load_projects, except: [:projects] + before_action :event_filter, only: :show def show @projects = @projects.includes(:namespace) diff --git a/app/controllers/explore/groups_controller.rb b/app/controllers/explore/groups_controller.rb index c51a4a211a..a7250b799f 100644 --- a/app/controllers/explore/groups_controller.rb +++ b/app/controllers/explore/groups_controller.rb @@ -1,5 +1,5 @@ class Explore::GroupsController < ApplicationController - skip_before_filter :authenticate_user!, + skip_before_action :authenticate_user!, :reject_blocked, :set_current_user_for_observers layout "explore" diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index b295f295bb..b1b0a2514d 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -1,5 +1,5 @@ class Explore::ProjectsController < ApplicationController - skip_before_filter :authenticate_user!, + skip_before_action :authenticate_user!, :reject_blocked layout 'explore' diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index cdb96c3daa..46ebdb74c5 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -1,10 +1,10 @@ class Groups::GroupMembersController < Groups::ApplicationController - skip_before_filter :authenticate_user!, only: [:index] - before_filter :group + skip_before_action :authenticate_user!, only: [:index] + before_action :group # Authorize - before_filter :authorize_read_group! - before_filter :authorize_admin_group!, except: [:index, :leave] + before_action :authorize_read_group! + before_action :authorize_admin_group!, except: [:index, :leave] layout :determine_layout diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb index 546ff2cc71..41564b04a9 100644 --- a/app/controllers/groups/milestones_controller.rb +++ b/app/controllers/groups/milestones_controller.rb @@ -1,7 +1,7 @@ class Groups::MilestonesController < ApplicationController layout 'group' - before_filter :authorize_group_milestone!, only: :update + before_action :authorize_group_milestone!, only: :update def index project_milestones = case params[:state] diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 7e819b5cd2..9ddd3b170f 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,17 +1,17 @@ class GroupsController < Groups::ApplicationController - skip_before_filter :authenticate_user!, only: [:show, :issues, :merge_requests] + skip_before_action :authenticate_user!, only: [:show, :issues, :merge_requests] respond_to :html - before_filter :group, except: [:new, :create] + before_action :group, except: [:new, :create] # Authorize - before_filter :authorize_read_group!, except: [:new, :create] - before_filter :authorize_admin_group!, only: [:edit, :update, :destroy, :projects] - before_filter :authorize_create_group!, only: [:new, :create] + before_action :authorize_read_group!, except: [:new, :create] + before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects] + before_action :authorize_create_group!, only: [:new, :create] # Load group projects - before_filter :load_projects, except: [:new, :create, :projects, :edit, :update] - before_filter :event_filter, only: :show - before_filter :set_title, only: [:new, :create] + before_action :load_projects, except: [:new, :create, :projects, :edit, :update] + before_action :event_filter, only: :show + before_action :set_title, only: [:new, :create] layout :determine_layout diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb index bb8d7e0235..ca78a4aaa8 100644 --- a/app/controllers/import/bitbucket_controller.rb +++ b/app/controllers/import/bitbucket_controller.rb @@ -1,15 +1,15 @@ class Import::BitbucketController < Import::BaseController - before_filter :verify_bitbucket_import_enabled - before_filter :bitbucket_auth, except: :callback + before_action :verify_bitbucket_import_enabled + before_action :bitbucket_auth, except: :callback rescue_from OAuth::Error, with: :bitbucket_unauthorized def callback - request_token = session.delete(:oauth_request_token) + request_token = session.delete(:oauth_request_token) raise "Session expired!" if request_token.nil? request_token.symbolize_keys! - + access_token = client.get_token(request_token, params[:oauth_verifier], callback_import_bitbucket_url) current_user.bitbucket_access_token = access_token.token @@ -21,7 +21,7 @@ class Import::BitbucketController < Import::BaseController def status @repos = client.projects - + @already_added_projects = current_user.created_projects.where(import_type: "bitbucket") already_added_projects_names = @already_added_projects.pluck(:import_source) @@ -41,7 +41,7 @@ class Import::BitbucketController < Import::BaseController repo_owner = repo["owner"] repo_owner = current_user.username if repo_owner == client.user["user"]["username"] @target_namespace = params[:new_namespace].presence || repo_owner - + namespace = get_or_create_namespace || (render and return) unless Gitlab::BitbucketImport::KeyAdder.new(repo, current_user).execute diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index 87b41454c7..b9f99c1b88 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -1,6 +1,6 @@ class Import::GithubController < Import::BaseController - before_filter :verify_github_import_enabled - before_filter :github_auth, except: :callback + before_action :verify_github_import_enabled + before_action :github_auth, except: :callback rescue_from Octokit::Unauthorized, with: :github_unauthorized @@ -36,7 +36,7 @@ class Import::GithubController < Import::BaseController repo_owner = repo.owner.login repo_owner = current_user.username if repo_owner == client.user.login @target_namespace = params[:new_namespace].presence || repo_owner - + namespace = get_or_create_namespace || (render and return) @project = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, current_user).execute diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb index bddbfded81..1b8962d892 100644 --- a/app/controllers/import/gitlab_controller.rb +++ b/app/controllers/import/gitlab_controller.rb @@ -1,6 +1,6 @@ class Import::GitlabController < Import::BaseController - before_filter :verify_gitlab_import_enabled - before_filter :gitlab_auth, except: :callback + before_action :verify_gitlab_import_enabled + before_action :gitlab_auth, except: :callback rescue_from OAuth2::Error, with: :gitlab_unauthorized @@ -13,7 +13,7 @@ class Import::GitlabController < Import::BaseController def status @repos = client.projects - + @already_added_projects = current_user.created_projects.where(import_type: "gitlab") already_added_projects_names = @already_added_projects.pluck(:import_source) @@ -33,7 +33,7 @@ class Import::GitlabController < Import::BaseController repo_owner = repo["namespace"]["path"] repo_owner = current_user.username if repo_owner == client.user["username"] @target_namespace = params[:new_namespace].presence || repo_owner - + namespace = get_or_create_namespace || (render and return) @project = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, current_user).execute diff --git a/app/controllers/import/google_code_controller.rb b/app/controllers/import/google_code_controller.rb index 73c912e285..5adf6ed785 100644 --- a/app/controllers/import/google_code_controller.rb +++ b/app/controllers/import/google_code_controller.rb @@ -1,8 +1,8 @@ class Import::GoogleCodeController < Import::BaseController - before_filter :user_map, only: [:new_user_map, :create_user_map] + before_action :user_map, only: [:new_user_map, :create_user_map] def new - + end def callback @@ -68,7 +68,7 @@ class Import::GoogleCodeController < Import::BaseController def status unless client.valid? - return redirect_to new_import_google_path + return redirect_to new_import_google_code_path end @repos = client.repos diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 1f97ff16c5..a29c03395f 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -1,6 +1,6 @@ class InvitesController < ApplicationController - before_filter :member - skip_before_filter :authenticate_user!, only: :decline + before_action :member + skip_before_action :authenticate_user!, only: :decline respond_to :html @@ -24,7 +24,7 @@ class InvitesController < ApplicationController if member.decline_invite! label, _ = source_info(member.source) - path = + path = if current_user dashboard_path else @@ -41,7 +41,7 @@ class InvitesController < ApplicationController def member return @member if defined?(@member) - + @token = params[:id] @member = Member.find_by_invite_token(@token) diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb index 386d103ee5..83eec1bf4a 100644 --- a/app/controllers/namespaces_controller.rb +++ b/app/controllers/namespaces_controller.rb @@ -1,5 +1,5 @@ class NamespacesController < ApplicationController - skip_before_filter :authenticate_user! + skip_before_action :authenticate_user! def show namespace = Namespace.find_by(path: params[:id]) diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index efa291d939..ea256de2c3 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -1,5 +1,5 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController - before_filter :authenticate_user! + before_action :authenticate_user! layout "profile" def index @@ -10,7 +10,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController @application = Doorkeeper::Application.new(application_params) @application.owner = current_user - + if @application.save flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) redirect_to oauth_application_url(@application) diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb index a57b4a60c2..6d3c1a320d 100644 --- a/app/controllers/oauth/authorizations_controller.rb +++ b/app/controllers/oauth/authorizations_controller.rb @@ -1,5 +1,5 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController - before_filter :authenticate_resource_owner! + before_action :authenticate_resource_owner! layout "profile" def new diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index ce057aebda..157ce038a2 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -1,6 +1,6 @@ class Profiles::KeysController < ApplicationController layout "profile" - skip_before_filter :authenticate_user!, only: [:get_keys] + skip_before_action :authenticate_user!, only: [:get_keys] def index @keys = current_user.keys diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 0c614969a3..b719a7fe9a 100644 --- a/app/controllers/profiles/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -1,11 +1,11 @@ class Profiles::PasswordsController < ApplicationController layout :determine_layout - skip_before_filter :check_password_expiration, only: [:new, :create] + skip_before_action :check_password_expiration, only: [:new, :create] - before_filter :set_user - before_filter :set_title - before_filter :authorize_change_password! + before_action :set_user + before_action :set_title + before_action :authorize_change_password! def new end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 7f76906066..eb001e8d73 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -1,9 +1,9 @@ class ProfilesController < ApplicationController include ActionView::Helpers::SanitizeHelper - before_filter :user - before_filter :authorize_change_username!, only: :update_username - skip_before_filter :require_email, only: [:show, :update] + before_action :user + before_action :authorize_change_username!, only: :update_username + skip_before_action :require_email, only: [:show, :update] layout 'profile' diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 4719933394..f7a28e920d 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -1,6 +1,6 @@ class Projects::ApplicationController < ApplicationController - before_filter :project - before_filter :repository + before_action :project + before_action :repository layout :determine_layout def authenticate_user! diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb index a482b90880..22a12c4b9a 100644 --- a/app/controllers/projects/avatars_controller.rb +++ b/app/controllers/projects/avatars_controller.rb @@ -1,7 +1,7 @@ class Projects::AvatarsController < Projects::ApplicationController layout 'project' - before_filter :project + before_action :project def show @blob = @project.repository.blob_at_branch('master', @project.avatar_in_git) diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index a87b8270a2..3362264dcc 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -2,9 +2,9 @@ class Projects::BlameController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show @blame = Gitlab::Git::Blame.new(@repository, @commit.id, @path) diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 4b7eb4df29..b762518d37 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -6,15 +6,15 @@ class Projects::BlobController < Projects::ApplicationController # Raised when given an invalid file path class InvalidPathError < StandardError; end - before_filter :require_non_empty_project, except: [:new, :create] - before_filter :authorize_download_code! - before_filter :authorize_push_code!, only: [:destroy] - before_filter :assign_blob_vars - before_filter :commit, except: [:new, :create] - before_filter :blob, except: [:new, :create] - before_filter :from_merge_request, only: [:edit, :update] - before_filter :after_edit_path, only: [:edit, :update] - before_filter :require_branch_head, only: [:edit, :update] + before_action :require_non_empty_project, except: [:new, :create] + before_action :authorize_download_code! + before_action :authorize_push_code!, only: [:destroy] + before_action :assign_blob_vars + before_action :commit, except: [:new, :create] + before_action :blob, except: [:new, :create] + before_action :from_merge_request, only: [:edit, :update] + before_action :after_edit_path, only: [:edit, :update] + before_action :require_branch_head, only: [:edit, :update] def new commit unless @repository.empty? diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index f049e96e61..696011b94b 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -1,9 +1,9 @@ class Projects::BranchesController < Projects::ApplicationController include ActionView::Helpers::SanitizeHelper # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! - before_filter :authorize_push_code!, only: [:create, :destroy] + before_action :require_non_empty_project + before_action :authorize_download_code! + before_action :authorize_push_code!, only: [:create, :destroy] def index @sort = params[:sort] || 'name' diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 894cf93b9a..8a1b7899be 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -3,9 +3,9 @@ # Not to be confused with CommitsController, plural. class Projects::CommitController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! - before_filter :commit + before_action :require_non_empty_project + before_action :authorize_download_code! + before_action :commit def show return git_not_found! unless @commit diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 4b6ab43747..d1c15174ae 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -3,9 +3,9 @@ require "base64" class Projects::CommitsController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show @repo = @project.repository diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 146808fa56..03e6c38127 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -1,7 +1,7 @@ class Projects::CompareController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :authorize_download_code! def index end diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index ced8e25191..1b88eb2e86 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -2,7 +2,7 @@ class Projects::DeployKeysController < Projects::ApplicationController respond_to :html # Authorize - before_filter :authorize_admin_project! + before_action :authorize_admin_project! layout "project_settings" diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 21a151a426..01a079d2e6 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -1,7 +1,7 @@ class Projects::ForksController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :authorize_download_code! def new @namespaces = current_user.manageable_namespaces diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 6e54af356e..a060ea6f99 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -1,7 +1,7 @@ class Projects::GraphsController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :authorize_download_code! def show respond_to do |format| diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index ba95bb13e1..57fc48ac7d 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -1,6 +1,6 @@ class Projects::HooksController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! + before_action :authorize_admin_project! respond_to :html diff --git a/app/controllers/projects/imports_controller.rb b/app/controllers/projects/imports_controller.rb index b64491b466..066b66014f 100644 --- a/app/controllers/projects/imports_controller.rb +++ b/app/controllers/projects/imports_controller.rb @@ -1,8 +1,8 @@ class Projects::ImportsController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! - before_filter :require_no_repo - before_filter :redirect_if_progress, except: :show + before_action :authorize_admin_project! + before_action :require_no_repo + before_action :redirect_if_progress, except: :show def new end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 88302276b5..c524e1a0ea 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -1,18 +1,18 @@ class Projects::IssuesController < Projects::ApplicationController - before_filter :module_enabled - before_filter :issue, only: [:edit, :update, :show, :toggle_subscription] + before_action :module_enabled + before_action :issue, only: [:edit, :update, :show, :toggle_subscription] # Allow read any issue - before_filter :authorize_read_issue! + before_action :authorize_read_issue! # Allow write(create) issue - before_filter :authorize_write_issue!, only: [:new, :create] + before_action :authorize_write_issue!, only: [:new, :create] # Allow modify issue - before_filter :authorize_modify_issue!, only: [:edit, :update] + before_action :authorize_modify_issue!, only: [:edit, :update] # Allow issues bulk update - before_filter :authorize_admin_issues!, only: [:bulk_update] + before_action :authorize_admin_issues!, only: [:bulk_update] respond_to :html @@ -99,7 +99,7 @@ class Projects::IssuesController < Projects::ApplicationController def toggle_subscription @issue.toggle_subscription(current_user) - + render nothing: true end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 207a01ed3b..2f8cb203cf 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,8 +1,8 @@ class Projects::LabelsController < Projects::ApplicationController - before_filter :module_enabled - before_filter :label, only: [:edit, :update, :destroy] - before_filter :authorize_labels! - before_filter :authorize_admin_labels!, except: [:index] + before_action :module_enabled + before_action :label, only: [:edit, :update, :destroy] + before_action :authorize_labels! + before_action :authorize_admin_labels!, except: [:index] respond_to :js, :html diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 47ce846735..ab75f2ddb7 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -1,20 +1,20 @@ require 'gitlab/satellite/satellite' class Projects::MergeRequestsController < Projects::ApplicationController - before_filter :module_enabled - before_filter :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status, :toggle_subscription] - before_filter :closes_issues, only: [:edit, :update, :show, :diffs] - before_filter :validates_merge_request, only: [:show, :diffs] - before_filter :define_show_vars, only: [:show, :diffs] + before_action :module_enabled + before_action :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status, :toggle_subscription] + before_action :closes_issues, only: [:edit, :update, :show, :diffs] + before_action :validates_merge_request, only: [:show, :diffs] + before_action :define_show_vars, only: [:show, :diffs] # Allow read any merge_request - before_filter :authorize_read_merge_request! + before_action :authorize_read_merge_request! # Allow write(create) merge_request - before_filter :authorize_write_merge_request!, only: [:new, :create] + before_action :authorize_write_merge_request!, only: [:new, :create] # Allow modify merge_request - before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] + before_action :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] def index terms = params['issue_search'] @@ -176,7 +176,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController def toggle_subscription @merge_request.toggle_subscription(current_user) - + render nothing: true end diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index b49b549547..61689488d1 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -1,12 +1,12 @@ class Projects::MilestonesController < Projects::ApplicationController - before_filter :module_enabled - before_filter :milestone, only: [:edit, :update, :destroy, :show, :sort_issues, :sort_merge_requests] + before_action :module_enabled + before_action :milestone, only: [:edit, :update, :destroy, :show, :sort_issues, :sort_merge_requests] # Allow read any milestone - before_filter :authorize_read_milestone! + before_action :authorize_read_milestone! # Allow admin milestone - before_filter :authorize_admin_milestone!, except: [:index, :show] + before_action :authorize_admin_milestone!, except: [:index, :show] respond_to :html diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb index 83d1c1daca..06aef91cad 100644 --- a/app/controllers/projects/network_controller.rb +++ b/app/controllers/projects/network_controller.rb @@ -2,9 +2,9 @@ class Projects::NetworkController < Projects::ApplicationController include ExtractsPath include ApplicationHelper - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show respond_to do |format| diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 868629a0bc..496b85cb46 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -1,9 +1,9 @@ class Projects::NotesController < Projects::ApplicationController # Authorize - before_filter :authorize_read_note! - before_filter :authorize_write_note!, only: [:create] - before_filter :authorize_admin_note!, only: [:update, :destroy] - before_filter :find_current_user_notes, except: [:destroy, :delete_attachment] + before_action :authorize_read_note! + before_action :authorize_write_note!, only: [:create] + before_action :authorize_admin_note!, only: [:update, :destroy] + before_action :find_current_user_notes, except: [:destroy, :delete_attachment] def index current_fetched_at = Time.now.to_i diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index ef7da47073..3c92319299 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -1,6 +1,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project!, except: :leave + before_action :authorize_admin_project!, except: :leave layout "project_settings" diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb index ac36ac6fcd..6b52eccebf 100644 --- a/app/controllers/projects/protected_branches_controller.rb +++ b/app/controllers/projects/protected_branches_controller.rb @@ -1,7 +1,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_admin_project! + before_action :require_non_empty_project + before_action :authorize_admin_project! layout "project_settings" diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index b1a029ce69..647c145407 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -2,9 +2,9 @@ class Projects::RawController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def show @blob = @repository.blob_at(@commit.id, @path) diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index ec3b2b8d75..01ca1537c0 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -1,9 +1,9 @@ class Projects::RefsController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project + before_action :assign_ref_vars + before_action :authorize_download_code! def switch respond_to do |format| diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 96defb0c72..c4a5e2d635 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -1,8 +1,8 @@ class Projects::RepositoriesController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project, except: :create - before_filter :authorize_download_code! - before_filter :authorize_admin_project!, only: :create + before_action :require_non_empty_project, except: :create + before_action :authorize_download_code! + before_action :authorize_admin_project!, only: :create def create @project.create_repository diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index d0bb9e6674..2c3209def7 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -1,7 +1,7 @@ class Projects::ServicesController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! - before_filter :service, only: [:edit, :update, :test] + before_action :authorize_admin_project! + before_action :service, only: [:edit, :update, :test] respond_to :html diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index ed26840037..3d75abcc29 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -1,18 +1,18 @@ class Projects::SnippetsController < Projects::ApplicationController - before_filter :module_enabled - before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] + before_action :module_enabled + before_action :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow read any snippet - before_filter :authorize_read_project_snippet! + before_action :authorize_read_project_snippet! # Allow write(create) snippet - before_filter :authorize_write_project_snippet!, only: [:new, :create] + before_action :authorize_write_project_snippet!, only: [:new, :create] # Allow modify snippet - before_filter :authorize_modify_project_snippet!, only: [:edit, :update] + before_action :authorize_modify_project_snippet!, only: [:edit, :update] # Allow destroy snippet - before_filter :authorize_admin_project_snippet!, only: [:destroy] + before_action :authorize_admin_project_snippet!, only: [:destroy] respond_to :html diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 83f4937bce..f565fbbbbc 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -1,9 +1,9 @@ class Projects::TagsController < Projects::ApplicationController # Authorize - before_filter :require_non_empty_project - before_filter :authorize_download_code! - before_filter :authorize_push_code!, only: [:create] - before_filter :authorize_admin_project!, only: [:destroy] + before_action :require_non_empty_project + before_action :authorize_download_code! + before_action :authorize_push_code!, only: [:create] + before_action :authorize_admin_project!, only: [:destroy] def index sorted = VersionSorter.rsort(@repository.tag_names) diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index b23010bf59..b659e15f24 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -2,9 +2,9 @@ class Projects::TreeController < Projects::ApplicationController include ExtractsPath - before_filter :require_non_empty_project, except: [:new, :create] - before_filter :assign_ref_vars - before_filter :authorize_download_code! + before_action :require_non_empty_project, except: [:new, :create] + before_action :assign_ref_vars + before_action :authorize_download_code! def show if tree.entries.empty? diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index 276dced865..6153ca2dc1 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -1,11 +1,11 @@ class Projects::UploadsController < Projects::ApplicationController layout 'project' - # We want to skip these filters for only the `show` action if `image?` is true, + # We want to skip these filters for only the `show` action if `image?` is true, # but `skip_before_filter` doesn't work with both `only` and `if`, so we accomplish the same like this. skipped_filters = [:authenticate_user!, :reject_blocked!, :project, :repository] - skip_before_filter *skipped_filters, only: [:show] - before_filter *skipped_filters, only: [:show], unless: :image? + skip_before_action *skipped_filters, only: [:show] + before_action *skipped_filters, only: [:show], unless: :image? def create link_to_file = ::Projects::UploadService.new(project, params[:file]). @@ -40,7 +40,7 @@ class Projects::UploadsController < Projects::ApplicationController file_project = Project.find_with_namespace("#{namespace}/#{id}") if file_project.nil? - @uploader = nil + @uploader = nil return end diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index aeb7f0699f..36ef86e190 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -1,10 +1,10 @@ require 'project_wiki' class Projects::WikisController < Projects::ApplicationController - before_filter :authorize_read_wiki! - before_filter :authorize_write_wiki!, only: [:edit, :create, :history] - before_filter :authorize_admin_wiki!, only: :destroy - before_filter :load_project_wiki + before_action :authorize_read_wiki! + before_action :authorize_write_wiki!, only: [:edit, :create, :history] + before_action :authorize_admin_wiki!, only: :destroy + before_action :load_project_wiki include WikiHelper def pages diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index bd6c99ca0f..694dcf35e8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,13 +1,13 @@ class ProjectsController < ApplicationController prepend_before_filter :render_go_import, only: [:show] - skip_before_filter :authenticate_user!, only: [:show] - before_filter :project, except: [:new, :create] - before_filter :repository, except: [:new, :create] + skip_before_action :authenticate_user!, only: [:show] + before_action :project, except: [:new, :create] + before_action :repository, except: [:new, :create] # Authorize - before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive] - before_filter :set_title, only: [:new, :create] - before_filter :event_filter, only: :show + before_action :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive] + before_action :set_title, only: [:new, :create] + before_action :event_filter, only: :show layout 'navless', only: [:new, :create, :fork] diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 38d116a4ee..830751a989 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,5 +1,5 @@ class RegistrationsController < Devise::RegistrationsController - before_filter :signup_enabled? + before_action :signup_enabled? def new redirect_to(new_user_session_path) diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index cd52556b20..a5259466cb 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,39 +1,39 @@ class SnippetsController < ApplicationController - before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] + before_action :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow modify snippet - before_filter :authorize_modify_snippet!, only: [:edit, :update] + before_action :authorize_modify_snippet!, only: [:edit, :update] # Allow destroy snippet - before_filter :authorize_admin_snippet!, only: [:destroy] + before_action :authorize_admin_snippet!, only: [:destroy] - before_filter :set_title + before_action :set_title - skip_before_filter :authenticate_user!, only: [:index, :user_index, :show, :raw] + skip_before_action :authenticate_user!, only: [:index, :user_index, :show, :raw] respond_to :html layout :determine_layout def index - @snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE) - end + if params[:username].present? + @user = User.find_by(username: params[:username]) - def user_index - @user = User.find_by(username: params[:username]) + render_404 and return unless @user - render_404 and return unless @user + @snippets = SnippetsFinder.new.execute(current_user, { + filter: :by_user, + user: @user, + scope: params[:scope] }). + page(params[:page]).per(PER_PAGE) - @snippets = SnippetsFinder.new.execute(current_user, { - filter: :by_user, - user: @user, - scope: params[:scope] }). - page(params[:page]).per(PER_PAGE) - - if @user == current_user - render 'current_user_index' + if @user == current_user + render 'current_user_index' + else + render 'user_index' + end else - render 'user_index' + @snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE) end end @@ -108,6 +108,6 @@ class SnippetsController < ApplicationController end def determine_layout - current_user ? 'navless' : 'public_users' + current_user ? 'snippets' : 'public_users' end end diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 938d3db286..67d02e1e2a 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -1,6 +1,6 @@ class UploadsController < ApplicationController - skip_before_filter :authenticate_user! - before_filter :find_model, :authorize_access! + skip_before_action :authenticate_user! + before_action :find_model, :authorize_access! def show uploader = @model.send(upload_mount) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 679d6897ce..460cc868b3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController - skip_before_filter :authenticate_user! - before_filter :set_user + skip_before_action :authenticate_user! + before_action :set_user layout :determine_layout def show diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 20457572a0..a6844b2a47 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -255,11 +255,15 @@ module ApplicationHelper # # Returns `html_options`, adding `rel: nofollow` for external links def add_nofollow(link, html_options = {}) - uri = URI(link) + begin + uri = URI(link) - if uri && uri.absolute? && uri.host != Gitlab.config.gitlab.host - rel = html_options.fetch(:rel, '') - html_options[:rel] = (rel + ' nofollow').strip + if uri && uri.absolute? && uri.host != Gitlab.config.gitlab.host + rel = html_options.fetch(:rel, '') + html_options[:rel] = (rel + ' nofollow').strip + end + rescue URI::Error + # noop end html_options @@ -314,12 +318,4 @@ module ApplicationHelper profile_key_path(key) end end - - def nav_sidebar_class - if nav_menu_collapsed? - "page-sidebar-collapsed" - else - "page-sidebar-expanded" - end - end end diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index aa1de2f50e..aff7011edd 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -74,6 +74,7 @@ module GitlabMarkdownHelper end end + # TODO (rspeicher): This should be its own filter def create_relative_links(text) paths = extract_paths(text) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index ad4a761272..c3b4731dff 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -108,4 +108,7 @@ module IssuesHelper xml.summary issue.title end end + + # Required for Gitlab::Markdown::IssueReferenceFilter + module_function :url_for_issue, :title_for_issue end diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 32ef2e7ca8..8272c177d5 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -1,4 +1,6 @@ module LabelsHelper + include ActionView::Helpers::TagHelper + def project_label_names @project.labels.pluck(:title) end @@ -7,9 +9,13 @@ module LabelsHelper label_color = label.color || Label::DEFAULT_COLOR text_color = text_color_for_bg(label_color) - content_tag :span, class: 'label color-label', style: "background-color:#{label_color};color:#{text_color}" do - label.name - end + # Intentionally not using content_tag here so that this method can be called + # by LabelReferenceFilter + span = %() + + escape_once(label.name) + '' + + span.html_safe end def suggested_colors @@ -42,13 +48,16 @@ module LabelsHelper r, g, b = bg_color.slice(1,7).scan(/.{2}/).map(&:hex) if (r + g + b) > 500 - "#333" + '#333333' else - "#FFF" + '#FFFFFF' end end def project_labels_options(project) options_from_collection_for_select(project.labels, 'name', 'name', params[:label_name]) end + + # Required for Gitlab::Markdown::LabelReferenceFilter + module_function :render_colored_label, :text_color_for_bg, :escape_once end diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index 2b03269800..9b1dd8b8e5 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -2,4 +2,20 @@ module NavHelper def nav_menu_collapsed? cookies[:collapsed_nav] == 'true' end + + def nav_sidebar_class + if nav_menu_collapsed? + "page-sidebar-collapsed" + else + "page-sidebar-expanded" + end + end + + def nav_header_class + if nav_menu_collapsed? + "header-collapsed" + else + "header-expanded" + end + end end diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index acd9a1edc4..aad5e51479 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -28,7 +28,7 @@ module Mentionable # Construct a String that contains possible GFM references. def mentionable_text - self.class.mentionable_attrs.map { |attr| send(attr) || '' }.join + self.class.mentionable_attrs.map { |attr| send(attr) }.compact.join("\n\n") end # The GFM reference to this Mentionable, which shouldn't be included in its #references. diff --git a/app/models/label.rb b/app/models/label.rb index 1f22ed23d4..eee28acefc 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -27,7 +27,7 @@ class Label < ActiveRecord::Base # Don't allow '?', '&', and ',' for label titles validates :title, presence: true, - format: { with: /\A[^&\?,&]+\z/ }, + format: { with: /\A[^&\?,]+\z/ }, uniqueness: { scope: :project_id } default_scope { order(title: :asc) } diff --git a/app/models/note.rb b/app/models/note.rb index 7a692c069f..8df55237dc 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -243,9 +243,9 @@ class Note < ActiveRecord::Base def cross_reference_exists?(noteable, mentioner) gfm_reference = mentioner_gfm_ref(noteable, mentioner) notes = if noteable.is_a?(Commit) - where(commit_id: noteable.id) + where(commit_id: noteable.id, noteable_type: 'Commit') else - where(noteable_id: noteable.id) + where(noteable_id: noteable.id, noteable_type: noteable.class) end notes.where('note like ?', cross_reference_note_pattern(gfm_reference)). diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index d264a56ebd..07520eab5d 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -50,8 +50,9 @@ class HipchatService < Service def execute(data) return unless supported_events.include?(data[:object_kind]) - - gate[room].send('GitLab', create_message(data)) + message = create_message(data) + return unless message.present? + gate[room].send('GitLab', message) end private diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index bacec6cb2a..aafd7cb6f6 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -28,13 +28,12 @@ class JiraService < IssueTrackerService before_validation :set_api_version, :set_jira_issue_transition_id def help - issue_tracker_link = help_page_path("integration", "external-issue-tracker") + line1 = 'Setting `project_url`, `issues_url` and `new_issue_url` will '\ + 'allow a user to easily navigate to the Jira issue tracker. See the '\ + '[integration doc](http://doc.gitlab.com/ce/integration/external-issue-tracker.html) '\ + 'for details.' - line1 = "Setting `project_url`, `issues_url` and `new_issue_url` will "\ - "allow a user to easily navigate to the Jira issue tracker. "\ - "See the [integration doc](#{issue_tracker_link}) for details." - - line2 = 'Support for referencing commits and automatic closing of Jira issues directly ' \ + line2 = 'Support for referencing commits and automatic closing of Jira issues directly '\ 'from GitLab is [available in GitLab EE.](http://doc.gitlab.com/ee/integration/jira.html)' [line1, line2].join("\n\n") diff --git a/app/views/admin/services/_form.html.haml b/app/views/admin/services/_form.html.haml index eb7a099bfe..34ca7776c9 100644 --- a/app/views/admin/services/_form.html.haml +++ b/app/views/admin/services/_form.html.haml @@ -3,7 +3,7 @@ %p #{@service.description} template -= form_for :service, url: admin_application_settings_service_path, method: :put, html: { class: 'form-horizontal fieldset-form' } do |f| += form_for :service, url: admin_application_settings_service_path, method: :put, html: { class: 'form-horizontal fieldset-form' } do |form| - if @service.errors.any? #error_explanation .alert.alert-danger @@ -15,80 +15,68 @@ = markdown @service.help .form-group - = f.label :active, "Active", class: "control-label" + = form.label :active, "Active", class: "control-label" .col-sm-10 - = f.check_box :active + = form.check_box :active - if @service.supported_events.length > 1 .form-group - = f.label :url, "Trigger", class: 'control-label' + = form.label :url, "Trigger", class: 'control-label' .col-sm-10 - if @service.supported_events.include?("push") %div - = f.check_box :push_events, class: 'pull-left' + = form.check_box :push_events, class: 'pull-left' .prepend-left-20 - = f.label :push_events, class: 'list-label' do + = form.label :push_events, class: 'list-label' do %strong Push events %p.light This url will be triggered by a push to the repository - if @service.supported_events.include?("tag_push") %div - = f.check_box :tag_push_events, class: 'pull-left' + = form.check_box :tag_push_events, class: 'pull-left' .prepend-left-20 - = f.label :tag_push_events, class: 'list-label' do + = form.label :tag_push_events, class: 'list-label' do %strong Tag push events %p.light This url will be triggered when a new tag is pushed to the repository - if @service.supported_events.include?("note") %div - = f.check_box :note_events, class: 'pull-left' + = form.check_box :note_events, class: 'pull-left' .prepend-left-20 - = f.label :note_events, class: 'list-label' do + = form.label :note_events, class: 'list-label' do %strong Comments %p.light This url will be triggered when someone adds a comment - if @service.supported_events.include?("issue") %div - = f.check_box :issues_events, class: 'pull-left' + = form.check_box :issues_events, class: 'pull-left' .prepend-left-20 - = f.label :issues_events, class: 'list-label' do + = form.label :issues_events, class: 'list-label' do %strong Issues events %p.light This url will be triggered when an issue is created - if @service.supported_events.include?("merge_request") %div - = f.check_box :merge_requests_events, class: 'pull-left' + = form.check_box :merge_requests_events, class: 'pull-left' .prepend-left-20 - = f.label :merge_requests_events, class: 'list-label' do + = form.label :merge_requests_events, class: 'list-label' do %strong Merge Request events %p.light This url will be triggered when a merge request is created - @service.fields.each do |field| - - name = field[:name] - - title = field[:title] || name.humanize - - value = @service.send(name) unless field[:type] == 'password' - type = field[:type] - - placeholder = field[:placeholder] - - choices = field[:choices] - - default_choice = field[:default_choice] - - help = field[:help] - .form-group - = f.label name, title, class: "control-label" - .col-sm-10 - - if type == 'text' - = f.text_field name, class: "form-control", placeholder: placeholder - - elsif type == 'textarea' - = f.text_area name, rows: 5, class: "form-control", placeholder: placeholder - - elsif type == 'checkbox' - = f.check_box name - - elsif type == 'select' - = f.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" } - - elsif type == 'password' - = f.password_field name, class: 'form-control' - - if help - %span.help-block= help + - if type == 'fieldset' + - fields = field[:fields] + - legend = field[:legend] + + %fieldset + %legend= legend + - fields.each do |subfield| + = render 'shared/field', form: form, field: subfield + - else + = render 'shared/field', form: form, field: field .form-actions - = f.submit 'Save', class: 'btn btn-save' + = form.submit 'Save', class: 'btn btn-save' diff --git a/app/views/devise/shared/_omniauth_box.html.haml b/app/views/devise/shared/_omniauth_box.html.haml index b647b906b7..8dce0b1693 100644 --- a/app/views/devise/shared/_omniauth_box.html.haml +++ b/app/views/devise/shared/_omniauth_box.html.haml @@ -7,4 +7,4 @@ - if default_providers.include?(provider) = link_to oauth_image_tag(provider), omniauth_authorize_path(resource_name, provider), class: 'oauth-image-link' - else - = link_to provider.to_s.titleize, omniauth_authorize_path(resource_name, provider), class: "btn" + = link_to provider.to_s.titleize, omniauth_authorize_path(resource_name, provider), class: "btn", "data-no-turbolink" => "true" diff --git a/app/views/explore/projects/trending.html.haml b/app/views/explore/projects/trending.html.haml index 9cad923893..18749ac00a 100644 --- a/app/views/explore/projects/trending.html.haml +++ b/app/views/explore/projects/trending.html.haml @@ -1,3 +1,9 @@ +.explore-title + %h3 + Explore GitLab + %p.lead + Discover projects and groups. Share your projects with others +%hr .explore-trending-block %p.lead %i.fa.fa-comments-o @@ -7,5 +13,5 @@ %ul.bordered-list = render @trending_projects - .center + .center.append-bottom-20 = link_to 'Show all projects', explore_projects_path, class: 'btn btn-primary' diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index 7b21ca30d8..ae072bacfb 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -187,7 +187,11 @@ %td.shortcut .key m %td Change milestone - %tbody{ class: 'hidden-shortcut merge_reuests', style: 'display:none' } + %tr + %td.shortcut + .key r + %td Reply (quoting selected text) + %tbody{ class: 'hidden-shortcut merge_requests', style: 'display:none' } %tr %th %th Merge Requests @@ -199,6 +203,10 @@ %td.shortcut .key m %td Change milestone + %tr + %td.shortcut + .key r + %td Reply (quoting selected text) :javascript diff --git a/app/views/import/google_code/new_user_map.html.haml b/app/views/import/google_code/new_user_map.html.haml index d55fcfc97a..9c6824ecad 100644 --- a/app/views/import/google_code/new_user_map.html.haml +++ b/app/views/import/google_code/new_user_map.html.haml @@ -8,9 +8,31 @@ Customize how Google Code email addresses and usernames are imported into GitLab. In the next step, you'll be able to select the projects you want to import. %p - The user map is a JSON document mapping Google Code users (as keys) to the way they will be imported into GitLab (as values). By default the username is masked to ensure users' privacy. - %p - To map a Google Code user to a full name or GitLab user, simply replace the value, e.g. "johnsmith@gmail.com": "John Smith" or "johnsmith@gmail.com": "@johnsmith". Be sure to preserve the surrounding double quotes and other punctuation. + The user map is a JSON document mapping the Google Code users that participated on your projects to the way their email addresses and usernames will be imported into GitLab. You can change this by changing the value on the right hand side of :. Be sure to preserve the surrounding double quotes, other punctuation and the email address or username on the left hand side. + %ul + %li + %strong Default: Directly import the Google Code email address or username + %p + "johnsmith@example.com": "johnsm...@example.com" + will add "By johnsm...@example.com" to all issues and comments originally created by johnsmith@example.com. + The email address or username is masked to ensure the user's privacy. + %li + %strong Map a Google Code user to a GitLab user + %p + "johnsmith@example.com": "@johnsmith" + will add "By @johnsmith" to all issues and comments originally created by johnsmith@example.com, + and will set @johnsmith as the assignee on all issues originally assigned to johnsmith@example.com. + %li + %strong Map a Google Code user to a full name + %p + "johnsmith@example.com": "John Smith" + will add "By John Smith" to all issues and comments originally created by johnsmith@example.com. + %li + %strong Map a Google Code user to a full email address + %p + "johnsmith@example.com": "johnsmith@example.com" + will add "By johnsmith@example.com" to all issues and comments originally created by johnsmith@example.com. + By default, the email address or username is masked to ensure the user's privacy. Use this option if you want to show the full email address. .form-group .col-sm-12 diff --git a/app/views/layouts/_empty_head_panel.html.haml b/app/views/layouts/_empty_head_panel.html.haml new file mode 100644 index 0000000000..b81c2d0364 --- /dev/null +++ b/app/views/layouts/_empty_head_panel.html.haml @@ -0,0 +1,5 @@ +%header.navbar.navbar-fixed-top.navbar-gitlab + .navbar-inner + .container + %h4.center + = image_tag 'logo-white.png', width: 32, height: 32 diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 0a962bd4b1..03830e7ec7 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -16,7 +16,7 @@ = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') - = render 'layouts/bootlint' if Rails.env == 'development' + = render 'layouts/bootlint' if Rails.env.development? -# Atom feed - if current_user diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index d58582c107..281ce31fe9 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -1,9 +1,10 @@ -%header.navbar.navbar-fixed-top.navbar-gitlab +%header.navbar.navbar-fixed-top.navbar-gitlab{ class: nav_header_class } .navbar-inner .container %div.app_logo = link_to root_path, class: "home has_bottom_tooltip", title: "Dashboard" do = brand_header_logo + %h3 GitLab %h1.title= title %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index 422966cdc5..1c164800b0 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -1,20 +1,18 @@ -- if defined?(sidebar) - .page-with-sidebar{ class: nav_sidebar_class } - = render "layouts/broadcast" - .sidebar-wrapper +.page-with-sidebar{ class: nav_sidebar_class } + = render "layouts/broadcast" + .sidebar-wrapper + - if defined?(sidebar) = render(sidebar) - .collapse-nav - = render partial: 'layouts/collapse_button' - .content-wrapper - .container-fluid - .content - = render "layouts/flash" - .clearfix - = yield -- else - .container.navless-container - .content - = yield + - elsif current_user + = render 'layouts/nav/dashboard' + .collapse-nav + = render partial: 'layouts/collapse_button' + .content-wrapper + .container-fluid + .content + = render "layouts/flash" + .clearfix + = yield = yield :embedded_scripts diff --git a/app/views/layouts/_public_head_panel.html.haml b/app/views/layouts/_public_head_panel.html.haml index 3d6d2bfc00..98a87a39bd 100644 --- a/app/views/layouts/_public_head_panel.html.haml +++ b/app/views/layouts/_public_head_panel.html.haml @@ -1,9 +1,10 @@ -%header.navbar.navbar-fixed-top.navbar-gitlab +%header.navbar.navbar-fixed-top.navbar-gitlab{ class: nav_header_class } .navbar-inner .container %div.app_logo = link_to explore_root_path, class: "home" do = brand_header_logo + %h3 GitLab %h1.title= title %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 0411843eb6..c7daa84e37 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -2,8 +2,8 @@ %html{ lang: "en"} = render "layouts/head" %body.ui_mars.login-page.application + = render "layouts/empty_head_panel" = render "layouts/broadcast" - = render "layouts/public_head_panel", title: '' .container.navless-container .content = render "layouts/flash" diff --git a/app/views/layouts/explore.html.haml b/app/views/layouts/explore.html.haml index 2bd0b8d85c..ca79382324 100644 --- a/app/views/layouts/explore.html.haml +++ b/app/views/layouts/explore.html.haml @@ -1,4 +1,4 @@ -- page_title = 'Explore' +- page_title = 'Explore GitLab' !!! 5 %html{ lang: "en"} = render "layouts/head", title: page_title @@ -8,23 +8,5 @@ = render "layouts/head_panel", title: link_to(page_title, explore_root_path) - else = render "layouts/public_head_panel", title: link_to(page_title, explore_root_path) - .container.navless-container - .content - .explore-title - %h3 - Explore GitLab - %p.lead - Discover projects and groups. Share your projects with others - - %ul.nav.nav-tabs - = nav_link(path: 'projects#trending') do - = link_to 'Trending Projects', explore_root_path - = nav_link(path: 'projects#starred') do - = link_to 'Most Starred Projects', starred_explore_projects_path - = nav_link(path: 'projects#index') do - = link_to 'All Projects', explore_projects_path - = nav_link(controller: :groups) do - = link_to 'All Groups', explore_groups_path - - = yield + = render 'layouts/page', sidebar: 'layouts/nav/explore' diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml index 46ae19f840..dc90d29c66 100644 --- a/app/views/layouts/nav/_admin.html.haml +++ b/app/views/layouts/nav/_admin.html.haml @@ -1,42 +1,42 @@ %ul.nav.nav-sidebar = nav_link(controller: :dashboard, html_options: {class: 'home'}) do = link_to admin_root_path, title: "Stats" do - %i.fa.fa-dashboard + = icon('dashboard fw') %span Overview = nav_link(controller: :projects) do = link_to admin_namespaces_projects_path, title: 'Projects' do - %i.fa.fa-cube + = icon('cube fw') %span Projects = nav_link(controller: :users) do = link_to admin_users_path, title: 'Users' do - %i.fa.fa-user + = icon('user fw') %span Users = nav_link(controller: :groups) do = link_to admin_groups_path, title: 'Groups' do - %i.fa.fa-group + = icon('group fw') %span Groups = nav_link(controller: :deploy_keys) do = link_to admin_deploy_keys_path, title: 'Deploy Keys' do - %i.fa.fa-key + = icon('key fw') %span Deploy Keys = nav_link(controller: :logs) do = link_to admin_logs_path, title: 'Logs' do - %i.fa.fa-file-text + = icon('file-text fw') %span Logs = nav_link(controller: :broadcast_messages) do = link_to admin_broadcast_messages_path, title: 'Broadcast Messages' do - %i.fa.fa-bullhorn + = icon('bullhorn fw') %span Messages = nav_link(controller: :hooks) do = link_to admin_hooks_path, title: 'Hooks' do - %i.fa.fa-external-link + = icon('external-link fw') %span Hooks = nav_link(controller: :git_hooks) do @@ -46,7 +46,7 @@ Git Hooks = nav_link(controller: :background_jobs) do = link_to admin_background_jobs_path, title: 'Background Jobs' do - %i.fa.fa-cog + = icon('cog fw') %span Background Jobs = nav_link(controller: :appearances) do @@ -57,19 +57,18 @@ = nav_link(controller: :applications) do = link_to admin_applications_path, title: 'Applications' do - %i.fa.fa-cloud + = icon('cloud fw') %span Applications = nav_link(controller: :services) do = link_to admin_application_settings_services_path, title: 'Service Templates' do - %i.fa.fa-copy + = icon('copy fw') %span Service Templates = nav_link(controller: :application_settings, html_options: { class: 'separate-item'}) do = link_to admin_application_settings_path, title: 'Settings' do - %i.fa.fa-cogs + = icon('cogs fw') %span Settings - diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml index e4f630c6a1..c5997e4437 100644 --- a/app/views/layouts/nav/_dashboard.html.haml +++ b/app/views/layouts/nav/_dashboard.html.haml @@ -1,38 +1,38 @@ %ul.nav.nav-sidebar = nav_link(path: 'dashboard#show', html_options: {class: 'home'}) do = link_to root_path, title: 'Home', class: 'shortcuts-activity' do - %i.fa.fa-dashboard + = icon('dashboard fw') %span Your Projects = nav_link(path: 'projects#starred') do = link_to starred_dashboard_projects_path, title: 'Starred Projects' do - %i.fa.fa-star + = icon('star fw') %span Starred Projects = nav_link(controller: :groups) do = link_to dashboard_groups_path, title: 'Groups' do - %i.fa.fa-group + = icon('group fw') %span Groups = nav_link(controller: :milestones) do = link_to dashboard_milestones_path, title: 'Milestones' do - %i.fa.fa-clock-o + = icon('clock-o fw') %span Milestones = nav_link(path: 'dashboard#issues') do = link_to assigned_issues_dashboard_path, title: 'Issues', class: 'shortcuts-issues' do - %i.fa.fa-exclamation-circle + = icon('exclamation-circle fw') %span Issues %span.count= current_user.assigned_issues.opened.count = nav_link(path: 'dashboard#merge_requests') do = link_to assigned_mrs_dashboard_path, title: 'Merge Requests', class: 'shortcuts-merge_requests' do - %i.fa.fa-tasks + = icon('tasks fw') %span Merge Requests %span.count= current_user.assigned_merge_requests.opened.count = nav_link(controller: :help) do = link_to help_path, title: 'Help' do - %i.fa.fa-question-circle + = icon('question-circle fw') %span Help diff --git a/app/views/layouts/nav/_explore.html.haml b/app/views/layouts/nav/_explore.html.haml new file mode 100644 index 0000000000..38d84cd9b5 --- /dev/null +++ b/app/views/layouts/nav/_explore.html.haml @@ -0,0 +1,18 @@ +%ul.nav.nav-sidebar + = nav_link(path: 'projects#trending') do + = link_to explore_root_path do + = icon('comments fw') + %span Trending Projects + = nav_link(path: 'projects#starred') do + = link_to starred_explore_projects_path do + = icon('star fw') + %span Most Starred Projects + = nav_link(path: 'projects#index') do + = link_to explore_projects_path do + = icon('bookmark fw') + %span All Projects + = nav_link(controller: :groups) do + = link_to explore_groups_path do + = icon('group fw') + %span All Groups + diff --git a/app/views/layouts/nav/_group.html.haml b/app/views/layouts/nav/_group.html.haml index f0d92b7a12..7cce9ffe3d 100644 --- a/app/views/layouts/nav/_group.html.haml +++ b/app/views/layouts/nav/_group.html.haml @@ -1,42 +1,42 @@ %ul.nav.nav-sidebar = nav_link(path: 'groups#show', html_options: {class: 'home'}) do = link_to group_path(@group), title: "Home" do - %i.fa.fa-dashboard + = icon('dashboard fw') %span Activity - if current_user = nav_link(controller: [:group, :milestones]) do = link_to group_milestones_path(@group), title: 'Milestones' do - %i.fa.fa-clock-o + = icon('clock-o fw') %span Milestones = nav_link(path: 'groups#issues') do = link_to issues_group_path(@group), title: 'Issues' do - %i.fa.fa-exclamation-circle + = icon('exclamation-circle fw') %span Issues - if current_user %span.count= Issue.opened.of_group(@group).count = nav_link(path: 'groups#merge_requests') do = link_to merge_requests_group_path(@group), title: 'Merge Requests' do - %i.fa.fa-tasks + = icon('tasks fw') %span Merge Requests - if current_user %span.count= MergeRequest.opened.of_group(@group).count = nav_link(controller: [:group_members]) do = link_to group_group_members_path(@group), title: 'Members' do - %i.fa.fa-users + = icon('users fw') %span Members - if can?(current_user, :admin_group, @group) = nav_link(html_options: { class: "#{"active" if group_settings_page?} separate-item" }) do = link_to edit_group_path(@group), title: 'Settings', class: "tab no-highlight" do - %i.fa.fa-cogs + = icon ('cogs fw') %span Settings - %i.fa.fa-angle-down + = icon ('angle-down fw') - if group_settings_page? = render 'groups/settings_nav' diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml index d88e862829..9f2932c79c 100644 --- a/app/views/layouts/nav/_profile.html.haml +++ b/app/views/layouts/nav/_profile.html.haml @@ -1,50 +1,50 @@ %ul.nav.nav-sidebar = nav_link(path: 'profiles#show', html_options: {class: 'home'}) do = link_to profile_path, title: "Profile" do - %i.fa.fa-user + = icon('user fw') %span Profile = nav_link(controller: :accounts) do = link_to profile_account_path, title: 'Account' do - %i.fa.fa-gear + = icon('gear fw') %span Account = nav_link(path: ['profiles#applications', 'applications#edit', 'applications#show', 'applications#new']) do = link_to applications_profile_path, title: 'Applications' do - %i.fa.fa-cloud + = icon('cloud fw') %span Applications = nav_link(controller: :emails) do = link_to profile_emails_path, title: 'Emails' do - %i.fa.fa-envelope-o + = icon('envelope-o fw') %span Emails %span.count= current_user.emails.count + 1 - unless current_user.ldap_user? = nav_link(controller: :passwords) do = link_to edit_profile_password_path, title: 'Password' do - %i.fa.fa-lock + = icon('lock fw') %span Password = nav_link(controller: :notifications) do = link_to profile_notifications_path, title: 'Notifications' do - %i.fa.fa-inbox + = icon('inbox fw') %span Notifications = nav_link(controller: :keys) do = link_to profile_keys_path, title: 'SSH Keys' do - %i.fa.fa-key + = icon('key fw') %span SSH Keys %span.count= current_user.keys.count = nav_link(path: 'profiles#design') do = link_to design_profile_path, title: 'Design' do - %i.fa.fa-image + = icon('image fw') %span Design = nav_link(path: 'profiles#history') do = link_to history_profile_path, title: 'History' do - %i.fa.fa-history + = icon('history fw') %span History diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml index 6c13f30f62..a2a9d8a340 100644 --- a/app/views/layouts/nav/_project.html.haml +++ b/app/views/layouts/nav/_project.html.haml @@ -2,7 +2,7 @@ - if @project_settings_nav = nav_link do = link_to project_path(@project), title: 'Back to project', class: "" do - %i.fa.fa-caret-square-o-left + = icon('caret-square-o-left fw') %span Back to project @@ -13,48 +13,48 @@ - else = nav_link(path: 'projects#show', html_options: {class: "home"}) do = link_to project_path(@project), title: 'Project', class: 'shortcuts-project' do - %i.fa.fa-dashboard + = icon('dashboard fw') %span Project - if project_nav_tab? :files = nav_link(controller: %w(tree blob blame edit_tree new_tree)) do = link_to namespace_project_tree_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Files', class: 'shortcuts-tree' do - %i.fa.fa-files-o + = icon('files-o fw') %span Files - if project_nav_tab? :commits = nav_link(controller: %w(commit commits compare repositories tags branches)) do = link_to namespace_project_commits_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Commits', class: 'shortcuts-commits' do - %i.fa.fa-history + = icon('history fw') %span Commits - if project_nav_tab? :network = nav_link(controller: %w(network)) do = link_to namespace_project_network_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Network', class: 'shortcuts-network' do - %i.fa.fa-code-fork + = icon('code-fork fw') %span Network - if project_nav_tab? :graphs = nav_link(controller: %w(graphs)) do = link_to namespace_project_graph_path(@project.namespace, @project, @ref || @repository.root_ref), title: 'Graphs', class: 'shortcuts-graphs' do - %i.fa.fa-area-chart + = icon('area-chart fw') %span Graphs - if project_nav_tab? :milestones = nav_link(controller: :milestones) do = link_to namespace_project_milestones_path(@project.namespace, @project), title: 'Milestones' do - %i.fa.fa-clock-o + = icon('clock-o fw') %span Milestones - if project_nav_tab? :issues = nav_link(controller: :issues) do = link_to url_for_project_issues(@project, only_path: true), title: 'Issues', class: 'shortcuts-issues' do - %i.fa.fa-exclamation-circle + = icon('exclamation-circle fw') %span Issues - if @project.default_issues_tracker? @@ -63,7 +63,7 @@ - if project_nav_tab? :merge_requests = nav_link(controller: :merge_requests) do = link_to namespace_project_merge_requests_path(@project.namespace, @project), title: 'Merge Requests', class: 'shortcuts-merge_requests' do - %i.fa.fa-tasks + = icon('tasks fw') %span Merge Requests %span.count.merge_counter= @project.merge_requests.opened.count @@ -71,27 +71,27 @@ - if project_nav_tab? :labels = nav_link(controller: :labels) do = link_to namespace_project_labels_path(@project.namespace, @project), title: 'Labels' do - %i.fa.fa-tags + = icon('tags fw') %span Labels - if project_nav_tab? :wiki = nav_link(controller: :wikis) do = link_to get_project_wiki_path(@project), title: 'Wiki', class: 'shortcuts-wiki' do - %i.fa.fa-book + = icon('book fw') %span Wiki - if project_nav_tab? :snippets = nav_link(controller: :snippets) do = link_to namespace_project_snippets_path(@project.namespace, @project), title: 'Snippets', class: 'shortcuts-snippets' do - %i.fa.fa-file-text-o + = icon('file-text-o fw') %span Snippets - if project_nav_tab? :settings = nav_link(html_options: {class: "#{project_tab_class} separate-item"}) do = link_to edit_project_path(@project), title: 'Settings', class: "stat-tab tab no-highlight" do - %i.fa.fa-cogs + = icon('cogs fw') %span Settings diff --git a/app/views/layouts/nav/_snippets.html.haml b/app/views/layouts/nav/_snippets.html.haml new file mode 100644 index 0000000000..edd05f2dd8 --- /dev/null +++ b/app/views/layouts/nav/_snippets.html.haml @@ -0,0 +1,11 @@ +%ul.nav.nav-sidebar + = nav_link(path: user_snippets_path(current_user), html_options: {class: 'home'}) do + = link_to user_snippets_path(current_user), title: 'Your snippets' do + = icon('dashboard fw') + %span + Your Snippets + = nav_link(path: snippets_path) do + = link_to snippets_path, title: 'Discover snippets' do + = icon('globe fw') + %span + Discover Snippets diff --git a/app/views/layouts/navless.html.haml b/app/views/layouts/navless.html.haml index 4d0278251a..10a0fcea2f 100644 --- a/app/views/layouts/navless.html.haml +++ b/app/views/layouts/navless.html.haml @@ -4,7 +4,4 @@ %body{class: "#{app_theme} application", :'data-page' => body_data_page} = render "layouts/broadcast" = render "layouts/head_panel", title: defined?(@title_url) ? link_to(@title, @title_url) : @title - .container.navless-container - .content - = render "layouts/flash" - = yield + = render 'layouts/page' diff --git a/app/views/layouts/snippets.html.haml b/app/views/layouts/snippets.html.haml new file mode 100644 index 0000000000..fbd29eb23a --- /dev/null +++ b/app/views/layouts/snippets.html.haml @@ -0,0 +1,6 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head", title: "Dashboard" + %body{class: "#{app_theme} application", :'data-page' => body_data_page } + = render "layouts/head_panel", title: link_to("Snippets", snippets_path) + = render 'layouts/page', sidebar: 'layouts/nav/snippets' diff --git a/app/views/profiles/design.html.haml b/app/views/profiles/design.html.haml index cc00d08d03..646576c316 100644 --- a/app/views/profiles/design.html.haml +++ b/app/views/profiles/design.html.haml @@ -12,17 +12,17 @@ = label_tag do .prev.default = f.radio_button :theme_id, 1 - Default + Graphite = label_tag do .prev.classic = f.radio_button :theme_id, 2 - Classic + Charcoal = label_tag do .prev.modern = f.radio_button :theme_id, 3 - Modern + Green = label_tag do .prev.gray diff --git a/app/views/projects/_md_preview.html.haml b/app/views/projects/_md_preview.html.haml index f356a25dbf..b869fd6e12 100644 --- a/app/views/projects/_md_preview.html.haml +++ b/app/views/projects/_md_preview.html.haml @@ -9,5 +9,5 @@ %div .md-write-holder = yield - .md-preview-holder.hide + .md.md-preview-holder.hide .js-md-preview{class: (preview_class if defined?(preview_class))} diff --git a/app/views/projects/merge_requests/_new_submit.html.haml b/app/views/projects/merge_requests/_new_submit.html.haml index d986ce67c0..4e72458932 100644 --- a/app/views/projects/merge_requests/_new_submit.html.haml +++ b/app/views/projects/merge_requests/_new_submit.html.haml @@ -82,12 +82,12 @@ .mr-compare.merge-request %ul.nav.nav-tabs.merge-request-tabs - %li.commits-tab{data: {action: 'commits'}} + %li.commits-tab{data: {action: 'commits', toggle: 'tab'}} = link_to url_for(params) do %i.fa.fa-history Commits %span.badge= @commits.size - %li.diffs-tab{data: {action: 'diffs'}} + %li.diffs-tab{data: {action: 'diffs', toggle: 'tab'}} = link_to url_for(params) do %i.fa.fa-list-alt Changes diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml index ce6b7a0737..1b465e3add 100644 --- a/app/views/projects/services/_form.html.haml +++ b/app/views/projects/services/_form.html.haml @@ -10,7 +10,7 @@ %hr -= form_for(@service, as: :service, url: namespace_project_service_path(@project.namespace, @project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f| += form_for(@service, as: :service, url: namespace_project_service_path(@project.namespace, @project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |form| - if @service.errors.any? .alert.alert-danger %ul @@ -23,83 +23,71 @@ = markdown @service.help .form-group - = f.label :active, "Active", class: "control-label" + = form.label :active, "Active", class: "control-label" .col-sm-10 - = f.check_box :active + = form.check_box :active - if @service.supported_events.length > 1 .form-group - = f.label :url, "Trigger", class: 'control-label' + = form.label :url, "Trigger", class: 'control-label' .col-sm-10 - if @service.supported_events.include?("push") %div - = f.check_box :push_events, class: 'pull-left' + = form.check_box :push_events, class: 'pull-left' .prepend-left-20 - = f.label :push_events, class: 'list-label' do + = form.label :push_events, class: 'list-label' do %strong Push events %p.light This url will be triggered by a push to the repository - if @service.supported_events.include?("tag_push") %div - = f.check_box :tag_push_events, class: 'pull-left' + = form.check_box :tag_push_events, class: 'pull-left' .prepend-left-20 - = f.label :tag_push_events, class: 'list-label' do + = form.label :tag_push_events, class: 'list-label' do %strong Tag push events %p.light This url will be triggered when a new tag is pushed to the repository - if @service.supported_events.include?("note") %div - = f.check_box :note_events, class: 'pull-left' + = form.check_box :note_events, class: 'pull-left' .prepend-left-20 - = f.label :note_events, class: 'list-label' do + = form.label :note_events, class: 'list-label' do %strong Comments %p.light This url will be triggered when someone adds a comment - if @service.supported_events.include?("issue") %div - = f.check_box :issues_events, class: 'pull-left' + = form.check_box :issues_events, class: 'pull-left' .prepend-left-20 - = f.label :issues_events, class: 'list-label' do + = form.label :issues_events, class: 'list-label' do %strong Issues events %p.light This url will be triggered when an issue is created - if @service.supported_events.include?("merge_request") %div - = f.check_box :merge_requests_events, class: 'pull-left' + = form.check_box :merge_requests_events, class: 'pull-left' .prepend-left-20 - = f.label :merge_requests_events, class: 'list-label' do + = form.label :merge_requests_events, class: 'list-label' do %strong Merge Request events %p.light This url will be triggered when a merge request is created - @service.fields.each do |field| - - name = field[:name] - - title = field[:title] || name.humanize - - value = service_field_value(field[:type], @service.send(name)) - type = field[:type] - - placeholder = field[:placeholder] - - choices = field[:choices] - - default_choice = field[:default_choice] - - help = field[:help] - .form-group - = f.label name, title, class: "control-label" - .col-sm-10 - - if type == 'text' - = f.text_field name, class: "form-control", placeholder: placeholder - - elsif type == 'textarea' - = f.text_area name, rows: 5, class: "form-control", placeholder: placeholder - - elsif type == 'checkbox' - = f.check_box name - - elsif type == 'select' - = f.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" } - - elsif type == 'password' - = f.password_field name, placeholder: value, class: 'form-control' - - if help - %span.help-block= help + - if type == 'fieldset' + - fields = field[:fields] + - legend = field[:legend] + + %fieldset + %legend= legend + - fields.each do |subfield| + = render 'shared/field', form: form, field: subfield + - else + = render 'shared/field', form: form, field: field .form-actions - = f.submit 'Save', class: 'btn btn-save' + = form.submit 'Save', class: 'btn btn-save'   - if @service.valid? && @service.activated? - disabled = @service.can_test? ? '':'disabled' diff --git a/app/views/shared/_field.html.haml b/app/views/shared/_field.html.haml new file mode 100644 index 0000000000..30d37dceb3 --- /dev/null +++ b/app/views/shared/_field.html.haml @@ -0,0 +1,24 @@ +- name = field[:name] +- title = field[:title] || name.humanize +- value = service_field_value(field[:type], @service.send(name)) +- type = field[:type] +- placeholder = field[:placeholder] +- choices = field[:choices] +- default_choice = field[:default_choice] +- help = field[:help] + +.form-group + = form.label name, title, class: "control-label" + .col-sm-10 + - if type == 'text' + = form.text_field name, class: "form-control", placeholder: placeholder + - elsif type == 'textarea' + = form.text_area name, rows: 5, class: "form-control", placeholder: placeholder + - elsif type == 'checkbox' + = form.check_box name + - elsif type == 'select' + = form.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" } + - elsif type == 'password' + = form.password_field name, placeholder: value, class: 'form-control' + - if help + %span.help-block= help diff --git a/app/views/snippets/current_user_index.html.haml b/app/views/snippets/current_user_index.html.haml index 0df5ade500..6bb2237a75 100644 --- a/app/views/snippets/current_user_index.html.haml +++ b/app/views/snippets/current_user_index.html.haml @@ -3,37 +3,32 @@ .pull-right = link_to new_snippet_path, class: "btn btn-new btn-grouped", title: "New Snippet" do Add new snippet - = link_to snippets_path, class: "btn btn-grouped" do - Discover snippets %p.light Share code pastes with others out of git repository -%hr -.row - .col-md-3 - %ul.nav.nav-pills.nav-stacked - = nav_tab :scope, nil do - = link_to user_snippets_path(@user) do - All - %span.pull-right - = @user.snippets.count - = nav_tab :scope, 'are_private' do - = link_to user_snippets_path(@user, scope: 'are_private') do - Private - %span.pull-right - = @user.snippets.are_private.count - = nav_tab :scope, 'are_internal' do - = link_to user_snippets_path(@user, scope: 'are_internal') do - Internal - %span.pull-right - = @user.snippets.are_internal.count - = nav_tab :scope, 'are_public' do - = link_to user_snippets_path(@user, scope: 'are_public') do - Public - %span.pull-right - = @user.snippets.are_public.count +%ul.nav.nav-tabs + = nav_tab :scope, nil do + = link_to user_snippets_path(@user) do + All + %span.badge + = @user.snippets.count + = nav_tab :scope, 'are_private' do + = link_to user_snippets_path(@user, scope: 'are_private') do + Private + %span.badge + = @user.snippets.are_private.count + = nav_tab :scope, 'are_internal' do + = link_to user_snippets_path(@user, scope: 'are_internal') do + Internal + %span.badge + = @user.snippets.are_internal.count + = nav_tab :scope, 'are_public' do + = link_to user_snippets_path(@user, scope: 'are_public') do + Public + %span.badge + = @user.snippets.are_public.count - .col-md-9.my-snippets - = render 'snippets' +.my-snippets + = render 'snippets' diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml index 5cd8ae26cf..108dd0cca3 100644 --- a/app/views/snippets/index.html.haml +++ b/app/views/snippets/index.html.haml @@ -2,7 +2,6 @@ Public snippets .pull-right - - if current_user = link_to new_snippet_path, class: "btn btn-new btn-grouped", title: "New Snippet" do Add new snippet diff --git a/config/initializers/6_rack_profiler.rb b/config/initializers/6_rack_profiler.rb index b634028756..bdad6202b1 100644 --- a/config/initializers/6_rack_profiler.rb +++ b/config/initializers/6_rack_profiler.rb @@ -1,4 +1,4 @@ -if Rails.env == 'development' +if Rails.env.development? require 'rack-mini-profiler' # initialization is skipped so trigger it diff --git a/config/initializers/8_default_url_options.rb b/config/initializers/8_default_url_options.rb new file mode 100644 index 0000000000..8c1b56846d --- /dev/null +++ b/config/initializers/8_default_url_options.rb @@ -0,0 +1,13 @@ +unless Rails.env.test? + default_url_options = { + host: Gitlab.config.gitlab.host, + protocol: Gitlab.config.gitlab.protocol, + script_name: Gitlab.config.gitlab.relative_url_root + } + + unless Gitlab.config.gitlab_on_standard_port? + default_url_options[:port] = Gitlab.config.gitlab.port + end + + Rails.application.routes.default_url_options = default_url_options +end diff --git a/config/routes.rb b/config/routes.rb index 9ec68b5d66..843dfe2b29 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ require 'sidekiq/web' require 'api/api' Gitlab::Application.routes.draw do + mount JasmineRails::Engine => '/specs' if defined?(JasmineRails) use_doorkeeper do controllers applications: 'oauth/applications', authorized_applications: 'oauth/authorized_applications', @@ -51,7 +52,8 @@ Gitlab::Application.routes.draw do get 'raw' end end - get '/s/:username' => 'snippets#user_index', as: :user_snippets, constraints: { username: /.*/ } + + get '/s/:username' => 'snippets#index', as: :user_snippets, constraints: { username: /.*/ } # # Invites diff --git a/doc/integration/slack.md b/doc/integration/slack.md index 2fd22c513a..84f1d74c05 100644 --- a/doc/integration/slack.md +++ b/doc/integration/slack.md @@ -16,7 +16,7 @@ To enable Slack integration you must create an Incoming WebHooks integration on 1. Choose the channel name you want to send notifications to -1. Click **Add Incoming WebHooks Integration**Add Integrations. +1. Click **Add Incoming WebHooks Integration** - Optional step; You can change bot's name and avatar by clicking modifying the bot name or avatar under **Integration Settings**. 1. Copy the **Webhook URL**, we'll need this later for GitLab. @@ -32,10 +32,15 @@ After Slack is ready we need to setup GitLab. Here are the steps to achieve this 1. Navigate to Settings -> Services -> Slack -1. Fill in your Slack details +1. Pick the triggers you want to activate +1. Fill in your Slack details + - Webhook: Paste the Webhook URL from the step above + - Username: Fill this in if you want to change the username of the bot + - Channel: Fill this in if you want to change the channel where the messages will be posted - Mark it as active - - Paste in the webhook URL you got from Slack + +1. Save your settings Have fun :) diff --git a/doc/markdown/markdown.md b/doc/markdown/markdown.md index 1d5fd4c8b0..8ec5a20035 100644 --- a/doc/markdown/markdown.md +++ b/doc/markdown/markdown.md @@ -163,7 +163,7 @@ Consult the [Emoji Cheat Sheet](http://emoji.codes) for a list of all supported ## Special GitLab References -GFM recognized special references. +GFM recognizes special references. You can easily reference e.g. an issue, a commit, a team member or even the whole team within a project. @@ -171,19 +171,30 @@ GFM will turn that reference into a link so you can navigate between them easily GFM will recognize the following: -- @foo : for specific team members or groups -- @all : for the whole team -- #123 : for issues -- !123 : for merge requests -- $123 : for snippets -- 1234567 : for commits -- \[file\](path/to/file) : for file references +| input | references | +|-----------------------:|:---------------------------| +| `@user_name` | specific user | +| `@group_name` | specific group | +| `@all` | entire team | +| `#123` | issue | +| `!123` | merge request | +| `$123` | snippet | +| `~123` | label by ID | +| `~bug` | one-word label by name | +| `~"feature request"` | multi-word label by name | +| `9ba12248` | specific commit | +| `9ba12248...b19a04f5` | commit range comparison | +| `[README](doc/README)` | repository file references | -GFM also recognizes references to commits, issues, and merge requests in other projects: +GFM also recognizes certain cross-project references: -- namespace/project#123 : for issues -- namespace/project!123 : for merge requests -- namespace/project@1234567 : for commits +| input | references | +|----------------------------------------:|:------------------------| +| `namespace/project#123` | issue | +| `namespace/project!123` | merge request | +| `namespace/project$123` | snippet | +| `namespace/project@9ba12248` | specific commit | +| `namespace/project@9ba12248...b19a04f5` | commit range comparison | ## Task Lists diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index 2e41fad89e..bfef975024 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -162,6 +162,7 @@ Options: ``` BACKUP=timestamp_of_backup (required if more than one backup exists) +force=yes (do not ask if the authorized_keys file should get regenerated) ``` Example output: diff --git a/doc/update/6.x-or-7.x-to-7.10.md b/doc/update/6.x-or-7.x-to-7.10.md index 7ab26c8837..f03436b9a0 100644 --- a/doc/update/6.x-or-7.x-to-7.10.md +++ b/doc/update/6.x-or-7.x-to-7.10.md @@ -126,7 +126,7 @@ sudo apt-get install nodejs ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v2.6.0 +sudo -u git -H git checkout v2.6.2 ``` ## 7. Install libs, migrations, etc. diff --git a/doc/update/7.8-to-7.9.md b/doc/update/7.8-to-7.9.md index 28fd433e1c..6ffa21c614 100644 --- a/doc/update/7.8-to-7.9.md +++ b/doc/update/7.8-to-7.9.md @@ -42,6 +42,8 @@ sudo -u git -H git checkout v2.6.0 ### 4. Install libs, migrations, etc. +Please refer to the [Node.js setup documentation](https://github.com/joyent/node/wiki/installing-node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions) if you aren't running default GitLab server setup. + ```bash sudo apt-get install nodejs diff --git a/doc/update/7.9-to-7.10.md b/doc/update/7.9-to-7.10.md new file mode 100644 index 0000000000..0512e7cde7 --- /dev/null +++ b/doc/update/7.9-to-7.10.md @@ -0,0 +1,118 @@ +# From 7.9 to 7.10 + +### 0. Stop server + + sudo service gitlab stop + +### 1. Backup + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 2. Get latest code + +```bash +sudo -u git -H git fetch --all +sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically +``` + +For GitLab Community Edition: + +```bash +sudo -u git -H git checkout 7-10-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 7-10-stable-ee +``` + +### 3. Update gitlab-shell + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v2.6.2 +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL installations (note: the line below states '--without ... postgres') +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL installations (note: the line below states '--without ... mysql') +sudo -u git -H bundle install --without development test mysql --deployment + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +``` + +### 5. Update config files + +#### New configuration options for `gitlab.yml` + +There are new configuration options available for [`gitlab.yml`](config/gitlab.yml.example). View them with the command below and apply them to your current `gitlab.yml`. + +``` +git diff origin/7-9-stable:config/gitlab.yml.example origin/7-10-stable:config/gitlab.yml.example +``` + +#### Change Nginx settings + +* HTTP setups: Make `/etc/nginx/sites-available/gitlab` the same as [`lib/support/nginx/gitlab`](/lib/support/nginx/gitlab) but with your settings. +* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as [`lib/support/nginx/gitlab-ssl`](/lib/support/nginx/gitlab-ssl) but with your settings. +* A new `location /uploads/` section has been added that needs to have the same content as the existing `location @gitlab` section. + +#### Setup time zone (optional) + +Consider setting the time zone in `gitlab.yml` otherwise GitLab will default to UTC. If you set a time zone previously in [`application.rb`](config/application.rb) (unlikely), unset it. + +### 6. Start application + + sudo service gitlab start + sudo service nginx restart + +### 7. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade is complete! + +### 8. GitHub settings (if applicable) + +If you are using GitHub as an OAuth provider for authentication, you should change the callback URL so that it +only contains a root URL (ex. `https://gitlab.example.com/`) + +## Things went south? Revert to previous version (7.9) + +### 1. Revert the code to the previous version +Follow the [upgrade guide from 7.8 to 7.8](7.8-to-7.9.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` +If you have more than one backup *.tar file(s) please add `BACKUP=timestamp_of_backup` to the command above. \ No newline at end of file diff --git a/doc/update/upgrader.md b/doc/update/upgrader.md index f62a53d334..e32984c4e6 100644 --- a/doc/update/upgrader.md +++ b/doc/update/upgrader.md @@ -26,12 +26,11 @@ If you have local changes to your GitLab repository the script will stash them a Note: GitLab 7.9 adds `nodejs` as a dependency. GitLab 7.6 adds `libkrb5-dev` as a dependency (installed by default on Ubuntu and OSX). GitLab 7.2 adds `pkg-config` and `cmake` as dependency. Please check the dependencies in the [installation guide.](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#1-packages-dependencies) - # Starting with GitLab version 7.0 upgrader script has been moved to bin directory cd /home/git/gitlab - if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb; else sudo -u git -H ruby script/upgrade.rb; fi + sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"v7.10.0"' -e 'end' -e 'end' -e 'Gitlab::Upgrader.new.execute' # to perform a non-interactive install (no user input required) you can add -y - # if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb -y; else sudo -u git -H ruby script/upgrade.rb -y; fi + # sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"v7.10.0"' -e 'end' -e 'end' -e 'Gitlab::Upgrader.new.execute' -- -y ## 3. Start application @@ -66,11 +65,12 @@ Here is a one line command with step 1 to 5 for the next time you upgrade: cd /home/git/gitlab; \ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \ sudo service gitlab stop; \ - if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb -y; else sudo -u git -H ruby script/upgrade.rb -y; fi; \ + sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"v7.10.0"' -e 'end' -e 'end' -e 'Gitlab::Upgrader.new.execute' -- -y; \ cd /home/git/gitlab-shell; \ sudo -u git -H git fetch; \ sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`; \ cd /home/git/gitlab; \ sudo service gitlab start; \ - sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + sudo service nginx restart; \ + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production ``` diff --git a/features/steps/snippets/user.rb b/features/steps/snippets/user.rb index 866f637ab6..146cc535d8 100644 --- a/features/steps/snippets/user.rb +++ b/features/steps/snippets/user.rb @@ -32,19 +32,19 @@ class Spinach::Features::SnippetsUser < Spinach::FeatureSteps end step 'I click "Internal" filter' do - within('.nav-stacked') do + within('.nav-tabs') do click_link "Internal" end end step 'I click "Private" filter' do - within('.nav-stacked') do + within('.nav-tabs') do click_link "Private" end end step 'I click "Public" filter' do - within('.nav-stacked') do + within('.nav-tabs') do click_link "Public" end end diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index b5e82563ff..70bfe05977 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -30,7 +30,10 @@ module Gitlab def user_map @user_map ||= begin - user_map = Hash.new { |hash, user| Client.mask_email(user) } + user_map = Hash.new do |hash, user| + # Replace ... by \.\.\., so `johnsm...@gmail.com` isn't autolinked. + Client.mask_email(user).sub("...", "\\.\\.\\.") + end import_data = project.import_data.try(:data) stored_user_map = import_data["user_map"] if import_data @@ -203,25 +206,25 @@ module Gitlab end def linkify_issues(s) - s.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2') + s = s.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2') + s = s.gsub(/([Cc]omment) #([0-9]+)/, '\1 \2') + s end def escape_for_markdown(s) - s = s.gsub("*", "\\*") - s = s.gsub("#", "\\#") + # No headings and lists + s = s.gsub(/^#/, "\\#") + s = s.gsub(/^-/, "\\-") + + # No inline code s = s.gsub("`", "\\`") - s = s.gsub(":", "\\:") - s = s.gsub("-", "\\-") - s = s.gsub("+", "\\+") - s = s.gsub("_", "\\_") - s = s.gsub("(", "\\(") - s = s.gsub(")", "\\)") - s = s.gsub("[", "\\[") - s = s.gsub("]", "\\]") - s = s.gsub("<", "\\<") - s = s.gsub(">", "\\>") + + # Carriage returns make me sad s = s.gsub("\r", "") + + # Markdown ignores single newlines, but we need them as
. s = s.gsub("\n", " \n") + s end @@ -276,11 +279,18 @@ module Gitlab if raw_updates.has_key?("blockedOn") blocked_ons = raw_updates["blockedOn"].map do |raw_blocked_on| name, id = raw_blocked_on.split(":", 2) - if name == project.import_source - "##{id}" - else - "#{project.namespace.path}/#{name}##{id}" - end + + deleted = name.start_with?("-") + name = name[1..-1] if deleted + + text = + if name == project.import_source + "##{id}" + else + "#{project.namespace.path}/#{name}##{id}" + end + text = "~~#{text}~~" if deleted + text end updates << "*Blocked on: #{blocked_ons.join(", ")}*" end @@ -288,11 +298,18 @@ module Gitlab if raw_updates.has_key?("blocking") blockings = raw_updates["blocking"].map do |raw_blocked_on| name, id = raw_blocked_on.split(":", 2) - if name == project.import_source - "##{id}" - else - "#{project.namespace.path}/#{name}##{id}" - end + + deleted = name.start_with?("-") + name = name[1..-1] if deleted + + text = + if name == project.import_source + "##{id}" + else + "#{project.namespace.path}/#{name}##{id}" + end + text = "~~#{text}~~" if deleted + text end updates << "*Blocking: #{blockings.join(", ")}*" end @@ -340,7 +357,7 @@ module Gitlab def format_issue_body(author, date, content, attachments) body = [] - body << "*By #{author} on #{date}*" + body << "*By #{author} on #{date} (imported from Google Code)*" body << "---" if content.blank? diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 47c456d8dc..44779d7fdd 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -1,5 +1,4 @@ require 'html/pipeline' -require 'html/pipeline/gitlab' module Gitlab # Custom parser for GitLab-flavored Markdown @@ -10,11 +9,11 @@ module Gitlab # Supported reference formats are: # * @foo for team members # * #123 for issues - # * #JIRA-123 for Jira issues + # * JIRA-123 for Jira issues # * !123 for merge requests # * $123 for snippets - # * 123456 for commits - # * 123456...7890123 for commit ranges (comparisons) + # * 1c002d for specific commit + # * 1c002d...35cfb2 for commit ranges (comparisons) # # It also parses Emoji codes to insert images. See # http://www.emoji-cheat-sheet.com/ for a list of the supported icons. @@ -30,9 +29,16 @@ module Gitlab # >> gfm(":trollface:") # => "\":trollface:\" module Markdown - include IssuesHelper - - attr_reader :options, :html_options + # Provide autoload paths for filters to prevent a circular dependency error + autoload :CommitRangeReferenceFilter, 'gitlab/markdown/commit_range_reference_filter' + autoload :CommitReferenceFilter, 'gitlab/markdown/commit_reference_filter' + autoload :EmojiFilter, 'gitlab/markdown/emoji_filter' + autoload :ExternalIssueReferenceFilter, 'gitlab/markdown/external_issue_reference_filter' + autoload :IssueReferenceFilter, 'gitlab/markdown/issue_reference_filter' + autoload :LabelReferenceFilter, 'gitlab/markdown/label_reference_filter' + autoload :MergeRequestReferenceFilter, 'gitlab/markdown/merge_request_reference_filter' + autoload :SnippetReferenceFilter, 'gitlab/markdown/snippet_reference_filter' + autoload :UserReferenceFilter, 'gitlab/markdown/user_reference_filter' # Public: Parse the provided text with GitLab-Flavored Markdown # @@ -65,47 +71,24 @@ module Gitlab reference_only_path: true ) - @options = options - @html_options = html_options + pipeline = HTML::Pipeline.new(filters) - # TODO: add popups with additional information + context = { + # SanitizationFilter + whitelist: sanitization_whitelist, - # Used markdown pipelines in GitLab: - # GitlabEmojiFilter - performs emoji replacement. - # SanitizationFilter - remove unsafe HTML tags and attributes - # - # see https://gitlab.com/gitlab-org/html-pipeline-gitlab for more filters - filters = [ - HTML::Pipeline::Gitlab::GitlabEmojiFilter, - HTML::Pipeline::SanitizationFilter - ] + # EmojiFilter + asset_root: Gitlab.config.gitlab.url, + asset_host: Gitlab::Application.config.asset_host, - whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST - whitelist[:attributes][:all].push('class', 'id') - whitelist[:elements].push('span') - - # Remove the rel attribute that the sanitize gem adds, and remove the - # href attribute if it contains inline javascript - fix_anchors = lambda do |env| - name, node = env[:node_name], env[:node] - if name == 'a' - node.remove_attribute('rel') - if node['href'] && node['href'].match('javascript:') - node.remove_attribute('href') - end - end - end - whitelist[:transformers].push(fix_anchors) - - markdown_context = { - asset_root: Gitlab.config.gitlab.url, - asset_host: Gitlab::Application.config.asset_host, - whitelist: whitelist + # ReferenceFilter + current_user: current_user, + only_path: options[:reference_only_path], + project: project, + reference_class: html_options[:class] } - markdown_pipeline = HTML::Pipeline::Gitlab.new(filters).pipeline - - result = markdown_pipeline.call(text, markdown_context) + result = pipeline.call(text, context) save_options = 0 if options[:xhtml] @@ -114,21 +97,6 @@ module Gitlab text = result[:output].to_html(save_with: save_options) - # Extract pre blocks so they are not altered - # from http://github.github.com/github-flavored-markdown/ - text.gsub!(%r{
.*?
|.*?}m) { |match| extract_piece(match) } - # Extract links with probably parsable hrefs - text.gsub!(%r{.*?}m) { |match| extract_piece(match) } - # Extract images with probably parsable src - text.gsub!(%r{}m) { |match| extract_piece(match) } - - text = parse(text, project) - - # Insert pre block extractions - text.gsub!(/\{gfm-extraction-(\h{32})\}/) do - insert_piece($1) - end - if options[:parse_tasks] text = parse_tasks(text) end @@ -138,242 +106,53 @@ module Gitlab private - def extract_piece(text) - @extractions ||= {} - - md5 = Digest::MD5.hexdigest(text) - @extractions[md5] = text - "{gfm-extraction-#{md5}}" - end - - def insert_piece(id) - @extractions[id] - end - - # Private: Parses text for references + # Filters used in our pipeline # - # text - Text to parse + # SanitizationFilter should come first so that all generated reference HTML + # goes through untouched. # - # Returns parsed text - def parse(text, project = @project) - parse_references(text, project) if project + # See https://gitlab.com/gitlab-org/html-pipeline-gitlab for more filters + def filters + [ + HTML::Pipeline::SanitizationFilter, - text + Gitlab::Markdown::EmojiFilter, + + Gitlab::Markdown::UserReferenceFilter, + Gitlab::Markdown::IssueReferenceFilter, + Gitlab::Markdown::ExternalIssueReferenceFilter, + Gitlab::Markdown::MergeRequestReferenceFilter, + Gitlab::Markdown::SnippetReferenceFilter, + Gitlab::Markdown::CommitRangeReferenceFilter, + Gitlab::Markdown::CommitReferenceFilter, + Gitlab::Markdown::LabelReferenceFilter, + ] end - NAME_STR = Gitlab::Regex::NAMESPACE_REGEX_STR - PROJ_STR = "(?#{NAME_STR}/#{NAME_STR})" - - REFERENCE_PATTERN = %r{ - (?\W)? # Prefix - ( # Reference - @(?#{NAME_STR}) # User name - |~(?