-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
276 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
//= link_tree ../images | ||
//= link_tree ../builds | ||
//= link_tree ../builds |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Imageable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_save :image_resize | ||
end | ||
|
||
def image_resize | ||
self.image_derivatives! if self.image_changed? | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Slugable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_validation :set_slug | ||
|
||
def self.with_slug(id_or_slug) | ||
where(id: id_or_slug).or(where(slug: id_or_slug.to_s)) | ||
end | ||
|
||
def self.find(id_or_slug) | ||
where(id: id_or_slug).or(where(slug: id_or_slug.to_s)).first | ||
end | ||
|
||
def self.find!(id_or_slug) | ||
where(id: id_or_slug).or(where(slug: id_or_slug.to_s)).first! | ||
end | ||
end | ||
|
||
def to_param | ||
self.slug.presence || self.id | ||
end | ||
|
||
def set_slug | ||
if self.slug.blank? | ||
prefix = (self.try(:name) || self.try(:title) || SecureRandom.hex).parameterize | ||
suffix = nil | ||
while self.class.where(slug: [prefix, suffix].compact.join('-')).count.positive? do | ||
suffix = suffix.to_i + 1 | ||
end | ||
self.slug = [prefix, suffix].compact.join('-') | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'image_processing/mini_magick' | ||
require 'fastimage' | ||
|
||
class ImageUploader < Shrine | ||
plugin :derivatives | ||
plugin :pretty_location | ||
plugin :store_dimensions | ||
plugin :validation_helpers | ||
plugin :determine_mime_type | ||
|
||
Attacher.validate do | ||
validate_mime_type %w[image/jpeg image/png] | ||
validate_extension %w[jpg jpeg png] | ||
validate_max_size 10*1024*1024 | ||
end | ||
|
||
Attacher.derivatives do |original| | ||
magick = ImageProcessing::MiniMagick.source(original) | ||
{ | ||
thumb: magick.resize_to_limit!(100, 100), | ||
small: magick.resize_to_limit!(300, 300), | ||
medium: magick.resize_to_limit!(600, 600), | ||
large: magick.resize_to_limit!(1200, 1200), | ||
} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%= turbo_stream.replace "user_cards" do %> | ||
<%= render partial: '/users/user', collection: @users, as: :user %> | ||
<div id="user_cards"></div> | ||
<% end %> | ||
<%= turbo_stream.replace "load_more" do %> | ||
<%= render partial: "/partials/load_more", locals: { total: @users.length, count: @users_count, offset: @offset + @limit } %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.