-
Notifications
You must be signed in to change notification settings - Fork 5
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
38 changed files
with
623 additions
and
712 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,8 @@ def become | |
redirect_to root_url, error: "not allowed" | ||
end | ||
end | ||
|
||
def disable_footer | ||
@disable_footer = true | ||
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
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,3 +1,37 @@ | ||
class PodcasterInfo < ApplicationRecord | ||
belongs_to :user | ||
has_one_attached :avatar | ||
|
||
|
||
store_accessor :data, :spotify_url | ||
store_accessor :data, :apple_podcasts_url | ||
store_accessor :data, :google_podcasts_url | ||
store_accessor :data, :stitcher_url | ||
store_accessor :data, :overcast_url | ||
store_accessor :data, :pocket_casts_url | ||
|
||
# You can add validations for these fields if needed | ||
validates :spotify_url, url: true, allow_blank: true | ||
validates :apple_podcasts_url, url: true, allow_blank: true | ||
validates :google_podcasts_url, url: true, allow_blank: true | ||
validates :stitcher_url, url: true, allow_blank: true | ||
validates :overcast_url, url: true, allow_blank: true | ||
validates :pocket_casts_url, url: true, allow_blank: true | ||
|
||
# You can add custom methods to work with these fields | ||
def has_podcast_links? | ||
spotify_url.present? || apple_podcasts_url.present? || google_podcasts_url.present? || | ||
stitcher_url.present? || overcast_url.present? || pocket_casts_url.present? | ||
end | ||
|
||
def podcast_links | ||
{ | ||
spotify: spotify_url, | ||
apple_podcasts: apple_podcasts_url, | ||
google_podcasts: google_podcasts_url, | ||
stitcher: stitcher_url, | ||
overcast: overcast_url, | ||
pocket_casts: pocket_casts_url | ||
}.compact | ||
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class UrlValidator < ActiveModel::EachValidator | ||
def validate_each(record, attribute, value) | ||
record.errors.add(attribute, (options[:message] || "must be a valid URL")) unless url_valid?(value) | ||
end | ||
|
||
# a URL may be technically well-formed but may | ||
# not actually be valid, so this checks for both. | ||
def url_valid?(url) | ||
encoded_url = URI::DEFAULT_PARSER.escape(url) | ||
url = begin | ||
URI.parse(encoded_url) | ||
rescue StandardError | ||
false | ||
end | ||
url.is_a?(URI::HTTP) || url.is_a?(URI::HTTPS) | ||
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
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
Oops, something went wrong.