diff --git a/app/assets/javascripts/.eslintrc.js b/app/assets/javascripts/.eslintrc.js index e5019c433cc72..c4522c82dca44 100644 --- a/app/assets/javascripts/.eslintrc.js +++ b/app/assets/javascripts/.eslintrc.js @@ -26,7 +26,6 @@ module.exports = { initializeBaseUserData: false, initializeDisplayAdVisibility: false, initializeReadingListIcons: false, - initializeSponsorshipVisibility: false, ActiveXObject: false, AndroidBridge: false, }, diff --git a/app/assets/javascripts/initializePage.js b/app/assets/javascripts/initializePage.js index 371059e77b174..fb2bc01612df9 100644 --- a/app/assets/javascripts/initializePage.js +++ b/app/assets/javascripts/initializePage.js @@ -49,7 +49,6 @@ function initializePage() { } initializeBroadcast(); initializeReadingListIcons(); - initializeSponsorshipVisibility(); initializeDisplayAdVisibility(); if (document.getElementById('sidebar-additional')) { document.getElementById('sidebar-additional').classList.add('showing'); diff --git a/app/assets/javascripts/initializers/initializeLocalStorageRender.js b/app/assets/javascripts/initializers/initializeLocalStorageRender.js index 0e67055b8257c..6fd41fead0866 100644 --- a/app/assets/javascripts/initializers/initializeLocalStorageRender.js +++ b/app/assets/javascripts/initializers/initializeLocalStorageRender.js @@ -6,7 +6,6 @@ function initializeLocalStorageRender() { initializeBaseUserData(); initializeReadingListIcons(); initializeDisplayAdVisibility(); - initializeSponsorshipVisibility(); } } catch (err) { browserStoreCache('remove'); diff --git a/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js b/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js deleted file mode 100644 index b3c799d8bc57d..0000000000000 --- a/app/assets/javascripts/initializers/initializeSponsorshipVisibility.js +++ /dev/null @@ -1,77 +0,0 @@ -/* - * kept as a stand function so it can be loaded again without issue - * see: https://github.com/forem/forem/issues/6468 - */ -function sponsorClickHandler(event) { - ga( - 'send', - 'event', - 'click', - 'click sponsor link', - event.target.dataset.details, - null, - ); -} - -function sponsorClickHandlerGA4(event) { - gtag('event', 'click sponsor link', { - event_category: 'click', - event_label: event.target.dataset.details, - }); -} - -function listenForSponsorClick() { - setTimeout(() => { - if (window.ga || window.gtag) { - var links = document.getElementsByClassName('partner-link'); - // eslint-disable-next-line no-plusplus - for (var i = 0; i < links.length; i++) { - if (window.ga) { - links[i].onclick = sponsorClickHandler; - } - if (window.gtag) { - links[i].onclick = sponsorClickHandlerGA4; - } - } - } - }, 400); -} - -function initializeSponsorshipVisibility() { - var el = - document.getElementById('sponsorship-widget') || - document.getElementById('partner-content-display'); - var user = userData(); - if (el) { - setTimeout(() => { - if (document.querySelectorAll('[data-partner-seen]').length === 0) { - if (window.ga) { - ga( - 'send', - 'event', - 'view', - 'sponsor displayed on page', - el.dataset.details, - null, - ); - } - if (window.gtag) { - gtag('event', 'sponsor displayed on page', { - event_category: 'view', - event_label: el.dataset.details, - }); - } - el.dataset.partnerSeen = 'true'; - } - }, 400); - } - if (el && user && user.display_sponsors) { - el.classList.remove('hidden'); - listenForSponsorClick(); - } else if (el && user) { - el.classList.add('hidden'); - } else if (el) { - el.classList.remove('hidden'); - listenForSponsorClick(); - } -} diff --git a/app/assets/stylesheets/views.scss b/app/assets/stylesheets/views.scss index ade82102f0b8f..7e77c66ba49ad 100644 --- a/app/assets/stylesheets/views.scss +++ b/app/assets/stylesheets/views.scss @@ -10,4 +10,3 @@ @import 'views/mod-center'; @import 'views/signin'; @import 'views/signup-modal'; -@import 'views/sponsors'; diff --git a/app/assets/stylesheets/views/sponsors.scss b/app/assets/stylesheets/views/sponsors.scss deleted file mode 100644 index b696af27a6288..0000000000000 --- a/app/assets/stylesheets/views/sponsors.scss +++ /dev/null @@ -1,44 +0,0 @@ -@import '../config/import'; - -.sponsors { - display: block; - margin-bottom: var(--su-6); - - @media (min-width: $breakpoint-m) { - display: grid; - grid-template-columns: 33% 1fr; - grid-gap: var(--su-4); - } - - @media (min-width: $breakpoint-l) { - grid-template-columns: 25% 1fr; - grid-gap: var(--su-6); - } - - &__label { - background: var(--base-0); - padding: var(--su-4); - border-radius: var(--radius); - margin-bottom: var(--su-4); - - @media (min-width: $breakpoint-m) { - margin-bottom: 0; - } - } - - &__items { - display: grid; - grid-gap: var(--su-6); - } - - &__logo { - border-radius: var(--radius); - background: white; - padding: var(--su-4); - margin-bottom: var(--su-4); - max-width: 250px; - height: auto; - display: block; - border: 1px solid var(--base-20); - } -} diff --git a/app/controllers/admin/sponsorships_controller.rb b/app/controllers/admin/sponsorships_controller.rb deleted file mode 100644 index 31dc28091e2be..0000000000000 --- a/app/controllers/admin/sponsorships_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -module Admin - class SponsorshipsController < Admin::ApplicationController - layout "admin" - - def index - @sponsorships = Sponsorship.includes(:organization, :user, :sponsorable) - .order(created_at: :desc) - .page(params[:page]).per(50) - - return if params[:status].blank? - - @sponsorships = @sponsorships.where(status: params[:status]) - end - - def new - @sponsorship = Sponsorship.new - end - - def edit - @sponsorship = Sponsorship.find(params[:id]) - end - - def create - @sponsorship = Sponsorship.new(sponsorship_params) - - if @sponsorship.save - flash[:success] = I18n.t("admin.sponsorships_controller.created") - redirect_to admin_sponsorships_path - else - flash[:danger] = @sponsorship.errors_as_sentence - render :new - end - end - - def update - @sponsorship = Sponsorship.find(params[:id]) - if @sponsorship.update(sponsorship_params) - flash[:notice] = I18n.t("admin.sponsorships_controller.updated") - redirect_to admin_sponsorships_path - else - flash[:danger] = @sponsorship.errors_as_sentence - render action: :edit - end - end - - def destroy - @sponsorship = Sponsorship.find(params[:id]) - if @sponsorship.destroy - flash[:notice] = I18n.t("admin.sponsorships_controller.destroyed") - else - flash[:danger] = I18n.t("admin.sponsorships_controller.not_destroyed") - end - redirect_to admin_sponsorships_path - end - - private - - def sponsorship_params - strong_params = params.fetch(:sponsorship, {}) - .permit(:status, :expires_at, :tagline, :url, - :blurb_html, :featured_number, - :instructions, :level, :user_id, - :sponsorable_id, :sponsorable_type, - :organization_id, :instructions_updated_at) - - if strong_params[:sponsorable_id].try(:empty?) || strong_params[:sponsorable_type].try(:empty?) - # Clear sponsorable & sponsorable_type if they were left empty - strong_params.delete("sponsorable_id") - strong_params.delete("sponsorable_type") - end - strong_params - end - end -end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 5217591f71938..d04503014134e 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -51,7 +51,7 @@ def update flash[:success] = I18n.t("tags_controller.tag_successfully_updated") redirect_to "#{URL.tag_path(@tag)}/edit" else - flash[:error] = @tag.errors.full_messages + flash.now[:error] = @tag.errors.full_messages render :edit end end @@ -80,7 +80,7 @@ def suggest private def tags - @tags ||= Tag.direct.includes(:sponsorship).limit(100) + @tags ||= Tag.direct.order("hotness_score DESC").limit(100) end def convert_empty_string_to_nil diff --git a/app/decorators/sponsorship_decorator.rb b/app/decorators/sponsorship_decorator.rb deleted file mode 100644 index 2cd5bfba35f0f..0000000000000 --- a/app/decorators/sponsorship_decorator.rb +++ /dev/null @@ -1,11 +0,0 @@ -class SponsorshipDecorator < ApplicationDecorator - def level_background_color - hexes = { - "gold" => "linear-gradient(to right, #faf0e6 8%, #faf3e6 18%, #fcf6eb 33%);", - "silver" => "linear-gradient(to right, #e3e3e3 8%, #f0eded 18%, #e8e8e8 33%);", - "bronze" => "linear-gradient(to right, #ebe2d3 8%, #f5eee1 18%, #ede6d8 33%);" - } - - hexes[level].to_s - end -end diff --git a/app/lib/constants/settings/general.rb b/app/lib/constants/settings/general.rb index 6a74eeccf19cd..3f756a803183b 100644 --- a/app/lib/constants/settings/general.rb +++ b/app/lib/constants/settings/general.rb @@ -99,10 +99,6 @@ def self.details description: I18n.t("lib.constants.settings.general.sidebar.description"), placeholder: I18n.t("lib.constants.settings.general.sidebar.placeholder") }, - sponsor_headline: { - description: I18n.t("lib.constants.settings.general.sponsor.description"), - placeholder: I18n.t("lib.constants.settings.general.sponsor.placeholder") - }, stripe_api_key: { description: I18n.t("lib.constants.settings.general.stripe_api.description"), placeholder: "sk_live_...." diff --git a/app/models/admin_menu.rb b/app/models/admin_menu.rb index 032a79b93b419..b3ddded4ae73a 100644 --- a/app/models/admin_menu.rb +++ b/app/models/admin_menu.rb @@ -46,7 +46,6 @@ class AdminMenu scope :advanced, "flashlight-line", [ item(name: "broadcasts"), item(name: "response templates"), - item(name: "sponsorships"), item(name: "developer tools", controller: "tools", children: [ item(name: "tools"), item(name: "vault secrets", controller: "secrets"), diff --git a/app/models/settings/general.rb b/app/models/settings/general.rb index 2416f584ea996..8187e0ee4e1d3 100644 --- a/app/models/settings/general.rb +++ b/app/models/settings/general.rb @@ -93,9 +93,6 @@ class General < Base } setting :twitter_hashtag, type: :string - # Sponsors - setting :sponsor_headline, default: -> { I18n.t("models.settings.general.community_sponsors") } - # Tags setting :sidebar_tags, type: :array, default: %w[] diff --git a/app/services/slack/messengers/sponsorship.rb b/app/services/slack/messengers/sponsorship.rb deleted file mode 100644 index cac149604d44b..0000000000000 --- a/app/services/slack/messengers/sponsorship.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Slack - module Messengers - class Sponsorship - def initialize(user:, organization:, level:, tag: nil) - @user = user - @organization = organization - @level = level - @tag = tag - end - - def self.call(...) - new(...).call - end - - def call - type = tag.present? ? "##{tag.name}" : level - message = I18n.t( - "services.slack.messengers.sponsorship.body", - user: user.username, - type: type, - organization: organization.username, - ) - - Slack::Messengers::Worker.perform_async( - "message" => message, - "channel" => "incoming-partners", - "username" => "media_sponsor", - "icon_emoji" => ":partyparrot:", - ) - end - - private - - attr_reader :user, :organization, :level, :tag - end - end -end diff --git a/app/views/admin/settings/forms/_sponsors.html.erb b/app/views/admin/settings/forms/_sponsors.html.erb deleted file mode 100644 index a71a023a21bc8..0000000000000 --- a/app/views/admin/settings/forms/_sponsors.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -<%= form_for(Settings::General.new, - url: admin_settings_general_settings_path, - html: { data: { action: "submit->config#updateConfigurationSettings" } }) do |f| %> -
- Sponsors -
-
-
- <%= admin_config_label :sponsor_headline %> - <%= admin_config_description Constants::Settings::General.details[:sponsor_headline][:description] %> - <%= f.text_field :sponsor_headline, - class: "crayons-textfield", - value: Settings::General.sponsor_headline, - placeholder: Constants::Settings::General.details[:sponsor_headline][:placeholder] %> -
-
- <%= render "update_setting_button", f: f %> -
-
-<% end %> diff --git a/app/views/admin/settings/show.html.erb b/app/views/admin/settings/show.html.erb index 73105455fa1e8..d98826c3ce26c 100644 --- a/app/views/admin/settings/show.html.erb +++ b/app/views/admin/settings/show.html.erb @@ -22,7 +22,6 @@ <%= render partial: "forms/newsletter" %> <%= render partial: "forms/onboarding" %> <%= render partial: "forms/rate_limit" %> - <%= render partial: "forms/sponsors" %> <%= render partial: "forms/tags" %> <%= render partial: "forms/user_experience" %> diff --git a/app/views/admin/sponsorships/edit.html.erb b/app/views/admin/sponsorships/edit.html.erb deleted file mode 100644 index bebca815b7f58..0000000000000 --- a/app/views/admin/sponsorships/edit.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -

<%= "Edit Sponsorship ##{@sponsorship.id}" %>

- -
- <%= form_for [:admin, @sponsorship] do |f| %> -
- Creator: <%= link_to "@#{@sponsorship.user.username}", "/#{@sponsorship.user.username}" %> -
-
- Organization: <%= link_to "@#{@sponsorship.organization.username}", "/#{@sponsorship.organization.username}" %> -
-
- Created at: <%= f.object.created_at.strftime("%d %B %Y %H:%M UTC") %> -
-
- Level: <%= @sponsorship.level %> -
-
- <% if @sponsorship.sponsorable.is_a?(ActsAsTaggableOn::Tag) %> - Sponsorable: <%= link_to @sponsorship.sponsorable.name, "/t/#{@sponsorship.sponsorable.name}" %> - <% end %> -
-
- <%= f.label :status %> - <%= f.select :status, Sponsorship::STATUSES %> -
-
- <%= f.label :expires_at %> - <%= f.datetime_select :expires_at, required: true, start_year: Time.current.year, end_year: Time.current.year + 2, class: "form-control" %> UTC Time -
-
- <%= f.label :tagline %> - <%= f.text_field :tagline, class: "form-control" %> -
-
- <%= f.label :url %> - <%= f.text_field :url, class: "form-control" %> -
-
- <%= f.label :blurb_html %> - <%= f.text_area :blurb_html, class: "form-control" %> -
-
- <%= f.label :featured_number %> - <%= f.text_field :featured_number, class: "form-control" %> -
-
- <%= f.label :instructions %> - <%= f.text_field :instructions, class: "form-control" %> -
-
- <%= f.label :instructions_updated_at %> - <%= f.datetime_select :instructions_updated_at, required: true, start_year: Time.current.year, end_year: Time.current.year + 2, class: "form-control" %> UTC Time -
- <%= f.submit "Update Sponsorship", class: "btn btn-primary" %> - <%= link_to "Destroy Sponsorship", admin_sponsorship_path(@sponsorship), class: "btn btn-danger", method: :delete, data: { confirm: "Are you sure?" } %> - <% end %> -
diff --git a/app/views/admin/sponsorships/index.html.erb b/app/views/admin/sponsorships/index.html.erb deleted file mode 100644 index eeb1b8d4e5a9a..0000000000000 --- a/app/views/admin/sponsorships/index.html.erb +++ /dev/null @@ -1,56 +0,0 @@ - - -<%= paginate @sponsorships %> - - - - - - - - - - - - - - - - - <% @sponsorships.each do |sponsorship| %> - - - - - - - - - - - - <% end %> - -
IDLevelStatusExpires AtSponsorableCreated AtCreatorOrganizationActions
<%= link_to sponsorship.id, edit_admin_sponsorship_path(sponsorship) %><%= sponsorship.level %><%= sponsorship.status %><%= sponsorship.expires_at&.strftime("%d %B %Y %H:%M UTC") %> - <% if sponsorship.sponsorable.is_a?(ActsAsTaggableOn::Tag) %> - <%= link_to sponsorship.sponsorable.name, "/t/#{sponsorship.sponsorable.name}" %> - <% end %> - <%= sponsorship.created_at.strftime("%d %B %Y %H:%M UTC") %><%= link_to "@#{sponsorship.user.username}", "/#{sponsorship.user.username}" %> - <%= link_to "@#{sponsorship.organization.username}", "/#{sponsorship.organization.username}" %> - - <%= link_to "edit", edit_admin_sponsorship_path(sponsorship) %> -
- -<%= paginate @sponsorships %> diff --git a/app/views/admin/sponsorships/new.html.erb b/app/views/admin/sponsorships/new.html.erb deleted file mode 100644 index 32c2ad7876046..0000000000000 --- a/app/views/admin/sponsorships/new.html.erb +++ /dev/null @@ -1,66 +0,0 @@ -

Make a new Sponsorship:

-
- <%= form_for([:admin, @sponsorship], method: :post) do |f| %> -
- <%= f.label :user_id, "Creator ID:" %> - <%= f.text_field :user_id, required: true, class: "form-control" %> -
- -
- <%= f.label :organization_id, "Organization ID:" %> - <%= f.text_field :organization_id, required: true, class: "form-control" %> -
- -
- <%= f.label :level, "Level:" %> - <%= f.select :level, options_for_select(Sponsorship::LEVELS, selected: @sponsorship.level), required: true, class: "form-control" %> -
- -
- <%= f.label :status, "Status:" %> - <%= f.select :status, options_for_select(Sponsorship::STATUSES, selected: @sponsorship.status), required: true, class: "form-control" %> -
- -
- <%= f.label :expires_at, "Expires At:" %> - <%= f.datetime_select :expires_at, start_year: Time.current.year, end_year: Time.current.year + 2, class: "form-control" %> UTC Time -
- -
- <%= f.label :tagline, "Tagline:" %> - <%= f.text_field :tagline, class: "form-control" %> -
- -
- <%= f.label :url, "URL:" %> - <%= f.text_field :url, class: "form-control" %> -
- -
- <%= f.label :blurb_html, "Blurb HTML:" %> - <%= f.text_area :blurb_html, size: "100x10", class: "form-control" %> -
- -
- <%= f.label :featured_number, "Featured Number:" %> - <%= f.text_field :featured_number, required: true, class: "form-control" %> -
- -
- <%= f.label :instructions, "Instructions:" %> - <%= f.text_field :instructions, class: "form-control" %> -
- -
- <%= f.label :sponsorable_id, "Sponsorable:" %> - <%= f.text_field :sponsorable_id, class: "form-control" %> -
- -
- <%= f.label :sponsorable_type, "Sponsorable Type:" %> - <%= f.text_field :sponsorable_type, class: "form-control" %> -
- - <%= submit_tag "Create Sponsorship", class: "crayons-btn" %> - <% end %> -
diff --git a/app/views/articles/_sidebar.html.erb b/app/views/articles/_sidebar.html.erb index 9302e0542cf65..032313ec01015 100644 --- a/app/views/articles/_sidebar.html.erb +++ b/app/views/articles/_sidebar.html.erb @@ -4,20 +4,7 @@ <%= render partial: "shared/auth_widget", locals: { tracking_id: "ca_left_sidebar_home_page", source: "left_sidebar" } unless user_signed_in? %> <%= render partial: "layouts/main_nav", locals: { context: "sidebar" } %> <%= render "layouts/sidebar_tags" %> - <% @sponsorships = Sponsorship.gold.live.includes(:organization).order(featured_number: :asc) %> <%# the pattern .present?/.each has the advantage of issuing only a single SQL query to load objects in memory %> - <% if @sponsorships.present? %> -
px-1" id="sponsorship-widget"> -

- <%= Settings::General.sponsor_headline %> - <%= crayons_icon_tag("twemoji/heart", class: "ml-1", native: true, title: t("views.sponsor.seek")) %> -

-
- <%= render partial: "articles/single_sponsor", collection: @sponsorships, as: :sponsorship %> - <%= t("views.sponsor.seek") %> -
-
- <% end %> <% end %> <% cache("display-area-left-#{rand(5)}-#{user_signed_in?}", expires_in: 5.minutes) do %> <% @left_sidebar_ad = DisplayAd.for_display("sidebar_left", user_signed_in?) %> diff --git a/app/views/articles/_single_sponsor.html.erb b/app/views/articles/_single_sponsor.html.erb deleted file mode 100644 index f0e5e18135bad..0000000000000 --- a/app/views/articles/_single_sponsor.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% organization = sponsorship.organization %> - diff --git a/app/views/organizations/_sidebar_additional.html.erb b/app/views/organizations/_sidebar_additional.html.erb index 80b30237cea87..4de3f575e2b54 100644 --- a/app/views/organizations/_sidebar_additional.html.erb +++ b/app/views/organizations/_sidebar_additional.html.erb @@ -1,11 +1,6 @@