-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use tidy-html5 to validate the term-table page #15577
Conversation
91c5e90
to
119ada7
Compare
119ada7
to
5662448
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still also quite hesitant of adding such a large fixture for this change. If you only need somewhere that has both a name with double quotes, and also both normal images and placeholders, the popolo for The Bahamas is one sixth of the size.
require 'test_helper' | ||
require_relative '../../../app' | ||
|
||
describe 'Phillipines' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "Philippines"
@@ -12,6 +12,7 @@ | |||
require 'everypolitician/popolo' | |||
|
|||
require_relative './lib/popolo_helper' | |||
require_relative './helpers/html' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be consistent where the helpers live? If we're making a new 'helpers' directory for them, then we should probably move the popolo_helper
there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that and I think it may be a good idea. I've seen that in other frameworks as Rails or Middleman and I think it helps to keep concerns separated. But I am happy to put this file under lib if we prefer it so.
end | ||
end | ||
|
||
helpers HTMLEscapeHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the PopoloHelper
we set it up in app.rb
itself. I'm not sure whether it's generally preferred to do it that way or this, but again I think we should be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment. I am happy to move it to app.rb though.
|
||
it 'doesnt break for names with double quotes' do | ||
img = tiangco.css('img.person-card__image') | ||
img.attr('alt').text.must_equal 'Member headshot for Tiangco, Tobias "Toby" M.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are actually two different images with this text, and only one of them is getting checked here. Both of them actually get returned from this css selector, though, so it should be quite easy to check both.
|
||
module Sinatra | ||
module HTMLEscapeHelper | ||
def h(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is h
a general standard for naming functions like this? I'm generally a fan of brevity, but I'm a little hesitant here, unless this is a universally recognised approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this was copied from the official documentation, I can certainly rename it
@tmtmtmtm Feedback addressed in fixup commits
|
@@ -198,7 +198,7 @@ | |||
<div class="page-section page-section--grey source-credits"> | |||
<div class="container"> | |||
<% if @page.data_sources %> | |||
<p>Main Source<% if @page.data_sources.size > 1 %>s<% end %>: <%= @page.data_sources.map { |url| %Q(<a href="#{url}">#{url}</a>) }.join(", ") %></p> | |||
<p>Main Source<% if @page.data_sources.size > 1 %>s<% end %>: <%= @page.data_sources.map { |url| %Q(<a href="#{escape_uri(url)}">#{url}</a>) }.join(", ") %></p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach concerns me. If the problem is that EP is giving us invalid URLs, then we should fix that upstream, so that everyone consuming the data doesn't need to do things like this.
Whichever approach we take, however, this feels like something that deserves a PR of its own, properly explaining the problem and solution etc., rather than cramming more into this PR.
@octopusinvitro when you say "it couldn't make it work", what was the problem? |
The fixture is needed to HTML-validate the term-table page, in particular, the contents of the alt attribute in images, for which a person with a normal image, a person with a placeholder image and a person with double quotes in their name are needed.
Errors corrected: - An "img" element must have an "alt" attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. (All occurrences)
3df7f00
to
fee6b58
Compare
Closed as it was moved to #15587 |
What does this do?
HTML-validates the term-table page and in doing so addresses this comments
Why was this needed?
HTML was broken
Relevant Issue(s)
everypolitician/everypolitician#505
Implementation notes
None
Screenshots
None
Notes to Reviewer
Errors corrected:
conditions. For details, consult guidance on providing text alternatives
for images. (All occurrences)
Notes to Merger
This branch has been rebased with master. An HTML helper is being introduced as part of #15584, a helper to which this PR would be adding new methods, so that PR should probably be merged first so that adding a new helper is not part of this PR, but just modifying it.