Misc/minor article fixes (#18846)
* Don't assume all requests are JSON * Prevent nil error from optimized_image_tag (possible local data issue) * Slug miss should 404, instead of Podcast not found * Plain html rescue satisfies spec(s)
This commit is contained in:
parent
a914a79399
commit
e63423573c
3 changed files with 18 additions and 6 deletions
|
|
@ -111,7 +111,16 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def bad_request
|
||||
render json: { error: I18n.t("application_controller.bad_request") }, status: :bad_request
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
raise if Rails.env.development?
|
||||
|
||||
render plain: "The request could not be understood (400).", status: :bad_request
|
||||
end
|
||||
format.json do
|
||||
render json: { error: I18n.t("application_controller.bad_request") }, status: :bad_request
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def error_too_many_requests(exc)
|
||||
|
|
|
|||
|
|
@ -38,10 +38,11 @@ class StoriesController < ApplicationController
|
|||
handle_article_show
|
||||
elsif (@article = Article.find_by(slug: params[:slug])&.decorate)
|
||||
handle_possible_redirect
|
||||
else
|
||||
@podcast = Podcast.available.find_by!(slug: params[:username])
|
||||
elsif (@podcast = Podcast.available.find_by(slug: params[:username]))
|
||||
@episode = @podcast.podcast_episodes.available.find_by!(slug: params[:slug])
|
||||
handle_podcast_show
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
<a href="<%= article.path %>" data-preload-image="<%= cloud_cover_url(article.main_image) %>" class="crayons-link mt-6 block">
|
||||
<div class="flex items-center">
|
||||
<span class="crayons-avatar crayons-avatar--xl m:crayons-avatar--2xl mr-4 shrink-0">
|
||||
<%= optimized_image_tag(article.cached_user.profile_image_url,
|
||||
optimizer_options: { crop: "imagga_scale", width: 100, height: 100 },
|
||||
image_options: { loading: "lazy", alt: "#{article.cached_user.username} profile image", class: "crayons-avatar__image" }) %>
|
||||
<% if article.cached_user.profile_image_url %>
|
||||
<%= optimized_image_tag(article.cached_user.profile_image_url,
|
||||
optimizer_options: { crop: "imagga_scale", width: 100, height: 100 },
|
||||
image_options: { loading: "lazy", alt: "#{article.cached_user.username} profile image", class: "crayons-avatar__image" }) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div>
|
||||
<h3 class="fs-xl mb-0 lh-tight"><%= article.title %></h3>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue