diff --git a/Gemfile b/Gemfile index f94985827..3f47596b4 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,6 @@ gem "ahoy_matey", "~> 3.2" # Tracking analytics for Rails gem "ancestry", "~> 3.2" # Ancestry allows the records of a ActiveRecord model to be organized in a tree structure gem "blazer", "~> 2.4.2" # Allows admins to query data gem "bootsnap", ">= 1.1.0", require: false # Boot large ruby/rails apps faster -gem "buffer", "~> 0.1" # Buffer is a Ruby Wrapper for the Buffer API gem "carrierwave", "~> 2.2" # Upload files in your Ruby applications, map them to a range of ORMs, store them on different backends gem "carrierwave-bombshelter", "~> 0.2" # Protect your carrierwave from image bombs gem "cloudinary", "~> 1.19" # Client library for easily using the Cloudinary service diff --git a/Gemfile.lock b/Gemfile.lock index d05d58e8a..dec999910 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -149,15 +149,6 @@ GEM brpoplpush-redis_script (0.1.2) concurrent-ruby (~> 1.0, >= 1.0.5) redis (>= 1.0, <= 5.0) - buffer (0.1.3) - addressable - environs - faraday - faraday_middleware - hashie - multi_json - rake - yajl-ruby buftok (0.2.0) builder (3.2.4) bullet (6.1.4) @@ -262,7 +253,6 @@ GEM email_validator (2.2.2) activemodel emoji_regex (3.2.2) - environs (1.1.0) equalizer (0.0.11) errbase (0.2.1) erubi (1.10.0) @@ -284,8 +274,6 @@ GEM multipart-post (>= 1.2, < 3) ruby2_keywords faraday-net_http (1.0.1) - faraday_middleware (1.0.0) - faraday (~> 1.0) fastimage (2.2.1) fastly (3.0.1) feedjira (3.1.2) @@ -859,7 +847,6 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - yajl-ruby (1.4.1) yard (0.9.26) yard-activerecord (0.0.16) yard (>= 0.8.3) @@ -888,7 +875,6 @@ DEPENDENCIES blazer (~> 2.4.2) bootsnap (>= 1.1.0) brakeman (~> 5.0) - buffer (~> 0.1) bullet (~> 6.1) bundler-audit (~> 0.8) capybara (~> 3.35.3) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index c95d7afca..cdc1684d3 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -211,7 +211,7 @@ label { // rendered from boostrap. We want to remove these to be // consistent with links in the crayons design system. .crayons-link, - .crayons-tabs__item { + .crayons-tabs__item { text-decoration: none; &:hover { diff --git a/app/controllers/admin/articles_controller.rb b/app/controllers/admin/articles_controller.rb index d4150123d..859d9b28a 100644 --- a/app/controllers/admin/articles_controller.rb +++ b/app/controllers/admin/articles_controller.rb @@ -7,22 +7,10 @@ module Admin end def index - @pending_buffer_updates = BufferUpdate.where(status: "pending").includes(:article) - @user_buffer_updates = BufferUpdate.where(status: "sent_direct", approver_user_id: current_user.id).where( - "created_at > ?", 24.hours.ago - ) - case params[:state] - when /not-buffered/ - days_ago = params[:state].split("-")[2].to_f - @articles = articles_not_buffered(days_ago) when /top-/ months_ago = params[:state].split("-")[1].to_i.months.ago @articles = articles_top(months_ago) - when "satellite" - @articles = articles_satellite - when "satellite-not-buffered" - @articles = articles_satellite.where(last_buffered: nil) when "boosted-additional-articles" @articles = articles_boosted_additional when "chronological" @@ -49,17 +37,6 @@ module Admin private - def articles_not_buffered(days_ago) - Article.published - .where(last_buffered: nil) - .where("published_at > ? OR crossposted_at > ?", days_ago.days.ago, days_ago.days.ago) - .includes(:user) - .limited_columns_internal_select - .order(public_reactions_count: :desc) - .page(params[:page]) - .per(50) - end - def articles_top(months_ago) Article.published .where("published_at > ?", months_ago) @@ -70,19 +47,9 @@ module Admin .per(50) end - def articles_satellite - Article.published.where(last_buffered: nil) - .includes(:user, :buffer_updates) - .tagged_with(Tag.bufferized_tags, any: true).unscope(:select) - .limited_columns_internal_select - .order(hotness_score: :desc) - .page(params[:page]) - .per(60) - end - def articles_boosted_additional Article.boosted_via_additional_articles - .includes(:user, :buffer_updates) + .includes(:user) .limited_columns_internal_select .order(published_at: :desc) .page(params[:page]) @@ -111,7 +78,7 @@ module Admin Article.published.or(Article.where(published_from_feed: true)) .where(featured: true) .where("featured_number > ?", Time.current.to_i) - .includes(:user, :buffer_updates) + .includes(:user) .limited_columns_internal_select .order(featured_number: :desc) end @@ -128,7 +95,6 @@ module Admin featured_number user_id co_author_ids_list - last_buffered published_at] params.require(:article).permit(allowed_params) end diff --git a/app/controllers/admin/buffer_updates_controller.rb b/app/controllers/admin/buffer_updates_controller.rb deleted file mode 100644 index b7a42ede0..000000000 --- a/app/controllers/admin/buffer_updates_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Admin - class BufferUpdatesController < Admin::ApplicationController - def create - article_id = params[:article_id] - article = Article.find(article_id) if article_id.present? - fb_post = params[:fb_post] - tweet = params[:tweet] - listing_id = params[:listing_id] - listing = Listing.find(params[:listing_id]) if listing_id.present? - article&.update(featured: true) - case params[:social_channel] - when "main_twitter" - Bufferizer::MainTweet.call(article, tweet, current_user.id) - render body: nil - when "satellite_twitter" - Bufferizer::SatelliteTweet.call(article, tweet, current_user.id) - render body: nil - when "facebook" - Bufferizer::FacebookPost.call(article, fb_post, current_user.id) - render body: nil - when "listings_twitter" - Bufferizer::ListingsTweet.call(listing, tweet, current_user.id) - render body: nil - end - end - - def update - BufferUpdate.upbuff!(params[:id], current_user.id, params[:body_text], params[:status]) - render body: nil - end - - private - - def authorize_admin - authorize BufferUpdate, :access?, policy_class: InternalPolicy - end - end -end diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index dafe84989..a3661413e 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -75,7 +75,6 @@ class ArticlesController < ApplicationController @article = @article.decorate @user = @article.user @rating_vote = RatingVote.where(article_id: @article.id, user_id: @user.id).first - @buffer_updates = BufferUpdate.where(composer_user_id: @user.id, article_id: @article.id) @organizations = @user&.organizations # TODO: fix this for multi orgs @org_members = @organization.users.pluck(:name, :id) if @organization diff --git a/app/controllers/buffer_updates_controller.rb b/app/controllers/buffer_updates_controller.rb deleted file mode 100644 index 72111e524..000000000 --- a/app/controllers/buffer_updates_controller.rb +++ /dev/null @@ -1,63 +0,0 @@ -class BufferUpdatesController < ApplicationController - after_action :verify_authorized - - def create - @article = Article.find(params[:buffer_update][:article_id]) - authorize @article, policy_class: BufferUpdatePolicy - create_main_tweet - create_satellite_tweets - create_facebook_post - redirect_back(fallback_location: "/mod") - end - - def create_main_tweet - BufferUpdate.create( - article_id: @article.id, - composer_user_id: current_user.id, - body_text: modified_body_text, - social_service_name: "twitter", - buffer_profile_id_code: ApplicationConfig["BUFFER_TWITTER_ID"], - status: "pending", - ) - end - - def create_satellite_tweets - tags_names = @article.decorate.cached_tag_list_array - tags_names.each do |name| - tag = Tag.find_by(name: name) - - next if tag&.buffer_profile_id_code.blank? - - BufferUpdate.create( - article_id: @article.id, - composer_user_id: current_user.id, - body_text: modified_body_text, - social_service_name: "twitter", - buffer_profile_id_code: tag.buffer_profile_id_code, - tag_id: tag.id, - status: "pending", - ) - end - end - - def create_facebook_post - BufferUpdate.create( - article_id: @article.id, - composer_user_id: current_user.id, - body_text: "#{params[:buffer_update][:body_text]} #{URL.article(@article)}", - social_service_name: "facebook", - buffer_profile_id_code: ApplicationConfig["BUFFER_FACEBOOK_ID"], - status: "pending", - ) - end - - def modified_body_text - @user = @article.user - [ - params[:buffer_update][:body_text], - ("\n\n{ author: @#{@user.twitter_username} }" if @user.twitter_username.present?), - (" #{SiteConfig.twitter_hashtag}" if SiteConfig.twitter_hashtag.present?), - "\n#{URL.article(@article)}", - ].compact.join - end -end diff --git a/app/javascript/admin/__tests__/controllers/buffer_controller.test.js b/app/javascript/admin/__tests__/controllers/buffer_controller.test.js deleted file mode 100644 index 276e1873c..000000000 --- a/app/javascript/admin/__tests__/controllers/buffer_controller.test.js +++ /dev/null @@ -1,54 +0,0 @@ -import { Application } from 'stimulus'; -import BufferController from '../../controllers/buffer_controller'; - -describe('BufferController', () => { - beforeEach(() => { - document.body.innerHTML = ` -
-

- - - -
`; - - const application = Application.start(); - application.register('buffer', BufferController); - }); - - describe('#tagBufferUpdateConfirmed', () => { - it('adds a badge to the header', () => { - const button = document.getElementsByTagName('button')[0]; - const header = document.getElementsByTagName('h2')[0]; - - button.click(); - - expect(header.firstChild.textContent).toMatch(/Confirm/); - }); - }); - - describe('#tagBufferUpdateDismissed', () => { - it('adds a badge to the header', () => { - const button = document.getElementsByTagName('button')[1]; - const header = document.getElementsByTagName('h2')[0]; - - button.click(); - - expect(header.firstChild.textContent).toMatch(/Dismiss/); - }); - }); - - describe('#highlightElement', () => { - it('adds a class to the controller element', () => { - const button = document.getElementsByTagName('button')[2]; - const element = document.querySelector("[data-controller='buffer']"); - - button.click(); - - expect( - element.classList.contains('bg-highlighted', 'border-highlighted'), - ).toBe(true); - }); - }); -}); diff --git a/app/javascript/admin/__tests__/controllers/sidebar_controller.test.js b/app/javascript/admin/__tests__/controllers/sidebar_controller.test.js index f42f40258..c783a90a1 100644 --- a/app/javascript/admin/__tests__/controllers/sidebar_controller.test.js +++ b/app/javascript/admin/__tests__/controllers/sidebar_controller.test.js @@ -85,16 +85,16 @@ describe('SidebarController', () => { describe('#disableCurrentNavItem', () => { it('sets the disabled attribute on the open menu button', () => { - window.dispatchEvent(new Event('load')) + window.dispatchEvent(new Event('load')); const button = document.getElementById('apps_button'); - expect(button.getAttribute("disabled")).toEqual("true"); + expect(button.getAttribute('disabled')).toEqual('true'); }); }); describe('#expandDropdown', () => { beforeEach(() => { - let assignMock = jest.fn(); + const assignMock = jest.fn(); delete window.location; window.location = { href: assignMock }; @@ -108,15 +108,14 @@ describe('SidebarController', () => { const button = document.getElementById('advanced_button'); button.click(); - expect(window.location.href).toEqual("/admin/advanced/broadcasts") + expect(window.location.href).toEqual('/admin/advanced/broadcasts'); }); it('closes other menu items', () => { const button = document.getElementById('advanced_button'); button.click(); - expect(document.getElementById('apps').classList).toContain("hide"); + expect(document.getElementById('apps').classList).toContain('hide'); }); - - }) + }); }); diff --git a/app/javascript/admin/controllers/buffer_controller.js b/app/javascript/admin/controllers/buffer_controller.js deleted file mode 100644 index 81691d7e0..000000000 --- a/app/javascript/admin/controllers/buffer_controller.js +++ /dev/null @@ -1,46 +0,0 @@ -import { Controller } from 'stimulus'; - -const CONFIRM_BADGE_HTML = - 'Confirm'; -const DISMISS_BADGE_HTML = - 'Dismiss'; - -export default class BufferController extends Controller { - static classes = ['bgHighlighted', 'borderHighlighted']; - static targets = ['header', 'bodyText']; - - tagBufferUpdateConfirmed() { - this.clearPreviousBadge(); - - this.headerTarget.innerHTML += CONFIRM_BADGE_HTML; - } - - tagBufferUpdateDismissed() { - this.clearPreviousBadge(); - - this.headerTarget.innerHTML += DISMISS_BADGE_HTML; - } - - highlightElement() { - this.element.classList.add( - this.bgHighlightedClass, - this.borderHighlightedClass, - ); - setTimeout(() => { - this.element.classList.remove(this.bgHighlightedClass); - }, 350); - } - - autosizeBodyText() { - this.bodyTextTarget.rows = this.bodyTextTarget.value.split( - /\r\n|\r|\n/, - ).length; - } - - clearPreviousBadge() { - const badge = this.headerTarget.getElementsByClassName('badge')[0]; - if (badge) { - badge.remove(); - } - } -} diff --git a/app/javascript/admin/controllers/sidebar_controller.js b/app/javascript/admin/controllers/sidebar_controller.js index ddbd01caf..c4502c5d2 100644 --- a/app/javascript/admin/controllers/sidebar_controller.js +++ b/app/javascript/admin/controllers/sidebar_controller.js @@ -2,14 +2,14 @@ import { Controller } from 'stimulus'; // eslint-disable-next-line no-restricted-syntax export default class SidebarController extends Controller { - static targets = [ - 'submenu' - ]; + static targets = ['submenu']; disableCurrentNavItem() { - const activeMenuId = this.submenuTargets.filter((item) => item.classList.contains("show"))[0].id + const activeMenuId = this.submenuTargets.filter((item) => + item.classList.contains('show'), + )[0].id; const activeButton = document.getElementById(`${activeMenuId}_button`); - activeButton.setAttribute("disabled", true) + activeButton.setAttribute('disabled', true); } expandDropdown(event) { @@ -26,7 +26,7 @@ export default class SidebarController extends Controller { const collapsedList = ['collapse', 'hide']; this.submenuTargets.map((item) => { - if (item.classList.contains("show")) { + if (item.classList.contains('show')) { item.classList.remove(...expandedList); item.classList.add(...collapsedList); } diff --git a/app/javascript/crayons/MentionAutocompleteTextArea/__stories__/mention-autocomplete.md b/app/javascript/crayons/MentionAutocompleteTextArea/__stories__/mention-autocomplete.md index d28a9ec38..f94b05137 100644 --- a/app/javascript/crayons/MentionAutocompleteTextArea/__stories__/mention-autocomplete.md +++ b/app/javascript/crayons/MentionAutocompleteTextArea/__stories__/mention-autocomplete.md @@ -1,8 +1,12 @@ ## Mention autocomplete -The `MentionAutocompleteTextArea` component uses the [Reach UI Combobox](https://reach.tech/combobox/) under the hood. It works by _replacing_ the textarea you pass in props with one enhanced with the `@mention` functionality. +The `MentionAutocompleteTextArea` component uses the +[Reach UI Combobox](https://reach.tech/combobox/) under the hood. It works by +_replacing_ the textarea you pass in props with one enhanced with the `@mention` +functionality. -The autocomplete will begin fetching suggestions once a user has typed `@` plus at least two characters. A user's selection is confirmed when they either: +The autocomplete will begin fetching suggestions once a user has typed `@` plus +at least two characters. A user's selection is confirmed when they either: - Click on a search option - Hit enter on a search option @@ -11,8 +15,15 @@ The autocomplete will begin fetching suggestions once a user has typed `@` plus ### Mention autocomplete accessibility -The component replaces the given textarea with one generated using [Reach UI Combobox](https://reach.tech/combobox/). The underlying behavior then conforms to the [WAI_ARIA guidelines on comboboxes](https://www.w3.org/TR/wai-aria-practices-1.2/#combobox). +The component replaces the given textarea with one generated using +[Reach UI Combobox](https://reach.tech/combobox/). The underlying behavior then +conforms to the +[WAI_ARIA guidelines on comboboxes](https://www.w3.org/TR/wai-aria-practices-1.2/#combobox). -An `aria-live` region communicates to a screen reader user when the list has been populated with suggestions. +An `aria-live` region communicates to a screen reader user when the list has +been populated with suggestions. -Please note: When using the `MentionAutocompleteTextArea`, you must have either an `aria-labelledby` or `aria-label` attribute on the textarea you pass as a prop. These attributes are copied across to the Reach UI Combobox input, ensuring it is labelled correctly for accessibility. +Please note: When using the `MentionAutocompleteTextArea`, you must have either +an `aria-labelledby` or `aria-label` attribute on the textarea you pass as a +prop. These attributes are copied across to the Reach UI Combobox input, +ensuring it is labelled correctly for accessibility. diff --git a/app/lib/constants/role.rb b/app/lib/constants/role.rb index a57b00c8a..72f8476ee 100644 --- a/app/lib/constants/role.rb +++ b/app/lib/constants/role.rb @@ -17,7 +17,6 @@ module Constants "Resource Admin: Badge", "Resource Admin: BadgeAchievement", "Resource Admin: Broadcast", - "Resource Admin: BufferUpdate", "Resource Admin: ChatChannel", "Resource Admin: Comment", "Resource Admin: Config", diff --git a/app/models/article.rb b/app/models/article.rb index 0105bd0f8..b4e7b1b29 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,4 +1,6 @@ class Article < ApplicationRecord + self.ignored_columns = %w[facebook_last_buffered last_buffered].freeze + include CloudinaryHelper include ActionView::Helpers include Storext.model @@ -29,7 +31,6 @@ class Article < ApplicationRecord counter_culture :user counter_culture :organization - has_many :buffer_updates, dependent: :destroy has_many :comments, as: :commentable, inverse_of: :commentable, dependent: :nullify has_many :html_variant_successes, dependent: :nullify has_many :html_variant_trials, dependent: :nullify @@ -115,9 +116,8 @@ class Article < ApplicationRecord # data in the column. However, since `published_at` is a *very* diverse # column and can scope down the result set significantly, the query planner # can make heavy use of it. - scope :published, -> { - self - .where(published: true) + scope :published, lambda { + where(published: true) .where("published_at <= ?", Time.current) } scope :unpublished, -> { where(published: false) } @@ -165,8 +165,7 @@ class Article < ApplicationRecord :video, :user_id, :organization_id, :video_source_url, :video_code, :video_thumbnail_url, :video_closed_caption_track_url, :social_image, :published_from_feed, :crossposted_at, :published_at, :featured_number, - :last_buffered, :facebook_last_buffered, :created_at, :body_markdown, - :email_digest_eligible, :processed_html, :co_author_ids) + :created_at, :body_markdown, :email_digest_eligible, :processed_html, :co_author_ids) } scope :boosted_via_additional_articles, lambda { diff --git a/app/models/listing.rb b/app/models/listing.rb index 4b832cd08..5de42af67 100644 --- a/app/models/listing.rb +++ b/app/models/listing.rb @@ -2,6 +2,7 @@ class Listing < ApplicationRecord # We used to use both "classified listing" and "listing" throughout the app. # We standardized on the latter, but keeping the table name was easier. self.table_name = "classified_listings" + self.ignored_columns = ["last_buffered"].freeze include Searchable diff --git a/app/models/tag.rb b/app/models/tag.rb index 46b3bd85e..ef535cbee 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,6 +1,8 @@ require_relative "../lib/acts_as_taggable_on/tag" class Tag < ActsAsTaggableOn::Tag + self.ignored_columns = ["buffer_profile_id_code"].freeze + attr_accessor :points, :tag_moderator_id, :remove_moderator_id acts_as_followable @@ -21,7 +23,6 @@ class Tag < ActsAsTaggableOn::Tag belongs_to :badge, optional: true belongs_to :mod_chat_channel, class_name: "ChatChannel", optional: true - has_many :buffer_updates, dependent: :nullify has_many :articles, through: :taggings, source: :taggable, source_type: "Article" has_one :sponsorship, as: :sponsorable, inverse_of: :sponsorable, dependent: :destroy @@ -66,12 +67,6 @@ class Tag < ActsAsTaggableOn::Tag User.with_role(:tag_moderator, self).order(id: :asc).ids end - def self.bufferized_tags - Rails.cache.fetch("bufferized_tags_cache", expires_in: 2.hours) do - where.not(buffer_profile_id_code: nil).pluck(:name) - end - end - def self.valid_categories ALLOWED_CATEGORIES end diff --git a/app/models/user.rb b/app/models/user.rb index f5bbcaab8..71c37c70d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,10 +131,6 @@ class User < ApplicationRecord inverse_of: :blocked, dependent: :delete_all has_many :blocker_blocks, class_name: "UserBlock", foreign_key: :blocker_id, inverse_of: :blocker, dependent: :delete_all - has_many :buffer_updates_approved, class_name: "BufferUpdate", foreign_key: :approver_user_id, - inverse_of: :approver_user, dependent: :nullify - has_many :buffer_updates_composed, class_name: "BufferUpdate", foreign_key: :composer_user_id, - inverse_of: :composer_user, dependent: :nullify has_many :chat_channel_memberships, dependent: :destroy has_many :chat_channels, through: :chat_channel_memberships has_many :collections, dependent: :destroy diff --git a/app/policies/buffer_update_policy.rb b/app/policies/buffer_update_policy.rb deleted file mode 100644 index da587cfeb..000000000 --- a/app/policies/buffer_update_policy.rb +++ /dev/null @@ -1,11 +0,0 @@ -class BufferUpdatePolicy < ApplicationPolicy - def create? - user_is_trusted? || user_is_author? - end - - private - - def user_is_author? - record.user_id == user.id - end -end diff --git a/app/services/bufferizer/facebook_post.rb b/app/services/bufferizer/facebook_post.rb deleted file mode 100644 index a51d78906..000000000 --- a/app/services/bufferizer/facebook_post.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Bufferizer - class FacebookPost - def self.call(article, post, admin_id) - return unless article && post && admin_id - - BufferUpdate.buff!( - article.id, - fb_buffer_text(post, article), - social_service_name: "facebook", - admin_id: admin_id, - ) - - BufferUpdate.buff!( - article.id, - fb_buffer_text(post, article) + social_tags(article), - social_service_name: "linkedin", - admin_id: admin_id, - ) - - article.update(facebook_last_buffered: Time.current) - end - - def self.fb_buffer_text(post, article) - "#{post} #{URL.article(article)}" - end - - private_class_method :fb_buffer_text - - def self.social_tags(article) - # for linkedin's followable tags - tags = article.tag_list.map { |tag| "##{tag}" }.join(" ") - " #programming #softwareengineering #{tags}" - end - - private_class_method :social_tags - end -end diff --git a/app/services/bufferizer/listings_tweet.rb b/app/services/bufferizer/listings_tweet.rb deleted file mode 100644 index d50e7046a..000000000 --- a/app/services/bufferizer/listings_tweet.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Bufferizer - class ListingsTweet - TWEET_SIZE_LIMIT = 255 - - def self.call(listing, tweet) - return unless listing && tweet - - buffer_listings_id = ApplicationConfig["BUFFER_LISTINGS_PROFILE"] - - BufferUpdate.send_to_buffer( - listings_twitter_text(tweet, listing), - buffer_listings_id, - ) - - listing.update(last_buffered: Time.current) - end - - def self.listings_twitter_text(tweet, listing) - "#{tweet} #{URL.url(listing.path)}" if tweet.size <= TWEET_SIZE_LIMIT - end - - private_class_method :listings_twitter_text - end -end diff --git a/app/services/bufferizer/main_tweet.rb b/app/services/bufferizer/main_tweet.rb deleted file mode 100644 index c78a5cf02..000000000 --- a/app/services/bufferizer/main_tweet.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Bufferizer - class MainTweet - TWEET_SIZE_LIMIT = 255 - - def self.call(article, tweet, admin_id) - return unless article && tweet && admin_id - - BufferUpdate.buff!( - article.id, - twitter_buffer_text(tweet, article), - admin_id: admin_id, - ) - - article.update(last_buffered: Time.current) - end - - def self.twitter_buffer_text(tweet, article) - "#{tweet} #{URL.article(article)}" if tweet.size <= TWEET_SIZE_LIMIT - end - - private_class_method :twitter_buffer_text - end -end diff --git a/app/services/bufferizer/satellite_tweet.rb b/app/services/bufferizer/satellite_tweet.rb deleted file mode 100644 index 5c1c98100..000000000 --- a/app/services/bufferizer/satellite_tweet.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Bufferizer - class SatelliteTweet - TWEET_SIZE_LIMIT = 255 - TEXT_SIZE_LIMIT = 250 - - def self.call(article, tweet, admin_id) - return unless article && tweet && admin_id - - article.tags.find_each do |tag| - next if tag.buffer_profile_id_code.blank? - - text = twitter_buffer_text(tweet, article) - - if text.length < TEXT_SIZE_LIMIT && SiteConfig.twitter_hashtag - text = text.gsub( - " #{SiteConfig.twitter_hashtag}", - " #{SiteConfig.twitter_hashtag} ##{tag.name}", - ) - end - - BufferUpdate.buff!( - article.id, - text, - buffer_profile_id_code: tag.buffer_profile_id_code, - tag_id: tag.id, - admin_id: admin_id, - ) - end - - article.update(last_buffered: Time.current) - end - - def self.twitter_buffer_text(tweet, article) - "#{tweet} #{URL.article(article)}" if tweet.size <= TWEET_SIZE_LIMIT - end - - private_class_method :twitter_buffer_text - end -end diff --git a/app/services/users/delete_articles.rb b/app/services/users/delete_articles.rb index 41b5ef2fc..33d8945e1 100644 --- a/app/services/users/delete_articles.rb +++ b/app/services/users/delete_articles.rb @@ -8,7 +8,6 @@ module Users virtual_articles = user.articles.map { |article| Article.new(article.attributes) } user.articles.find_each do |article| article.reactions.delete_all - article.buffer_updates.delete_all article.comments.includes(:user).find_each do |comment| comment.reactions.delete_all EdgeCache::BustComment.call(comment.commentable) diff --git a/app/views/admin/articles/_individual_article.html.erb b/app/views/admin/articles/_individual_article.html.erb index 02f9af2c5..5776c4dc7 100644 --- a/app/views/admin/articles/_individual_article.html.erb +++ b/app/views/admin/articles/_individual_article.html.erb @@ -126,36 +126,12 @@ <%= f.check_box :boosted_additional_articles, id: "boosted_additional_articles-#{article.id}" %> - <% unless article.last_buffered %> -
- <%= f.check_box :last_buffered, id: "last_buffered-#{article.id}" %> - -
- <% end %>
<% end %> - <% if article.last_buffered %> -
- Last Buffered <%= article.last_buffered %> - <% article.buffer_updates.order(created_at: :asc).each do |buffer_update| %> -
- - <%= buffer_update.social_service_name %> - <%= " MAIN" if buffer_update.buffer_profile_id_code == ApplicationConfig["BUFFER_TWITTER_ID"] %> - -
- <%= time_ago_in_words(buffer_update.created_at) %> ago -

- <%= buffer_update.body_text %> -

- <% end %> -
- <% end %> - <% if article.boosted_dev_digest_email %>

<% phrase = "#{article.path}?booster_org=#{article.organization&.slug || 'generic'}" %> @@ -173,53 +149,5 @@ <%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where.not(opened_at: nil).where("sent_at > ?", 1.week.ago).size %> OPENED EMAILS IN THE PAST WEEK <% end %> - -
- -
- -
-
-
- <%= article.processed_html&.html_safe %> -
- -
- <%= form_with url: admin_buffer_updates_path, html: { data: { action: "submit->article#highlightElement" } } do %> - - -
Twitter MAIN
-
- -
- - <% end %> - - <% if (article.decorate.cached_tag_list_array & Tag.bufferized_tags).any? %> - <%= form_with url: admin_buffer_updates_path, html: { data: { action: "submit->article#highlightElement" } } do %> - - -
Twitter Satellite
-
- -
- - <% end %> - <% end %> - <%= form_with url: admin_buffer_updates_path, html: { data: { action: "submit->article#highlightElement" } } do %> - - -
Facebook & LinkedIn
-
- -
- - <% end %> -
-
-
diff --git a/app/views/admin/articles/index.html.erb b/app/views/admin/articles/index.html.erb index 0ab52ce9f..9fddd5ac2 100644 --- a/app/views/admin/articles/index.html.erb +++ b/app/views/admin/articles/index.html.erb @@ -1,19 +1,3 @@ -<% if ENV["BUFFER_ACCESS_TOKEN"].blank? %> - -<% elsif @user_buffer_updates.any? %> - -<% else %> - -<% end %> -
<% if params[:state] && params[:state].include?("top-") && params[:state] != "top-3" && params[:state] != "top-6" %>

@@ -60,73 +21,6 @@

<% end %>
- <% if @pending_buffer_updates.any? %> -
-
- Suggested Tweets (<%= @pending_buffer_updates.size %>) - <% @pending_buffer_updates.each do |buffer_update| %> - <% next unless buffer_update.article %> -
-
-

<%= buffer_update.article.title %>

-
-
-

Score: <%= buffer_update.article.score %>

-
- <%= HTML_Truncator.truncate( - buffer_update.article.processed_html, - 50, - ellipsis: "... Read Entire Post", - ).html_safe %> -
-
- - <%= Tag.find_by(id: buffer_update.tag_id)&.name || buffer_update.social_service_name %>: - - <%= form_with( - url: admin_buffer_update_path(buffer_update.id), - class: "buffer-form buffer-confirm", - html: { data: { action: "submit->buffer#highlightElement" } }, - ) do |f| %> -
- - - - - -
- - <% end %> - - <%= form_with( - url: admin_buffer_update_path(buffer_update.id), - class: "buffer-form buffer-dismiss", - html: { data: { action: "submit->buffer#highlightElement" } }, - ) do |f| %> -
- - - - -
- - <% end %> -
-
- <% end %> -
-
- <% end %>
<% if @featured_articles.present? %>

Manually Featured Articles

diff --git a/app/views/admin/listings/index.html.erb b/app/views/admin/listings/index.html.erb index d2b166e29..77f5f8f02 100644 --- a/app/views/admin/listings/index.html.erb +++ b/app/views/admin/listings/index.html.erb @@ -58,45 +58,6 @@ <%= listing.published ? "Yes" : "No" %> <%= listing.bumped_at ? "#{time_ago_in_words(listing.bumped_at)} ago" : "Draft" %> - - - - - <% if listing.last_buffered.present? %> - - Last shared: <%= listing.last_buffered.strftime("%d %B %Y") %> - - <% end %> -
-

<%= listing.title %>

-

<%= listing.processed_html&.html_safe %>

- <%= form_with url: admin_buffer_updates_path, html: { data: { action: "submit->buffer#highlightElement" } } do %> - - - - - <% end %> -
- - <% end %> diff --git a/app/views/admin/shared/_nested_sidebar.html.erb b/app/views/admin/shared/_nested_sidebar.html.erb index a1ca11b09..aea53aaeb 100644 --- a/app/views/admin/shared/_nested_sidebar.html.erb +++ b/app/views/admin/shared/_nested_sidebar.html.erb @@ -5,8 +5,7 @@ " href="/admin/<%= group[:children][0][:controller] %>" aria-page="<%= "page" if deduced_controller(request) == group[:children][0][:controller] %>" - data-action="click->sidebar#expandDropdown" - > + data-action="click->sidebar#expandDropdown"> <%= inline_svg_tag(group[:svg], aria: true, class: "dropdown-icon crayons-icon") %> <%= display_name(group_name) %> @@ -19,22 +18,19 @@ data-target-href="/admin/<%= group_name %>/<%= group[:children][0][:controller] %>" aria-expanded="<%= (deduced_scope(request) == group_name.to_s).to_s %>" aria-controls="<%= group_name %>" - data-action="click->sidebar#expandDropdown" - > + data-action="click->sidebar#expandDropdown"> <%= inline_svg_tag(group[:svg], aria: true, class: "dropdown-icon crayons-icon") %> <%= display_name(group_name) %>