diff --git a/app/Http/Controllers/SearchController-.php b/app/Http/Controllers/SearchController-.php new file mode 100755 index 000000000..b1d9f5c7f --- /dev/null +++ b/app/Http/Controllers/SearchController-.php @@ -0,0 +1,127 @@ +eventTransformer = $eventTransformer; + } + + public function search(Request $request): View + { + + $query = $request->input('q', ''); + $selected_year = $request->input('year', Carbon::now()->year); + + $country_iso = $request->input('country_iso', null); + $tag = $request->input('tag', ''); + + $selected_country = []; + + if (! is_null($country_iso)) { + $country = Country::where('iso', $country_iso)->first(); + if ($country) { + $country->translation = __('countries.'.$country->name); + $selected_country[] = $country; + } + + } + + $current_year = Carbon::now()->year; + $years = []; + for ($year = $current_year; $year >= 2014; $year--) { + $years[] = $year; + } + + return view('event.search', compact(['query', 'years', 'selected_country', 'selected_year', 'tag'])); + } + + public function searchPOST(EventFilters $filters, Request $request) + { + $events = $this->getEvents($filters); + + //Log::info($request->input('page')); + if ($request->input('page')) { + $result = [$events]; + } else { + Log::info('no page'); + $eventsMap = $this->getAllEventsToMap($filters); + $result = [$events, $eventsMap]; + } + + return $result; + } + + protected function getEvents(EventFilters $filters) + { + + $events = Event::where('status', 'like', 'APPROVED') + ->filter($filters) + ->orderBy('start_date') + ->get() + ->groupBy(function ($event) { + if ($event->start_date <= Carbon::today()) { + return 'past'; + } + + return 'future'; + }); + + if (is_null($events->get('future')) || is_null($events->get('past'))) { + return $events->flatten()->paginate(12); + } + + return $events->get('future')->merge($events->get('past'))->paginate(12); + + } + + protected function getAllEventsToMap(EventFilters $filters) + { + + $flattened = Arr::flatten($filters->getFilters()); + + $composed_key = ''; + + foreach ($flattened as $value) { + $composed_key .= $value.','; + } + + $value = Cache::get($composed_key, function () use ($composed_key, $filters) { + Log::info("Building cache [{$composed_key}]"); + $events = Event::where('status', 'like', 'APPROVED') + ->filter($filters) + ->get(); + + $events = $this->eventTransformer->transformCollection($events); + + $events = $events->groupBy('country'); + + Cache::put($composed_key, $events, 5 * 60); + + return $events; + }); + + Log::info("Serving from cache [{$composed_key}]"); + + return $value; + + } +} diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php old mode 100755 new mode 100644 index b1d9f5c7f..b6725b478 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -1,127 +1,13 @@ -eventTransformer = $eventTransformer; - } - - public function search(Request $request): View - { - - $query = $request->input('q', ''); - $selected_year = $request->input('year', Carbon::now()->year); - - $country_iso = $request->input('country_iso', null); - $tag = $request->input('tag', ''); - - $selected_country = []; - - if (! is_null($country_iso)) { - $country = Country::where('iso', $country_iso)->first(); - if ($country) { - $country->translation = __('countries.'.$country->name); - $selected_country[] = $country; - } - - } - - $current_year = Carbon::now()->year; - $years = []; - for ($year = $current_year; $year >= 2014; $year--) { - $years[] = $year; - } - - return view('event.search', compact(['query', 'years', 'selected_country', 'selected_year', 'tag'])); - } - - public function searchPOST(EventFilters $filters, Request $request) - { - $events = $this->getEvents($filters); - - //Log::info($request->input('page')); - if ($request->input('page')) { - $result = [$events]; - } else { - Log::info('no page'); - $eventsMap = $this->getAllEventsToMap($filters); - $result = [$events, $eventsMap]; - } - - return $result; - } - - protected function getEvents(EventFilters $filters) + public function index() { - - $events = Event::where('status', 'like', 'APPROVED') - ->filter($filters) - ->orderBy('start_date') - ->get() - ->groupBy(function ($event) { - if ($event->start_date <= Carbon::today()) { - return 'past'; - } - - return 'future'; - }); - - if (is_null($events->get('future')) || is_null($events->get('past'))) { - return $events->flatten()->paginate(12); - } - - return $events->get('future')->merge($events->get('past'))->paginate(12); - - } - - protected function getAllEventsToMap(EventFilters $filters) - { - - $flattened = Arr::flatten($filters->getFilters()); - - $composed_key = ''; - - foreach ($flattened as $value) { - $composed_key .= $value.','; - } - - $value = Cache::get($composed_key, function () use ($composed_key, $filters) { - Log::info("Building cache [{$composed_key}]"); - $events = Event::where('status', 'like', 'APPROVED') - ->filter($filters) - ->get(); - - $events = $this->eventTransformer->transformCollection($events); - - $events = $events->groupBy('country'); - - Cache::put($composed_key, $events, 5 * 60); - - return $events; - }); - - Log::info("Serving from cache [{$composed_key}]"); - - return $value; - + return view('static.search'); } -} +} \ No newline at end of file diff --git a/app/Livewire/SearchContentComponent.php b/app/Livewire/SearchContentComponent.php new file mode 100644 index 000000000..33aa9ca2f --- /dev/null +++ b/app/Livewire/SearchContentComponent.php @@ -0,0 +1,30 @@ + ['except' => ''], + ]; + + public function render() + { + $results = collect(); // Initialize an empty collection + + if ($this->searchQuery) { + $results = Podcast::active() + ->where('title', 'like', '%' . $this->searchQuery . '%') + ->get(); // get() returns a collection + } + + return view('livewire.search-content-component', [ + 'results' => $results, + ]); + } +} \ No newline at end of file diff --git a/public/build/manifest.json b/public/build/manifest.json deleted file mode 100644 index 1575ff596..000000000 --- a/public/build/manifest.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "resources/assets/sass/app.scss": { - "file": "assets/app-Bk4IeqgE.css", - "src": "resources/assets/sass/app.scss", - "isEntry": true - }, - "resources/css/app.css": { - "file": "assets/app-CqcMzzla.css", - "src": "resources/css/app.css", - "isEntry": true - }, - "resources/js/app.js": { - "file": "assets/app-BYTeXSp6.js", - "name": "app", - "src": "resources/js/app.js", - "isEntry": true, - "dynamicImports": [ - "resources/lang/php_al.json", - "resources/lang/php_ba.json", - "resources/lang/php_bg.json", - "resources/lang/php_cs.json", - "resources/lang/php_da.json", - "resources/lang/php_de.json", - "resources/lang/php_el.json", - "resources/lang/php_en.json", - "resources/lang/php_es.json", - "resources/lang/php_et.json", - "resources/lang/php_fi.json", - "resources/lang/php_fr.json", - "resources/lang/php_hr.json", - "resources/lang/php_hu.json", - "resources/lang/php_it.json", - "resources/lang/php_lt.json", - "resources/lang/php_lv.json", - "resources/lang/php_me.json", - "resources/lang/php_mk.json", - "resources/lang/php_mt.json", - "resources/lang/php_nl.json", - "resources/lang/php_pl.json", - "resources/lang/php_pt.json", - "resources/lang/php_ro.json", - "resources/lang/php_rs.json", - "resources/lang/php_sk.json", - "resources/lang/php_sl.json", - "resources/lang/php_sv.json", - "resources/lang/php_tr.json", - "resources/lang/php_ua.json" - ], - "css": [ - "assets/app-B6V_wt1S.css" - ] - }, - "resources/lang/php_al.json": { - "file": "assets/php_al-CTMA073o.js", - "name": "php_al", - "src": "resources/lang/php_al.json", - "isDynamicEntry": true - }, - "resources/lang/php_ba.json": { - "file": "assets/php_ba-B-bm2W_u.js", - "name": "php_ba", - "src": "resources/lang/php_ba.json", - "isDynamicEntry": true - }, - "resources/lang/php_bg.json": { - "file": "assets/php_bg-Bp_JSgh3.js", - "name": "php_bg", - "src": "resources/lang/php_bg.json", - "isDynamicEntry": true - }, - "resources/lang/php_cs.json": { - "file": "assets/php_cs-vBIPLxwX.js", - "name": "php_cs", - "src": "resources/lang/php_cs.json", - "isDynamicEntry": true - }, - "resources/lang/php_da.json": { - "file": "assets/php_da-BvCTaOK1.js", - "name": "php_da", - "src": "resources/lang/php_da.json", - "isDynamicEntry": true - }, - "resources/lang/php_de.json": { - "file": "assets/php_de-BzFjuUAc.js", - "name": "php_de", - "src": "resources/lang/php_de.json", - "isDynamicEntry": true - }, - "resources/lang/php_el.json": { - "file": "assets/php_el-BUcmEI9B.js", - "name": "php_el", - "src": "resources/lang/php_el.json", - "isDynamicEntry": true - }, - "resources/lang/php_en.json": { - "file": "assets/php_en-L--1S7AX.js", - "name": "php_en", - "src": "resources/lang/php_en.json", - "isDynamicEntry": true - }, - "resources/lang/php_es.json": { - "file": "assets/php_es-AQitKYM6.js", - "name": "php_es", - "src": "resources/lang/php_es.json", - "isDynamicEntry": true - }, - "resources/lang/php_et.json": { - "file": "assets/php_et-DNo2kFwz.js", - "name": "php_et", - "src": "resources/lang/php_et.json", - "isDynamicEntry": true - }, - "resources/lang/php_fi.json": { - "file": "assets/php_fi-Q91gCbBI.js", - "name": "php_fi", - "src": "resources/lang/php_fi.json", - "isDynamicEntry": true - }, - "resources/lang/php_fr.json": { - "file": "assets/php_fr-CLD_O7zr.js", - "name": "php_fr", - "src": "resources/lang/php_fr.json", - "isDynamicEntry": true - }, - "resources/lang/php_hr.json": { - "file": "assets/php_hr-CwOypjAU.js", - "name": "php_hr", - "src": "resources/lang/php_hr.json", - "isDynamicEntry": true - }, - "resources/lang/php_hu.json": { - "file": "assets/php_hu-CdCTJ55X.js", - "name": "php_hu", - "src": "resources/lang/php_hu.json", - "isDynamicEntry": true - }, - "resources/lang/php_it.json": { - "file": "assets/php_it-B5bkY6OV.js", - "name": "php_it", - "src": "resources/lang/php_it.json", - "isDynamicEntry": true - }, - "resources/lang/php_lt.json": { - "file": "assets/php_lt-BdXylXoJ.js", - "name": "php_lt", - "src": "resources/lang/php_lt.json", - "isDynamicEntry": true - }, - "resources/lang/php_lv.json": { - "file": "assets/php_lv-Da1g3-oP.js", - "name": "php_lv", - "src": "resources/lang/php_lv.json", - "isDynamicEntry": true - }, - "resources/lang/php_me.json": { - "file": "assets/php_me-BYUA1Z4b.js", - "name": "php_me", - "src": "resources/lang/php_me.json", - "isDynamicEntry": true - }, - "resources/lang/php_mk.json": { - "file": "assets/php_mk-DysHXhvC.js", - "name": "php_mk", - "src": "resources/lang/php_mk.json", - "isDynamicEntry": true - }, - "resources/lang/php_mt.json": { - "file": "assets/php_mt-BHqCbEC3.js", - "name": "php_mt", - "src": "resources/lang/php_mt.json", - "isDynamicEntry": true - }, - "resources/lang/php_nl.json": { - "file": "assets/php_nl-sKqgism8.js", - "name": "php_nl", - "src": "resources/lang/php_nl.json", - "isDynamicEntry": true - }, - "resources/lang/php_pl.json": { - "file": "assets/php_pl-yeqGbtgn.js", - "name": "php_pl", - "src": "resources/lang/php_pl.json", - "isDynamicEntry": true - }, - "resources/lang/php_pt.json": { - "file": "assets/php_pt-jC-pz6b0.js", - "name": "php_pt", - "src": "resources/lang/php_pt.json", - "isDynamicEntry": true - }, - "resources/lang/php_ro.json": { - "file": "assets/php_ro-BFabPsiG.js", - "name": "php_ro", - "src": "resources/lang/php_ro.json", - "isDynamicEntry": true - }, - "resources/lang/php_rs.json": { - "file": "assets/php_rs-Cd9pUlhp.js", - "name": "php_rs", - "src": "resources/lang/php_rs.json", - "isDynamicEntry": true - }, - "resources/lang/php_sk.json": { - "file": "assets/php_sk-CeePtAnh.js", - "name": "php_sk", - "src": "resources/lang/php_sk.json", - "isDynamicEntry": true - }, - "resources/lang/php_sl.json": { - "file": "assets/php_sl-V4TCb-sd.js", - "name": "php_sl", - "src": "resources/lang/php_sl.json", - "isDynamicEntry": true - }, - "resources/lang/php_sv.json": { - "file": "assets/php_sv-D0hzzsWo.js", - "name": "php_sv", - "src": "resources/lang/php_sv.json", - "isDynamicEntry": true - }, - "resources/lang/php_tr.json": { - "file": "assets/php_tr-BAj1PB-h.js", - "name": "php_tr", - "src": "resources/lang/php_tr.json", - "isDynamicEntry": true - }, - "resources/lang/php_ua.json": { - "file": "assets/php_ua-DgvW0kYz.js", - "name": "php_ua", - "src": "resources/lang/php_ua.json", - "isDynamicEntry": true - } -} \ No newline at end of file diff --git a/public/images/search/searchbg.png b/public/images/search/searchbg.png new file mode 100644 index 000000000..4fc54be8b Binary files /dev/null and b/public/images/search/searchbg.png differ diff --git a/public/images/search/searchlg.png b/public/images/search/searchlg.png new file mode 100644 index 000000000..9168ae0e5 Binary files /dev/null and b/public/images/search/searchlg.png differ diff --git a/public/images/search/searchsm.png b/public/images/search/searchsm.png new file mode 100644 index 000000000..1bca3e919 Binary files /dev/null and b/public/images/search/searchsm.png differ diff --git a/resources/assets/sass/components/banner.scss b/resources/assets/sass/components/banner.scss index 3e2615a02..886f95a17 100644 --- a/resources/assets/sass/components/banner.scss +++ b/resources/assets/sass/components/banner.scss @@ -142,6 +142,9 @@ .codeweek-banner.about{ background-color: #72A8D0; } +.codeweek-banner.search{ + background-color: #164194; +} .codeweek-banner.error{ background-color: #e57373; } diff --git a/resources/js/components/SearchPageComponent.vue b/resources/js/components/SearchPageComponent.vue index 17e0b8cba..24e5a48df 100644 --- a/resources/js/components/SearchPageComponent.vue +++ b/resources/js/components/SearchPageComponent.vue @@ -1,5 +1,5 @@