diff --git a/src/ConfiguredSilex.php b/src/ConfiguredSilex.php index debef68..80aaea1 100644 --- a/src/ConfiguredSilex.php +++ b/src/ConfiguredSilex.php @@ -1,33 +1,37 @@ -get('/', 'Sheffugees\\Controllers\\All::index'); - - $this->register(new \Silex\Provider\TwigServiceProvider(), [ - 'twig.path' => __DIR__ . '/../views', - ]); - } -} +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', + ]); + } +} diff --git a/src/Controllers/All.php b/src/Controllers/All.php index f156874..cb74fe4 100644 --- a/src/Controllers/All.php +++ b/src/Controllers/All.php @@ -1,26 +1,84 @@ -render('index.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"); + } + +} diff --git a/translate-demo/translation-demo b/translate-demo/translation-demo new file mode 100644 index 0000000..5286921 --- /dev/null +++ b/translate-demo/translation-demo @@ -0,0 +1,64 @@ + + + + + + + + + + + + +
+
+
+ Hello! Welcome to our new website +
+ + + \ No newline at end of file diff --git a/translate-demo/yandex-api-key b/translate-demo/yandex-api-key new file mode 100644 index 0000000..7d74803 --- /dev/null +++ b/translate-demo/yandex-api-key @@ -0,0 +1 @@ +trnsl.1.1.20160206T123230Z.37bca81167793559.4914b0cdb53f30907bf278a6726aee775e04cfb1 \ No newline at end of file diff --git a/views/base.twig b/views/base.twig new file mode 100644 index 0000000..39bc727 --- /dev/null +++ b/views/base.twig @@ -0,0 +1,36 @@ + + + + + + + Foundation for Sites + + + +
+
+ {% block languages %} + English|العربية + {% endblock %} +
+
+ +
+
+

{% block title %}{% endblock %}

+ + {% block standfirst %}{% endblock %} +
+
+ +
+ {% block content %}{% endblock %} +
+ + + + + + + diff --git a/views/choose-ar.twig b/views/choose-ar.twig new file mode 100644 index 0000000..b9345af --- /dev/null +++ b/views/choose-ar.twig @@ -0,0 +1,58 @@ +{% extends "base.twig" %} + +{% block title %}What do you need? (Arabic){% endblock %} + +{% block content %} +
+ +
+{% endblock %} diff --git a/views/choose-en.twig b/views/choose-en.twig new file mode 100644 index 0000000..f25379f --- /dev/null +++ b/views/choose-en.twig @@ -0,0 +1,58 @@ +{% extends "base.twig" %} + +{% block title %}What do you need?{% endblock %} + +{% block content %} +
+ +
+{% endblock %} diff --git a/views/index.twig b/views/index.twig deleted file mode 100644 index 3a36e53..0000000 --- a/views/index.twig +++ /dev/null @@ -1 +0,0 @@ -

Test

diff --git a/views/location-ar.twig b/views/location-ar.twig new file mode 100644 index 0000000..dafea13 --- /dev/null +++ b/views/location-ar.twig @@ -0,0 +1,19 @@ +{% extends "base.twig" %} + +{% block title %}Set your location (in Arabic){% endblock %} + +{% block content %} +
+ + +

I'm at home now: set my location.

+
+
+ +
+ + +

I'm not at home: add my address.

+
+
+{% endblock %} diff --git a/views/location-en.twig b/views/location-en.twig new file mode 100644 index 0000000..00b709c --- /dev/null +++ b/views/location-en.twig @@ -0,0 +1,19 @@ +{% extends "base.twig" %} + +{% block title %}Set your location{% endblock %} + +{% block content %} +
+ + +

I'm at home now: set my location.

+
+
+ +
+ + +

I'm not at home: add my address.

+
+
+{% endblock %} diff --git a/views/need-ar-money.twig b/views/need-ar-money.twig new file mode 100644 index 0000000..81666e3 --- /dev/null +++ b/views/need-ar-money.twig @@ -0,0 +1,33 @@ +{% extends "base.twig" %} + +{% block title %}Money (in Arabic){% endblock %} + +{% block standfirst %} +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum maximus tincidunt sagittis. Pellentesque justo neque, tincidunt non viverra nec, auctor eget nisl.

+{% endblock %} + +{% block content %} +
+
+ +

Post office

+

If you have your identification card you can get money form the Post Office.

+ + +

Find a Post Office

+
+
+
+ +
+
+ +

Western Union

+

You can receive money from your family using Western Union

+ + +

Find Western Union

+
+
+
+{% endblock %} diff --git a/views/need-en-money.twig b/views/need-en-money.twig new file mode 100644 index 0000000..299d073 --- /dev/null +++ b/views/need-en-money.twig @@ -0,0 +1,33 @@ +{% extends "base.twig" %} + +{% block title %}Money{% endblock %} + +{% block standfirst %} +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum maximus tincidunt sagittis. Pellentesque justo neque, tincidunt non viverra nec, auctor eget nisl.

+{% endblock %} + +{% block content %} +
+
+ +

Post office

+

If you have your identification card you can get money form the Post Office.

+ + +

Find a Post Office

+
+
+
+ +
+
+ +

Western Union

+

You can receive money from your family using Western Union

+ + +

Find Western Union

+
+
+
+{% endblock %} diff --git a/views/results-ar-postoffice.twig b/views/results-ar-postoffice.twig new file mode 100644 index 0000000..267e1ac --- /dev/null +++ b/views/results-ar-postoffice.twig @@ -0,0 +1,47 @@ +{% extends "base.twig" %} + +{% block title %}Post offices near you (in Arabic){% endblock %} + +{% block content %} +
+
+ +

228 Shoreham St, Sheffield, England

+ +
+
+ +
+
+ +

43 Charles St, Sheffield, England

+ +
+
+{% endblock %} diff --git a/views/results-en-postoffice.twig b/views/results-en-postoffice.twig new file mode 100644 index 0000000..8e39a92 --- /dev/null +++ b/views/results-en-postoffice.twig @@ -0,0 +1,47 @@ +{% extends "base.twig" %} + +{% block title %}Post offices near you{% endblock %} + +{% block content %} +
+
+ +

228 Shoreham St, Sheffield, England

+ +
+
+ +
+
+ +

43 Charles St, Sheffield, England

+ +
+
+{% endblock %} diff --git a/views/start.twig b/views/start.twig new file mode 100644 index 0000000..b0a7031 --- /dev/null +++ b/views/start.twig @@ -0,0 +1,18 @@ +{% extends "base.twig" %} + +{% block languages %}{% endblock %} + +{% block title %}Welcome to Sheffield!{% endblock %} + +{% block content %} +
+
+
+ English +
+ +
+
+{% endblock %} diff --git a/web/microframework.php b/web/index.php similarity index 100% rename from web/microframework.php rename to web/index.php diff --git a/web/index.html b/web/old-index.html similarity index 100% rename from web/index.html rename to web/old-index.html