Skip to content

Commit

Permalink
chore: Use exampleMatchingUrl everywhere instead of exampleUrl or…
Browse files Browse the repository at this point in the history
… `matchingUrl`

Rely on dis-moi/backend#286
  • Loading branch information
lutangar committed Nov 10, 2020
1 parent 73aceae commit d6bac49
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/lmem/contributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ContributorId = number;

export interface PinnedNotice {
sort?: number;
matchingUrl: string;
exampleMatchingUrl: string;
noticeId: number;
noticeUrl: string;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/lmem/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface BaseNotice {
strippedMessage: string;
ratings: Ratings;
visibility: 'public' | 'private';
exampleUrl?: string;
exampleMatchingUrl?: string;
screenshot?: string;
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/profiles/App/Pages/Profiles/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export const Profile = ({
const handleSeeNoticeInContext = (notice?: NoticeWithContributor) => () => {
if (connected) {
if (contributor?.subscribed) {
if (notice && notice.exampleUrl) {
window.open(notice.exampleUrl, '_blank');
if (notice && notice.exampleMatchingUrl) {
window.open(notice.exampleMatchingUrl, '_blank');
}
} else {
setSubscribePopinOpened(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ storiesOf('Profile/ProfileNoticeListItem', module)
<ProfileNoticeListItem
loading={false}
notice={generateStatefulNotice({
exampleUrl:
exampleMatchingUrl:
'http://www.seomofo.com/experiments/title-and-h1-of-this-post-but-for-the-sake-of-keyword-prominence-stuffing-im-going-to-mention-it-again-using-various-synonyms-stemmed-variations-and-of-coursea-big-fat-prominent-font-size-heres-the-stumper-that-stumped-me-what-is-the-max-number-of-chars-in-a-url-that-google-is-willing-to-crawl-and-index-for-whatever-reason-i-thought-i-had-read-somewhere-that-googles-limit-on-urls-was-255-characters-but-that-turned-out-to-be-wrong-so-maybe-i-just-made-that-number-up-the-best-answer-i-could-find-was-this-quote-from-googles-webmaster-trends-analyst-john-mueller-we-can-certainly-crawl-and-index-urls-over-1000-characters-long-but-that-doesnt-mean-that-its-a-good-practice-the-setup-for-this-experiment-is-going-to-be-pretty-simple-im-going-to-edit-the-permalink-of-this-post-to-be-really-really-long-then-im-going-to-see-if-google-indexes-it-i-might-even-see-if-yahoo-and-bing-index-iteven-though-no-one-really-cares-what-those-assholes-are-doing-url-character-limits-unrelated-to-google-the-question-now-is-how-many-characters-should-i-make-the-url-of-this-post-there-are-a-couple-of-sources-ill-reference-to-help-me-make-this-decision-the-first-is-this-quote-from-the-microsoft-support-pages-microsoft-internet-explorer-has-a-maximum-uniform-resource-locator-url-length-of-2083-characters-internet-explorer-also-has-a-maximum-path-length-of-2048-characters-this-limit-applies-to-both-post-request-and-get-request-urls-the-second-source-ill-cite-is-the-http-11-protocol-which-says-the-http-protocol-does-not-place-any-a-priori-limit-on-the-length-of-a-uri-servers-must-be-able-to-handle-the-uri-of-any-resource-they-serve-and-should-be-able-to-handle-uris-of-unbounded-length-if-they-provide-get-based-forms-that-could-generate-such-uris-a-server-should-return-414-request-uri-too-long-status-if-a-uri-is-longer.html'
})}
seeInContext={action('seeInContext')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,26 @@ export const ProfileNoticeListItem = ({
<img
style={{ width: '100%' }}
src={notice.screenshot}
alt={`Rendu de la contribution sur ${notice.exampleUrl} une fois l'extension installée.`}
alt={`Rendu de la contribution sur ${notice.exampleMatchingUrl} une fois l'extension installée.`}
/>
)}
<Paragraph dangerouslySetInnerHTML={{ __html: notice.strippedMessage }} />
{notice.exampleUrl && (
{notice.exampleMatchingUrl && (
<NoticeTopLine>
<Pin />
<NoticeHighlight>
Message épinglé sur{' '}
<NoticeURL>{stripUrlProtocol(notice.exampleUrl)}</NoticeURL>
<NoticeURL>{stripUrlProtocol(notice.exampleMatchingUrl)}</NoticeURL>
</NoticeHighlight>{' '}
et d&apos;autres pages web
</NoticeTopLine>
)}
<NoticeBottomLine>
Visible depuis le {format(notice.created, 'DD/MM/YYYY')}
<BorderButton onClick={seeInContext} disabled={!notice.exampleUrl}>
<BorderButton
onClick={seeInContext}
disabled={!notice.exampleMatchingUrl}
>
Voir en contexte
</BorderButton>
</NoticeBottomLine>
Expand Down
17 changes: 15 additions & 2 deletions test/fakers/generateContributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,23 @@ export const generateContributor = ({
contributions: contributions || Faker.random.number(),
contribution: {
example: {
matchingUrl: 'http://www.bulles.fr',
exampleMatchingUrl: 'http://www.bulles.fr',
noticeId: 1,
noticeUrl: 'http://'
}
},
starred: {
exampleMatchingUrl: 'http://www.bulles.fr',
noticeId: 1,
noticeUrl: 'http://'
},
pinnedNotices: [
{
sort: 0,
exampleMatchingUrl: 'http://www.bulles.fr',
noticeId: 1,
noticeUrl: 'http://'
}
]
},
avatar: noAvatar
? undefined
Expand Down
6 changes: 3 additions & 3 deletions test/fakers/generateNotice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Options {
disliked?: boolean;
dismissed?: boolean;
read?: boolean;
exampleUrl?: string;
exampleMatchingUrl?: string;
}

export const defaultMessage = `L’économie est (vraiment) un sport de combat : “La boule puante de MM. Cahuc et Zylberberg contre le “négationnisme” des économistes critiques le confirme : le combat idéologique tombe parfois dans le caniveau. Depuis vingt ans pourtant, s’est construit en France une contre-expertise économique crédible qui veut fournir aux dominés des outils pour penser (et résister à) la pseudo” construit en France une contre-expertise`;
Expand All @@ -33,13 +33,13 @@ export const generateStatefulNotice = ({
disliked,
dismissed,
read,
exampleUrl
exampleMatchingUrl
}: Options = {}): StatefulNoticeWithContributor => {
const id = Math.random() * 1000;
return {
id,
url: `http://backend.dismoi.io/notices/${id}`,
exampleUrl: exampleUrl || Faker.internet.url(),
exampleMatchingUrl: exampleMatchingUrl || Faker.internet.url(),
created: created || subMonths(new Date(), 1),
modified: modified || subWeeks(new Date(), 1),
message: message || defaultMessage,
Expand Down

0 comments on commit d6bac49

Please sign in to comment.