From ba098844892f05d96a9cc4e70485de68b38296d1 Mon Sep 17 00:00:00 2001 From: Theo Diamantidis Date: Sun, 18 Feb 2018 04:17:58 +0200 Subject: [PATCH] Created migrations, seeders, relationship speaker -> schedule; Removed sponsors from home; Sessions layout; Home controller pulls sessions from database --- app/Http/Controllers/HomeController.php | 30 ++-- app/Schedule.php | 26 ++++ app/Speaker.php | 9 +- ...18_02_18_005101_create_schedules_table.php | 37 +++++ ...018_02_18_005326_create_speakers_table.php | 34 +++++ database/seeds/ScheduleSeeder.php | 64 ++++++--- database/seeds/SpeakersSeeder.php | 20 --- public/css/app.css | 127 +++++++++++------ resources/assets/sass/app.scss | 113 +++++++++------ resources/lang/el/general.php | 7 +- resources/lang/en/general.php | 14 +- resources/views/home.twig | 133 ++++-------------- resources/views/schedule.twig | 28 ++-- resources/views/speakers.twig | 6 +- 14 files changed, 386 insertions(+), 262 deletions(-) create mode 100644 database/migrations/2018_02_18_005101_create_schedules_table.php create mode 100644 database/migrations/2018_02_18_005326_create_speakers_table.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 3d04eb6..4ec05a7 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,24 +3,38 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use LaravelLocalization; +use App\Speaker; class HomeController extends Controller { public function index(Request $request) { - // $speakers = DB::table('speakers')->get(); + $speakers = Speaker::all(); - $data['name'] = 'Big Shaq'; - $data['short_description'] = "Enterpreneur computer engineer and white hat hacker"; - $data['id'] = 'jobs'; - $data['img_src'] = 'https://i1.sndcdn.com/artworks-000241864958-t7ad44-t500x500.jpg'; - $speakers = array($data, $data, $data); + $sessions = [ + ['from' => '10:30', 'to' => '12:30'], + ['from' => '13:00', 'to' => '15:00'], + ['from' => '15:30', 'to' => '17:30'] + ]; + + /* Contains three arrays, one for each session */ + $speakersBySession = [[], [], []]; + + foreach($speakers as $speaker) { + $talk = $speaker->talk; + foreach($sessions as $i => $session) { + if($talk->hour >= $session['from'] && $talk->hour <= $session['to']) { + $speakersBySession[$i][] = $speaker; + break; + } + } + } $isPjax = $request->header('X-PJAX'); if ($isPjax) { - return response()->view('home', compact('isPjax', 'speakers'), 200) + return response()->view('home', compact('isPjax', 'sessions', 'speakersBySession'), 200) ->header('X-PJAX-URL', LaravelLocalization::getLocalizedURL()); } - return view('home', compact('speakers')); + return view('home', compact('sessions', 'speakersBySession')); } } diff --git a/app/Schedule.php b/app/Schedule.php index 5f1c514..ad6a3ee 100644 --- a/app/Schedule.php +++ b/app/Schedule.php @@ -11,4 +11,30 @@ class Schedule extends Model // type: workshop or talk use HasTranslations; public $translatable = ['event_title','event_prev','subtitle']; + public $timestamps = false; + + public function speaker() { + return $this->belongsTo('App\Speaker')->withDefault(); + } + + /* So that toArray() method in Schedule controller returns the translated value of each attribute + and also returns the event title link mutator attribute */ + public function toArray() { + $attributes = parent::toArray(); + + foreach ($this->getTranslatableAttributes() as $name) { + $attributes[$name] = $this->getTranslation($name, app()->getLocale()); + } + $attributes["event_title_link"] = $this->event_title_link; + + return $attributes; + } + + public function getEventTitleLinkAttribute() { + if($this->type == "talk") { + return '' . $this->speaker->name . ''; + } else { + return $this->event_title; + } + } } \ No newline at end of file diff --git a/app/Speaker.php b/app/Speaker.php index 3f5d22f..8e1fff7 100644 --- a/app/Speaker.php +++ b/app/Speaker.php @@ -7,7 +7,12 @@ class Speaker extends Model { - // other fields: id,img_src + // other fields: id,img_src,schedule_id; use HasTranslations; - public $translatable = ['name','talk_title','talk_prev','bio']; + public $translatable = ['name','bio']; + public $timestamps = false; + + public function talk() { + return $this->hasOne('App\Schedule'); + } } diff --git a/database/migrations/2018_02_18_005101_create_schedules_table.php b/database/migrations/2018_02_18_005101_create_schedules_table.php new file mode 100644 index 0000000..d3fb643 --- /dev/null +++ b/database/migrations/2018_02_18_005101_create_schedules_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->char('hour', 5); + $table->text('img_src'); + $table->text('type'); + $table->unsignedInteger('speaker_id')->nullable(); + $table->json('event_title'); + $table->json('event_prev'); + $table->json('subtitle'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('schedules'); + } +} diff --git a/database/migrations/2018_02_18_005326_create_speakers_table.php b/database/migrations/2018_02_18_005326_create_speakers_table.php new file mode 100644 index 0000000..568dad5 --- /dev/null +++ b/database/migrations/2018_02_18_005326_create_speakers_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('sid')->unique(); + $table->text('img_src'); + $table->json('name'); + $table->json('bio'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('speakers'); + } +} diff --git a/database/seeds/ScheduleSeeder.php b/database/seeds/ScheduleSeeder.php index 0c16f6d..a94193b 100644 --- a/database/seeds/ScheduleSeeder.php +++ b/database/seeds/ScheduleSeeder.php @@ -11,25 +11,55 @@ class ScheduleSeeder extends Seeder */ public function run() { - DB::table('schedules')->insert([ - 'hour'=>'13:12', - 'img_src'=>'scienceReactors.jpeg', - 'type'=>'performance', - 'event_title'=>json_encode([ - 'en'=>'Science Reactors', - 'el'=> 'Science Reactors', - ]), - 'event_prev'=>json_encode([ - 'en'=>'Why god studied electrical engineering', - 'el'=>'Γιατί ο θεός είναι ηλεκτρολόγος', + $schedules = [ + App\Schedule::create([ + 'hour' => '13:12', + 'img_src' => 'scienceReactors.jpeg', + 'type' => 'performance', + /* Be careful not to use json_encode in create method, since laravel-translatable takes care of it by itself */ + 'event_title' => [ + 'en' => 'Science Reactors', + 'el' => 'Science Reactors' + ], + 'event_prev' => [ + 'en' => 'Why God studied Electrical Engineering', + 'el' => 'Γιατί ο Θεός είναι ηλεκτρολόγος' + ], + 'subtitle' => [ + 'en' => 'Justification.', + 'el' => 'Ερμηνεία-Επεξήγηση' + ] ]), - 'subtitle'=>json_encode([ - 'en'=>'Justification.', - 'el'=>'Ερμηνεία-Επεξήγηση.', + App\Schedule::create([ + 'hour' => '14:00', + 'img_src' => 'styllas.jpeg', + 'type' => 'talk', + 'event_title' => [ + 'en' => 'Michail Styllas', + 'el' => 'Μιχάλης Στύλλας' + ], + 'event_prev' => [ + 'en' => 'Everest, the end of chaos!', + 'el' => 'Το τέλος του χάους στο everest!' + ], + 'subtitle' => [ + 'en' => 'Chaos is extreme weather, chaos is extreme love!', + 'el'=> 'Χάος είναι ο ακραίος καιρός του έβερεστ, χάος είναι η αγάπη' + ], + 'speaker_id' => App\Speaker::create([ + 'name' => [ + 'en' => 'Michail Styllas', + 'el' => 'Μιχάλης Στύλλας' + ], + 'sid' => 'styllas', + 'img_src' => 'styllas.jpeg', + 'bio' => [ + 'en' => 'dede', + 'el'=> 'δεδεδ', + ] + ])->id ]) - ]); - - + ]; } } diff --git a/database/seeds/SpeakersSeeder.php b/database/seeds/SpeakersSeeder.php index 387092a..a3621a5 100644 --- a/database/seeds/SpeakersSeeder.php +++ b/database/seeds/SpeakersSeeder.php @@ -11,25 +11,5 @@ class SpeakersSeeder extends Seeder */ public function run() { - DB::table('speakers')->insert([ - 'name'=>json_encode([ - 'en'=> 'Michail Styllas', - 'el'=> 'Μιχάλης Στύλας' - ]), - 'id'=>'styllas', - 'img_src'=>'styllas.jpeg', - 'talk_title'=>json_encode([ - 'en'=>'Everest, the end of chaos!', - 'el'=> 'Το τέλος του χάους στο everest!', - ]), - 'talk_prev'=>json_encode([ - 'en'=>'Chaos is extreme weather, chaos is extreme love!', - 'el'=>'Χάος είναι ο ακραίος καιρός του έβερεστ, χάος είναι η αγάπη' - ]), - 'bio'=>json_encode([ - 'en'=>'dede', - 'el'=>'δεδεδ' - ]) - ]); } } diff --git a/public/css/app.css b/public/css/app.css index 80d1c97..e574732 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -13477,6 +13477,73 @@ article.home a.call-to-action:hover { background-color: #3A3A3A; } +article.home #sessions h2, +article.home #sessions h4 { + width: 100%; + margin-bottom: 0; + text-align: center; +} + +article.home #sessions .speaker-container { + margin: 2rem 0; +} + +article.home #sessions .speaker-container img, +article.home #speakers .speaker-container img { + width: 100%; + height: auto; + opacity: .9; + position: absolute; + top: 0; + left: 0; + -webkit-transition: opacity .5s; + transition: opacity .5s; + z-index: 1; +} + +article.home #sessions .speaker-container a, +article.home #speakers .speaker-container a { + background-color: transparent; + -webkit-transition: background-color .5s; + transition: background-color .5s; + text-align: center; + display: block; + color: black; + position: relative; + width: 100%; + padding-bottom: 100%; +} + +article.home #sessions .speaker-container a:hover img, +article.home #speakers .speaker-container a:hover img { + opacity: 1; +} + +article.home #sessions .speaker-container .speaker-info, +article.home #speakers .speaker-container .speaker-info { + position: absolute; + bottom: 1rem; + z-index: 2; + color: white; + text-shadow: none; + padding: 0 1rem; + text-shadow: 0 0 18px black, 0 0 6px black; + width: 100%; +} + +article.home #sessions .speaker-container h3, +article.home #speakers .speaker-container h3 { + margin-top: 1rem; + margin-bottom: .25rem; + font-size: 1.5rem; +} + +article.home #sessions .speaker-container p, +article.home #speakers .speaker-container p { + font-size: 1em; + line-height: 1.25; +} + article.home #schedule .card-columns { -webkit-column-count: 1; column-count: 1; @@ -13522,57 +13589,25 @@ article.home #schedule .media-body { font-size: .9rem; } -article.home #speakers .speaker-container img { - width: 60%; - height: auto; - opacity: .9; - -webkit-transition: opacity .5s; - transition: opacity .5s; -} - -article.home #speakers .speaker-container a { - background-color: transparent; - -webkit-transition: background-color .5s; - transition: background-color .5s; - text-align: center; - display: block; - color: black; - padding: 1rem 2rem; -} - -article.home #speakers .speaker-container a:hover img { - opacity: 1; -} - -article.home #speakers .speaker-container h3 { - margin-top: 1rem; - margin-bottom: .25rem; - font-size: 1.5rem; -} - -article.home #speakers .speaker-container p { - font-size: 1em; - line-height: 1.25; -} - -article.home #sponsors .sponsor-container h3 { +article.home #sponsors .auspices-container h3 { font-weight: bold; margin-bottom: 1rem; } -article.home #sponsors .sponsor-container span { +article.home #sponsors .auspices-container span { display: block; font-weight: 300; margin-top: .5rem; } -article.home #sponsors .sponsor-container a { +article.home #sponsors .auspices-container a { color: black; display: block; + max-width: 400px; text-align: center; } -article.home #sponsors .sponsor-container img { +article.home #sponsors .auspices-container img { width: 80%; height: auto; -webkit-transition: -webkit-transform .5s; @@ -13581,7 +13616,7 @@ article.home #sponsors .sponsor-container img { transition: transform .5s, -webkit-transform .5s; } -article.home #sponsors .sponsor-container a:hover img { +article.home #sponsors .auspices-container a:hover img { -webkit-transform: scale(1.05); transform: scale(1.05); } @@ -14121,10 +14156,9 @@ article.contact .g-recaptcha.error > div { -webkit-box-shadow: inset 0 -80px 80px -80px rgba(0, 0, 0, 0.4), inset 0 80px 80px -80px rgba(0, 0, 0, 0.4); box-shadow: inset 0 -80px 80px -80px rgba(0, 0, 0, 0.4), inset 0 80px 80px -80px rgba(0, 0, 0, 0.4); font-size: 1.25em; - } - - article.home section h2 { - text-align: left; + /*h2 { + text-align: left; + }*/ } article.home section .section-intro { @@ -14180,16 +14214,19 @@ article.contact .g-recaptcha.error > div { column-gap: .8rem; } - article.home #speakers h3 { + article.home #sessions .speaker-container h3, + article.home #speakers .speaker-container h3 { font-size: 1.75rem; margin-bottom: .5rem; } - article.home #speakers .col { + article.home #sessions .speaker-container .col, + article.home #speakers .speaker-container .col { border-right: 1px solid #777; } - article.home #speakers .col:last-child { + article.home #sessions .speaker-container .col:last-child, + article.home #speakers .speaker-container .col:last-child { border-right: 1px solid transparent; } diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss index ad1282e..0f5052b 100644 --- a/resources/assets/sass/app.scss +++ b/resources/assets/sass/app.scss @@ -583,6 +583,62 @@ article.home { background-color: #3A3A3A; } } + #sessions { + h2, h4 { + width: 100%; + margin-bottom: 0; + text-align: center; + } + .speaker-container { + margin: 2rem 0; + } + } + #sessions, #speakers { + .speaker-container { + img { + width: 100%; + height: auto; + opacity: .9; + position: absolute; + top: 0; + left: 0; + transition: opacity .5s; + z-index: 1; + } + a { + background-color: transparent; + transition: background-color .5s; + text-align: center; + display: block; + color: black; + position: relative; + width: 100%; + padding-bottom: 100%; + &:hover img { + opacity: 1; + } + } + .speaker-info { + position: absolute; + bottom: 1rem; + z-index: 2; + color: white; + text-shadow: none; + padding: 0 1rem; + text-shadow: 0 0 18px black, 0 0 6px black; + width: 100%; + } + h3 { + margin-top: 1rem; + margin-bottom: .25rem; + font-size: 1.5rem; + } + p { + font-size: 1em; + line-height: 1.25; + } + } + } #schedule { .card-columns { column-count: 1; @@ -619,38 +675,8 @@ article.home { font-size: .9rem; } } - #speakers { - .speaker-container { - img { - width: 60%; - height: auto; - opacity: .9; - transition: opacity .5s; - } - a { - background-color: transparent; - transition: background-color .5s; - text-align: center; - display: block; - color: black; - padding: 1rem 2rem; - &:hover img { - opacity: 1; - } - } - h3 { - margin-top: 1rem; - margin-bottom: .25rem; - font-size: 1.5rem; - } - p { - font-size: 1em; - line-height: 1.25; - } - } - } #sponsors { - .sponsor-container { + .auspices-container { h3 { font-weight: bold; margin-bottom: 1rem; @@ -663,6 +689,7 @@ article.home { a { color: black; display: block; + max-width: 400px; text-align: center; } img { @@ -1113,9 +1140,9 @@ article.contact { /* top and bottom inset box shadow */ box-shadow: inset 0 -80px 80px -80px rgba(0, 0, 0, .4), inset 0 80px 80px -80px rgba(0, 0, 0, .4); font-size: 1.25em; - h2 { + /*h2 { text-align: left; - } + }*/ .section-intro { display: flex; } @@ -1156,15 +1183,17 @@ article.contact { column-gap: .8rem; } } - #speakers { - h3 { - font-size: 1.75rem; - margin-bottom: .5rem; - } - .col { - border-right: 1px solid #777; - &:last-child { - border-right: 1px solid transparent; + #sessions, #speakers { + .speaker-container { + h3 { + font-size: 1.75rem; + margin-bottom: .5rem; + } + .col { + border-right: 1px solid #777; + &:last-child { + border-right: 1px solid transparent; + } } } } diff --git a/resources/lang/el/general.php b/resources/lang/el/general.php index 0b142cc..d29a4a5 100644 --- a/resources/lang/el/general.php +++ b/resources/lang/el/general.php @@ -72,9 +72,10 @@ 'calltoaction' => 'Δείτε όλες τις αναρτήσεις', ], 'sponsors' => [ - 'title' => 'Χορηγοί', - 'desc' => 'Η εκδήλωσή μας δεν θα ήταν εφικτή χωρίς τη στήριξη από οργανισμούς που συμμερίζονται τις αξίες και τα οράματά μας. Επισκεφθείτε τις ιστοσελίδες τους και μάθετε περισσότερα για αυτούς. Οι μεγαλύτεροι χορηγοί μας παρατίθενται παρακάτω.', - 'calltoaction' => 'Δείτε όλους τους χορηγούς μας', + 'title' => 'Χορηγοί & Υποστηρικτές', + 'desc' => 'Η εκδήλωσή μας δεν θα ήταν εφικτή χωρίς τη στήριξη από οργανισμούς που συμμερίζονται τις αξίες και τα οράματά μας. Επισκεφθείτε τις ιστοσελίδες τους και μάθετε περισσότερα για αυτούς. Σημαντικότερος υποστηρικτής βέβαια, είναι το ίδιο το πανεπιστήμιό μας.', + 'calltoaction' => 'Δείτε τους χορηγούς μας', + 'auspices' => 'Υπό την αιγίδα του ΕΜΠ', ], 'map' => [ 'title' => 'Χάρτης', diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 04a00da..ebb0eaf 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -51,6 +51,17 @@ 'tickets' => 'Get your tickets now', ], 'sections' => [ + 'sessions' => [ + [ + 'title' => 'Session 1: Initial Conditions', + ], + [ + 'title' => 'Session 2: Observation', + ], + [ + 'title' => 'Session 3: Creating Order' + ], + ], 'schedule' => [ 'title' => 'Schedule', 'desc' => 'The very essence of a TEDx event is its medley of talks, performances and workshops. Discover the topics that will be explored and join us in a journey of Chaos.', @@ -73,8 +84,9 @@ ], 'sponsors' => [ 'title' => 'Sponsors', - 'desc' => 'Our event would not have been po,ssible without the support from organizations that share our values and visions. Visit their websites and learn more about them. Our largest sponsors are listed below.', + 'desc' => 'Our event would not have been possible without the support from organizations that share our values and visions. Visit their websites and learn more about them. Of course, the most important supporter is our university itself.', 'calltoaction' => 'See all our sponsors', + 'auspices' => 'Under the auspices of NTUA', ], 'map' => [ 'title' => 'Map & Venue', diff --git a/resources/views/home.twig b/resources/views/home.twig index 0a45d42..fa6709d 100644 --- a/resources/views/home.twig +++ b/resources/views/home.twig @@ -24,99 +24,35 @@ -
+
-

{{ trans('general.home.sections.schedule.title') }}

-
-
{{ trans('general.home.sections.schedule.desc') | raw }}
- -
-
-
-
TALK
-
-
- -
-

Reapproaching the Established

- This talk will influence many people. This talk will influence many people. This talk will influence many people. This talk will influence many people. -
-
-
-
-
-
PERFORMANCE
-
-
- -
-

Reapproaching the Established

- This performance will influence many people. This performance will influence many people. This performance will influence many people. This performance will influence many people. -
-
-
-
-
-
WORKSHOP
-
-
- -
-

Reapproaching the Established

- This workshop will influence many people. This workshop will influence many people. This workshop will influence many people. This workshop will influence many people. -
-
-
-
-
-
TALK
-
-
- -
-

Reapproaching the Established

- This talk will influence many people. This talk will influence many people. This talk will influence many people. This talk will influence many people. -
-
-
-
-
-
-
- -
- -
-

{{ trans('general.home.sections.speakers.title') }}

-
-
{{ trans('general.home.sections.speakers.desc') | raw }}
- -
-
+
+ {% for key, session in sessions -%}
- {% for key, speaker in speakers %} -
- - -

{{ speaker.name }}

-

{{ speaker.short_description }}

-
+

{{ trans('general.home.sections.sessions.' ~ key ~ '.title') }}

+

{{ session.from }}-{{ session.to }}

+
+
+ {% for speaker in speakersBySession[key] -%} + + {% endfor -%} +
- {% endfor %}
-
+ {% endfor -%} +
@@ -149,29 +85,12 @@ -