Remove SheCoded Specific Code (#13363)

Closes https://github.com/forem/forem/issues/13212.
This commit is contained in:
Vaidehi Joshi 2021-04-12 11:04:58 -07:00 committed by GitHub
parent 31091371e6
commit 4e14350438
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 8 additions and 159 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

View file

@ -14,7 +14,7 @@ module Constants
},
campaign_featured_tags: {
description: "Posts with which tags will be featured in the campaign sidebar (comma separated, letters only)",
placeholder: "List of campaign tags: comma separated, letters only e.g. shecoded,theycoded"
placeholder: "List of campaign tags: comma separated, letters only e.g. tagone,tagtwo"
},
campaign_hero_html_variant_name: {
description: "Hero HtmlVariant name",

View file

@ -1,132 +0,0 @@
<style>
body {
background-image: url(<%= asset_path "shecoded-background.jpg" %>);
background-size: 100%;
margin: 0;
padding: 0;
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
}
.preview-div-wrapper {
overflow: hidden;
position: relative;
}
.preview-div {
background: #fff;
border: 0.25vw solid #8220B0;
box-shadow: 0.8vw 1vw 0px #8220B0;
width: 94vw;
height: 45vw;
margin: 2.25vw auto 5vw;
overflow: hidden;
position: relative;
border-radius: 0.3vw;
border-top-left-radius: 2.3vw;
border-top-right-radius: 2.3vw;
}
.preview-info-header {
color: #8220B0;
margin: 2vw 2.5vw 0vw;
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, "Roboto", monospace;
font-size: 3.5vw;
width: 92%;
}
.preview-info-header img {
height: 2.5vw;
vertical-align: -0.15vw;
margin-left: 1vw;
margin-right: 0.5vw;
}
.title-area {
position: absolute;
bottom: 12vw;
left: 0;
right: 0;
top: 0;
}
h1 {
color: #8220B0;
width: 94%;
margin: 1vw auto;
position: absolute;
padding-left: 2.5%;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
line-height: 1.05em;
}
.preview-user {
font-size: 3vw;
position: absolute;
color: #8220B0;
left: 1.5vw;
bottom: 1.25vw;
padding: 0.8vw 2vw;
padding-left: 0.8vw;
font-weight: 500;
}
.preview-user img {
border-radius: 100vw;
height: 4.5vw;
width: 4.5vw;
vertical-align: -1.3vw;
border: 0.25vw solid #8220B0;
}
.badge-images {
position: absolute;
bottom: 1.4vw;
right: 1.5vw;
text-align: right;
}
.badge-images img {
height: 6vw;
right: 6vw;
fill: #8220B0;
margin-left: 0.5vw;
transform: rotate(5deg);
}
</style>
<div class="preview-div-wrapper">
<div class="preview-div">
<% if @article.title.size < 15 %>
<% font_size = 12 %>
<% elsif @article.title.size < 30 %>
<% font_size = 9.2 %>
<% elsif @article.title.size < 50 %>
<% font_size = 8.3 %>
<% else %>
<% font_size = 15 - (((@article.title.size**0.92) + 85) / 16) %>
<% end %>
<style>
.title-area {
top: 4.5vw;
}
</style>
<% font_size *= 0.9 %>
<div class="preview-info-header">
<%= (@article.tag_list & Campaign.current.featured_tags).map { |tag| "##{tag}" }.join(" ") %>
</div>
<div class="title-area">
<h1 style="font-size:<%= font_size %>vw;"><%= @article.title %></h1>
</div>
<div class="preview-user">
<img src="<%= Images::Profile.call(@article.user.profile_image_url, length: 90) %>" />
<%= truncate @article.user.name, length: 28 %>・<%= @article.readable_publish_date %>
</div>
<div class="badge-images">
<% @tag_badges.each do |badge| %>
<%# Use a seed in Random so we don't break cache on every render %>
<% not_so_rand = Random.new(badge.id + @article.id) %>
<img src="<%= badge.badge_image_url %>" style="transform: rotate(<%= not_so_rand.rand(-6..6) %>deg);" />
<% end %>
<img src="https://thepracticaldev.s3.amazonaws.com/i/bh2wmpcltaybu1xsnico.png" />
</div>
</div>
</div>

View file

@ -1,7 +1,9 @@
module DataUpdateScripts
class UpdateTagsSocialPreviewTemplates
def run
Tag.where(name: %w[shecoded theycoded shecodedally]).update_all(social_preview_template: "shecoded")
# This script references the shecoded campaign, which has been removed from the app code entirely.
# Tag.where(name: %w[shecoded theycoded shecodedally]).update_all(social_preview_template: "shecoded")
end
end
end

View file

@ -274,7 +274,7 @@ RSpec.describe "Articles", type: :request do
context "with authorized user with tag param" do
it "returns a new article" do
get "/new", params: { slug: "shecoded" }
get "/new", params: { slug: "mytag" }
expect(response).to have_http_status(:ok)
end
end

View file

@ -32,27 +32,6 @@ RSpec.describe "SocialPreviews", type: :request do
expect(first_request_body).to eq second_request_body
end
it "renders custom template when tagged with shecoded" do
create(:tag, social_preview_template: "shecoded")
she_coded_article = create(:article, tags: "shecoded")
get "/social_previews/article/#{she_coded_article.id}"
expect(response.body).to include CGI.escapeHTML(she_coded_article.title)
end
it "includes campaign tags when tagged with 2 campaign tags" do
create(:tag, name: "shecoded", social_preview_template: "shecoded")
create(:tag, name: "theycoded", social_preview_template: "shecoded")
she_coded_article = create(:article, tags: "shecoded, theycoded")
SiteConfig.campaign_featured_tags = "shecoded,theycoded"
get "/social_previews/article/#{she_coded_article.id}"
expect(response.body).to include("#shecoded #theycoded")
end
it "renders an image when requested and redirects to image url" do
get "/social_previews/article/#{article.id}.png"

View file

@ -198,12 +198,12 @@ RSpec.describe "StoriesIndex", type: :request do
context "with campaign_sidebar" do
before do
allow(SiteConfig).to receive(:campaign_featured_tags).and_return("shecoded,theycoded")
allow(SiteConfig).to receive(:campaign_featured_tags).and_return("mytag,yourtag")
allow(SiteConfig).to receive(:home_feed_minimum_score).and_return(7)
a_body = "---\ntitle: Super-sheep#{rand(1000)}\npublished: true\ntags: heyheyhey,shecoded\n---\n\nHello"
a_body = "---\ntitle: Super-sheep#{rand(1000)}\npublished: true\ntags: heyheyhey,mytag\n---\n\nHello"
create(:article, approved: true, body_markdown: a_body, score: 1)
u_body = "---\ntitle: Unapproved-post#{rand(1000)}\npublished: true\ntags: heyheyhey,shecoded\n---\n\nHello"
u_body = "---\ntitle: Unapproved-post#{rand(1000)}\npublished: true\ntags: heyheyhey,mytag\n---\n\nHello"
create(:article, approved: false, body_markdown: u_body, score: 1)
end