-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Sheffugees/needs-directory
- Loading branch information
Showing
17 changed files
with
554 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Configured Silex application. | ||
*/ | ||
|
||
namespace Sheffugees; | ||
|
||
use Silex\Application; | ||
|
||
/** | ||
* @class | ||
* ConfiguredSilex. | ||
*/ | ||
class ConfiguredSilex extends Application | ||
{ | ||
/** | ||
* @inheritDoc | ||
* | ||
* Configure routes, services etc. | ||
*/ | ||
public function __construct(array $values = []) | ||
{ | ||
parent::__construct($values); | ||
|
||
$this->get('/', 'Sheffugees\\Controllers\\All::index'); | ||
|
||
$this->register(new \Silex\Provider\TwigServiceProvider(), [ | ||
'twig.path' => __DIR__ . '/../views', | ||
]); | ||
} | ||
} | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Configured Silex application. | ||
*/ | ||
|
||
namespace Sheffugees; | ||
|
||
use Silex\Application; | ||
|
||
/** | ||
* @class | ||
* ConfiguredSilex. | ||
*/ | ||
class ConfiguredSilex extends Application | ||
{ | ||
/** | ||
* @inheritDoc | ||
* | ||
* Configure routes, services etc. | ||
*/ | ||
public function __construct(array $values = []) | ||
{ | ||
parent::__construct($values); | ||
|
||
$this->get('/', 'Sheffugees\\Controllers\\All::index'); | ||
$this->get('/{lang}', 'Sheffugees\\Controllers\\All::location'); | ||
$this->get('/{lang}/choose', 'Sheffugees\\Controllers\\All::choose'); | ||
$this->get('/{lang}/need/{need}', 'Sheffugees\\Controllers\\All::need'); | ||
$this->get('/{lang}/results/{find}', 'Sheffugees\\Controllers\\All::results'); | ||
|
||
$this->register(new \Silex\Provider\TwigServiceProvider(), [ | ||
'twig.path' => __DIR__ . '/../views', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,84 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Controller for all pages in prototype. | ||
*/ | ||
|
||
namespace Sheffugees\Controllers; | ||
|
||
use Silex\Application; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* @class | ||
* All. | ||
*/ | ||
class All | ||
{ | ||
/** | ||
* Callback: index, trying to choose language. | ||
*/ | ||
public function index(Request $request, Application $app) | ||
{ | ||
return $app['twig']->render('index.twig'); | ||
} | ||
} | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Controller for all pages in prototype. | ||
*/ | ||
|
||
namespace Sheffugees\Controllers; | ||
|
||
use Silex\Application; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* @class | ||
* All. | ||
*/ | ||
class All | ||
{ | ||
/** | ||
* Page callback: welcome and pick language. | ||
*/ | ||
public function index(Request $request, Application $app) | ||
{ | ||
return $app['twig']->render('start.twig'); | ||
} | ||
|
||
/** | ||
* Page callback: set location. | ||
*/ | ||
public function location(Request $request, Application $app, $lang) | ||
{ | ||
if (!preg_match("/^[a-z]{2}\$/", $lang)) { | ||
return $app->redirect('/'); | ||
} | ||
|
||
return $app['twig']->render("location-$lang.twig"); | ||
} | ||
|
||
/** | ||
* Page callback: choose a need. | ||
*/ | ||
public function choose(Request $request, Application $app, $lang) | ||
{ | ||
if (!preg_match("/^[a-z]{2}\$/", $lang)) { | ||
return $app->redirect('/'); | ||
} | ||
|
||
return $app['twig']->render("choose-$lang.twig"); | ||
} | ||
|
||
/** | ||
* Page callback: define a need. | ||
*/ | ||
public function need(Request $request, Application $app, $lang, $need) | ||
{ | ||
if (!preg_match("/^[a-z]{2}\$/", $lang)) { | ||
return $app->redirect('/'); | ||
} | ||
|
||
if (!preg_match("/^[a-z]+\$/", $need)) { | ||
return $app->redirect('/'); | ||
} | ||
|
||
|
||
return $app['twig']->render("need-$lang-$need.twig"); | ||
} | ||
|
||
/** | ||
* Page callback: return some results. | ||
*/ | ||
public function results(Request $request, Application $app, $lang, $find) | ||
{ | ||
if (!preg_match("/^[a-z]{2}\$/", $lang)) { | ||
return $app->redirect('/'); | ||
} | ||
|
||
if (!preg_match("/^[a-z]+\$/", $find)) { | ||
return $app->redirect('/'); | ||
} | ||
|
||
return $app['twig']->render("results-$lang-$find.twig"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<html> | ||
<head> | ||
|
||
<script src="http://code.jquery.com/jquery-1.8.2.js"></script> | ||
<script> | ||
$(document).ready(function() { | ||
$('#languages').data('pre', $(this).val()); | ||
$('#languages').bind('change', runTranslation); | ||
|
||
function runTranslation(evt) { | ||
var before_change = $(this).data('pre');//get the pre data | ||
var langCode = $("#languages option:selected").val(); | ||
|
||
// Empty string returned on first interaction with select? | ||
if (!before_change) { | ||
before_change = document.getElementById('languages').options[0].value; | ||
} | ||
|
||
// Hardcoded for now, just pass originalText in as a parameter and it will replace the spaces and send to the api | ||
var originalText = "Hello! Welcome to our new website"; | ||
var replacedText = originalText.split(' ').join('+'); | ||
|
||
var langCode = $("#languages option:selected").val(); | ||
var xhr = new XMLHttpRequest(); | ||
|
||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState == 4 && xhr.status == 200) { | ||
var jsonObject = JSON.parse(xhr.responseText); | ||
$('#textArea').text(jsonObject.text[0]); | ||
} | ||
}; | ||
|
||
// Had a problem translating from certain languages to others (encoding issues I think). But our source content will always be in English | ||
// so we can just use that and translate to the selected languages | ||
|
||
// API Key hardcoded for now | ||
//xhr.open("GET", "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20160206T123230Z.37bca81167793559.4914b0cdb53f30907bf278a6726aee775e04cfb1&text=" + replacedText +"&lang=" + before_change + "-" + langCode, false); | ||
xhr.open("GET", "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20160206T123230Z.37bca81167793559.4914b0cdb53f30907bf278a6726aee775e04cfb1&text=" + replacedText +"&lang=" + langCode, false); | ||
xhr.send(); | ||
|
||
$(this).data('pre', $(this).val()); | ||
} | ||
}); | ||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<!--Harcoded in a few language codes as examples, full supported list available here: https://tech.yandex.com/translate/doc/dg/concepts/langs-docpage/ --> | ||
<select id="languages"> | ||
<option value="en">English</option> | ||
<option value="ar">Arabic</option> | ||
<option value="hy">Armenian</option> | ||
<option value="bs">Bosnian</option> | ||
</select> | ||
<br/> | ||
<br/> | ||
<div id="textArea"> | ||
Hello! Welcome to our new website | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
trnsl.1.1.20160206T123230Z.37bca81167793559.4914b0cdb53f30907bf278a6726aee775e04cfb1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!doctype html> | ||
<html class="no-js" lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Foundation for Sites</title> | ||
<link rel="stylesheet" href="/css/app.css"> | ||
</head> | ||
<body> | ||
<div class="row"> | ||
<div class="large-12 columns"> | ||
{% block languages %} | ||
<a href="/en">English</a>|<a href="/ar" dir="rtl">العربية</a> | ||
{% endblock %} | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="large-12 columns"> | ||
<h1>{% block title %}{% endblock %}</h1> | ||
|
||
{% block standfirst %}{% endblock %} | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
|
||
<script src="/bower_components/jquery/dist/jquery.js"></script> | ||
<script src="/bower_components/what-input/what-input.js"></script> | ||
<script src="/bower_components/foundation-sites/dist/foundation.js"></script> | ||
<script src="/js/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{% extends "base.twig" %} | ||
|
||
{% block title %}What do you need? (Arabic){% endblock %} | ||
|
||
{% block content %} | ||
<div> | ||
<ul class="small-up-2 medium-up-4 large-up-4 button-list"> | ||
<li class="column"> | ||
<a href="/ar/need/money" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Money</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Food</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Language help</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Places for help</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Government Information</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Home office centre</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Health</p> | ||
</a> | ||
</li> | ||
<li class="column"> | ||
<a href="#" class="button expand"> | ||
<img src="//placehold.it/64x64" class="thumbnail" alt=""> | ||
<p>Transport</p> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.