diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/entities.rb | 22 | ||||
-rw-r--r-- | lib/api/settings.rb | 35 | ||||
-rw-r--r-- | lib/backup/database.rb | 14 |
4 files changed, 72 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index d2a35c78fc1..eebd44ea5b6 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -49,5 +49,6 @@ module API mount Namespaces mount Branches mount Labels + mount Settings end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 14a8f929d76..31202fa8c1f 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -277,5 +277,27 @@ module API class BroadcastMessage < Grape::Entity expose :message, :starts_at, :ends_at, :color, :font end + + class ApplicationSetting < Grape::Entity + expose :id + expose :default_projects_limit + expose :signup_enabled + expose :signin_enabled + expose :gravatar_enabled + expose :sign_in_text + expose :created_at + expose :updated_at + expose :home_page_url + expose :default_branch_protection + expose :twitter_sharing_enabled + expose :restricted_visibility_levels + expose :max_attachment_size + expose :session_expire_delay + expose :default_project_visibility + expose :default_snippet_visibility + expose :restricted_signup_domains + expose :user_oauth_applications + expose :after_sign_out_path + end end end diff --git a/lib/api/settings.rb b/lib/api/settings.rb new file mode 100644 index 00000000000..c885fcd7ea3 --- /dev/null +++ b/lib/api/settings.rb @@ -0,0 +1,35 @@ +module API + class Settings < Grape::API + before { authenticated_as_admin! } + + helpers do + def current_settings + @current_setting ||= + (ApplicationSetting.current || ApplicationSetting.create_from_defaults) + end + end + + # Get current applicaiton settings + # + # Example Request: + # GET /application/settings + get "application/settings" do + present current_settings, with: Entities::ApplicationSetting + end + + # Modify applicaiton settings + # + # Example Request: + # PUT /application/settings + put "application/settings" do + attributes = current_settings.attributes.keys - ["id"] + attrs = attributes_for_keys(attributes) + + if current_settings.update_attributes(attrs) + present current_settings, with: Entities::ApplicationSetting + else + render_validation_error!(current_settings) + end + end + end +end diff --git a/lib/backup/database.rb b/lib/backup/database.rb index 7aa54dd55ae..b8aa6b9ff2f 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -23,9 +23,19 @@ module Backup end report_success(success) abort 'Backup failed' unless success + + $progress.print 'Compressing database ... ' + success = system('gzip', db_file_name) + report_success(success) + abort 'Backup failed: compress error' unless success end def restore + $progress.print 'Decompressing database ... ' + success = system('gzip', '-d', db_file_name_gz) + report_success(success) + abort 'Restore failed: decompress error' unless success + success = case config["adapter"] when /^mysql/ then $progress.print "Restoring MySQL database #{config['database']} ... " @@ -45,6 +55,10 @@ module Backup File.join(db_dir, 'database.sql') end + def db_file_name_gz + File.join(db_dir, 'database.sql.gz') + end + def mysql_args args = { 'host' => '--host', |