[deploy] Make adjustments in ld+json logic (#7307)
* Make adjustments in ld+json logic * Add github url
This commit is contained in:
parent
817f12c788
commit
2c6a4b4ecf
7 changed files with 146 additions and 68 deletions
|
|
@ -368,8 +368,8 @@ class StoriesController < ApplicationController
|
|||
@user_json_ld[:alumniOf] = @user.education if @user.education.present?
|
||||
@user_json_ld[:email] = @user.email if @user.email_public
|
||||
@user_json_ld[:jobTitle] = @user.employment_title if @user.employment_title.present?
|
||||
@user_json_ld[:sameAs].append(@user.twitter_username) if @user.twitter_username.present?
|
||||
@user_json_ld[:sameAs].append(@user.github_username) if @user.github_username.present?
|
||||
@user_json_ld[:sameAs].append("https://twitter.com/#{@user.twitter_username}") if @user.twitter_username.present?
|
||||
@user_json_ld[:sameAs].append("https://github.com/#{@user.github_username}") if @user.github_username.present?
|
||||
end
|
||||
|
||||
def set_user_same_as_json_ld
|
||||
|
|
|
|||
|
|
@ -3,20 +3,21 @@
|
|||
<div id="video-player-source" data-source="<%= article.video_source_url %>"></div>
|
||||
<script src="//content.jwplatform.com/libraries/b1zWy2iv.js" async></script>
|
||||
<div id="video-player-<%= article.id %>" class="video-player"></div>
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "VideoObject",
|
||||
"url": "<%= article.video_source_url %>",
|
||||
"uploadDate": "<%= article.published_at&.rfc3339 %>",
|
||||
"name": "<%= article.title %>",
|
||||
"description": "<%= article.description %>",
|
||||
"thumbnailUrl": "<%= cloudinary(article.video_thumbnail_url, 880) %>",
|
||||
"contentUrl": "<%= article.video_source_url %>",
|
||||
"duration": "<%= format("PT%<minutes>sM%<seconds>sS", minutes: minutes, seconds: seconds) %>"
|
||||
}
|
||||
</script>
|
||||
<% unless internal_navigation? || user_signed_in? %>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "VideoObject",
|
||||
"url": "<%= article.video_source_url %>",
|
||||
"uploadDate": "<%= article.published_at&.rfc3339 %>",
|
||||
"name": "<%= article.title %>",
|
||||
"description": "<%= article.description %>",
|
||||
"thumbnailUrl": "<%= cloudinary(article.video_thumbnail_url, 880) %>",
|
||||
"contentUrl": "<%= article.video_source_url %>",
|
||||
"duration": "<%= format("PT%<minutes>sM%<seconds>sS", minutes: minutes, seconds: seconds) %>"
|
||||
}
|
||||
</script>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" async>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<%= render "shared/webcomponents_loader_script" %>
|
||||
<%= javascript_packs_with_chunks_tag "clipboardCopy", "webShare", defer: true %>
|
||||
|
||||
<% cache("content-related-optional-scripts-#{@article.id}-#{@article.updated_at}", expires_in: 30.hours) do %>
|
||||
<% cache("content-related-optional-scripts-#{@article.id}-#{@article.updated_at}-#{internal_navigation?}-#{user_signed_in?}", expires_in: 30.hours) do %>
|
||||
<% if @article.processed_html.include? "ltag_gist-liquid-tag" %>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/postscribe/2.0.8/postscribe.min.js"
|
||||
integrity="sha256-xOIPU/XvDtRLeDQ3qj9GOKmlbMSqKa6D7ZIS6ygHBSo="
|
||||
|
|
@ -30,40 +30,41 @@
|
|||
}, 500)
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Article",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "<%= article_url(@article) %>"
|
||||
},
|
||||
"url": "<%= article_url(@article) %>",
|
||||
"image": "<%= article_social_image_url(@article) %>",
|
||||
"publisher": {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Organization",
|
||||
"name": "<%= community_qualified_name %>",
|
||||
"logo": {
|
||||
<% unless internal_navigation? || user_signed_in? %>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "ImageObject",
|
||||
"url": "<%= cloudinary(SiteConfig.logo_png, 192, "png") %>",
|
||||
"width": "192",
|
||||
"height": "192"
|
||||
"@type": "Article",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "<%= article_url(@article) %>"
|
||||
},
|
||||
"url": "<%= article_url(@article) %>",
|
||||
"image": "<%= article_social_image_url(@article) %>",
|
||||
"publisher": {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Organization",
|
||||
"name": "<%= community_qualified_name %>",
|
||||
"logo": {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "ImageObject",
|
||||
"url": "<%= cloudinary(SiteConfig.logo_png, 192, "png") %>",
|
||||
"width": "192",
|
||||
"height": "192"
|
||||
}
|
||||
},
|
||||
"headline": "<%= @article.title %>",
|
||||
"author": {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Person",
|
||||
"url": "<%= user_url(@user) %>",
|
||||
"name": "<%= @user.name %>"
|
||||
},
|
||||
"datePublished": "<%= @article.published_timestamp %>",
|
||||
"dateModified": "<%= @article.edited_at&.iso8601 || @article.published_timestamp %>"
|
||||
}
|
||||
},
|
||||
"headline": "<%= @article.title %>",
|
||||
"author": {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Person",
|
||||
"url": "<%= user_url(@user) %>",
|
||||
"name": "<%= @user.name %>"
|
||||
},
|
||||
"datePublished": "<%= @article.published_timestamp %>",
|
||||
"dateModified": "<%= @article.edited_at&.iso8601 || @article.published_timestamp %>"
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<% if @article.processed_html.include? "runkit-element" %>
|
||||
<%= javascript_include_tag "https://embed.runkit.com" %>
|
||||
|
|
|
|||
|
|
@ -10,20 +10,22 @@
|
|||
<% end %>
|
||||
</style>
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Organization",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "<%= user_url(@user) %>"
|
||||
},
|
||||
"url": "<%= user_url(@user) %>",
|
||||
"image": "<%= ProfileImage.new(@user).get(width: 320) %>",
|
||||
"name": "<%= sanitize @user.name %>",
|
||||
"description": "<%= sanitize(@user.summary.presence || "404 bio not found") %>"
|
||||
}
|
||||
</script>
|
||||
<% unless internal_navigation? || user_signed_in? %>
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Organization",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "<%= user_url(@user) %>"
|
||||
},
|
||||
"url": "<%= user_url(@user) %>",
|
||||
"image": "<%= ProfileImage.new(@user).get(width: 320) %>",
|
||||
"name": "<%= sanitize @user.name %>",
|
||||
"description": "<%= sanitize(@user.summary.presence || "404 bio not found") %>"
|
||||
}
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<div class="user-profile-header" style="<%= user_colors_style(@user) %>">
|
||||
<a href="<%= user_url(@user) %>"></a>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
<%= render "users/meta" %>
|
||||
<% end %>
|
||||
|
||||
<% unless internal_navigation? || user_signed_in? %>
|
||||
<script type="application/ld+json">
|
||||
<%= @user_json_ld.to_json.html_safe %>
|
||||
</script>
|
||||
<% end %>
|
||||
<% cache "main-user-profile-header-area-#{@user.id}-#{@user.profile_updated_at}", expires_in: 10.days do %>
|
||||
<style>
|
||||
.widget header {
|
||||
|
|
@ -24,11 +29,6 @@
|
|||
}
|
||||
<% end %>
|
||||
</style>
|
||||
|
||||
<script type="application/ld+json">
|
||||
<%= @user_json_ld.to_json.html_safe %>
|
||||
</script>
|
||||
|
||||
<div class="user-profile-header" style="<%= user_colors_style(@user) %>">
|
||||
<a href="https://dev.to/<%= user_url(@user) %>"></a>
|
||||
<div class="user-profile-header-container">
|
||||
|
|
|
|||
|
|
@ -37,4 +37,41 @@ RSpec.describe "ArticlesShow", type: :request do
|
|||
expect(response.body).to include CGI.escapeHTML(organization_article.title)
|
||||
end
|
||||
end
|
||||
|
||||
context "when user signed in" do
|
||||
before do
|
||||
sign_in user
|
||||
get article.path
|
||||
end
|
||||
|
||||
describe "GET /:slug (user)" do
|
||||
it "does not render json ld" do
|
||||
expect(response.body).not_to include "application/ld+json"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when user not signed in" do
|
||||
before do
|
||||
get article.path
|
||||
end
|
||||
|
||||
describe "GET /:slug (user)" do
|
||||
it "does not render json ld" do
|
||||
expect(response.body).to include "application/ld+json"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when user not signed in but internal nav triggered" do
|
||||
before do
|
||||
get article.path + "?i=i"
|
||||
end
|
||||
|
||||
describe "GET /:slug (user)" do
|
||||
it "does not render json ld" do
|
||||
expect(response.body).not_to include "application/ld+json"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,4 +49,41 @@ RSpec.describe "UserShow", type: :request do
|
|||
expect(response.body).to include CGI.escapeHTML(user.email)
|
||||
end
|
||||
end
|
||||
|
||||
context "when user signed in" do
|
||||
before do
|
||||
sign_in user
|
||||
get user.path
|
||||
end
|
||||
|
||||
describe "GET /:slug (user)" do
|
||||
it "does not render json ld" do
|
||||
expect(response.body).not_to include "application/ld+json"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when user not signed in" do
|
||||
before do
|
||||
get user.path
|
||||
end
|
||||
|
||||
describe "GET /:slug (user)" do
|
||||
it "does not render json ld" do
|
||||
expect(response.body).to include "application/ld+json"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when user not signed in but internal nav triggered" do
|
||||
before do
|
||||
get user.path + "?i=i"
|
||||
end
|
||||
|
||||
describe "GET /:slug (user)" do
|
||||
it "does not render json ld" do
|
||||
expect(response.body).not_to include "application/ld+json"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue