2627 - Арт Проект. Подключение турбо страниц для сайта task-on.com

parent c1e52a41
...@@ -4,7 +4,7 @@ namespace common\assets; ...@@ -4,7 +4,7 @@ namespace common\assets;
class JqueryCookieAsset extends \yii\web\AssetBundle class JqueryCookieAsset extends \yii\web\AssetBundle
{ {
public $sourcePath = '@bower/jquery-cookie/src'; public $sourcePath = '@bower/jquery-cookie';
public $js = [ public $js = [
'jquery.cookie.js', 'jquery.cookie.js',
]; ];
......
...@@ -28,4 +28,8 @@ return [ ...@@ -28,4 +28,8 @@ return [
'useFileTransport' => true, 'useFileTransport' => true,
], ],
], ],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
]
]; ];
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace common\modules\blog\controllers; namespace common\modules\blog\controllers;
use common\modules\blog\models\SearchPost; use common\modules\blog\models\Rss;
use common\modules\languages\models\Languages; use common\modules\languages\models\Languages;
use Yii; use Yii;
use common\components\BaseController; use common\components\BaseController;
...@@ -32,8 +32,15 @@ class PostController extends BaseController ...@@ -32,8 +32,15 @@ class PostController extends BaseController
'Send-article' => 'Послать статью', 'Send-article' => 'Послать статью',
'Set-cookie' => 'Установить куки', 'Set-cookie' => 'Установить куки',
'Tag-index' => 'Перезагрузка статей с учетом тэгов', 'Tag-index' => 'Перезагрузка статей с учетом тэгов',
'Rss' => 'Rss'
]; ];
} }
public function actionRss($lang)
{
return (new Rss($lang))->render();
}
/** /**
* Displays all Post models. * Displays all Post models.
* @return mixed * @return mixed
......
...@@ -18,7 +18,7 @@ use common\modules\blog\models\Post; ...@@ -18,7 +18,7 @@ use common\modules\blog\models\Post;
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
* *
* @property Posts $post * @property Post $post
* @property Languages $lang * @property Languages $lang
*/ */
class PostLang extends \common\components\ActiveRecordModel class PostLang extends \common\components\ActiveRecordModel
......
<?php
namespace common\modules\blog\models;
use common\modules\content\models\CoContent;
use common\modules\content\models\CoContentLang;
use common\modules\languages\models\Languages;
use sokolnikov911\YandexTurboPages\Channel;
use sokolnikov911\YandexTurboPages\Feed;
use sokolnikov911\YandexTurboPages\Item;
use yii\base\BaseObject;
use yii\helpers\Url;
use yii\web\NotFoundHttpException;
/**
* Class Rss
* @package common\modules\content\models
*/
class Rss extends BaseObject
{
/**
* @var string
*/
protected $lang;
/**
* Rss constructor.
* @param string $lang
* @param array $config
*/
public function __construct($lang, $config = [])
{
parent::__construct($config);
$this->lang = $lang;
}
public function render()
{
/** @var Languages $language */
$language = Languages::find()
->andWhere(['url' => $this->lang])
->one();
if(!$language) {
throw new NotFoundHttpException('Language not found!');
}
$feed = new Feed();
$channel = new Channel();
$channel
->title('TaskOn Blog')
->link(Url::to(['/'], true))
->language('ru')
->appendTo($feed);
/** @var PostLang[] $models */
$models = PostLang::find()
->alias('pl')
->leftJoin(Post::tableName() . ' p', 'p.id = pl.post_id')
->andWhere([
'pl.lang_id' => $language->id,
'p.active' => Post::ACTIVE_TRUE
])
->all();
foreach ($models as $model) {
$item = new Item();
$item
->title($model->title)
->link(Url::to(["/{$model->post->url}"], true))
->turboContent($model->text)
->pubDate($model->created_at)
->appendTo($channel);
}
return $feed;
}
}
\ No newline at end of file
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
namespace common\modules\content\controllers; namespace common\modules\content\controllers;
use common\modules\users\models\User; use common\modules\users\models\User;
use Yii;
use yii\web\BadRequestHttpException;
use common\modules\content\models\CoContent; use common\modules\content\models\CoContent;
use common\modules\school\models\Lessons;
class PageController extends \common\components\BaseController class PageController extends \common\components\BaseController
{ {
...@@ -57,4 +54,7 @@ class PageController extends \common\components\BaseController ...@@ -57,4 +54,7 @@ class PageController extends \common\components\BaseController
]); ]);
} }
} }
...@@ -12,27 +12,28 @@ ...@@ -12,27 +12,28 @@
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2" "source": "https://github.com/yiisoft/yii2"
}, },
"minimum-stability": "dev", "minimum-stability": "stable",
"require": { "require": {
"php": ">=5.4.0", "php": ">=5.4.0",
"yiisoft/yii2": "*", "yiisoft/yii2": "~2.0.6",
"yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-bootstrap": "~2.0.5",
"yiisoft/yii2-swiftmailer": "*", "yiisoft/yii2-swiftmailer": "~2.0.6",
"yiisoft/yii2-imagine": "dev-master", "yiisoft/yii2-imagine": "~2.0.3",
"lagman/yii2-eav": "*", "lagman/yii2-eav": "dev-master#d86a5ee",
"himiklab/yii2-sortable-grid-view-widget": "*", "himiklab/yii2-sortable-grid-view-widget": "~1.0.7",
"c006/yii2-migration-utility": "dev-master", "c006/yii2-migration-utility": "~1.1.2",
"2amigos/yii2-date-picker-widget": "~1.0", "2amigos/yii2-date-picker-widget": "~1.0.5",
"kartik-v/dependent-dropdown": "dev-master", "kartik-v/dependent-dropdown": "~1.4.4",
"mirocow/yii2-minify-view" : "*", "rmrevin/yii2-minify-view" : "2.0.0",
"kartik-v/yii2-widget-fileinput": "@dev", "kartik-v/yii2-widget-fileinput": "~1.0.4",
"nodge/yii2-eauth": "~2.0", "nodge/yii2-eauth": "~2.4.1",
"xj/yii2-tagit-widget": "*", "xj/yii2-tagit-widget": "1.0.1",
"bower-asset/jquery-cookie": "*", "bower-asset/jquery-cookie": "~1.4.1",
"2amigos/yii2-transliterator-helper": "*", "2amigos/yii2-transliterator-helper": "~0.1.0",
"kbsali/redmine-api" : "~1.0", "kbsali/redmine-api" : "~1.5.9",
"netcarver/textile" : "3.5.*", "netcarver/textile" : "~3.5.6",
"coderlex/yii2-markitup" : "*" "coderlex/yii2-markitup" : "~1.0.1",
"sokolnikov911/yandex-turbo-pages-php5": "~1.1.2"
}, },
"require-dev": { "require-dev": {
"yiisoft/yii2-codeception": "*", "yiisoft/yii2-codeception": "*",
...@@ -41,12 +42,15 @@ ...@@ -41,12 +42,15 @@
"yiisoft/yii2-faker": "*" "yiisoft/yii2-faker": "*"
}, },
"config": { "config": {
"process-timeout": 1800 "process-timeout": 1800,
"fxp-asset": {
"enabled": false
}
}, },
"extra": { "repositories": [
"asset-installer-paths": { {
"npm-asset-library": "vendor/npm", "type": "composer",
"bower-asset-library": "vendor/bower" "url": "https://asset-packagist.org"
} }
} ]
} }
...@@ -45,7 +45,6 @@ class AppAsset extends AssetBundle ...@@ -45,7 +45,6 @@ class AppAsset extends AssetBundle
]; ];
public $depends = [ public $depends = [
'yii\web\YiiAsset', 'yii\web\YiiAsset',
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset', 'yii\bootstrap\BootstrapAsset',
'common\assets\JqueryCookieAsset', 'common\assets\JqueryCookieAsset',
]; ];
......
...@@ -61,16 +61,13 @@ return [ ...@@ -61,16 +61,13 @@ return [
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',
], ],
'view' => [ 'view' => [
'class' => '\mirocow\minify\View', 'class' => 'rmrevin\yii\minify\View',
'base_path' => '@app/web', // path alias to web base 'basePath' => '@app/web',
'minify_path' => '@app/web/minify', // path alias to save minify result 'minifyPath' => '@app/web/minify',
'minify_css' => true, 'minifyCss' => true,
'minify_js' => true, 'minifyJs' => true,
'minify_html' => true, 'forceCharset' => 'UTF-8',
'js_len_to_minify' => 1000, // Больше этого размера inlinejs будет сжиматься и упаковываться в файл 'expandImports' => true,
'force_charset' => 'UTF-8', // charset forcibly assign, otherwise will use all of the files found charset
'expand_imports' => true, // whether to change @import on content
//'css_linebreak_pos' => false,
], ],
'user' => [ 'user' => [
'identityClass' => 'common\modules\users\models\User', 'identityClass' => 'common\modules\users\models\User',
...@@ -171,6 +168,7 @@ return [ ...@@ -171,6 +168,7 @@ return [
['pattern' => 'sitemapg', 'route' => 'sitemap/default/google', 'suffix' => '.xml'], ['pattern' => 'sitemapg', 'route' => 'sitemap/default/google', 'suffix' => '.xml'],
'' => 'content/page/view', '' => 'content/page/view',
'blog/<lang>.rss' => 'blog/post/rss',
'reviews' => 'reviews/review/index', 'reviews' => 'reviews/review/index',
'faq/view/all' => 'faq/faq/all', 'faq/view/all' => 'faq/faq/all',
'faq/video/<url>' => 'faq/faq/view-video', 'faq/video/<url>' => 'faq/faq/view-video',
......
*
!.gitignore
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment