Add meilisearch support

This commit is contained in:
Amanmyrat 2023-05-10 11:46:17 +05:00
parent ad377e673e
commit 3287e4e45b
27 changed files with 1178 additions and 1081 deletions

View File

@ -8,7 +8,9 @@
"php": "^8.0.2",
"october/rain": "^3.3",
"laravel/framework": "^9.0",
"october/all": "^3.1"
"october/all": "^3.1",
"laravel/scout": "^10.1",
"meilisearch/meilisearch-php": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^8.5|^9.0"
@ -36,7 +38,8 @@
"config": {
"preferred-install": "dist",
"allow-plugins": {
"composer/installers": true
"composer/installers": true,
"php-http/discovery": true
}
},
"autoload": {

147
config/scout.php Normal file
View File

@ -0,0 +1,147 @@
<?php
use Indikator\News\Models\Posts;
return [
/*
|--------------------------------------------------------------------------
| Default Search Engine
|--------------------------------------------------------------------------
|
| This option controls the default search connection that gets used while
| using Laravel Scout. This connection is used when syncing all models
| to the search service. You should adjust this based on your needs.
|
| Supported: "algolia", "meilisearch", "database", "collection", "null"
|
*/
'driver' => env('SCOUT_DRIVER', 'algolia'),
/*
|--------------------------------------------------------------------------
| Index Prefix
|--------------------------------------------------------------------------
|
| Here you may specify a prefix that will be applied to all search index
| names used by Scout. This prefix may be useful if you have multiple
| "tenants" or applications sharing the same search infrastructure.
|
*/
'prefix' => env('SCOUT_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Queue Data Syncing
|--------------------------------------------------------------------------
|
| This option allows you to control if the operations that sync your data
| with your search engines are queued. When this is set to "true" then
| all automatic data syncing will get queued for better performance.
|
*/
'queue' => env('SCOUT_QUEUE', false),
/*
|--------------------------------------------------------------------------
| Database Transactions
|--------------------------------------------------------------------------
|
| This configuration option determines if your data will only be synced
| with your search indexes after every open database transaction has
| been committed, thus preventing any discarded data from syncing.
|
*/
'after_commit' => false,
/*
|--------------------------------------------------------------------------
| Chunk Sizes
|--------------------------------------------------------------------------
|
| These options allow you to control the maximum chunk size when you are
| mass importing data into the search engine. This allows you to fine
| tune each of these chunk sizes based on the power of the servers.
|
*/
'chunk' => [
'searchable' => 500,
'unsearchable' => 500,
],
/*
|--------------------------------------------------------------------------
| Soft Deletes
|--------------------------------------------------------------------------
|
| This option allows to control whether to keep soft deleted records in
| the search indexes. Maintaining soft deleted records can be useful
| if your application still needs to search for the records later.
|
*/
'soft_delete' => false,
/*
|--------------------------------------------------------------------------
| Identify User
|--------------------------------------------------------------------------
|
| This option allows you to control whether to notify the search engine
| of the user performing the search. This is sometimes useful if the
| engine supports any analytics based on this application's users.
|
| Supported engines: "algolia"
|
*/
'identify' => env('SCOUT_IDENTIFY', false),
/*
|--------------------------------------------------------------------------
| Algolia Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Algolia settings. Algolia is a cloud hosted
| search engine which works great with Scout out of the box. Just plug
| in your application ID and admin API key to get started searching.
|
*/
'algolia' => [
'id' => env('ALGOLIA_APP_ID', ''),
'secret' => env('ALGOLIA_SECRET', ''),
],
/*
|--------------------------------------------------------------------------
| Meilisearch Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Meilisearch settings. Meilisearch is an open
| source search engine with minimal configuration. Below, you can state
| the host and key information for your own Meilisearch installation.
|
| See: https://docs.meilisearch.com/guides/advanced_guides/configuration.html
|
*/
'meilisearch' => [
'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
'key' => env('MEILISEARCH_KEY'),
'index-settings' => [
Posts::class => [
'sortableAttributes' => ['published_at','created_at','updated_at'],
],
// 'users' => [
// 'filterableAttributes'=> ['id', 'name', 'email'],
// ],
],
],
];

View File

@ -1,5 +1,8 @@
<?php namespace Indikator\News\Models;
use Event;
use Lang;
use Laravel\Scout\Searchable;
use Model;
use BackendAuth;
use Carbon\Carbon;
@ -7,6 +10,9 @@ use Cms\Classes\Page as CmsPage;
use Indikator\News\Models\Categories as NewsCategories;
use Db;
use App;
use October\Rain\Database\Traits\Sluggable;
use October\Rain\Database\Traits\Validation;
use October\Rain\Router\Router;
use Str;
use Url;
// require "plugins\\donatello-za\\rake-php-plus\\src\\RakePlus.php";
@ -24,8 +30,9 @@ use October\Rain\Support\Facades\Config;
class Posts extends Model
{
use \October\Rain\Database\Traits\Sluggable;
use \October\Rain\Database\Traits\Validation;
use Sluggable;
use Validation;
use Searchable;
public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel'];
@ -148,6 +155,21 @@ class Posts extends Model
]
];
/**
* Get the indexable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
return [
'title' => $this->title,
'slug'=> $this->slug,
'introductory'=> $this->introductory,
'content'=> $this->content
];
}
public $preview = null;
public function getSendAttribute() {
@ -416,7 +438,7 @@ class Posts extends Model
public function duplicate($post)
{
$clone = new Posts();
$clone->title = \Lang::get('indikator.news::lang.form.clone_of').' '.$post->title;
$clone->title = Lang::get('indikator.news::lang.form.clone_of').' '.$post->title;
$clone->slug = $post->slug.'-'.now()->format('Y-m-d-h-i-s');
$clone->status = 3;
$clone->introductory = $post->introductory;
@ -434,7 +456,7 @@ class Posts extends Model
$clone->save();
\Event::fire('indikator.news.posts.duplicate', [&$clone, $post]);
Event::fire('indikator.news.posts.duplicate', [&$clone, $post]);
return $clone;
}
@ -605,7 +627,7 @@ class Posts extends Model
$page->rewriteTranslatablePageUrl($locale);
$params = ['category' => $item->getCategory()['slug'], 'id' => $item->id, 'slug' => $item->slug];
$router = new \October\Rain\Router\Router;
$router = new Router;
$localeUrl = $router->urlFromPattern($page->url, $params);
return url($locale.$localeUrl);

View File

@ -34,15 +34,14 @@ forceUrl = 1
</body>
<script src="{{ ['assets/js/jquery.js', 'assets/js/moment.min.js', 'assets/js/slick.min.js', 'assets/js/news-slider.js',
'assets/js/jquery.fancybox.min.js', 'assets/js/main.js']|theme }}"></script>
{% framework %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BGT89NCBQC"></script>
<script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BGT89NCBQC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BGT89NCBQC');
</script>
</script>
</html>

View File

@ -46,13 +46,14 @@ forceUrl = 1
{% framework %}
<!-- <script src="{{ 'assets/js/main.js'|theme }}"></script> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BGT89NCBQC"></script>
<script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BGT89NCBQC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BGT89NCBQC');
</script>
</script>
</html>

View File

@ -15,4 +15,4 @@ is_hidden = 0
</div>
</div>
</div>
</section>
</section>

View File

@ -282,4 +282,4 @@ is_hidden = 0
</div>
</div>
</div>
</div>

View File

@ -11,26 +11,26 @@ localeUrl[en] = "/archive"
==
<?php
function onStart(){
if(input("date")){
$this['todayNews'] = \Indikator\News\Models\Posts::whereDate('published_at', '=', input("date"))->where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->orderBy('created_at', 'desc')->get();
$this['todayNews'] = \Indikator\News\Models\Posts::whereDate('published_at', '=', input("date"))
->where("locale", App::getLocale())->where("status", 1)
->where("category_id", "!=", $this->theme->colleagues_news)
->orderBy('created_at', 'desc')->get();
}else{
$this['todayNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->orderBy('published_at', 'desc')->take(6)->get();
$this['todayNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)
->orderBy('published_at', 'desc')
->take(6)->get();
}
$this['dateToday'] = input("date");
}
}
?>
==
<section class="section" id="intro">
<div class="auto_container">
<div class="which_page">
<a href="{{ 'index'|page}}">
<div class="page_name">
{{'Главная'|_}}
</div>
@ -92,9 +92,9 @@ function onStart(){
<script src="{{ 'assets/js/moment.min.js'|theme }}"></script>
<script src="{{ 'assets/js/lightpick.js'|theme }}"></script>
<script>;
<script>
var picker = new Lightpick({
let picker = new Lightpick({
inline: true,
selectBackward: true,
selectForward: false,

View File

@ -21,9 +21,13 @@ categoryPage = "category"
==
<?php
function onStart(){
$this["category"] = $this->param('slug');
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->whereNotIn('category_id', [20,21,22])->orderBy('published_at', 'desc')->limit(6)->get();
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)
->whereNotIn('category_id', [20,21,22])
->orderBy('published_at', 'desc')
->limit(6)->get();
}
@ -40,7 +44,6 @@ function onEnd(){
<div class="auto_container">
<div class="which_page">
<a href="{{ 'index'|page}}">
<div class="page_name">
{{'Главная'|_}}
</div>

View File

@ -5,10 +5,7 @@ is_hidden = 0
==
<?php
function onStart(){
$this["channel"] = $this->param('slug');
}
?>
==
@ -76,7 +73,7 @@ function onStart(){
<script src="{{ 'assets/js/plyr.js'|theme }}"></script>
<script>
var channel = '{{ channel }}'
let channel = '{{ channel }}'
switch(channel) {
case "altyn_asyr":
@ -101,21 +98,16 @@ function onStart(){
Altynasyr();
}
function Altynasyr() {
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch001.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch001.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch001.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -128,21 +120,19 @@ function onStart(){
plyr.setup(video);
});
}
});
};
});
}
function Yaslyk() {
console.log(channel);
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch002.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch002.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch002.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -155,8 +145,8 @@ function Yaslyk() {
plyr.setup(video);
});
}
});
};
});
}
@ -164,13 +154,13 @@ function Yaslyk() {
function Miras() {
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch003.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch003.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch003.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -183,19 +173,19 @@ function Miras() {
plyr.setup(video);
});
}
});
};
});
}
function Sport() {
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch004.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch004.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch004.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -208,19 +198,19 @@ function Sport() {
plyr.setup(video);
});
}
});
};
});
}
function Owaz() {
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch005.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch005.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch005.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -233,19 +223,19 @@ function Owaz() {
plyr.setup(video);
});
}
});
};
});
}
function Ashgabat() {
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch006.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch006.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch006.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -258,20 +248,20 @@ function Ashgabat() {
plyr.setup(video);
});
}
});
};
});
}
function Turkmenistan() {
$(function() {
var video_source = 'http://alpha.tv.online.tm/hls/ch007.m3u8';
let video_source = 'http://alpha.tv.online.tm/hls/ch007.m3u8';
if (location.protocol == 'https:') {
video_source = 'https://alpha.tv.online.tm/hls/ch007.m3u8';
}
var video = document.getElementById('webtv-video');
let video = document.getElementById('webtv-video');
if(Hls.isSupported()) {
var hls = new Hls();
let hls = new Hls();
hls.loadSource(video_source);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
@ -284,8 +274,8 @@ function Turkmenistan() {
plyr.setup(video);
});
}
});
};
});
}
</script>

View File

@ -3,22 +3,6 @@ url = "/contact"
layout = "default"
is_hidden = 0
==
<?php
public function onSend(){
$vars = ['name' => Input::get('name') , 'email' => Input::get('email')];
Mail::send('admin.contact::mail.message', $vars, function($message) {
$message->to('tekemuradov@gmail.com', 'Admin Person');
$message->subject(Input::get('theme'));
});
}
?>
==
<section class="section" id="intro">
<div class="auto_container">
<div class="which_page">

View File

@ -19,8 +19,11 @@ function onStart(){
$gallery = Admin\Photos\Models\Photo::orderBy("date",'desc')->paginate(10);
$this['gallery'] = $gallery;
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->whereNotIn('category_id', [20,21,22])->orderBy('published_at', 'desc')->limit(6)->get();
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)
->where("category_id", "!=", $this->theme->colleagues_news)
->whereNotIn('category_id', [20,21,22])
->orderBy('published_at', 'desc')
->limit(6)->get();
}
?>
@ -29,7 +32,6 @@ function onStart(){
<div class="auto_container">
<div class="which_page">
<a href="{{ 'index'|page}}">
<div class="page_name">
{{'Главная'|_}}
</div>
@ -71,14 +73,9 @@ function onStart(){
</div>
</div>
</div>
{% endfor %}
</div>
{% if gallery.total > 10 %}
<div class="section_end">
<div class="page_num">

View File

@ -26,46 +26,49 @@ protected $translator;
function onStart()
{
$this['currentLanguage'] = $this->activeLocale;
// featured news
$this->translator = Translator::instance();
$this['SelectedLanguage'] = $this->activeLocale = $this->translator->getLocale();
$featured = \Indikator\News\Models\Posts::where("featured", true)->where("locale", App::getLocale())->where("status", 1)->orderBy('published_at', 'desc')->get()->first();
// featured news
$featured = \Indikator\News\Models\Posts::where("featured", true)
->where("locale", App::getLocale())->where("status", 1)
->orderBy('published_at', 'desc')
->get()->first();
$this['postFeatured'] = $featured;
if($featured->image){
//$this['imageType'] = $featured->getImageDetails($featured->images->last->path->disk_name);
$this['imageType'] = $featured->image[0]["type"];
}
// end featured news
// last news
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->whereNotIn('category_id', [20,21,22])->orderBy('published_at', 'desc')->limit(10)->get();
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)
->where("category_id", "!=", $this->theme->colleagues_news)
->whereNotIn('category_id', [20,21,22])
->orderBy('published_at', 'desc')
->limit(10)->get();
// end last news
// collegue News
$this['collegueNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", $this->theme->colleagues_news)->orderBy('published_at', 'desc')->limit(9)->get();
$this['collegueNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)
->where("category_id", $this->theme->colleagues_news)
->orderBy('published_at', 'desc')
->limit(9)->get();
$this["collegueNews_cat"] = \Indikator\News\Models\Categories::where("id", $this->theme->colleagues_news)->first();
// end collegue News
// intro news 3rd column
$this['intro_cat_news'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", $this->theme->intro_cat_news)->orderBy('published_at', 'desc')->limit(10)->get();
$this['intro_cat_news'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)
->where("category_id", $this->theme->intro_cat_news)
->orderBy('published_at', 'desc')->limit(10)->get();
$this["intro_cat"] = \Indikator\News\Models\Categories::where("id", $this->theme->intro_cat_news)->first();
// end intro new
}
@ -73,10 +76,6 @@ function onStart()
==
{% set CurrentLanguage = SelectedLanguage %}
<!-- Intro ===================== -->
{% partial 'home_intro' %}
<!-- partial 'year_category' -->
{% partial 'home_categories' %}

View File

@ -20,12 +20,14 @@ function onStart()
{
$this['currentLanguage'] = $this->activeLocale;
// featured news
$this->translator = Translator::instance();
$this['SelectedLanguage'] = $this->activeLocale = $this->translator->getLocale();
$featured = \Indikator\News\Models\Posts::where("featured", true)->where("locale", App::getLocale())
->where("status", 1)->orderBy('published_at', 'desc')
// featured news
$featured = \Indikator\News\Models\Posts::where("featured", true)
->where("locale", App::getLocale())
->where("status", 1)
->orderBy('published_at', 'desc')
->get()->first();
$this['postFeatured'] = $featured;
@ -38,7 +40,9 @@ function onStart()
// last news
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)
->whereNotIn('category_id', [20,21,22])->orderBy('published_at', 'desc')->limit(10)->get();
->whereNotIn('category_id', [20,21,22])
->orderBy('published_at', 'desc')
->limit(10)->get();
// end last news
$this['partners'] = \Admin\Partners\Models\Partner::where('type', 'partner')->get();
@ -47,7 +51,8 @@ function onStart()
// intro news 3rd column
$this['intro_cat_news'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)->where("category_id", $this->theme->intro_cat_news)
->orderBy('published_at', 'desc')->limit(10)->get();
->orderBy('published_at', 'desc')
->limit(10)->get();
$this["intro_cat"] = \Indikator\News\Models\Categories::where("id", $this->theme->intro_cat_news)->first();
// end intro new

View File

@ -8,7 +8,7 @@ is_hidden = 0
<p>google <a href="https://play.google.com/store/apps/details?id=com.tpsadvertising.digital.tdh">play market</a></p>
<p>apple <a href="https://apps.apple.com/ru/app/tdh-%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8/id1554832462">app store</a></p>
<script>
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
let userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Windows Phone must come first because its UA also contains "Android"
if (/windows phone/i.test(userAgent)) {
@ -24,4 +24,4 @@ is_hidden = 0
location.replace('https://apps.apple.com/ru/app/tdh-%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8/id1554832462');
}
</script>
</script>

View File

@ -9,9 +9,11 @@ id = "{{ :id }}"
==
<?php
function onStart(){
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->whereNotIn('category_id', [20,21,22])->orderBy('published_at', 'desc')->limit(10)->get();
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)
->whereNotIn('category_id', [20,21,22])
->orderBy('published_at', 'desc')
->limit(10)->get();
}
?>
==
@ -21,7 +23,6 @@ function onStart(){
<div class="auto_container">
<div class="which_page">
<a href="{{ 'index'|page}}" class="page_name">
<div>
{{'Главная'|_}}
</div>
@ -40,8 +41,6 @@ function onStart(){
</div>
</div>
<div class="section_wrapper">
<div class="center">
<div class="title">
{{ post.category.name }}
@ -125,8 +124,6 @@ function onStart(){
<p class="para_text">
{{ post.content|raw }}
</p>
</div>
</div>
<div class="right_side break">

View File

@ -9,27 +9,14 @@ localeTitle[en] = "Search"
localeUrl[ru] = "/search"
localeUrl[en] = "/search"
[newsPosts]
pageNumber = "{{ :page }}"
postsPerPage = 10
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
postFeatured = 0
postPage = "archive"
categoryPage = "archive"
==
<?php
function onStart(){
$this['search_results'] = \Indikator\News\Models\Posts::search(
input("query"))->orderBy('published_at', 'desc')->paginate(10);
//$this['search_results'] = \Indikator\News\Models\Posts::searchWhere(input("q"))->where("locale", App::getLocale())->orderBy('created_at', 'desc')->paginate(10);
//$search_results = \Indikator\News\Models\Posts::searchWhere(input("search"))->orderBy('created_at', 'desc')->get();
//dd($search_results);
$this['query'] = input('q');
}
$this['query'] = input("query");
}
?>
==
<section class="section" id="intro">
@ -52,7 +39,7 @@ function onStart(){
{{'Результат поиска'|_}}
</div>
<div class="main_news">
{% for item in newsPosts.posts %}
{% for item in search_results %}
<div class="main_news-item">
<div class="main_news-date">
<span>
@ -76,29 +63,28 @@ function onStart(){
</div>
</div>
{% endfor %}
</div>
{% if newsPosts.posts.total > 10 %}
{% if search_results.total > 10 %}
<div class="section_end">
<div class="page_num">
<a href="{{newsPosts.posts.previousPageUrl}}{{'&q='~query}}">
<a href="{{search_results.previousPageUrl}}">
<div class="direct_btn">
<img src="{{ 'assets/images/left.svg'|theme }}" alt="">
</div>
</a>
<form action="" method="GET">
<input type="text" name="page" value="{{newsPosts.posts.currentPage}}" class="input_page">
<input type="hidden" name="query" value="{{query}}" />
<input type="text" name="page" value="{{search_results.currentPage}}" class="input_page">
</form>
<a href="{{newsPosts.posts.nextPageUrl}}{{'&q='~query}}">
<a href="{{search_results.nextPageUrl}}">
<div class="direct_btn">
<img src="{{ 'assets/images/right.svg'|theme }}" alt="">
</div>
</a>
</div>
<div class="page_list">
{{(newsPosts.posts.total/newsPosts.posts.perPage)|round(0,"ceil")}} {{'страниц'|_}}
{{(search_results.total/search_results.perPage)|round(0,"ceil")}} {{'страниц'|_}}
</div>
</div>
{% endif %}
@ -109,14 +95,14 @@ function onStart(){
</div>
<form class="form" method="GET">
<div class="input">
<input type="text" name="q" placeholder="Поиск">
<input type="text" name="query" placeholder="Поиск">
</div>
<button class="search">
<img src="{{ 'assets/images/lupa.svg'|theme }}" alt="">
</button>
</form>
<div class="found_news">
{{'По вашему запросу было найдено'|_}} <span class="quantity_num">{{newsPosts.posts.total}}</span> {{'статей'|_}}
{{'По вашему запросу было найдено'|_}} <span class="quantity_num">{{search_results.total}}</span> {{'статей'|_}}
</div>
</div>
</div>

View File

@ -15,12 +15,14 @@ localeMeta_description[en] = "Top news of Turkmenistan. News by tag Video Report
==
<?php
function onStart(){
$this['videos'] = Admin\Videos\Models\Video::orderBy('date','desc')->paginate(10);
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)->whereNotIn('category_id', [20,21,22])->orderBy('published_at', 'desc')->limit(6)->get();
$this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)
->where("category_id", "!=", $this->theme->colleagues_news)
->whereNotIn('category_id', [20,21,22])
->orderBy('published_at', 'desc')
->limit(6)->get();
}
?>
==
@ -51,9 +53,6 @@ function onStart(){
<div class="gallery_video" data-src="{{item.video[0].path}}">
<img src="{{item.image[0].thumb(350, auto)}}" alt="">
<!-- <div class="video_view" data-src="{{item.video[0].path}}">
{{'Просмотреть'|_}}
</div> -->
</div>
<div class="player_bg">
<div class="player">
@ -71,8 +70,6 @@ function onStart(){
<input type="range" name="volume" class="player__slider" min="0" max="1"
step="0.05" value="1">
</div>
<button class="player__button fullscreen bigger" title="FullScreen">🞕</button>
</div>
</div>
@ -145,77 +142,73 @@ function onStart(){
<script>
// Video Player
const video = document.querySelector('.viewer');
const toggle = document.querySelector('.toggle');
const volume = document.querySelector('.volume');
const skipButtons = document.querySelectorAll('[data-skip]');
const ranges = document.querySelectorAll('.player__slider');
const progress = document.querySelector('.progress');
const progressBar = document.querySelector('.progress__filled');
const fullscreen = document.querySelector('.fullscreen');
// Video Player
const video = document.querySelector('.viewer');
const toggle = document.querySelector('.toggle');
const volume = document.querySelector('.volume');
const skipButtons = document.querySelectorAll('[data-skip]');
const ranges = document.querySelectorAll('.player__slider');
const progress = document.querySelector('.progress');
const progressBar = document.querySelector('.progress__filled');
const fullscreen = document.querySelector('.fullscreen');
// defining functions
function togglePlay() {
// defining functions
function togglePlay() {
// toggle for video play and pause
const playOrPause = video.paused ? 'play' : 'pause';
video[playOrPause]();
// toggle for icon change when play or pause
playOrPause === 'play' ? toggle.textContent = '❚ ❚' : toggle.textContent = '►';
}
}
function skip() {
function skip() {
// add or substract the skip time to current time of video
video.currentTime += parseFloat(this.dataset.skip);
}
}
function handleRangeChange() {
function handleRangeChange() {
// Change the video's range value
video[this.name] = this.value;
}
}
function handleProgress() {
function handleProgress() {
// convert video's current time into percentage
const percent = (video.currentTime / video.duration) * 100;
// append it to the flexBasis property (CSS)
progressBar.style.flexBasis = `${percent}%`;
}
}
function scrub(e) {
const scrubTime = (e.offsetX / progress.offsetWidth) * video.duration;
video.currentTime = scrubTime;
}
function scrub(e) {
video.currentTime = (e.offsetX / progress.offsetWidth) * video.duration;
}
function handleFullScreen() {
function handleFullScreen() {
video.requestFullscreen();
}
}
// Play or Pause events(On video click)
video.addEventListener('click', togglePlay);
// (On button click)
toggle.addEventListener('click', togglePlay);
// Play or Pause events(On video click)
video.addEventListener('click', togglePlay);
// (On button click)
toggle.addEventListener('click', togglePlay);
// skipping video back and forth
skipButtons.forEach(button => button.addEventListener('click', skip));
// skipping video back and forth
skipButtons.forEach(button => button.addEventListener('click', skip));
// volume or fast forward events
ranges.forEach(range => range.addEventListener('change', handleRangeChange));
// volume or fast forward events
ranges.forEach(range => range.addEventListener('change', handleRangeChange));
// Change progress wrt time
video.addEventListener('timeupdate', handleProgress);
// event on clicking progress bar
let mouseDown = false;
progress.addEventListener('click', scrub);
progress.addEventListener('mousemove', (e) => mouseDown && scrub(e));
progress.addEventListener('mousedown', () => mouseDown = true);
progress.addEventListener('mouseup', () => mouseDown = false);
// add full screen event
fullscreen.addEventListener('click', handleFullScreen);
// Change progress wrt time
video.addEventListener('timeupdate', handleProgress);
// event on clicking progress bar
let mouseDown = false;
progress.addEventListener('click', scrub);
progress.addEventListener('mousemove', (e) => mouseDown && scrub(e));
progress.addEventListener('mousedown', () => mouseDown = true);
progress.addEventListener('mouseup', () => mouseDown = false);
// add full screen event
fullscreen.addEventListener('click', handleFullScreen);
</script>

View File

@ -6,8 +6,6 @@ is_hidden = 0
<?php
function onStart(){
//phpinfo();
$month = Input::get('month');
$year = Input::get('year');
@ -21,15 +19,21 @@ function onStart(){
}
if(isset($month) && isset($year)){
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::where("month", $month)->where("year", $year)->orderBy('year', 'DESC')->orderBy('month', 'DESC')->orderBy('week', 'DESC')->paginate($paginate);
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::where("month", $month)
->where("year", $year)->orderBy('year', 'DESC')
->orderBy('month', 'DESC')
->orderBy('week', 'DESC')->paginate($paginate);
}else if(isset($month) || isset($year)){
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::where("month", $month)->orWhere("year", $year)->orderBy('year', 'DESC')->orderBy('month', 'DESC')->orderBy('week', 'DESC')->paginate($paginate);
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::where("month", $month)
->orWhere("year", $year)
->orderBy('year', 'DESC')->orderBy('month', 'DESC')-
>orderBy('week', 'DESC')->paginate($paginate);
}else{
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::orderBy('year', 'DESC')->orderBy('month', 'DESC')->orderBy('week', 'DESC')->paginate($paginate);
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::orderBy('year', 'DESC')
->orderBy('month', 'DESC')->orderBy('week', 'DESC')
->paginate($paginate);
}
//dd(Admin\WeeklyNews\Models\WeeklyNews::all());
}
?>
==
@ -111,15 +115,12 @@ function onStart(){
</option>
<option value="2021">2021</option>
<!-- <option value="2020">2020</option>
<option value="2019">2019</option> -->
</select>
</div>
</div>
</div>
<div class="magazines">
{% for key, item in news %}
@ -174,20 +175,13 @@ function onStart(){
</div>
</section>
<script>
//if({{month}}){
// var month = {{month}};
//}
//var year = {{year}};
var url_string = window.location.href;
var url = new URL(url_string);
var month = url.searchParams.get("month");
var year = url.searchParams.get("year");
let url_string = window.location.href;
let url = new URL(url_string);
let month = url.searchParams.get("month");
let year = url.searchParams.get("year");
console.log("month: " + month + "\n" + "year: " + year);
function onMonthSelect(month){
@ -214,10 +208,10 @@ function onStart(){
</script>
<script>
<script>
// select box ====================
var x, i, j, l, ll, selElmnt, a, b, c;
let x, i, j, l, ll, selElmnt, a, b, c;
x = document.getElementsByClassName("custom-select");
l = x.length;
for (i = 0; i < l; i++) {
@ -233,7 +227,7 @@ function onStart(){
c = document.createElement("DIV");
c.innerHTML = selElmnt.options[j].innerHTML;
c.addEventListener("click", function (e) {
var y, i, k, s, h, sl, yl;
let y, i, k, s, h, sl, yl;
s = this.parentNode.parentNode.getElementsByTagName("select")[0];
sl = s.length;
h = this.parentNode.previousSibling;
@ -265,7 +259,7 @@ function onStart(){
});
}
function closeAllSelect(elmnt) {
var x, y, i, xl, yl, arrNo = [];
let x, y, i, xl, yl, arrNo = [];
x = document.getElementsByClassName("select-items");
y = document.getElementsByClassName("select-selected");
xl = x.length;
@ -286,4 +280,4 @@ function onStart(){
document.addEventListener("click", closeAllSelect);
// select box end ====================
</script>
</script>

View File

@ -3,7 +3,6 @@
function onStart(){
$categories = \Indikator\News\Models\Categories::where("hidden", 2)->where("status", 1)->limit(6)->get();
$this["categories"] = $categories;
}
?>
==
@ -20,7 +19,7 @@ function onStart(){
<form class="search__form" action="{{ 'search'|page }}" method="GET">
{{form_token()}}
<div class="input__wrap">
<input type="text" class="for__search" name="q" placeholder="{{'Поиск'|_}}">
<input type="text" class="for__search" name="query" placeholder="{{'Поиск'|_}}">
<button type="submit" class="input__magnify">
<img src="{{ 'assets/images/lupa.svg'|theme }}" alt="">
</button>
@ -49,7 +48,7 @@ function onStart(){
</a>
<form action="{{ 'search'|page }}" method="GET" class="mobile__form">
<div class="mobile_input__wrap">
<input type="text" type="text" name="q" placeholder="{{'Поиск'|_}}">
<input type="text" type="text" name="query" placeholder="{{'Поиск'|_}}">
<button type="submit" class="mobile__magnify">
<img src="{{ 'assets/images/lupa.svg'|theme }}" alt="">
</button>
@ -72,7 +71,6 @@ function onStart(){
{% for item in categories %}
<a href="{{ 'category'|page({ slug: item.slug })}}" class="nav__link">{{item.name}}</a>
{% endfor %}
<!-- <a href="/{{data}}/rss.xml" class="nav__link" target="blank">RSS</a> -->
</div>
<div class="nav__col">
<a href="{{ 'archive'|page}}" class="nav__group">

View File

@ -2,12 +2,15 @@
<?php
function onStart(){
$this['categories'] = \Indikator\News\Models\Categories::orderBy("sort_order")->where("id", "!=", $this->theme->politics_news)->limit(4)->get();
$this['categories'] = \Indikator\News\Models\Categories::orderBy("sort_order")
->where("id", "!=", $this->theme->politics_news)->limit(4)->get();
$this['interesting'] = Admin\Interesting\Models\Interesing::all();
$this['news'] = Admin\WeeklyNews\Models\WeeklyNews::orderBy('created_at', 'desc')->get()->first();
$this['mainNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("category_id", $this->theme->main_news)->orderBy('published_at', 'desc')->limit(4)->get();
$this['mainNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("category_id", $this->theme->main_news)
->orderBy('published_at', 'desc')->limit(4)->get();
$this["main_news_cat"] = \Indikator\News\Models\Categories::where("id", $this->theme->main_news)->first();
}
?>
@ -93,9 +96,6 @@ function onStart(){
</div>
<div class="recent__info">
<!-- <div class="recent__time">
{{ post.published_at| date("d.m") }}
</div> -->
<a href="{{ ''| page}}/post/{{post.id}}/{{post.slug}}" class="recent__text">
{{ post.title }}
</a>
@ -126,8 +126,6 @@ function onStart(){
</div>
<!-- Advert end ======================================================= -->
<div class="recent">
<div class="auto_container">
<div class="recent__inner">

View File

@ -70,7 +70,6 @@
</a>
</div>
{% endfor %}
</div>
</div>
</div>

View File

@ -1,15 +1,13 @@
==
<?php
function onStart(){
$this['gallery'] = Admin\Photos\Models\Photo::orderBy("date", "desc")->limit(2)->get();
$this['videos'] = Admin\Videos\Models\Video::orderBy("date", "desc")->limit(2)->get();
}
?>
==
<!-- Media Content ==================================================== -->
<div class="Media">
<div class="Media">
<div class="auto_container">
<div class="media_inner">
<div class="media">
@ -27,11 +25,6 @@ function onStart(){
data-width="1500" data-height="1000">
<img src="{{item.image[0].thumb(auto, 270)}}" alt="">
<!-- <h3 class="photo_view">
<a class="fancybox" href="{{item.getImages().first.path}}" data-fancybox="{{key}}"
data-width="1500" data-height="1000"><i
class="icon-camera"></i> {{'Просмотреть'|_}}</a>
</h3> -->
</div>
<div style="display: none;">
@ -44,9 +37,6 @@ function onStart(){
<div class="item_text">
{{ item.title }}
</div>
<!-- <div class="item_date">
{{ item.date| date("d.m.Y") }}
</div> -->
</div>
{% endfor %}
@ -64,17 +54,11 @@ function onStart(){
<div class="item">
<div class="item_img video_item" data-src="{{item.video[0].path}}">
<img src="{{item.image[0].thumb(350, auto)}}" alt="">
<!-- <div class="video_view" data-src="{{item.video[0].path}}">
{{'Просмотреть'|_}}
</div> -->
</div>
<div class="player_bg">
<div class="player">
<video class="player__video viewer">
<!-- <source url="video/3.mp4"> -->
</video>
<video class="player__video viewer"></video>
<div class="player__controls">
<div class="progress">
@ -94,9 +78,6 @@ function onStart(){
<div class="item_text">
{{ item.title }}
</div>
<!-- <div class="item_date">
{{ item.date| date("d.m.Y") }}
</div> -->
</div>
{% endfor %}
@ -105,8 +86,8 @@ function onStart(){
</div>
</div>
</div>
</div>
<!-- Media Content end ================================================ -->
</div>
<!-- Media Content end ================================================ -->
<!-- Channel ===================== -->
<div class="auto_container">

View File

@ -93,21 +93,21 @@ function onStart(){
<script>
function openImageModal(images){
var media_wrapper = document.getElementById('media_section');
let media_wrapper = document.getElementById('media_section');
var modalItems = [];
let modalItems = [];
for (let i = 0; i < images.length / 12; i++) {
var modal_images = [];
let modal_images = [];
images.slice(i*12,(i+1)*12).forEach(function(image, index) {
var image =
let img =
`
<a class="fancybox modal_gal-item" href="${image.path}" data-fancybox="gallery">
<img src="${image.path}" alt="" />
</a>
`
modal_images += image;
modal_images += img;
});
var modalItem =
let modalItem =
`
<div class="modal_gal-group">
<div class="box">
@ -117,7 +117,7 @@ function onStart(){
`;
modalItems += modalItem;
}
var gallery_modal =
let gallery_modal =
`<div class="modal modal-photo mod modClose active" id='image-modal' >
<div class="modal_gal">
<div class="modal_gal-box owl-carousel owl-theme">
@ -168,9 +168,6 @@ function onStart(){
}
window.addEventListener('click', function(e){
//if (document.getElementById('image-modal').contains(e.target) && !e.target.closest('.modal_gal') && !e.target.closest('.owl-nav')){
// document.getElementById('image-modal').remove();
//}
if (document.getElementById('image-modal') != undefined) {
if (document.getElementById('image-modal').contains(e.target) && !e.target.closest('.modal_gal') && !e.target.closest('.owl-nav')) {

View File

@ -1,6 +1,6 @@
==
<!-- New Intro ========================================================= -->
<div class="new__intro" id="intro">
<div class="new__intro" id="intro">
<div class="auto_container">
<div class="intro__inner">
<div {% if imageType == 'vertical' %} class="event__vertical wow fadeIn" data-wow-duration=".5s" data-wow-delay=".1s" {% else %} class="event__horizontal wow fadeIn" data-wow-duration=".5s" data-wow-delay=".1s"{% endif %}>
@ -59,5 +59,5 @@
</div>
</div>
</div>
</div>
<!-- New Intro end ==================================================== -->
</div>
<!-- New Intro end ==================================================== -->

View File

@ -2,11 +2,13 @@
<?php
function onStart(){
$this['categories'] = \Indikator\News\Models\Categories::orderBy("sort_order")->where("id", "!=", $this->theme->politics_news)->limit(8)->get();
$this['categories'] = \Indikator\News\Models\Categories::orderBy("sort_order")
->where("id", "!=", $this->theme->politics_news)->limit(8)->get();
$last_categories = $this['categories']->slice(0, 4)->pluck('id')->toArray();
$this['last_category_posts'] = \Indikator\News\Models\Posts::whereIn('category_id', $last_categories)->where("locale", App::getLocale())->orderBy("published_at", "desc")->limit(4)->get();
$this['last_category_posts'] = \Indikator\News\Models\Posts::whereIn('category_id', $last_categories)
->where("locale", App::getLocale())
->orderBy("published_at", "desc")->limit(4)->get();
}
?>

View File

@ -2,10 +2,18 @@
<?php
function onStart()
{
$this['news'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", $this->theme->year_category)->orderBy('published_at', 'desc')->get()->first();
$this['news'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)->where("category_id", $this->theme->year_category)
->orderBy('published_at', 'desc')
->get()->first();
$this["cat"] = \Indikator\News\Models\Categories::where("id", $this->theme->year_category)->first();
$this['news_second'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())->where("status", 1)->where("category_id", $this->theme->year_category_second)->orderBy('published_at', 'desc')->get()->first();
$this['news_second'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
->where("status", 1)
->where("category_id", $this->theme->year_category_second)
->orderBy('published_at', 'desc')
->get()->first();
$this["cat_second"] = \Indikator\News\Models\Categories::where("id", $this->theme->year_category_second)->first();
}
?>
@ -28,9 +36,6 @@ function onStart()
<img src="{{attribute(this.theme, 'year_category_image').path}}" alt="">
</a>
<div class="univer__info new_univer_info">
<!-- <div class="univer__time">
{{ news.published_at| date("d.m") }}
</div> -->
<a href="{{ ''| page}}/post/{{news.id}}/{{news.slug}}" class="univer__text">
{{ news.title }}
</a>
@ -42,9 +47,6 @@ function onStart()
<img src="{{attribute(this.theme, 'year_category_second_image').path}}" alt="">
</a>
<div class="univer__info new_univer_info">
<!-- <div class="univer__time">
{{ news_second.published_at| date("d.m") }}
</div> -->
<a href="{{ ''| page}}/post/{{news_second.id}}/{{news_second.slug}}" class="univer__text">
{{ news_second.title }}
</a>