Skip to content

Conversation

kumar303
Copy link
Contributor

@kumar303
Copy link
Contributor Author

@muffinresearch I bumbled through this one, let me know how it looks. I have not manually tested the install button since I'm not sure what about:config settings need tweaking.

const { i18n, addon } = this.props;
const authorList = [];
for (const author of addon.authors) {
authorList.push(<a key={author.url} href={author.url}>{author.name}</a>);
Copy link
Contributor

@muffinresearch muffinresearch Aug 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should be a ul since its a list of something. You could then add the comma with generated content.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah now I see it's in an h1, in which case it can't be a ul. Ignore the previous comment.

<span className="author">by <a href="#">AwesomeAddons</a></span></h1>
<InstallButton slug="placeholder" />
<h1>
{addon.name} <span className="author">{i18n.gettext('by')} {authorList}</span>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muffinresearch I almost forgot to localize this. Is it ok to isolate the by like this? It seems like creating a longer format string would be complicated because of the span tag.

Copy link
Contributor

@muffinresearch muffinresearch Aug 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

If we only translate by the downside would be if a locale needed to change the word order for some reason it couldn't.

In the past we've done things like this to be able to expose the full context for translation allthought for disco pane the string was built on the server.

{i18n.sprintf(i18n.gettext('%(addonName)s %(startSpan)sby %(authorList)s%(endSpan)s'), { addonName, authorList, startSpan, endSpan })}

If passed through dompurify if the tags are reversed via the translation you will still get a sane output albeit the markup won't be wrapping the things it should, but you will at least get valid HTML.

e.g:

</span>foo<span>

becomes:

foo<span></span>

@kumar303
Copy link
Contributor Author

@muffinresearch this is ready for another look

@muffinresearch
Copy link
Contributor

I have not manually tested the install button since I'm not sure what about:config settings need tweaking.

Yeah it won't magically work since the APIs aren't going to be exposed to non-disco pane hosts.
We'll need to start a conversation about opening this up to amo and the implications around it.

});

it('converts \r\n\r\n to <br/>', () => {
assert.equal(nl2br('\r\n\r\n'), '<br /><br />');
Copy link
Contributor

@muffinresearch muffinresearch Aug 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this normalize multiple sets of line breaks to a single <br /> like the description string suggests?

@muffinresearch
Copy link
Contributor

Gave this a spin and it looks good.

r+wc

@kumar303
Copy link
Contributor Author

@muffinresearch if you have a mo' could you check that the new title localization is sane?

}

const authorList = addon.authors.map(
(author) => `<a href=${author.url}>${author.name}</a>`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing quotes on the attr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh. Refactoring casualty. Thanks.

@kumar303 kumar303 merged commit b6381f7 into mozilla:master Aug 16, 2016
@kumar303 kumar303 deleted the detail-data branch August 16, 2016 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hook up details page to real data.

2 participants