Add/fix org call-to-action box/copy (#1000)

This commit is contained in:
Ben Halpern 2018-10-24 13:49:57 -04:00 committed by GitHub
parent 3c61c026c5
commit ae3ec2e237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 20 deletions

View file

@ -148,28 +148,38 @@
p{
margin:12px 0px;
}
code {
background: $light-gray;
border-radius: 3px;
padding: 3px 4px;
color:#333842;
font-family: $monospace;
}
a.primary-sticky-nav-org-cta-link{
width:100%;
display: block;
font-size:1.25em;
border:0px;
border-radius:3px;
padding: 8px 0px 3px;
padding: 11px 0px 5px;
margin-top: 20px;
background: white;
color: $black;
font-family: $helvetica-condensed;
border: 1px solid darken($light-medium-gray, 7%);
font-weight: bold;
border: 1px solid darken($light-medium-gray, 10%);
text-align: center;
font-stretch: condensed;
.primary-sticky-nav-org-cta-link-domain-small{
display: block;
font-weight: 400;
padding-top: 2px;
font-size:0.75em;
color: darken($light-medium-gray, 7%);
color: darken($light-medium-gray, 9%);
font-family: $monospace;
}
&:hover {
border: 1px solid darken($light-medium-gray, 12%);
border: 1px solid darken($light-medium-gray, 14%);
box-shadow: $shadow;
transition: all 0.1s;
}

View file

@ -26,7 +26,7 @@ class MarkdownParser
return if @content.blank?
renderer = Redcarpet::Render::HTMLRouge.new(hard_wrap: true, filter_html: false)
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
tag_whitelist = %w(strong i u b em p br)
tag_whitelist = %w(strong i u b em p br code)
attribute_whitelist = %w(href strong em ref rel src title alt class)
ActionController::Base.helpers.sanitize markdown.render(@content).html_safe,
tags: tag_whitelist,

View file

@ -34,14 +34,14 @@ class Organization < ApplicationRecord
allow_blank: true }
validates :tech_stack, :story, length: { maximum: 640 }
validates :cta_button_url,
url: { allow_blank: true, no_local: true, schemes: ["https", "http"] }, if: :approved
validates :cta_button_text, length: { maximum: 12 }
url: { allow_blank: true, no_local: true, schemes: ["https", "http"] }
validates :cta_button_text, length: { maximum: 20 }
validates :cta_body_markdown, length: { maximum: 256 }
before_save :remove_at_from_usernames
after_save :bust_cache
before_save :generate_secret
before_validation :downcase_slug
before_validation :evaluate_markdown, if: :approved
before_validation :evaluate_markdown
validate :unique_slug_including_users
@ -80,7 +80,7 @@ class Organization < ApplicationRecord
end
def approved_and_filled_out_cta?
approved && cta_body_markdown? && cta_button_text? && cta_button_url?
cta_processed_html?
end
def profile_image_90

View file

@ -50,10 +50,14 @@
<% elsif @actor.class.name == "Organization" && @actor.approved_and_filled_out_cta? %>
<div class="primary-sticky-nav-org-summary">
<%= @actor.cta_processed_html.html_safe %>
<a href="<%= @actor.cta_button_url || "LEARN MORE" %>" class="primary-sticky-nav-org-cta-link">
<%= @actor.cta_button_text.upcase %>
<span class="primary-sticky-nav-org-cta-link-domain-small"><%= Addressable::URI.parse(@actor.cta_button_url).domain %></span>
</a>
<% if @actor.cta_button_text.present? && @actor.cta_button_url.present? %>
<a href="<%= @actor.cta_button_url || "LEARN MORE" %>" class="primary-sticky-nav-org-cta-link">
<%= @actor.cta_button_text %>
<span class="primary-sticky-nav-org-cta-link-domain-small">
<%= Addressable::URI.parse(@actor.cta_button_url).domain %>
</span>
</a>
<% end %>
</div>
<% end %>
</div>

View file

@ -119,18 +119,23 @@
<%= f.text_area :tech_stack, maxlength: 640, placeholder: "Limit of 640 characters" %>
</div>
<h2>Call-to-action box</h2>
<h4 style="margin-top:-25px">Customizable text that appears next to every post for your organization</h4>
<h4 style="margin-top:-25px">Customizable text that appears to the right of every post for your organization</h4>
<h4 style="margin-top:-15px">See an example from the <a href="https://dev.to/devteam/the-dev-badge-is-available-on-font-awesome-2ihe" target="_blank">DEV Team</a>.</h4>
<div class="field">
<%= f.label "Body text (markdown inline only)" %>
<%= f.text_area :cta_body_markdown, maxlength: 256, placeholder: "Limit of 256 characters" %>
<%= f.label "Body text (Limited markdown — bold/italic/etc)" %>
<%= f.text_area :cta_body_markdown, maxlength: 256, placeholder: "**This is an example**
_italic_ and **bold** is okay. Links, and headers etc. will not show up.
256 character limit." %>
</div>
<div class="field">
<%= f.label "CTA Link Text" %>
<%= f.text_field :cta_button_text, maxlength: 12, placeholder: "Limit of 12 characters" %>
<%= f.label "Link Text" %>
<%= f.text_field :cta_button_text, maxlength: 20, placeholder: "Limit of 20 characters" %>
</div>
<div class="field">
<%= f.label "CTA Link URL" %>
<%= f.text_field :cta_button_url %>
<%= f.label "Link Text" %>
<%= f.text_field :cta_button_url, placeholder: "https://example.com" %>
</div>
<div class="field">
<label></label>