Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
21ccd45f
Unverified
Commit
21ccd45f
authored
Jul 09, 2020
by
Benjamin Wheeler
Committed by
GitHub
Jul 09, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4121 from apple502j/wiki-link
Set wiki link per user's selected language
parents
e0d96ccd
a635cd93
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
3 deletions
+55
-3
src/components/footer/www/footer.jsx
src/components/footer/www/footer.jsx
+12
-3
src/lib/scratch-wiki.js
src/lib/scratch-wiki.js
+24
-0
test/unit/lib/scratch-wiki.test.js
test/unit/lib/scratch-wiki.test.js
+19
-0
No files found.
src/components/footer/www/footer.jsx
View file @
21ccd45f
...
...
@@ -2,12 +2,15 @@ const FormattedMessage = require('react-intl').FormattedMessage;
const
injectIntl
=
require
(
'
react-intl
'
).
injectIntl
;
const
intlShape
=
require
(
'
react-intl
'
).
intlShape
;
const
MediaQuery
=
require
(
'
react-responsive
'
).
default
;
const
connect
=
require
(
'
react-redux
'
).
connect
;
const
PropTypes
=
require
(
'
prop-types
'
);
const
React
=
require
(
'
react
'
);
const
FooterBox
=
require
(
'
../container/footer.jsx
'
);
const
LanguageChooser
=
require
(
'
../../languagechooser/languagechooser.jsx
'
);
const
frameless
=
require
(
'
../../../lib/frameless
'
);
const
getScratchWikiLink
=
require
(
'
../../../lib/scratch-wiki
'
);
require
(
'
./footer.scss
'
);
...
...
@@ -108,7 +111,7 @@ const Footer = props => (
</
a
>
</
dd
>
<
dd
>
<
a
href=
"https://en.scratch-wiki.info/"
>
<
a
href=
{
props
.
scratchWikiLink
}
>
<
FormattedMessage
id=
"general.wiki"
/>
</
a
>
</
dd
>
...
...
@@ -213,7 +216,13 @@ const Footer = props => (
);
Footer
.
propTypes
=
{
intl
:
intlShape
.
isRequired
intl
:
intlShape
.
isRequired
,
scratchWikiLink
:
PropTypes
.
string
};
module
.
exports
=
injectIntl
(
Footer
);
const
mapStateToProps
=
(
state
,
ownProps
)
=>
({
scratchWikiLink
:
getScratchWikiLink
(
ownProps
.
intl
.
locale
)
});
const
ConnectedFooter
=
connect
(
mapStateToProps
)(
Footer
);
module
.
exports
=
injectIntl
(
ConnectedFooter
);
src/lib/scratch-wiki.js
0 → 100644
View file @
21ccd45f
// This list has to be updated when a new Scratch Wiki is made.
// Note that wikis under testwiki are not included.
const
wwwLocaleToScratchWikiLocale
=
{
en
:
'
en
'
,
ja
:
'
ja
'
,
fr
:
'
fr
'
,
de
:
'
de
'
,
ru
:
'
ru
'
,
hu
:
'
hu
'
,
nl
:
'
nl
'
,
id
:
'
id
'
};
const
getScratchWikiLink
=
locale
=>
{
if
(
!
wwwLocaleToScratchWikiLocale
.
hasOwnProperty
(
locale
))
{
locale
=
locale
.
split
(
'
-
'
)[
0
];
if
(
!
wwwLocaleToScratchWikiLocale
.
hasOwnProperty
(
locale
))
{
locale
=
'
en
'
;
}
}
return
`https://
${
wwwLocaleToScratchWikiLocale
[
locale
]}
.scratch-wiki.info/`
;
};
module
.
exports
=
getScratchWikiLink
;
test/unit/lib/scratch-wiki.test.js
0 → 100644
View file @
21ccd45f
const
getScratchWikiLink
=
require
(
'
../../../src/lib/scratch-wiki
'
);
describe
(
'
unit test lib/scratch-wiki.js
'
,
()
=>
{
test
(
'
getScratchWikiLink exists
'
,
()
=>
{
expect
(
typeof
getScratchWikiLink
).
toBe
(
'
function
'
);
});
test
(
'
it returns link to jawiki when ja is given
'
,
()
=>
{
expect
(
getScratchWikiLink
(
'
ja
'
)).
toBe
(
'
https://ja.scratch-wiki.info/
'
);
});
test
(
'
it returns link to jawiki when ja-Hira is given
'
,
()
=>
{
expect
(
getScratchWikiLink
(
'
ja-Hira
'
)).
toBe
(
'
https://ja.scratch-wiki.info/
'
);
});
test
(
'
it returns link to enwiki when invalid locale is given
'
,
()
=>
{
expect
(
getScratchWikiLink
(
'
test
'
)).
toBe
(
'
https://en.scratch-wiki.info/
'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment