Add language detection

This commit is contained in:
SaintPeter
2016-02-09 20:57:23 -08:00
parent dd77f69ecb
commit ba18520845
7 changed files with 15 additions and 9 deletions

View File

@ -6,6 +6,7 @@
#wikiFrame {
width: 100%;
height: 100%;
padding-top: 30px;
top:0;
bottom: 0;
position: absolute;
@ -129,8 +130,6 @@
border-color: darkgreen;
}
wiki
.wiki-aside-action-item {
display: flex;
/* main axis */

View File

@ -382,8 +382,11 @@ $(document).ready(function() {
function showWiki() {
if (!main.isWikiAsideLoad) {
var lang = window.location.toString().match(/\/\w{2}\//);
lang = (lang) ? lang[0] : '/en/';
var wikiURL = 'http://freecodecamp.github.io/wiki' + lang;
var wikiAside = $('<iframe>');
wikiAside.attr('src', 'http://freecodecamp.github.io/wiki'); /* <----------------------------------------- here */
wikiAside.attr('src', wikiURL);
$('.wiki-aside').append(wikiAside);
main.isWikiAsideLoad = true;
}

View File

@ -11,7 +11,7 @@
"target": "_blank"
},{
"content": "Wiki",
"link": "https://github.com/freecodecamp/freecodecamp/wiki/",
"link": "/wiki",
"target": "_blank"
},{
"content": "Jobs",

View File

@ -1,5 +1,6 @@
module.exports = function(app) {
var router = app.loopback.Router();
router.get('/wiki/*', showWiki);
router.get('/wiki', showWiki);
app.use(router);

View File

@ -66,8 +66,7 @@ export default function csp() {
'*.twitter.com',
'*.ghbtns.com',
'*.freecatphotoapp.com',
'freecodecamp.github.io',
'localhost:8000'
'freecodecamp.github.io'
].concat(trusted)
},
// set to true if you only want to report errors

View File

@ -20,7 +20,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
li.hidden-xs
a#nav-wiki-btn(href='#' onclick='return false') Wiki
li.visible-xs
a(href='//github.com/FreeCodeCamp/freecodecamp/wiki/Home', target='_blank') Wiki
a(href='/wiki', target='_blank') Wiki
li
a(href='/jobs') Jobs
li

View File

@ -1,3 +1,7 @@
extends ../layout-wide
block content
iframe#wikiFrame(frameborder='no', src='http://freecodecamp.github.io/wiki')
iframe#wikiFrame(frameborder='no')
script.
var lang = window.location.toString().match(/\/\w{2}\//);
lang = (lang) ? lang[0] : '/en/';
$('#wikiFrame').attr('src','http://freecodecamp.github.io/wiki' + lang);