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

parent c1e52a41
......@@ -4,7 +4,7 @@ namespace common\assets;
class JqueryCookieAsset extends \yii\web\AssetBundle
{
public $sourcePath = '@bower/jquery-cookie/src';
public $sourcePath = '@bower/jquery-cookie';
public $js = [
'jquery.cookie.js',
];
......
......@@ -28,4 +28,8 @@ return [
'useFileTransport' => true,
],
],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
]
];
......@@ -2,7 +2,7 @@
namespace common\modules\blog\controllers;
use common\modules\blog\models\SearchPost;
use common\modules\blog\models\Rss;
use common\modules\languages\models\Languages;
use Yii;
use common\components\BaseController;
......@@ -32,8 +32,15 @@ class PostController extends BaseController
'Send-article' => 'Послать статью',
'Set-cookie' => 'Установить куки',
'Tag-index' => 'Перезагрузка статей с учетом тэгов',
'Rss' => 'Rss'
];
}
public function actionRss($lang)
{
return (new Rss($lang))->render();
}
/**
* Displays all Post models.
* @return mixed
......
......@@ -18,7 +18,7 @@ use common\modules\blog\models\Post;
* @property integer $created_at
* @property integer $updated_at
*
* @property Posts $post
* @property Post $post
* @property Languages $lang
*/
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 @@
namespace common\modules\content\controllers;
use common\modules\users\models\User;
use Yii;
use yii\web\BadRequestHttpException;
use common\modules\content\models\CoContent;
use common\modules\school\models\Lessons;
class PageController extends \common\components\BaseController
{
......@@ -57,4 +54,7 @@ class PageController extends \common\components\BaseController
]);
}
}
......@@ -12,27 +12,28 @@
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-imagine": "dev-master",
"lagman/yii2-eav": "*",
"himiklab/yii2-sortable-grid-view-widget": "*",
"c006/yii2-migration-utility": "dev-master",
"2amigos/yii2-date-picker-widget": "~1.0",
"kartik-v/dependent-dropdown": "dev-master",
"mirocow/yii2-minify-view" : "*",
"kartik-v/yii2-widget-fileinput": "@dev",
"nodge/yii2-eauth": "~2.0",
"xj/yii2-tagit-widget": "*",
"bower-asset/jquery-cookie": "*",
"2amigos/yii2-transliterator-helper": "*",
"kbsali/redmine-api" : "~1.0",
"netcarver/textile" : "3.5.*",
"coderlex/yii2-markitup" : "*"
"yiisoft/yii2": "~2.0.6",
"yiisoft/yii2-bootstrap": "~2.0.5",
"yiisoft/yii2-swiftmailer": "~2.0.6",
"yiisoft/yii2-imagine": "~2.0.3",
"lagman/yii2-eav": "dev-master#d86a5ee",
"himiklab/yii2-sortable-grid-view-widget": "~1.0.7",
"c006/yii2-migration-utility": "~1.1.2",
"2amigos/yii2-date-picker-widget": "~1.0.5",
"kartik-v/dependent-dropdown": "~1.4.4",
"rmrevin/yii2-minify-view" : "2.0.0",
"kartik-v/yii2-widget-fileinput": "~1.0.4",
"nodge/yii2-eauth": "~2.4.1",
"xj/yii2-tagit-widget": "1.0.1",
"bower-asset/jquery-cookie": "~1.4.1",
"2amigos/yii2-transliterator-helper": "~0.1.0",
"kbsali/redmine-api" : "~1.5.9",
"netcarver/textile" : "~3.5.6",
"coderlex/yii2-markitup" : "~1.0.1",
"sokolnikov911/yandex-turbo-pages-php5": "~1.1.2"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
......@@ -41,12 +42,15 @@
"yiisoft/yii2-faker": "*"
},
"config": {
"process-timeout": 1800
"process-timeout": 1800,
"fxp-asset": {
"enabled": false
}
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
}
]
}
......@@ -45,7 +45,6 @@ class AppAsset extends AssetBundle
];
public $depends = [
'yii\web\YiiAsset',
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
'common\assets\JqueryCookieAsset',
];
......
......@@ -61,16 +61,13 @@ return [
'class' => 'yii\caching\FileCache',
],
'view' => [
'class' => '\mirocow\minify\View',
'base_path' => '@app/web', // path alias to web base
'minify_path' => '@app/web/minify', // path alias to save minify result
'minify_css' => true,
'minify_js' => true,
'minify_html' => true,
'js_len_to_minify' => 1000, // Больше этого размера inlinejs будет сжиматься и упаковываться в файл
'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,
'class' => 'rmrevin\yii\minify\View',
'basePath' => '@app/web',
'minifyPath' => '@app/web/minify',
'minifyCss' => true,
'minifyJs' => true,
'forceCharset' => 'UTF-8',
'expandImports' => true,
],
'user' => [
'identityClass' => 'common\modules\users\models\User',
......@@ -171,6 +168,7 @@ return [
['pattern' => 'sitemapg', 'route' => 'sitemap/default/google', 'suffix' => '.xml'],
'' => 'content/page/view',
'blog/<lang>.rss' => 'blog/post/rss',
'reviews' => 'reviews/review/index',
'faq/view/all' => 'faq/faq/all',
'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