From c2c26793b0510d6ba17367609410c43bec33d439 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Wed, 29 Aug 2018 02:21:01 -0400 Subject: [PATCH] Update uri -> url in the front end + examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This continues a consistency update we’ve been making to standardize on URL. This also helps with copying and pasting between all-badge-examples and new-style services, where it’s otherwise easy to make a mistake. --- .prettierignore | 1 + doc/TUTORIAL.md | 2 +- frontend/components/badge-examples.js | 44 +- frontend/components/dynamic-badge-maker.js | 8 +- frontend/components/examples-page.js | 10 +- frontend/components/footer.js | 10 +- frontend/components/markup-modal.js | 42 +- frontend/components/search-results.js | 4 +- frontend/components/static-badge-maker.js | 10 +- frontend/components/suggestion-and-search.js | 24 +- frontend/components/usage.js | 22 +- frontend/constants.js | 4 +- frontend/lib/generate-image-markup.js | 16 +- lib/all-badge-examples.js | 626 +++++++++---------- lib/all-badge-examples.spec.js | 8 +- services/base.js | 4 +- services/base.spec.js | 12 +- 17 files changed, 424 insertions(+), 423 deletions(-) diff --git a/.prettierignore b/.prettierignore index b2ae4bd695fe8..65d17f6404dfa 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,3 +8,4 @@ package-lock.json /.next /build /coverage +**/*.md diff --git a/doc/TUTORIAL.md b/doc/TUTORIAL.md index 2fbeaa9cd233c..b48a7fe38aeb5 100644 --- a/doc/TUTORIAL.md +++ b/doc/TUTORIAL.md @@ -218,7 +218,7 @@ Downloads, ...) and add your badge: keywords: [ 'some-search-keyword' ], - previewUri: '/test/subject/STATUS.svg', + previewUrl: '/test/subject/STATUS.svg', }, ``` diff --git a/frontend/components/badge-examples.js b/frontend/components/badge-examples.js index 637d3ea126b40..bf6311c2a743f 100644 --- a/frontend/components/badge-examples.js +++ b/frontend/components/badge-examples.js @@ -6,11 +6,11 @@ import resolveBadgeUrl from '../lib/badge-url' const Badge = ({ title, - exampleUri, - previewUri, + exampleUrl, + previewUrl, urlPattern, documentation, - baseUri, + baseUrl, longCache, shouldDisplay = () => true, onClick, @@ -19,26 +19,26 @@ const Badge = ({ ? () => onClick({ title, - exampleUri, - previewUri, + exampleUrl, + previewUrl, urlPattern, documentation, }) : undefined - const previewImage = previewUri ? ( + const previewImage = previewUrl ? ( ) : ( '\u00a0' ) // non-breaking space - const resolvedExampleUri = resolveBadgeUrl( - urlPattern || previewUri, - baseUri, + const resolvedExampleUrl = resolveBadgeUrl( + urlPattern || previewUrl, + baseUrl, { longCache: false } ) @@ -57,7 +57,7 @@ const Badge = ({ className={classNames({ clickable: onClick })} onClick={handleClick} > - {resolvedExampleUri} + {resolvedExampleUrl} @@ -67,17 +67,17 @@ const Badge = ({ } Badge.propTypes = { title: PropTypes.string.isRequired, - exampleUri: PropTypes.string, - previewUri: PropTypes.string, + exampleUrl: PropTypes.string, + previewUrl: PropTypes.string, urlPattern: PropTypes.string, documentation: PropTypes.string, - baseUri: PropTypes.string, + baseUrl: PropTypes.string, longCache: PropTypes.bool.isRequired, shouldDisplay: PropTypes.func, onClick: PropTypes.func.isRequired, } -const Category = ({ category, examples, baseUri, longCache, onClick }) => { +const Category = ({ category, examples, baseUrl, longCache, onClick }) => { if (examples.filter(example => example.shouldDisplay()).length === 0) { return null } @@ -92,7 +92,7 @@ const Category = ({ category, examples, baseUri, longCache, onClick }) => { @@ -110,24 +110,24 @@ Category.propTypes = { examples: PropTypes.arrayOf( PropTypes.shape({ title: PropTypes.string.isRequired, - exampleUri: PropTypes.string, - previewUri: PropTypes.string, + exampleUrl: PropTypes.string, + previewUrl: PropTypes.string, urlPattern: PropTypes.string, documentation: PropTypes.string, }) ).isRequired, - baseUri: PropTypes.string, + baseUrl: PropTypes.string, longCache: PropTypes.bool.isRequired, onClick: PropTypes.func.isRequired, } -const BadgeExamples = ({ categories, baseUri, longCache, onClick }) => ( +const BadgeExamples = ({ categories, baseUrl, longCache, onClick }) => (
{categories.map((categoryData, i) => ( @@ -141,7 +141,7 @@ BadgeExamples.propTypes = { examples: Category.propTypes.examples, }) ), - baseUri: PropTypes.string, + baseUrl: PropTypes.string, longCache: PropTypes.bool.isRequired, onClick: PropTypes.func.isRequired, } diff --git a/frontend/components/dynamic-badge-maker.js b/frontend/components/dynamic-badge-maker.js index a8eb0f1957ac3..36ff017c80794 100644 --- a/frontend/components/dynamic-badge-maker.js +++ b/frontend/components/dynamic-badge-maker.js @@ -4,7 +4,7 @@ import { dynamicBadgeUrl } from '../lib/badge-url' export default class DynamicBadgeMaker extends React.Component { static propTypes = { - baseUri: PropTypes.string, + baseUrl: PropTypes.string, } state = { @@ -17,9 +17,9 @@ export default class DynamicBadgeMaker extends React.Component { suffix: '', } - makeBadgeUri() { + makeBadgeUrl() { const { datatype, label, url, query, color, prefix, suffix } = this.state - const { baseUri: baseUrl = document.location.href } = this.props + const { baseUrl: baseUrl = document.location.href } = this.props return dynamicBadgeUrl(baseUrl, datatype, label, url, query, { color, prefix, @@ -29,7 +29,7 @@ export default class DynamicBadgeMaker extends React.Component { handleSubmit(e) { e.preventDefault() - document.location = this.makeBadgeUri() + document.location = this.makeBadgeUrl() } get isValid() { diff --git a/frontend/components/examples-page.js b/frontend/components/examples-page.js index f60b512e612f8..352406accda65 100644 --- a/frontend/components/examples-page.js +++ b/frontend/components/examples-page.js @@ -7,7 +7,7 @@ import SearchResults from './search-results' import MarkupModal from './markup-modal' import Usage from './usage' import Footer from './footer' -import { baseUri, longCache } from '../constants' +import { baseUrl, longCache } from '../constants' export default class ExamplesPage extends React.Component { constructor(props) { @@ -78,7 +78,7 @@ export default class ExamplesPage extends React.Component { onRequestClose={() => { this.setState({ example: null }) }} - baseUri={baseUri} + baseUrl={baseUrl} />
{ this.setState({ example }) }} - baseUri={baseUri} + baseUrl={baseUrl} longCache={longCache} /> @@ -94,8 +94,8 @@ export default class ExamplesPage extends React.Component {
{this.renderSearchResults()} - -