source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/affiliates/base_controller.rb | Ruby | mit | 8,966 | main | 263 | # frozen_string_literal: true
class Admin::Affiliates::BaseController < Admin::BaseController
before_action :set_affiliate_user
private
def set_affiliate_user
@affiliate_user = User.find_by_external_id!(params[:affiliate_external_id])
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/affiliates/products/base_controller.rb | Ruby | mit | 8,966 | main | 262 | # frozen_string_literal: true
class Admin::Affiliates::Products::BaseController < Admin::Affiliates::BaseController
before_action :set_product
private
def set_product
@product = Link.find_by_external_id!(params[:product_external_id])
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/affiliates/products/purchases_controller.rb | Ruby | mit | 8,966 | main | 555 | # frozen_string_literal: true
class Admin::Affiliates::Products::PurchasesController < Admin::Affiliates::Products::BaseController
include Pagy::Backend
def index
scope = @product.sales.for_affiliate_user(@affiliate_user)
pagination, purchases = pagy_countless(
scope.for_admin_listing.includes(:sub... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/products/base_controller.rb | Ruby | mit | 8,966 | main | 238 | # frozen_string_literal: true
class Admin::Products::BaseController < Admin::BaseController
before_action :set_product
private
def set_product
@product = Link.find_by_external_id!(params[:product_external_id])
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/products/purchases_controller.rb | Ruby | mit | 8,966 | main | 1,308 | # frozen_string_literal: true
class Admin::Products::PurchasesController < Admin::Products::BaseController
include Pagy::Backend
def index
pagination, purchases = pagy_countless(
@product.sales.for_admin_listing.includes(:subscription, :price, :refunds),
limit: params[:per_page],
page: param... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/products/staff_picked_controller.rb | Ruby | mit | 8,966 | main | 406 | # frozen_string_literal: true
class Admin::Products::StaffPickedController < Admin::Products::BaseController
include AfterCommitEverywhere
def create
authorize [:admin, :products, :staff_picked, @product]
staff_picked_product = @product.staff_picked_product || @product.build_staff_picked_product
staf... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/admin/products/details_controller.rb | Ruby | mit | 8,966 | main | 289 | # frozen_string_literal: true
class Admin::Products::DetailsController < Admin::Products::BaseController
def show
if @product.filegroup
render json: { details: ProductPresenter.new(product: @product).admin_info }
else
render json: { details: nil }
end
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/stripe/setup_intents_controller.rb | Ruby | mit | 8,966 | main | 4,554 | # frozen_string_literal: true
# Stateless API calls we need to make for the frontend to setup future charges for given CC, before passing this
# CC data to be saved/charged along with the preorder, subscription, or bundle payment.
class Stripe::SetupIntentsController < ApplicationController
before_action :validate_c... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/communities/last_read_chat_messages_controller.rb | Ruby | mit | 8,966 | main | 752 | # frozen_string_literal: true
class Communities::LastReadChatMessagesController < ApplicationController
before_action :authenticate_user!
before_action :set_community
after_action :verify_authorized
def create
message = @community.community_chat_messages.find_by_external_id!(params[:message_id])
Last... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/communities/notification_settings_controller.rb | Ruby | mit | 8,966 | main | 771 | # frozen_string_literal: true
class Communities::NotificationSettingsController < ApplicationController
before_action :authenticate_user!
before_action :set_community
after_action :verify_authorized
def update
authorize @community, :show?
settings = current_seller.community_notification_settings.find... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/communities/chat_messages_controller.rb | Ruby | mit | 8,966 | main | 2,531 | # frozen_string_literal: true
class Communities::ChatMessagesController < ApplicationController
before_action :authenticate_user!
before_action :set_community
before_action :set_message, only: [:update, :destroy]
after_action :verify_authorized
def create
message = @community.community_chat_messages.bui... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/integrations/circle_controller.rb | Ruby | mit | 8,966 | main | 1,871 | # frozen_string_literal: true
class Integrations::CircleController < Sellers::BaseController
before_action :skip_authorization
def communities
return render json: { success: false } if params[:api_key].blank?
communities_response = CircleApi.new(params[:api_key]).get_communities
return render json: {... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/integrations/zoom_controller.rb | Ruby | mit | 8,966 | main | 998 | # frozen_string_literal: true
class Integrations::ZoomController < ApplicationController
before_action :authenticate_user!, except: [:oauth_redirect]
def account_info
zoom_api = ZoomApi.new
oauth_response = zoom_api.oauth_token(params[:code], oauth_redirect_integrations_zoom_index_url)
access_token = ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/integrations/discord_controller.rb | Ruby | mit | 8,966 | main | 4,472 | # frozen_string_literal: true
class Integrations::DiscordController < ApplicationController
before_action :authenticate_user!, except: [:oauth_redirect, :join_server, :leave_server]
def server_info
discord_api = DiscordApi.new
oauth_response = discord_api.oauth_token(params[:code], oauth_redirect_integrat... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/integrations/google_calendar_controller.rb | Ruby | mit | 8,966 | main | 1,788 | # frozen_string_literal: true
class Integrations::GoogleCalendarController < ApplicationController
before_action :authenticate_user!, except: [:oauth_redirect]
def account_info
gcal_api = GoogleCalendarApi.new
oauth_response = gcal_api.oauth_token(params[:code], oauth_redirect_integrations_google_calendar... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/discover/search_autocomplete_controller.rb | Ruby | mit | 8,966 | main | 366 | # frozen_string_literal: true
class Discover::SearchAutocompleteController < ApplicationController
def delete_search_suggestion
DiscoverSearchSuggestion
.by_user_or_browser(user: logged_in_user, browser_guid: cookies[:_gumroad_guid])
.where(discover_searches: { query: params[:query] })
.each(&:... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/utm_link_tracking.rb | Ruby | mit | 8,966 | main | 3,241 | # frozen_string_literal: true
module UtmLinkTracking
extend ActiveSupport::Concern
private
def track_utm_link_visit
return unless request.get?
required_params = {
utm_source: params[:utm_source].presence,
utm_medium: params[:utm_medium].presence,
utm_campaign: params[:utm_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/helper_widget.rb | Ruby | mit | 8,966 | main | 810 | # frozen_string_literal: true
module HelperWidget
extend ActiveSupport::Concern
included do
helper_method :helper_widget_host, :helper_session
end
def helper_widget_host
GlobalConfig.get("HELPER_WIDGET_HOST")
end
def helper_session
return unless current_seller && helper_widget_secret.present... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/custom_domain_route_builder.rb | Ruby | mit | 8,966 | main | 932 | # frozen_string_literal: true
module CustomDomainRouteBuilder
extend ActiveSupport::Concern
included do
before_action :set_is_user_custom_domain
helper_method :build_view_post_route
end
def build_view_post_route(post:, purchase_id: nil)
return if post&.slug.blank?
if @is_user_custom_domain
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/fetch_product_by_unique_permalink.rb | Ruby | mit | 8,966 | main | 669 | # frozen_string_literal: true
module FetchProductByUniquePermalink
# Fetches a product by unique permalink (only!) identified via `id` or `link_id` params.
# Requires the product's owner or an admin user to be logged in.
#
# This method shouldn't be used to fetch a product by custom_permalink because they are ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/impersonate.rb | Ruby | mit | 8,966 | main | 1,855 | # frozen_string_literal: true
# Handles impersonation for both web and mobile API
module Impersonate
extend ActiveSupport::Concern
include CurrentApiUser
include LoggedInUser
included do
helper_method :impersonating_user, :impersonated_user, :impersonating?
end
def impersonate_user(user)
reset_im... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/mass_blocker.rb | Ruby | mit | 8,966 | main | 770 | # frozen_string_literal: true
module MassBlocker
extend ActiveSupport::Concern
# Records can be separated by whitespaces or commas
DELIMITER_REGEX = /\s|,/
BATCH_SIZE = 1_000
private
def schedule_mass_block(identifiers:, object_type:, expires_in: nil)
array_of_mass_block_args = identifiers.split(... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/custom_domain_config.rb | Ruby | mit | 8,966 | main | 1,637 | # frozen_string_literal: true
module CustomDomainConfig
extend ActiveSupport::Concern
include PageMeta::Base
def user_by_domain(host)
user_by_subdomain(host) || user_by_custom_domain(host)
end
def set_user_and_custom_domain_config
if GumroadDomainConstraint.matches?(request)
set_user
els... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/create_discover_search.rb | Ruby | mit | 8,966 | main | 567 | # frozen_string_literal: true
module CreateDiscoverSearch
def create_discover_search!(extras = {})
return if is_bot?
return unless Feature.active?(:store_discover_searches, OpenStruct.new(flipper_id: cookies[:_gumroad_guid]))
DiscoverSearch.transaction do
search = DiscoverSearch.create!({
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/current_api_user.rb | Ruby | mit | 8,966 | main | 446 | # frozen_string_literal: true
# Equivalent of current_user for API
#
module CurrentApiUser
extend ActiveSupport::Concern
included do
helper_method :current_api_user
end
def current_api_user
return unless defined?(doorkeeper_token) && doorkeeper_token.present?
@_current_api_user ||= User.find(doo... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/create_consumption_event.rb | Ruby | mit | 8,966 | main | 1,025 | # frozen_string_literal: true
module CreateConsumptionEvent
private
def create_consumption_event!(params)
return false if params[:url_redirect_id].blank? || ConsumptionEvent::EVENT_TYPES.exclude?(params[:event_type])
url_redirect_id = ObfuscateIds.decrypt(params[:url_redirect_id])
product_file... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/oauth_application_config.rb | Ruby | mit | 8,966 | main | 550 | # frozen_string_literal: true
module OauthApplicationConfig
extend ActiveSupport::Concern
included do
before_action :set_oauth_application, only: :new
end
def set_oauth_application
return if params[:next].blank?
begin
next_url = URI.parse(params[:next])
rescue URI::InvalidURIError
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/inertia_rendering.rb | Ruby | mit | 8,966 | main | 939 | # frozen_string_literal: true
module InertiaRendering
extend ActiveSupport::Concern
include ApplicationHelper
included do
inertia_share do
RenderingExtension.custom_context(view_context).merge(
authenticity_token: form_authenticity_token,
flash: inertia_flash_props,
title: page... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/current_seller.rb | Ruby | mit | 8,966 | main | 1,302 | # frozen_string_literal: true
module CurrentSeller
extend ActiveSupport::Concern
included do
helper_method :current_seller
before_action :verify_current_seller
end
def current_seller
return unless user_signed_in?
@_current_seller ||= find_seller_from_cookie(cookies.encrypted[:current_seller... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/logged_in_user.rb | Ruby | mit | 8,966 | main | 321 | # frozen_string_literal: true
module LoggedInUser
extend ActiveSupport::Concern
included do
helper_method :logged_in_user
end
# Usage of current_user is restricted to ensure current_user is not used accidentaly instead of current_seller
def logged_in_user
impersonated_user || current_user
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/two_factor_authentication_validator.rb | Ruby | mit | 8,966 | main | 3,093 | # frozen_string_literal: true
module TwoFactorAuthenticationValidator
extend ActiveSupport::Concern
TWO_FACTOR_AUTH_USER_ID_SESSION_NAME = :verify_two_factor_auth_for
TWO_FACTOR_AUTH_METHOD_SESSION_NAME = :two_factor_auth_method
private_constant :TWO_FACTOR_AUTH_USER_ID_SESSION_NAME, :TWO_FACTOR_AUTH_METHOD_S... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/search_products.rb | Ruby | mit | 8,966 | main | 1,770 | # frozen_string_literal: true
module SearchProducts
BLACK_FRIDAY_CODE = "BLACKFRIDAY2025"
ALLOWED_OFFER_CODES = [BLACK_FRIDAY_CODE].freeze
private
def search_products(params)
filetype_options = Link.filetype_options(params)
filetype_response = Link.search(filetype_options)
product_options ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/dashboard_preference.rb | Ruby | mit | 8,966 | main | 809 | # frozen_string_literal: true
module DashboardPreference
COOKIE_NAME = "last_viewed_dashboard"
SALES_DASHBOARD = "sales"
AUDIENCE_DASHBOARD = "audience"
private_constant :COOKIE_NAME, :SALES_DASHBOARD, :AUDIENCE_DASHBOARD
private
def preferred_dashboard_url
return @_preferred_dashboard_url if defi... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/validate_recaptcha.rb | Ruby | mit | 8,966 | main | 2,332 | # frozen_string_literal: true
module ValidateRecaptcha
ENTERPRISE_VERIFICATION_URL =
"https://recaptchaenterprise.googleapis.com/v1/projects/#{GOOGLE_CLOUD_PROJECT_ID}/" \
"assessments?key=#{GlobalConfig.get("ENTERPRISE_RECAPTCHA_API_KEY")}"
private_constant :ENTERPRISE_VERIFICATION_URL
private
def... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/throttling.rb | Ruby | mit | 8,966 | main | 554 | # frozen_string_literal: true
module Throttling
extend ActiveSupport::Concern
private
def throttle!(key:, limit:, period:, redis: $redis)
count = redis.incr(key)
redis.expire(key, period.to_i) if count == 1
if count > limit
retry_after = redis.ttl(key) || period.to_i
respons... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/process_refund.rb | Ruby | mit | 8,966 | main | 1,231 | # frozen_string_literal: true
module ProcessRefund
private
def process_refund(seller:, user:, purchase_external_id:, amount:, impersonating: false)
# We don't support commas in refund amount
# Reference: https://github.com/gumroad/web/pull/17747
return render json: { success: false, message: "C... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/pundit_authorization.rb | Ruby | mit | 8,966 | main | 3,459 | # frozen_string_literal: true
module PunditAuthorization
extend ActiveSupport::Concern
include Pundit::Authorization
included do
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
helper_method :pundit_user
end
def pundit_user
@_pundit_user ||= SellerContext.new(user: logged_in... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/events.rb | Ruby | mit | 8,966 | main | 4,256 | # frozen_string_literal: true
module Events
def create_user_event(name, seller_id: nil, on_custom_domain: false)
return if name.nil?
create_event(
event_name: name,
on_custom_domain:,
user_id: logged_in_user&.id
)
end
def create_post_event(installment)
@product = installment.t... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/csrf_token_injector.rb | Ruby | mit | 8,966 | main | 720 | # frozen_string_literal: true
module CsrfTokenInjector
extend ActiveSupport::Concern
TOKEN_PLACEHOLDER = "_CROSS_SITE_REQUEST_FORGERY_PROTECTION_TOKEN__"
SAFE_INSERTION_SELECTOR = /(<meta\s+name=["']csrf-token["']\s+content=["'])#{Regexp.escape(TOKEN_PLACEHOLDER)}(["'])/i
def rewrite_csrf_token(html, token)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/rack_mini_profiler_authorization.rb | Ruby | mit | 8,966 | main | 433 | # frozen_string_literal: true
module RackMiniProfilerAuthorization
extend ActiveSupport::Concern
included do
before_action :authorize_rack_mini_profiler
end
private
def authorize_rack_mini_profiler
Rack::MiniProfiler.authorize_request if authorize_rack_mini_profiler?
end
def authorize_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/mass_transfer_purchases.rb | Ruby | mit | 8,966 | main | 985 | # frozen_string_literal: true
module MassTransferPurchases
extend ActiveSupport::Concern
private
def transfer_purchases(user:, new_email:)
purchases = Purchase.where(email: user.email)
error_message = if user.suspended?
"Mass-transferring purchases for a suspended user is not allowed."
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/admin_action_tracker.rb | Ruby | mit | 8,966 | main | 315 | # frozen_string_literal: true
module AdminActionTracker
extend ActiveSupport::Concern
included do
before_action :track_admin_action_call
end
private
def track_admin_action_call
AdminActionCallInfo.find_by(controller_name: self.class.name, action_name:)&.increment!(:call_count)
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/discover_curated_products.rb | Ruby | mit | 8,966 | main | 1,119 | # frozen_string_literal: true
module DiscoverCuratedProducts
CURATED_PRODUCTS_TIMEOUT_SECONDS = 10
def taxonomies_for_nav(recommended_products: nil)
Discover::TaxonomyPresenter.new.taxonomies_for_nav(recommended_products: curated_products.map(&:product))
end
def curated_products
@root_recommended_pro... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/record_media_location.rb | Ruby | mit | 8,966 | main | 1,426 | # frozen_string_literal: true
module RecordMediaLocation
private
def record_media_location(params)
return false if params[:url_redirect_id].blank? || params[:product_file_id].blank? || params[:location].blank?
url_redirect_id = ObfuscateIds.decrypt(params[:url_redirect_id])
purchase_id = param... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/affiliate_cookie.rb | Ruby | mit | 8,966 | main | 975 | # frozen_string_literal: true
module AffiliateCookie
include AffiliateQueryParams
private
def set_affiliate_cookie
affiliate_id = fetch_affiliate_id(params)
return unless affiliate_id.present?
affiliate = Affiliate.find_by_external_id_numeric(affiliate_id)
create_affiliate_id_cookie(af... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/mass_unblocker.rb | Ruby | mit | 8,966 | main | 632 | # frozen_string_literal: true
module MassUnblocker
extend ActiveSupport::Concern
private
def schedule_mass_unblock(identifiers:)
array_of_mass_unblock_args = identifiers.split(MassBlocker::DELIMITER_REGEX)
.select(&:present?)
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/admin/commentable.rb | Ruby | mit | 8,966 | main | 1,230 | # frozen_string_literal: true
module Admin::Commentable
include Pagy::Backend
def index
pagination, comments = pagy(
commentable.comments.includes(:author).references(:author).order(created_at: :desc),
limit: params[:per_page] || 20,
page: params[:page] || 1
)
render json: {
c... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/admin/list_paginated_users.rb | Ruby | mit | 8,966 | main | 1,769 | # frozen_string_literal: true
module Admin::ListPaginatedUsers
extend ActiveSupport::Concern
include Pagy::Backend
# We list 5 users per page by default for the following reasons:
# - Feature: A list of user cards is used for the refund queue or for searching users, so we don't need to display too many users ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/admin/fetch_user.rb | Ruby | mit | 8,966 | main | 719 | # frozen_string_literal: true
module Admin::FetchUser
private
def fetch_user
@user = if user_param.include?("@")
User.find_by(email: user_param)
else
User.where(username: user_param)
.or(User.where(external_id: user_param))
.first
end
if @user.nil?... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/admin/users/list_paginated_products.rb | Ruby | mit | 8,966 | main | 975 | # frozen_string_literal: true
module Admin::Users::ListPaginatedProducts
include Pagy::Backend
PRODUCTS_ORDER = Arel.sql("ISNULL(COALESCE(purchase_disabled_at, banned_at, links.deleted_at)) DESC, created_at DESC")
PRODUCTS_PER_PAGE = 10
private
def list_paginated_products(user:, products:, inertia_templa... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/page_meta/favicon.rb | Ruby | mit | 8,966 | main | 343 | # frozen_string_literal: true
module PageMeta::Favicon
extend ActiveSupport::Concern
include PageMeta::Base
private
def set_favicon_meta_tags(user)
return unless user.avatar_url.present?
set_meta_tag(tag_name: "link", rel: "shortcut icon", href: user.avatar_url)
remove_meta_tag("apple-to... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/page_meta/base.rb | Ruby | mit | 8,966 | main | 2,751 | # frozen_string_literal: true
module PageMeta::Base
extend ActiveSupport::Concern
include ActionView::Helpers::OutputSafetyHelper
include ActionView::Helpers::TagHelper
delegate :image_path, to: "ActionController::Base.helpers"
private
def set_default_page_title
set_meta_tag(title: default_page_t... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/page_meta/product.rb | Ruby | mit | 8,966 | main | 4,121 | # frozen_string_literal: true
module PageMeta::Product
extend ActiveSupport::Concern
include PageMeta::Base
private
def set_product_page_meta(product)
product_description = product.description.present? ? product.plaintext_description : "Available on Gumroad"
set_meta_tag(name: "description", c... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/page_meta/user.rb | Ruby | mit | 8,966 | main | 1,546 | # frozen_string_literal: true
module PageMeta::User
extend ActiveSupport::Concern
include PageMeta::Base
private
def set_user_page_meta(user)
set_meta_tag(property: "og:site_name", value: "Gumroad")
set_meta_tag(property: "og:type", value: "website")
if user.bio.present?
title = ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/page_meta/analytics.rb | Ruby | mit | 8,966 | main | 1,079 | # frozen_string_literal: true
module PageMeta::Analytics
extend ActiveSupport::Concern
include PageMeta::Base
private
def set_analytics_meta_tags
set_meta_tag(property: "gr:google_analytics:enabled", content: analytics_enabled?.to_s)
set_meta_tag(property: "gr:fb_pixel:enabled", content: analyt... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/page_meta/post.rb | Ruby | mit | 8,966 | main | 1,180 | # frozen_string_literal: true
module PageMeta::Post
extend ActiveSupport::Concern
include PageMeta::Base
private
def set_post_page_meta(post, presenter)
set_meta_tag(name: "description", content: presenter.snippet)
set_meta_tag(property: "og:title", value: post.name)
set_meta_tag(propert... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/concerns/api/v2/tax_center_access.rb | Ruby | mit | 8,966 | main | 1,006 | # frozen_string_literal: true
module Api::V2::TaxCenterAccess
extend ActiveSupport::Concern
included do
before_action -> { doorkeeper_authorize!(:view_tax_data) }
before_action :ensure_tax_center_enabled
end
private
def ensure_tax_center_enabled
return if current_resource_owner.tax_center_e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/affiliate_requests/onboarding_form_controller.rb | Ruby | mit | 8,966 | main | 2,159 | # frozen_string_literal: true
class AffiliateRequests::OnboardingFormController < Sellers::BaseController
before_action :authenticate_user!
before_action :set_published_products, only: [:update]
def update
authorize [:affiliate_requests, :onboarding_form]
user_product_external_ids = @published_products... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/product_review_videos/streaming_urls_controller.rb | Ruby | mit | 8,966 | main | 1,201 | # frozen_string_literal: true
class ProductReviewVideos::StreamingUrlsController < ApplicationController
before_action :set_product_review_video
after_action :verify_authorized
def index
return head :unauthorized unless authorized?
render json: {
streaming_urls: [
product_review_video_str... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/product_review_videos/upload_contexts_controller.rb | Ruby | mit | 8,966 | main | 323 | # frozen_string_literal: true
class ProductReviewVideos::UploadContextsController < ApplicationController
before_action :authenticate_user!
def show
render json: {
aws_access_key_id: AWS_ACCESS_KEY,
s3_url: "#{AWS_S3_ENDPOINT}/#{S3_BUCKET}",
user_id: logged_in_user.external_id,
}
end
e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/product_review_videos/streams_controller.rb | Ruby | mit | 8,966 | main | 439 | # frozen_string_literal: true
class ProductReviewVideos::StreamsController < ApplicationController
before_action :set_product_review_video
def show
respond_to do |format|
format.smil { render plain: @product_review_video.video_file.smil_xml }
end
end
private
def set_product_review_video
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/custom_domain/verifications_controller.rb | Ruby | mit | 8,966 | main | 1,234 | # frozen_string_literal: true
class CustomDomain::VerificationsController < Sellers::BaseController
def create
authorize [:settings, :advanced, current_seller], :show?
has_valid_configuration = CustomDomainVerificationService.new(domain: params[:domain]).process
passes_model_validation =
if param... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/collaborators/base_controller.rb | Ruby | mit | 8,966 | main | 1,038 | # frozen_string_literal: true
class Collaborators::BaseController < Sellers::BaseController
before_action :authorize_user
layout "inertia"
inertia_share { CollaboratorPresenter.new(seller: current_seller).inertia_shared_props }
def destroy
raise NotImplementedError, "Subclasses must implement destroy" u... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/collaborators/incomings_controller.rb | Ruby | mit | 8,966 | main | 1,070 | # frozen_string_literal: true
class Collaborators::IncomingsController < Collaborators::BaseController
skip_before_action :authorize_user, only: [:accept, :decline]
prepend_before_action :set_collaborator, only: [:accept, :decline, :destroy]
before_action :set_invitation!, only: [:accept, :decline]
def index
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/collaborators/main_controller.rb | Ruby | mit | 8,966 | main | 1,952 | # frozen_string_literal: true
class Collaborators::MainController < Collaborators::BaseController
prepend_before_action :set_collaborator, only: [:edit, :update, :destroy]
def index
render inertia: "Collaborators/Index", props: CollaboratorsPresenter.new(seller: current_seller).index_props
end
def new
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/global_affiliates/product_eligibility_controller.rb | Ruby | mit | 8,966 | main | 1,202 | # frozen_string_literal: true
class GlobalAffiliates::ProductEligibilityController < Sellers::BaseController
class InvalidUrl < StandardError; end
GUMROAD_DOMAINS = [ROOT_DOMAIN, SHORT_DOMAIN, DOMAIN].map { |domain| Addressable::URI.parse("#{PROTOCOL}://#{domain}").domain } # Strip port (in test and development e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/checkout/form_controller.rb | Ruby | mit | 8,966 | main | 1,463 | # frozen_string_literal: true
class Checkout::FormController < Sellers::BaseController
layout "inertia", only: [:show]
def show
authorize [:checkout, :form]
set_meta_tag(title: "Checkout form")
form_props = Checkout::FormPresenter.new(pundit_user:).form_props
render inertia: "Checkout/Form/Show"... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/checkout/upsells_controller.rb | Ruby | mit | 8,966 | main | 6,982 | # frozen_string_literal: true
class Checkout::UpsellsController < Sellers::BaseController
include Pagy::Backend
PER_PAGE = 20
layout "inertia", only: [:index]
def index
authorize [:checkout, Upsell]
set_meta_tag(title: "Upsells")
pagination, upsells = fetch_upsells
upsells_props = Checkout:... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/checkout/discounts_controller.rb | Ruby | mit | 8,966 | main | 5,435 | # frozen_string_literal: true
class Checkout::DiscountsController < Sellers::BaseController
include Pagy::Backend
PER_PAGE = 10
rescue_from ActiveModel::RangeError, with: :handle_range_error
before_action :clean_params, only: [:create, :update]
layout "inertia", only: [:index]
def index
authorize ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/checkout/upsells/products_controller.rb | Ruby | mit | 8,966 | main | 1,415 | # frozen_string_literal: true
class Checkout::Upsells::ProductsController < ApplicationController
include CustomDomainConfig
MAX_PRODUCTS = 25
PRODUCT_INCLUDES = [
:skus_alive_not_default,
:variant_categories_alive,
:product_review_stat,
{ alive_variants: { variant_category: :link },
thum... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/checkout/upsells/pauses_controller.rb | Ruby | mit | 8,966 | main | 538 | # frozen_string_literal: true
class Checkout::Upsells::PausesController < Sellers::BaseController
before_action :set_upsell!
after_action :verify_authorized
def create
authorize [:checkout, @upsell], :pause?
@upsell.update!(paused: true)
head :no_content
end
def destroy
authorize [:check... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/internal/base_controller.rb | Ruby | mit | 8,966 | main | 522 | # frozen_string_literal: true
class Internal::BaseController < ApplicationController
def authorize_request
return render json: { success: false }, status: :unauthorized if request.authorization.nil?
decoded_credentials = ::Base64.decode64(request.authorization.split(" ", 2).last || "").split(":")
userna... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/other_refund_policies_controller.rb | Ruby | mit | 8,966 | main | 521 | # frozen_string_literal: true
class Products::OtherRefundPoliciesController < Sellers::BaseController
include FetchProductByUniquePermalink
def index
fetch_product_by_unique_permalink
authorize @product, :edit?
product_refund_policies = @product.user
.product_refund_policies
.for_visible_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/available_offer_codes_controller.rb | Ruby | mit | 8,966 | main | 595 | # frozen_string_literal: true
class Products::AvailableOfferCodesController < Sellers::BaseController
include FetchProductByUniquePermalink
MAX_OFFER_CODES_LIMIT = 20
INITIAL_OFFER_CODES_LIMIT = 5
def index
fetch_product_by_unique_permalink
authorize @product, :edit?
limit = params[:query].prese... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/affiliated_controller.rb | Ruby | mit | 8,966 | main | 934 | # frozen_string_literal: true
class Products::AffiliatedController < Sellers::BaseController
before_action :authorize
layout "inertia", only: [:index]
def index
set_meta_tag(title: "Products")
props = AffiliatedProductsPresenter.new(current_seller,
query: aff... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/archived_controller.rb | Ruby | mit | 8,966 | main | 2,462 | # frozen_string_literal: true
class Products::ArchivedController < Sellers::BaseController
include ProductsHelper
before_action :fetch_product_and_enforce_ownership, only: %i[create destroy]
layout "inertia", only: [:index]
def index
authorize [:products, :archived, Link]
return redirect_to product... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/mobile_tracking_controller.rb | Ruby | mit | 8,966 | main | 360 | # frozen_string_literal: true
class Products::MobileTrackingController < ApplicationController
before_action :hide_layouts
def show
product = Link.fetch(params[:link_id])
@tracking_props = MobileTrackingPresenter.new(seller: product.user).product_props(product:)
@tracking_props[:enabled] = analytics_e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/remaining_call_availabilities_controller.rb | Ruby | mit | 8,966 | main | 400 | # frozen_string_literal: true
class Products::RemainingCallAvailabilitiesController < ApplicationController
include FetchProductByUniquePermalink
before_action :fetch_product_by_unique_permalink
def index
if @product.native_type == Link::NATIVE_TYPE_CALL
render json: { call_availabilities: @product.r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/variants_controller.rb | Ruby | mit | 8,966 | main | 236 | # frozen_string_literal: true
class Products::VariantsController < Sellers::BaseController
def index
fetch_product_and_enforce_ownership
authorize [:products, :variants, @product]
render json: @product.options
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/products/collabs_controller.rb | Ruby | mit | 8,966 | main | 2,330 | # frozen_string_literal: true
class Products::CollabsController < Sellers::BaseController
before_action :authorize
layout "inertia"
def index
set_meta_tag(title: "Products")
presenter = CollabProductsPagePresenter.new(
pundit_user:,
query: collabs_params[:query],
products_page: collab... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/user/invalidate_active_sessions_controller.rb | Ruby | mit | 8,966 | main | 447 | # frozen_string_literal: true
class User::InvalidateActiveSessionsController < Sellers::BaseController
def update
user = current_seller
authorize [:settings, :main, user], :invalidate_active_sessions?
user.invalidate_active_sessions!
sign_out
flash[:notice] = "You have been signed out from all... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/user/passwords_controller.rb | Ruby | mit | 8,966 | main | 2,931 | # frozen_string_literal: true
class User::PasswordsController < Devise::PasswordsController
include InertiaRendering, PageMeta::Base
before_action :set_default_page_title
before_action :set_csrf_meta_tags
before_action :set_default_meta_tags
helper_method :erb_meta_tags
layout "inertia", only: [:new, :ed... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/user/omniauth_callbacks_controller.rb | Ruby | mit | 8,966 | main | 4,498 | # frozen_string_literal: true
class User::OmniauthCallbacksController < Devise::OmniauthCallbacksController
include PageMeta::Base
skip_before_action :verify_authenticity_token, only: [:apple]
before_action :set_default_page_title
before_action :set_csrf_meta_tags
before_action :set_default_meta_tags
bef... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/gumroad_blog/base_controller.rb | Ruby | mit | 8,966 | main | 269 | # frozen_string_literal: true
class GumroadBlog::BaseController < ApplicationController
private
def set_blog_owner!
owner_username = GlobalConfig.get("BLOG_OWNER_USERNAME", "gumroad")
@blog_owner = User.find_by!(username: owner_username)
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/gumroad_blog/posts_controller.rb | Ruby | mit | 8,966 | main | 1,107 | # frozen_string_literal: true
class GumroadBlog::PostsController < GumroadBlog::BaseController
layout "inertia"
before_action :set_blog_owner!
before_action :set_post, only: [:show]
after_action :verify_authorized
def index
authorize [:gumroad_blog, :posts]
posts = @blog_owner.installments
.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/users/review_reminders_controller.rb | Ruby | mit | 8,966 | main | 441 | # frozen_string_literal: true
class Users::ReviewRemindersController < ApplicationController
layout "inertia"
before_action :authenticate_user!
def subscribe
logged_in_user.update!(opted_out_of_review_reminders: false)
render inertia: "Users/ReviewReminders/Subscribe"
end
def unsubscribe
logge... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/subscriptions/magic_links_controller.rb | Ruby | mit | 8,966 | main | 1,062 | # frozen_string_literal: true
class Subscriptions::MagicLinksController < ApplicationController
before_action :fetch_subscription
layout "inertia", only: [:new]
def new
render inertia: "Subscriptions/MagicLinks/New", props: {
**Subscriptions::MagicLinkPresenter.new(subscription: @subscription).magic_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/wishlists/followers_controller.rb | Ruby | mit | 8,966 | main | 1,374 | # frozen_string_literal: true
class Wishlists::FollowersController < ApplicationController
before_action :authenticate_user!, except: :unsubscribe
after_action :verify_authorized, except: :unsubscribe
before_action { e404 if Feature.inactive?(:follow_wishlists, current_seller) }
def create
wishlist = Wish... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/wishlists/products_controller.rb | Ruby | mit | 8,966 | main | 1,522 | # frozen_string_literal: true
class Wishlists::ProductsController < ApplicationController
before_action :authenticate_user!, except: :index
after_action :verify_authorized, except: :index
def index
wishlist = Wishlist.find_by_external_id!(params[:wishlist_id])
render json: WishlistPresenter.new(wishlis... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/wishlists/following_controller.rb | Ruby | mit | 8,966 | main | 675 | # frozen_string_literal: true
class Wishlists::FollowingController < ApplicationController
before_action :authenticate_user!
after_action :verify_authorized
before_action { e404 if Feature.inactive?(:follow_wishlists, current_seller) }
layout "inertia"
def index
authorize Wishlist
set_meta_tag(tit... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/purchases/variants_controller.rb | Ruby | mit | 8,966 | main | 537 | # frozen_string_literal: true
class Purchases::VariantsController < Sellers::BaseController
before_action :set_purchase
def update
authorize [:audience, @purchase]
success = Purchase::VariantUpdaterService.new(
purchase: @purchase,
variant_id: params[:variant_id],
quantity: params[:quan... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/purchases/dispute_evidence_controller.rb | Ruby | mit | 8,966 | main | 3,334 | # frozen_string_literal: true
class Purchases::DisputeEvidenceController < ApplicationController
layout "inertia"
before_action :set_purchase, :set_dispute_evidence
before_action :check_if_needs_redirect, except: [:success]
def show
set_meta_tag(title: "Submit additional information")
set_noindex_hea... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/purchases/product_controller.rb | Ruby | mit | 8,966 | main | 775 | # frozen_string_literal: true
class Purchases::ProductController < ApplicationController
layout "inertia"
before_action :set_purchase
def show
purchase_product_presenter = PurchaseProductPresenter.new(@purchase)
# Ensure that the React component receives the same props as the product page, in case Produ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/purchases/invoices_controller.rb | Ruby | mit | 8,966 | main | 6,277 | # frozen_string_literal: true
class Purchases::InvoicesController < ApplicationController
layout "inertia", only: [:new, :confirm]
before_action :set_purchase, except: [:confirm]
before_action :set_noindex_header, only: [:new, :confirm]
before_action :require_email_confirmation, except: [:confirm]
before_ac... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/purchases/pings_controller.rb | Ruby | mit | 8,966 | main | 403 | # frozen_string_literal: true
class Purchases::PingsController < Sellers::BaseController
before_action :set_purchase
def create
authorize [:audience, @purchase], :create_ping?
@purchase.send_notification_webhook_from_ui
head :no_content
end
private
def set_purchase
(@purchase = curren... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/dismiss_ai_product_generation_promos_controller.rb | Ruby | mit | 8,966 | main | 370 | # frozen_string_literal: true
class Settings::DismissAiProductGenerationPromosController < Sellers::BaseController
before_action :authenticate_user!
after_action :verify_authorized
def create
authorize current_seller, :generate_product_details_with_ai?
current_seller.update!(dismissed_create_products_w... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/stripe_controller.rb | Ruby | mit | 8,966 | main | 339 | # frozen_string_literal: true
class Settings::StripeController < Sellers::BaseController
before_action :authenticate_user!, only: [:disconnect]
def disconnect
authorize [:settings, :payments, logged_in_user], :stripe_connect?
render json: { success: StripeMerchantAccountManager.disconnect(user: logged_in... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/main_controller.rb | Ruby | mit | 8,966 | main | 3,498 | # frozen_string_literal: true
class Settings::MainController < Settings::BaseController
include ActiveSupport::NumberHelper
before_action :authorize
def show
render inertia: "Settings/Main/Show", props: settings_presenter.main_props
end
def update
current_seller.with_lock { current_seller.update!... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/billing_controller.rb | Ruby | mit | 8,966 | main | 988 | # frozen_string_literal: true
class Settings::BillingController < Settings::BaseController
before_action :authorize
def show
render inertia: "Settings/Billing/Show", props: settings_presenter.billing_props
end
def update
billing_detail = BillingDetail.find_or_initialize_by(purchaser_id: current_selle... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/password_controller.rb | Ruby | mit | 8,966 | main | 1,325 | # frozen_string_literal: true
class Settings::PasswordController < Settings::BaseController
before_action :set_user
before_action :authorize
def show
render inertia: "Settings/Password/Show", props: settings_presenter.password_props
end
def update
if @user.provider.present?
unless @user.confi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.