Skip to content

Commit

Permalink
profile header upload
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Oct 13, 2023
1 parent 940efab commit e35e36a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ def get_meta_tags
}
)

@oembed_json = oembed_show_url(track_id: @track, format: :json)
@oembed_json = !@track.private? ?
oembed_show_url(track_id: @track, format: :json)
: private_oembed_track_url(track_id: @track.signed_id, format: :json)


end

def track_params
Expand Down
1 change: 1 addition & 0 deletions app/controllers/user_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def user_attributes
:suggested_content_app,
:new_message_email,
:new_message_app,
:profile_header,
:like_and_plays_on_your_post_email,
:tbk_commerce_code, :pst_enabled, :tbk_test_mode
)
Expand Down
8 changes: 4 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ def is_admin?
def profile_header_url(size)
url = case size
when :medium
profile_header.variant(resize_to_fill: [200, 200])&.processed&.url
profile_header.variant(resize_to_fill: [600, 200])&.processed&.url

when :large
profile_header.variant(resize_to_fill: [500, 500])&.processed&.url
profile_header.variant(resize_to_fill: [1200, 500])&.processed&.url

when :small
profile_header.variant(resize_to_fill: [50, 50])&.processed&.url
profile_header.variant(resize_to_fill: [300, 100])&.processed&.url

else
profile_header.variant(resize_to_fill: [200, 200])&.processed&.url
profile_header.variant(resize_to_fill: [300, 100])&.processed&.url
end

url || "daniel-schludi-mbGxz7pt0jM-unsplash-sqr-s-bn.png"
Expand Down
19 changes: 19 additions & 0 deletions app/views/user_settings/_profile_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@
</div>
</div>

<div class="sm:col-span-6">
<%= form.label gettext("Profile Header") %>

<div class="mt-1 flex items-center">
<%= image_tag(user.profile_header_url(:small), class: "inline-block h-12 w-48") %>

<div class="ml-4 flex space-x-2">
<div class="relative py-2 px-3 border border-blue-gray-300 rounded-md shadow-sm flex items-center cursor-pointer hover:bg-blue-gray-50 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-offset-blue-gray-50 focus-within:ring-blue-500">
<div class="sm:col-span-6">
<label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white" for="file_input">Upload file</label>
<%= form.file_field :profile_header, class: "block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400" %>
<p class="mt-1 text-sm text-gray-500 dark:text-gray-300" id="file_input_help">SVG, PNG, JPG or GIF (MAX. 800x400px).</p>
</div>
</div>

</div>
</div>
</div>

<div class="sm:col-span-6">

</div>
Expand Down

0 comments on commit e35e36a

Please sign in to comment.