diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-05-13 14:17:16 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-05-13 14:17:16 +0300 |
commit | f32a045ef41688859732abfcdc2a2030387be78f (patch) | |
tree | 883efa6fcf7d0eac100d7c07132400e1bcdfd4c3 | |
parent | cb8f974b2126122ad22fd01301c576f14c69ed01 (diff) | |
parent | 0928c3ae04c8e708753705746e9eb74c62001dad (diff) |
Merge branch 'version-check' into 'master'
Version check
See merge request !1509
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 1 | ||||
-rw-r--r-- | app/helpers/version_check_helper.rb | 7 | ||||
-rw-r--r-- | app/views/admin/application_settings/_form.html.haml | 6 | ||||
-rw-r--r-- | app/views/admin/dashboard/index.html.haml | 7 | ||||
-rw-r--r-- | app/views/help/index.html.haml | 2 | ||||
-rw-r--r-- | db/migrate/20150310194358_add_version_check_to_application_settings.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 1 | ||||
-rw-r--r-- | lib/version_check.rb | 18 | ||||
-rw-r--r-- | safe/public.pem | 9 |
9 files changed, 46 insertions, 10 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 3975e30835e..4c35622fff1 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -42,6 +42,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController :default_project_visibility, :default_snippet_visibility, :restricted_signup_domains_raw, + :version_check_enabled, restricted_visibility_levels: [], ) end diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb new file mode 100644 index 00000000000..f64d730b448 --- /dev/null +++ b/app/helpers/version_check_helper.rb @@ -0,0 +1,7 @@ +module VersionCheckHelper + def version_status_badge + if Rails.env.production? + image_tag VersionCheck.new.url + end + end +end diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index b9d7e8b4586..4ceae814805 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -32,6 +32,12 @@ = f.check_box :twitter_sharing_enabled, :'aria-describedby' => 'twitter_help_block' %strong Twitter enabled %span.help-block#twitter_help_block Show users a button to share their newly created public or internal projects on twitter + .form-group + .col-sm-offset-2.col-sm-10 + .checkbox + = f.label :version_check_enabled do + = f.check_box :version_check_enabled + Version check enabled %fieldset %legend Misc .form-group diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index d1c586328a2..3732ff847b9 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -56,7 +56,12 @@ %span.light.pull-right = boolean_to_icon Gitlab.config.omniauth.enabled .col-md-4 - %h4 Components + %h4 + Components + - if current_application_settings.version_check_enabled + .pull-right + = version_status_badge + %hr %p GitLab diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index af39dfeac5b..bf4b7234b21 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -3,6 +3,8 @@ GitLab %span= Gitlab::VERSION %small= Gitlab::REVISION + - if current_application_settings.version_check_enabled + = version_status_badge %p.slead GitLab is open source software to collaborate on code. %br diff --git a/db/migrate/20150310194358_add_version_check_to_application_settings.rb b/db/migrate/20150310194358_add_version_check_to_application_settings.rb new file mode 100644 index 00000000000..e9d42c1e749 --- /dev/null +++ b/db/migrate/20150310194358_add_version_check_to_application_settings.rb @@ -0,0 +1,5 @@ +class AddVersionCheckToApplicationSettings < ActiveRecord::Migration + def change + add_column :application_settings, :version_check_enabled, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index c89d22d241c..f7581eaf7fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -28,6 +28,7 @@ ActiveRecord::Schema.define(version: 20150509180749) do t.integer "default_branch_protection", default: 2 t.boolean "twitter_sharing_enabled", default: true t.text "restricted_visibility_levels" + t.boolean "version_check_enabled", default: true t.integer "max_attachment_size", default: 10, null: false t.integer "default_project_visibility" t.integer "default_snippet_visibility" diff --git a/lib/version_check.rb b/lib/version_check.rb new file mode 100644 index 00000000000..ea23344948c --- /dev/null +++ b/lib/version_check.rb @@ -0,0 +1,18 @@ +require "base64" + +# This class is used to build image URL to +# check if it is a new version for update +class VersionCheck + def data + { version: Gitlab::VERSION } + end + + def url + encoded_data = Base64.urlsafe_encode64(data.to_json) + "#{host}?gitlab_info=#{encoded_data}" + end + + def host + 'https://version.gitlab.com/check.png' + end +end diff --git a/safe/public.pem b/safe/public.pem deleted file mode 100644 index c5ffe20a5c7..00000000000 --- a/safe/public.pem +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnp2mUaLBoHFX127ysonX -OihiGpI4098eFfH1iAxpKHIof0vs0jFF05IUScNXJZ1U3w8G1U/unY/wGGa3NzAb -ZfDd22eOF6X2Gfiey6U4w9dFf0/UT5x1bphlpX357yh4O9oWWuNaWD062DTbOOsJ -U6UW2U/sZAu/QScys0Nw+gJ58t93hb4jFq+nO5IAQc6g4S8ek5YvIXOshFEpF2in -ZLbSYowx92+9GzfjvdQ7fk0Q2ssg0zfScVa6FY8n019osz0SC3wcSd/qicdfecpu -7oycpd9YDqk4lufE1qVMOsgE8OO4KXMrByz2f+T0p/bH9zdBa5HYylf1T7i60hIL -kQIDAQAB ------END PUBLIC KEY----- |