Cropping in the background

With database fields, sadly.
This commit is contained in:
Dominik M. Kwiatek 2020-05-17 20:14:40 +01:00
parent d185c54f03
commit d4f8e03d28
4 changed files with 34 additions and 14 deletions

View File

@ -41,9 +41,6 @@ class User < ApplicationRecord
has_one :theme, dependent: :destroy
attr_accessor :profile_picture_x, :profile_picture_y, :profile_picture_w, :profile_picture_h,
:profile_header_x, :profile_header_y, :profile_header_w, :profile_header_h
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i

View File

@ -48,10 +48,10 @@
= f.check_box :show_foreign_themes, label: 'Render other user themes when visiting their profile'
- %i[crop_x crop_y crop_w crop_h].each do |attrib|
- for attrib in %i(profile_picture_x profile_picture_y profile_picture_w profile_picture_h)
= f.hidden_field attrib, id: attrib
- %i[crop_h_x crop_h_y crop_h_w crop_h_h].each do |attrib|
- for attrib in %i(profile_header_x profile_header_y profile_header_w profile_header_h)
= f.hidden_field attrib, id: attrib
= f.submit t('views.actions.save'), class: 'btn btn-primary'

View File

@ -0,0 +1,23 @@
class RenameCropFields < ActiveRecord::Migration[5.2]
def up
rename_column :users, :crop_h, :profile_picture_h
rename_column :users, :crop_w, :profile_picture_w
rename_column :users, :crop_x, :profile_picture_x
rename_column :users, :crop_y, :profile_picture_y
rename_column :users, :crop_h_h, :profile_header_h
rename_column :users, :crop_h_w, :profile_header_w
rename_column :users, :crop_h_x, :profile_header_x
rename_column :users, :crop_h_y, :profile_header_y
end
def down
rename_column :users, :profile_picture_h, :crop_h
rename_column :users, :profile_picture_w, :crop_w
rename_column :users, :profile_picture_x, :crop_x
rename_column :users, :profile_picture_y, :crop_y
rename_column :users, :profile_header_h, :crop_h_h
rename_column :users, :profile_header_w, :crop_h_w
rename_column :users, :profile_header_x, :crop_h_x
rename_column :users, :profile_header_y, :crop_h_y
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_05_09_094402) do
ActiveRecord::Schema.define(version: 2020_05_17_190138) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -253,10 +253,10 @@ ActiveRecord::Schema.define(version: 2020_05_09_094402) do
t.integer "profile_picture_file_size"
t.datetime "profile_picture_updated_at"
t.boolean "profile_picture_processing"
t.integer "crop_x"
t.integer "crop_y"
t.integer "crop_w"
t.integer "crop_h"
t.integer "profile_picture_x"
t.integer "profile_picture_y"
t.integer "profile_picture_w"
t.integer "profile_picture_h"
t.boolean "privacy_allow_anonymous_questions", default: true
t.boolean "privacy_allow_public_timeline", default: true
t.boolean "privacy_allow_stranger_answers", default: true
@ -270,10 +270,10 @@ ActiveRecord::Schema.define(version: 2020_05_09_094402) do
t.integer "profile_header_file_size"
t.datetime "profile_header_updated_at"
t.boolean "profile_header_processing"
t.integer "crop_h_x"
t.integer "crop_h_y"
t.integer "crop_h_w"
t.integer "crop_h_h"
t.integer "profile_header_x"
t.integer "profile_header_y"
t.integer "profile_header_w"
t.integer "profile_header_h"
t.string "locale", default: "en"
t.string "confirmation_token"
t.datetime "confirmed_at"