Skip to content

Commit

Permalink
Merge branch 'dev' into gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
pollux authored Jun 16, 2018
2 parents 4a641ab + d35d7e0 commit efa2bbd
Show file tree
Hide file tree
Showing 29 changed files with 674 additions and 55 deletions.
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ REDIS_HOST=127.0.0.1
REDIS_PORT=6379
WEBHOOK_SECRET=geheim
TWITTER_SEARCH=%23savetheinternet
LANG_ORDER=en_GB,de_DE,fr_FR,it_IT
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@ yarn-error.log
/app/**/*.js.map

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/typings

Expand Down Expand Up @@ -88,7 +84,6 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
Expand All @@ -109,8 +104,6 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

### VisualStudioCode ###
.vscode/*
Expand Down
2 changes: 1 addition & 1 deletion assets/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
@import "pages/responsive-video";
@import "pages/imprint";
@import "pages/gallery";

@import "pages/about";
15 changes: 15 additions & 0 deletions assets/css/pages/about.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.about-heading{
font-size: 26px;
margin-top: 0;
margin-bottom: 7px;
}
p.about-text{
font-style: italic;

a {
color: $accent1;
}
a:hover{
color: $text;
}
}
7 changes: 7 additions & 0 deletions assets/css/pages/landing/article-thirteen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
margin: 0;
font-weight: 500;
}

.explainer {
a.highlight {
text-decoration: none;
color: $accent1;
}
}
}

.content-pair {
Expand Down
22 changes: 22 additions & 0 deletions assets/css/pages/landing/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@
}

}

.btn-petition {
padding: 15px 30px;
background: $accent1;
color: $background;
text-decoration: none;
border-radius: 25px;
}

.btn-petition:hover {
background: lighten($accent1, 10);
}

.description {
font-size: 1.2em;
}

.action {
text-align: center;
font-size: 1.1em;
margin-top: 65px;
}
}
.tagline {
text-align: center;
Expand Down
1 change: 1 addition & 0 deletions assets/css/pages/landing/twitter-feed.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
position: absolute;
text-align: center;
color: black;
line-height: 1em;
left: 0;
top: 0;
width: 100%;
Expand Down
7 changes: 5 additions & 2 deletions assets/js/pages/landing/tweets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function makeTemplate(element){
moment.locale(window.location.pathname === '/' ? 'en' : window.location.pathname.substring(1,3));
return '<div class="post-container" id="' + element.id + '">'+
'<div class="post-left">'+
'<img class="profile-pic" src="' + element.user.profile_image_url_https + '" />'+
Expand Down Expand Up @@ -83,13 +84,15 @@ function contains(id){
function updateTweets() {
$.get("/tweets", function(data) {
data = data.sort(function(a,b){
return a.id - b.id;
if(a != null && b != null) {
return b.id - a.id;
}
});

let inserted = 0;
data = data.slice(0, 6);
data.forEach(function(element) {
if(!contains(element.id) && inserted < 1)
if(element !== null && !contains(element.id) && inserted < 1)
{
inserted ++;
$('#tweets').prepend(makeTemplate(element));
Expand Down
Binary file modified assets/static/scroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/static/voxel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,39 @@
'_locale' => implode('|', \App\EventSubscriber\getAvailableLanguages()),
)));

$routes->add('imprint', new Route('/imprint', array(
$routes->add('imprint', new Route('/{_locale}/imprint', array(
'_controller' => 'App\\Controller\\IndexController::imprint',
'_locale' => 'en_GB',
), array(
'_locale' => implode('|', \App\EventSubscriber\getAvailableLanguages()),
)));

$routes->add('privacy', new Route('/privacy', array(
$routes->add('privacy', new Route('/{_locale}/privacy', array(
'_controller' => 'App\\Controller\\IndexController::privacy',
'_locale' => 'en_GB',
), array(
'_locale' => implode('|', \App\EventSubscriber\getAvailableLanguages()),
)));

$routes->add('gallery', new Route('/gallery', array(
$routes->add('about', new Route('/{_locale}/about', array(
'_controller' => 'App\\Controller\\IndexController::about',
'_locale' => 'en_GB',
), array(
'_locale' => implode('|', \App\EventSubscriber\getAvailableLanguages()),
)));

$routes->add('gallery', new Route('/{_locale}/gallery', array(
'_controller' => 'App\\Controller\\IndexController::gallery',
'_locale' => 'en_GB',
), array(
'_locale' => implode('|', \App\EventSubscriber\getAvailableLanguages()),
)));

$routes->add('resources', new Route('/{_locale}/resources', array(
'_controller' => 'App\\Controller\\IndexController::resources',
'_locale' => 'en_GB',
), array(
'_locale' => implode('|', \App\EventSubscriber\getAvailableLanguages()),
)));

return $routes;
26 changes: 20 additions & 6 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,25 @@ public function __construct(TweetService $tweetService)
}

/**
* @param string $_locale
* @return Response
*/
public function index(string $_locale): Response
public function index(): Response
{
return $this->render('index/index.html.twig');
}

/**
* @param string $_locale
* @return Response
*/
public function imprint(string $_locale): Response
public function imprint(): Response
{
return $this->render('imprint/index.html.twig');
}

/**
* @param string $_locale
* @return Response
*/
public function privacy(string $_locale): Response
public function privacy(): Response
{
return $this->render('privacy/index.html.twig');
}
Expand All @@ -62,6 +59,22 @@ public function privacy(string $_locale): Response
public function gallery(string $_locale): Response
{
return $this->render('gallery/index.html.twig');

/**
* @param string $_locale
* @return Response
*/
public function about(): Response
{
return $this->render('about/index.html.twig');
}

/**
* @return Response
*/
public function resources(): Response
{
return $this->render('resources/index.html.twig');
}

/**
Expand Down Expand Up @@ -98,6 +111,7 @@ public function update(Request $request)
exec('cd ' . __DIR__ . '/../../; composer install');
exec('cd ' . __DIR__ . '/../../; yarn install');
exec('cd ' . __DIR__ . '/../../; yarn run build');
exec('cd ' . __DIR__ . '/../../; php bin/console cache:clear');

return new Response();
}
Expand Down
44 changes: 40 additions & 4 deletions src/EventSubscriber/AvailableLocalesSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\EventSubscriber;

use Abraham\TwitterOAuth\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;

Expand All @@ -27,6 +28,9 @@ public function onKernelRequest(GetResponseEvent $event)
$languages = getAvailableLanguages();
$this->twig_Environment->addGlobal('locales', $languages);

// detect users language form browser
$this->setVisitorLanguage($event, $languages);

$codes = [];
foreach ($languages as $language) {
$parts = explode('_', $language);
Expand All @@ -40,12 +44,35 @@ public function onKernelRequest(GetResponseEvent $event)
public static function getSubscribedEvents()
{
return [
'kernel.request' => 'onKernelRequest',
'kernel.request' => 'onKernelRequest',
];
}

private function setVisitorLanguage(GetResponseEvent $event, array $languages)
{
// some logic to determine the $locale
$request = $event->getRequest();
$locale = $request->getLocale(); // browser locale

if (!is_null($request->query->get('_locale')))
{
$request->setLocale($request->query->get('_locale'));
}
elseif (in_array($locale, $languages)) {
$request->setLocale($locale);
} else {
$request->setLocale('en_GB');
}
}
}

function getAvailableLanguages() {
function getAvailableLanguages()
{
$languageOrder = [];
if (isset($_SERVER['LANG_ORDER'])) {
$languageOrder = explode(',', $_SERVER['LANG_ORDER']);
}

$translationFiles = scandir(__DIR__ . '/../../translations', SCANDIR_SORT_NONE);

$languages = [];
Expand All @@ -60,8 +87,17 @@ function getAvailableLanguages() {
continue;
}

$languages[] = $parts[1];
if (\in_array($parts[1], $languageOrder, true)) {
$position = \array_flip($languageOrder)[$parts[1]];

$languages[$position] = $parts[1];
} else {
$languages[] = $parts[1];
}

}

ksort($languages);

return $languages;
}
}
49 changes: 49 additions & 0 deletions templates/about/components/content.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<div class="container section-article-thirteen">
<div class="row">
<div class="col-12">
<div class="header">
<h2 class="title">
<span>{% trans %}about_title{% endtrans %}</span>
</h2>
<br>
<br>
<strong class="about-heading">{% trans %}about_sub_title1{% endtrans %}</strong>
<p class="about-text">
{% trans %}about_sub_text1{% endtrans %}
</p>
<br>
<strong class="about-heading">{% trans %}about_sub_title2{% endtrans %}</strong>
<p class="about-text">
{% trans %}about_sub_text2_1{% endtrans %}
<br><br>
{% trans %}about_sub_text2_2{% endtrans %}
</p>
<br>
<strong class="about-heading">{% trans %}about_sub_title3{% endtrans %}</strong>
<p class="about-text">
{% trans %}about_sub_text3_1{% endtrans %}
<br><br>
{% trans %}about_sub_text3_2{% endtrans %}
</p>
<br>
<strong class="about-heading">{% trans %}about_sub_title4{% endtrans %}</strong>
<p class="about-text">
{% trans %}about_sub_text4_1{% endtrans %}
<br><br>
{% trans %}about_sub_text4_2{% endtrans %}
</p>
<br>
<strong class="about-heading">{% trans %}about_sub_title5{% endtrans %}</strong>
<p class="about-text">
{% trans %}about_sub_text5_1{% endtrans %}
<br><br>
{% trans %}about_sub_text5_2{% endtrans %}
<br><br>
<strong>{% trans %}about_sub_text5_strong{% endtrans %}</strong>
<br><br>
<a>#savetheinternet</a> <a>#saveourinternet</a> <a>#fckart13</a>
</p>
</div>
</div>
</div>
</div>
20 changes: 20 additions & 0 deletions templates/about/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}

{% block title %}About | Save the Internet{% endblock %}

{% block body %}
{% include 'shared/langpicker.html.twig' %}

<!-- Share buttons -->
{% include 'shared/sharebuttons.html.twig' %}

<!-- Header -->
{% include 'shared/header.html.twig' %}

<!-- content -->
{% include 'about/components/content.html.twig' %}

<!-- Footer -->
{% include 'shared/footer.html.twig' %}

{% endblock %}
Loading

0 comments on commit efa2bbd

Please sign in to comment.