pinkify DEV (#2425)

This commit is contained in:
Ali Spittel 2019-04-13 11:25:02 -04:00 committed by Ben Halpern
parent 92eab3aa49
commit 409c280c10
4 changed files with 152 additions and 130 deletions

View file

@ -108,8 +108,8 @@ class User < ApplicationRecord
message: "%{value} must be either v1 or v2" }
validates :config_theme,
inclusion: { in: %w[default night_theme],
message: "%{value} must be either default or night theme" }
inclusion: { in: %w[default night_theme pink_theme],
message: "%{value} must be either default, pink theme, or night theme" }
validates :config_font,
inclusion: { in: %w[default sans_serif comic_sans],
message: "%{value} must be either default or sans serif" }

View file

@ -1,137 +1,154 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<% title = yield(:title) %>
<title><%= title || "#{ApplicationConfig['COMMUNITY_NAME']} Community" %></title>
<% if internal_navigation? %>
<style>
.universal-page-content-wrapper {
visibility: hidden;
}
</style>
<% else %>
<meta name="last-updated" content="<%= Time.current %>">
<meta name="user-signed-in" content="<%= user_signed_in? %>">
<meta name="algolia-public-id" content="<%= ApplicationConfig["ALGOLIASEARCH_APPLICATION_ID"] %>">
<meta name="algolia-public-key" content="<%= ALGOLIASEARCH_PUBLIC_SEARCH_ONLY_KEY %>">
<meta name="environment" content="<%= Rails.env %>">
<%= render "layouts/styles" %>
<style>
.home {
overflow: hidden;
position: relative;
text-align: center;
min-height: 440px;
margin: auto;
max-width: 1250px;
}
@media screen and (min-width: 950px) {
.home {
margin-top: 26px;
<head>
<meta charset="utf-8">
<% title = yield(:title) %>
<title><%= title || "#{ApplicationConfig['COMMUNITY_NAME']} Community" %></title>
<% if internal_navigation? %>
<style>
.universal-page-content-wrapper {
visibility: hidden;
}
}
</style>
<%= javascript_pack_tag "manifest", defer: true %>
<%= javascript_pack_tag "vendor", defer: true %>
<%= javascript_pack_tag "Search", defer: true %>
<% if core_pages? %>
<%= javascript_include_tag "base", defer: true %>
<% if user_signed_in? %>
<%= javascript_pack_tag "Onboarding", defer: true %>
</style>
<% else %>
<meta name="last-updated" content="<%= Time.current %>">
<meta name="user-signed-in" content="<%= user_signed_in? %>">
<meta name="algolia-public-id" content="<%= ApplicationConfig["ALGOLIASEARCH_APPLICATION_ID"] %>">
<meta name="algolia-public-key" content="<%= ALGOLIASEARCH_PUBLIC_SEARCH_ONLY_KEY %>">
<meta name="environment" content="<%= Rails.env %>">
<%= render "layouts/styles" %>
<style>
.home {
overflow: hidden;
position: relative;
text-align: center;
min-height: 440px;
margin: auto;
max-width: 1250px;
}
@media screen and (min-width: 950px) {
.home {
margin-top: 26px;
}
}
</style>
<%= javascript_pack_tag "manifest", defer: true %>
<%= javascript_pack_tag "vendor", defer: true %>
<%= javascript_pack_tag "Search", defer: true %>
<% if core_pages? %>
<%= javascript_include_tag "base", defer: true %>
<% if user_signed_in? %>
<%= javascript_pack_tag "Onboarding", defer: true %>
<% end %>
<% end %>
<% end %>
<% if !core_pages? %>
<%= stylesheet_link_tag "application", media: "all" %>
<% if render_js? %>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<% if !core_pages? %>
<%= stylesheet_link_tag "application", media: "all" %>
<% if render_js? %>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<%= javascript_include_tag "application" %>
<% end %>
<% end %>
<% if view_class == "users users-signout_confirm" %>
<%= javascript_include_tag "application" %>
<% end %>
<%= yield(:page_meta) %>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<%= favicon_link_tag %>
<link rel="apple-touch-icon" href="<%= asset_path "apple-icon.png" %>">
<link rel="apple-touch-icon" sizes="152x152" href="<%= asset_path "apple-icon-152x152.png" %>">
<link rel="apple-touch-icon" sizes="180x180" href="<%= asset_path "apple-icon-180x180.png" %>">
<link rel="apple-touch-icon" sizes="167x167" href="<%= asset_path "apple-icon-167x167.png" %>">
<link href="<%= asset_path "android-icon-192x192.png" %>" rel="icon" sizes="192x192" />
<link href="<%= asset_path "android-icon-128x128.png" %>" rel="icon" sizes="128x128" />
<meta name="apple-mobile-web-app-title" content="dev.to">
<meta name="application-name" content="dev.to">
<meta property="fb:pages" content="568966383279687" />
<meta name="theme-color" content="#000000" />
<% if view_class.include? "users-signout_confirm" %>
<%= csrf_meta_tags %>
<% end %>
<link rel="manifest" href="/manifest.json" />
<link rel="search" href="https://dev.to/search.xml" type="application/opensearchdescription+xml" title="The <%= ApplicationConfig["COMMUNITY_NAME"] %> Community" />
<% end %>
<% if view_class == "users users-signout_confirm" %>
<%= javascript_include_tag "application" %>
</head>
<body data-user-status="<%= user_logged_in_status %>" data-pusher-key="<%= ApplicationConfig["PUSHER_KEY"] %>">
<div id="body-styles"></div>
<% if user_signed_in? && !internal_navigation? %>
<script>
try {
var bodyClass = localStorage.getItem('config_body_class');
document.body.className = bodyClass;
if (bodyClass.includes('night-theme')) {
document.getElementById('body-styles').innerHTML = '<style>\
:root {\
--theme-background: #0d1219;\
--theme-color: #fff;\
--theme-anchor-color: #17a1f6;\
--theme-secondary-color: #cedae2;\
--theme-top-bar-background: #1c2938;\
--theme-top-bar-color: #fff;\
--theme-top-bar-search-background: #424a54;\
--theme-top-bar-search-color: #fff;\
--theme-top-bar-write-background: #00af81;\
--theme-top-bar-write-color: #fff;\
--theme-container-background: #141f2d;\
--theme-container-accent-background: #202c3d;\
--theme-container-background-hover: #37475c;\
--theme-gradient-background: linear-gradient(to right, #293d56 8%, #282833 18%, #293d56 33%);\
--theme-container-color: #fff;\
--theme-container-box-shadow: none;\
--theme-container-border: 1px solid #141d26;\
--theme-social-icon-invert: invert(100)</style>'
} else if (bodyClass.includes('pink-theme')) {
document.getElementById('body-styles').innerHTML = '<style>\
:root {\
--theme-background: #FFF7F9;\
--theme-color: #333;\
--theme-anchor-color: #6116f6;\
--theme-secondary-color: #6116f6;\
--theme-top-bar-background: #ff4983;\
--theme-top-bar-color: #fff;\
--theme-top-bar-search-background: #FFF7F9;\
--theme-top-bar-search-color: #000;\
--theme-top-bar-write-background: #ff4983;\
--theme-top-bar-write-color: #fff;\
--theme-container-background: #fff;\
--theme-container-accent-background: #ff4983;\
--theme-container-background-hover: #FFF7F9;\
--theme-gradient-background: linear-gradient(to right, #293d56 8%, #282833 18%, #293d56 33%);\
--theme-container-color: #ff4983;\
--theme-container-box-shadow: none;\
--theme-container-border: 1px solid #ff4983;\
--theme-social-icon-invert: invert(100)</style>'
}
} catch(e) {
console.log(e)
}
</script>
<% end %>
<%= yield(:page_meta) %>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<%= favicon_link_tag %>
<link rel="apple-touch-icon" href="<%= asset_path "apple-icon.png" %>">
<link rel="apple-touch-icon" sizes="152x152" href="<%= asset_path "apple-icon-152x152.png" %>">
<link rel="apple-touch-icon" sizes="180x180" href="<%= asset_path "apple-icon-180x180.png" %>">
<link rel="apple-touch-icon" sizes="167x167" href="<%= asset_path "apple-icon-167x167.png" %>">
<link href="<%= asset_path "android-icon-192x192.png" %>" rel="icon" sizes="192x192" />
<link href="<%= asset_path "android-icon-128x128.png" %>" rel="icon" sizes="128x128" />
<meta name="apple-mobile-web-app-title" content="dev.to">
<meta name="application-name" content="dev.to">
<meta property="fb:pages" content="568966383279687" />
<meta name="theme-color" content="#000000" />
<% if view_class.include? "users-signout_confirm" %>
<%= csrf_meta_tags %>
<% unless internal_navigation? %>
<div id="audiocontent">
<%= yield(:audio) %>
</div>
<% end %>
<link rel="manifest" href="/manifest.json" />
<link rel="search" href="https://dev.to/search.xml" type="application/opensearchdescription+xml" title="The <%= ApplicationConfig["COMMUNITY_NAME"] %> Community" />
<% end %>
</head>
<body data-user-status="<%= user_logged_in_status %>" data-pusher-key="<%= ApplicationConfig["PUSHER_KEY"] %>">
<div id="body-styles"></div>
<% if user_signed_in? && !internal_navigation? %>
<script>
try {
var bodyClass = localStorage.getItem('config_body_class');
document.body.className = bodyClass;
if (bodyClass.includes('night-theme')) {
document.getElementById('body-styles').innerHTML = '<style>\
:root {\
--theme-background: #0d1219;\
--theme-color: #fff;\
--theme-anchor-color: #17a1f6;\
--theme-secondary-color: #cedae2;\
--theme-top-bar-background: #1c2938;\
--theme-top-bar-color: #fff;\
--theme-top-bar-search-background: #424a54;\
--theme-top-bar-search-color: #fff;\
--theme-top-bar-write-background: #00af81;\
--theme-top-bar-write-color: #fff;\
--theme-container-background: #141f2d;\
--theme-container-accent-background: #202c3d;\
--theme-container-background-hover: #37475c;\
--theme-gradient-background: linear-gradient(to right, #293d56 8%, #282833 18%, #293d56 33%);\
--theme-container-color: #fff;\
--theme-container-box-shadow: none;\
--theme-container-border: 1px solid #141d26;\
--theme-social-icon-invert: invert(100)</style>'
}
} catch(e) {
console.log(e)
}
</script>
<% end %>
<% unless internal_navigation? %>
<div id="audiocontent">
<%= yield(:audio) %>
</div>
<% end %>
<% cache("application-top-bar--#{user_signed_in?}--#{internal_navigation?}", expires_in: 100.hours) do %>
<%= render "layouts/top_bar" unless internal_navigation? %>
<% end %>
<div id="message-notice"></div>
<div id="page-content" class="universal-page-content-wrapper <%= view_class %>" data-current-page="<%= current_page %>">
<div id="page-content-inner">
<%= yield %>
</div>
</div>
<% unless internal_navigation? %>
<% cache("footer-and-signup-modal--#{user_signed_in?}--#{ApplicationConfig['DEPLOYMENT_SIGNATURE']}", expires_in: 200.hours) do %>
<%= render "layouts/footer" %>
<%= render "layouts/signup_modal" unless user_signed_in? %>
<% end %>
<div id="live-article-indicator" class="live-article-indicator"></div>
<%= image_tag("twitter-logo.svg", class: "icon-img", style: "display:none") %>
<%= image_tag("github-logo.svg", class: "icon-img", style: "display:none") %>
<% end %>
</body>
<% cache("application-top-bar--#{user_signed_in?}--#{internal_navigation?}", expires_in: 100.hours) do %>
<%= render "layouts/top_bar" unless internal_navigation? %>
<% end %>
<div id="message-notice"></div>
<div id="page-content" class="universal-page-content-wrapper <%= view_class %>" data-current-page="<%= current_page %>">
<div id="page-content-inner">
<%= yield %>
</div>
</div>
<% unless internal_navigation? %>
<% cache("footer-and-signup-modal--#{user_signed_in?}--#{ApplicationConfig['DEPLOYMENT_SIGNATURE']}", expires_in: 200.hours) do %>
<%= render "layouts/footer" %>
<%= render "layouts/signup_modal" unless user_signed_in? %>
<% end %>
<div id="live-article-indicator" class="live-article-indicator"></div>
<%= image_tag("twitter-logo.svg", class: "icon-img", style: "display:none") %>
<%= image_tag("github-logo.svg", class: "icon-img", style: "display:none") %>
<% end %>
</body>
</html>

View file

@ -39,7 +39,7 @@
<%= form_for(@user) do |f| %>
<div class="sub-field">
<%= f.label :config_theme, "Site Theme" %>
<%= f.select(:config_theme, options_for_select(["default", "night theme"], @user.config_theme.tr("_", " "))) %>
<%= f.select(:config_theme, options_for_select(["default", "night theme", "pink theme"], @user.config_theme.tr("_", " "))) %>
<sub><em>Default is light style. Night theme is in public alpha.</em></sub>
</div>
<div class="sub-field">

View file

@ -474,6 +474,11 @@ RSpec.describe User, type: :model do
expect(user.decorate.config_body_class).to eq("night-theme default-article-body")
end
it "creates proper body class with pink theme" do
user.config_theme = "pink_theme"
expect(user.decorate.config_body_class).to eq("pink-theme default-article-body")
end
it "inserts into mailchimp" do
expect(user.subscribe_to_mailchimp_newsletter_without_delay).to eq true
end