diff --git a/plugins/rainlab/blog/components/Post.php b/plugins/rainlab/blog/components/Post.php index feec14364..ccedd539e 100644 --- a/plugins/rainlab/blog/components/Post.php +++ b/plugins/rainlab/blog/components/Post.php @@ -77,7 +77,7 @@ class Post extends ComponentBase { $this->categoryPage = $this->page['categoryPage'] = $this->property('categoryPage'); $this->post = $this->page['post'] = $this->loadPost(); - $this->page['meta_title'] = $this->post->title; + //$this->page['meta_title'] = $this->post->title; if (!$this->post) { $this->setStatusCode(404); return $this->controller->run('404'); diff --git a/plugins/rainlab/blog/models/post/fields.yaml b/plugins/rainlab/blog/models/post/fields.yaml index ec670334d..48a186c5b 100644 --- a/plugins/rainlab/blog/models/post/fields.yaml +++ b/plugins/rainlab/blog/models/post/fields.yaml @@ -44,6 +44,7 @@ secondaryTabs: author: label: 'Post author' span: auto + default: 'ORIENT news' type: text tab: 'rainlab.blog::lang.post.tab_manage' featured: diff --git a/plugins/rainlab/blogvideo/LICENCE.md b/plugins/rainlab/blogvideo/LICENCE.md new file mode 100644 index 000000000..d68943ee4 --- /dev/null +++ b/plugins/rainlab/blogvideo/LICENCE.md @@ -0,0 +1,19 @@ +# MIT license + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/plugins/rainlab/blogvideo/Plugin.php b/plugins/rainlab/blogvideo/Plugin.php new file mode 100644 index 000000000..d088a187a --- /dev/null +++ b/plugins/rainlab/blogvideo/Plugin.php @@ -0,0 +1,52 @@ + 'Blog Video Extension', + 'description' => 'Adds responsive video embedding features to the RainLab Blog module.', + 'author' => 'Alexey Bobkov, Samuel Georges', + 'icon' => 'icon-video-camera', + 'homepage' => 'https://github.com/rainlab/blogvideo-plugin' + ]; + } + + /** + * Register method, called when the plugin is first registered. + */ + public function register() + { + PostsController::extend(function($controller) { + if (!in_array(BackendController::$action, ['create', 'update'])) return; + $controller->addJs('/plugins/rainlab/blogvideo/assets/js/blog-video.js'); + $controller->addCss('/plugins/rainlab/blogvideo/assets/css/blog-video.css'); + }); + + /* + * Register the video tag processing callback + */ + TagProcessor::instance()->registerCallback(function($input, $preview) { + if (!$preview) return $input; + + $popup = file_get_contents(__DIR__.'/partials/popup.htm'); + + return preg_replace('|\([0-9]+)|m', + ' + Click to embed a video... + '.$popup.' + ', + $input); + }); + } +} diff --git a/plugins/rainlab/blogvideo/README.md b/plugins/rainlab/blogvideo/README.md new file mode 100644 index 000000000..5b9dd1b79 --- /dev/null +++ b/plugins/rainlab/blogvideo/README.md @@ -0,0 +1,43 @@ +# Blog Video plugin + +This plugin extends the [RainLab Blog plugin](/plugin/rainlab-blog) with the responsive video embedding features. The plugin was tested with Vimeo and YouTube videos, but in theory it can be used with any video service which uses iframes for embedding. + +## Adding video to a post + +Use the following syntax to insert a video placeholder to a blog post: + + ![1](video) + +The number in the first part is the placeholder index. If you use multiple videos in a post you should use unique indexes: + + ![1](video) + + ![2](video) + +## Styling the responsive videos + +The plugin adds a wrapping DIV element around the embedded iframe element. The wrapper allows to make the video responsive, fit the containing column and maintain the aspect ratio. + +
+ +Add the following CSS code to your website in order to support the video wrapper: + + .video-wrapper { + position: relative; + padding-top: 25px; + margin-bottom: 15px; + height: 0; + } + + .video-wrapper.ratio-5-4 {padding-bottom: 80%;} + .video-wrapper.ratio-4-3 {padding-bottom: 70%;} + .video-wrapper.ratio-16-10 {padding-bottom: 62.5%;} + .video-wrapper.ratio-16-9 {padding-bottom: 56.25%;} + + .video-wrapper iframe { + position: absolute; + top: 0; + left: 0; + width: 100%!important; + height: 100%!important; + } \ No newline at end of file diff --git a/plugins/rainlab/blogvideo/assets/css/blog-video.css b/plugins/rainlab/blogvideo/assets/css/blog-video.css new file mode 100644 index 000000000..f0be8a098 --- /dev/null +++ b/plugins/rainlab/blogvideo/assets/css/blog-video.css @@ -0,0 +1,72 @@ +.blog-post-preview span.video-placeholder { + background: #ecf0f1; + display: block; + border: 1px solid #e5e9ec; + padding: 25px; + min-height: 123px; + position: relative; + text-align: center; + cursor: pointer; + margin-bottom: 20px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.blog-post-preview span.video-placeholder a { + color: #b1b9be; + font-size: 16px; + display: inline-block; + margin-top: 25px; + text-decoration: none; +} +.blog-post-preview span.video-placeholder:before { + display: inline-block; + font-family: FontAwesome; + font-weight: normal; + font-style: normal; + text-decoration: inherit; + -webkit-font-smoothing: antialiased; + *margin-right: .3em; + content: "\f03d"; + position: absolute; + left: 25px; + top: 25px; + line-height: 100%; + font-size: 73px; + color: #d1d3d4; +} +.blog-post-preview span.video-placeholder.hover, +.blog-post-preview span.video-placeholder:hover { + background: #2f99da; +} +.blog-post-preview span.video-placeholder.hover:before, +.blog-post-preview span.video-placeholder:hover:before, +.blog-post-preview span.video-placeholder.hover a, +.blog-post-preview span.video-placeholder:hover a { + color: white; +} +.blog-post-preview .video-wrapper { + position: relative; + padding-top: 25px; + margin-bottom: 15px; + height: 0; +} +.blog-post-preview .video-wrapper.ratio-5-4 { + padding-bottom: 80%; +} +.blog-post-preview .video-wrapper.ratio-4-3 { + padding-bottom: 70%; +} +.blog-post-preview .video-wrapper.ratio-16-10 { + padding-bottom: 62.5%; +} +.blog-post-preview .video-wrapper.ratio-16-9 { + padding-bottom: 56.25%; +} +.blog-post-preview .video-wrapper iframe { + position: absolute; + top: 0; + left: 0; + width: 100%!important; + height: 100%!important; +} diff --git a/plugins/rainlab/blogvideo/assets/js/blog-video.js b/plugins/rainlab/blogvideo/assets/js/blog-video.js new file mode 100644 index 000000000..d07490bf3 --- /dev/null +++ b/plugins/rainlab/blogvideo/assets/js/blog-video.js @@ -0,0 +1,126 @@ ++function ($) { "use strict"; + var VideoTagProcessor = function() { + this.$form = $('#post-form') + this.$markdownEditor = $('[data-field-name=content] [data-control=markdowneditor]:first', this.$form) + + this.addToolbarButton() + this.initHandlers() + } + + VideoTagProcessor.prototype.addToolbarButton = function() { + this.buttonClickCount = 1 + + var self = this, + $button = this.$markdownEditor.markdownEditor('addToolbarButton', 'blogvideo', { + label: 'markdowneditor.video', + icon: 'video-camera', + action: 'insertLine', + template: '\n\n![1](video)\n', + insertAfter: 'image' + }) + + $button.on('click', function() { + $button.data('button-template', '\n\n!['+self.buttonClickCount+'](video)\n') + self.buttonClickCount++ + }) + } + + VideoTagProcessor.prototype.initHandlers = function() { + var self = this + + this.$markdownEditor.on('click', '.editor-preview span.video-placeholder', function() { + var $this = $(this) + + /* + * This is an unusual way to display a popup. + * We use it because the popup contents + * is loaded from the hidden script element + */ + $this.popup({ + content: $('script[type="text/template"]', $this).html() + }) + + var popup = $this.data('oc.popup'), + $textarea = $('textarea', popup.$content), + placeholderIndex = $this.data('index') + + setTimeout(function(){ + popup.setLoading(false) + $textarea.focus() + }, 500) + + $('button[type=submit]', popup.$target).click(function() { + self.embedVideo($textarea, placeholderIndex, $this, popup) + }) + }) + } + + VideoTagProcessor.prototype.embedVideo = function($textarea, placeholderIndex, $placeholder, popup) { + var text = $.trim($textarea.val()) + + if (!text.length) { + alert('Please paste the video code to embed.') + $textarea.focus() + return + } + + /* + * Calculate the aspect ratio from the iframe width and height + */ + var widthRegex = /width\s*=\s*"([0-9]+)"/g, + heightRegex = /height\s*=\s*"([0-9]+)"/g, + widthMatch = widthRegex.exec(text), + heightMatch = heightRegex.exec(text), + ratioClass = null, + padding = null; + + if (widthMatch && heightMatch && widthMatch.length >= 1 && heightMatch.length >= 1) { + var ratio = heightMatch[1] / widthMatch[1] * 100 + + ratioClass = this.getRatioClass(ratio) + + padding = ratio + '%' + } + + var $wrapper = $('
') + if (ratioClass) + $wrapper.addClass(ratioClass) + else + $wrapper.css('padding-bottom', padding) + + $wrapper.html(text) + + var wrapperText = $('
').append($wrapper.clone()).html() + + $.oc.blogPostForm.replacePlaceholder( + $placeholder, + wrapperText, + '!['+placeholderIndex+'](video)', + wrapperText + ); + + popup.hide() + + return false + } + + VideoTagProcessor.prototype.getRatioClass = function(ratio) { + if (Math.abs(ratio-80) < 1) + return 'ratio-5-4' + + if (Math.abs(ratio-70) < 1) + return 'ratio-4-3' + + if (Math.abs(ratio-62.5) < 1) + return 'ratio-16-10' + + if (Math.abs(ratio-56.25) < 1) + return 'ratio-16-9' + + return false + } + + $(document).ready(function(){ + new VideoTagProcessor() + }) +}(window.jQuery); \ No newline at end of file diff --git a/plugins/rainlab/blogvideo/assets/less/blog-video.less b/plugins/rainlab/blogvideo/assets/less/blog-video.less new file mode 100644 index 000000000..79b907ef9 --- /dev/null +++ b/plugins/rainlab/blogvideo/assets/less/blog-video.less @@ -0,0 +1,75 @@ +@import "../../../../../modules/backend/assets/less/core/boot.less"; + +.blog-post-preview { + span.video-placeholder { + background: #ecf0f1; + display: block; + border: 1px solid #e5e9ec; + padding: 25px; + min-height: 123px; + position: relative; + text-align: center; + cursor: pointer; + margin-bottom: 20px; + + .box-sizing(border-box); + + a { + color: #b1b9be; + font-size: 16px; + display: inline-block; + margin-top: 25px; + text-decoration: none; + } + + &:before { + display: inline-block; + .icon(@video-camera); + position: absolute; + left: 25px; + top: 25px; + line-height: 100%; + font-size: 73px; + color: #d1d3d4; + } + + &.hover, &:hover { + background: #2f99da; + + &:before, a { + color: white; + } + } + } + + .video-wrapper { + position: relative; + padding-top: 25px; + margin-bottom: 15px; + height: 0; + + &.ratio-5-4 { + padding-bottom: 80%; + } + + &.ratio-4-3 { + padding-bottom: 70%; + } + + &.ratio-16-10 { + padding-bottom: 62.5%; + } + + &.ratio-16-9 { + padding-bottom: 56.25%; + } + } + + .video-wrapper iframe { + position: absolute; + top: 0; + left: 0; + width: 100%!important; + height: 100%!important; + } +} \ No newline at end of file diff --git a/plugins/rainlab/blogvideo/composer.json b/plugins/rainlab/blogvideo/composer.json new file mode 100644 index 000000000..a56188fe0 --- /dev/null +++ b/plugins/rainlab/blogvideo/composer.json @@ -0,0 +1,8 @@ +{ + "name": "rainlab/blogvideo-plugin", + "type": "october-plugin", + "description": "None", + "require": { + "composer/installers": "~1.0" + } +} \ No newline at end of file diff --git a/plugins/rainlab/blogvideo/partials/popup.htm b/plugins/rainlab/blogvideo/partials/popup.htm new file mode 100644 index 000000000..31dc97e4f --- /dev/null +++ b/plugins/rainlab/blogvideo/partials/popup.htm @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/plugins/rainlab/blogvideo/updates/version.yaml b/plugins/rainlab/blogvideo/updates/version.yaml new file mode 100644 index 000000000..e933a3883 --- /dev/null +++ b/plugins/rainlab/blogvideo/updates/version.yaml @@ -0,0 +1,5 @@ +1.0.1: First version of Blog Video plugin +1.0.2: Fixes issue where videos cannot be uploaded caused by latest Markdown library. +1.1.0: Adds a new Video button to the Markdown editor toolbar. +1.1.1: Minor styling update. +1.1.2: Update toolbar icon. diff --git a/storage/framework/classes.php b/storage/framework/classes.php index 3f3cb0ad0..5982eac2e 100644 --- a/storage/framework/classes.php +++ b/storage/framework/classes.php @@ -457,4 +457,5 @@ 'System\\Twig\\MailPartialNode' => 'modules/system/twig/MailPartialNode.php', 'System\\Models\\MailPartial' => 'modules/system/models/MailPartial.php', 'Cms\\Twig\\DefaultNode' => 'modules/cms/twig/DefaultNode.php', + 'rainlab\\blogvideo\\Plugin' => 'plugins/rainlab/blogvideo/Plugin.php', ); \ No newline at end of file diff --git a/themes/modern2/content/static-pages-en/contact.htm b/themes/modern2/content/static-pages-en/contact.htm index 693589bc2..1d9f133e4 100644 --- a/themes/modern2/content/static-pages-en/contact.htm +++ b/themes/modern2/content/static-pages-en/contact.htm @@ -9,5 +9,5 @@ title = "Contact us"
Contacts
Address: Turkmenistan, Ashgabat city, Makhtumkuli avenue, 72
-
Phone: (+99312) 211059
+
Phone: (+99312) 211059
\ No newline at end of file diff --git a/themes/modern2/content/static-pages/contact.htm b/themes/modern2/content/static-pages/contact.htm index 17b41bac1..10095addb 100644 --- a/themes/modern2/content/static-pages/contact.htm +++ b/themes/modern2/content/static-pages/contact.htm @@ -1,11 +1,12 @@ [viewBag] title = "Связаться с нами" -url = "/contact-us" +url = "/habarlash" layout = "contacts" is_hidden = 0 navigation_hidden = 0 robot_index = "index" robot_follow = "follow" +localeUrl[en] = "/habarlash" == {% put form %}
Обратная связь
@@ -16,5 +17,5 @@ robot_follow = "follow"
Наши контакты:
Наш адрес: Туркменистан, г.Ашхабад, проспект Махтумкули, 72
-
Тел: (+99312) 211059
+
Тел: (+99312) 211059
\ No newline at end of file diff --git a/themes/modern2/pages/index.htm b/themes/modern2/pages/index.htm index f6f11e19f..a91aceb40 100644 --- a/themes/modern2/pages/index.htm +++ b/themes/modern2/pages/index.htm @@ -103,10 +103,10 @@ random = 0
{% component 'adv_center_5' %}
- {% partial 'index/partner_news' %} +
- + {% partial 'index/partner_news' %} {% component 'right_top' css_class= 'main__sidebar-adv' %} {% partial 'tags' %} {% component 'right_middle' css_class = 'main__sidebar-adv' %} @@ -117,7 +117,4 @@ random = 0
- - - +================================================ --> \ No newline at end of file diff --git a/themes/modern2/partials/index/partner_news.htm b/themes/modern2/partials/index/partner_news.htm index 1729215a3..bc93d14fa 100644 --- a/themes/modern2/partials/index/partner_news.htm +++ b/themes/modern2/partials/index/partner_news.htm @@ -9,8 +9,7 @@ maxItems = 6 {{'partner_news'|_}}
-
- {% for news in rssItems.items.slice(0,3) %} + {% for news in rssItems.items %}
@@ -34,33 +33,6 @@ maxItems = 6
{% endfor %} -
-
- {% for news in rssItems.items.slice(3) %} - -
-
-
- {{news.source}} -
-
-
-
{{news.published_at|date('d.m.Y')}} - - - - {{news.published_at|date('H:i')}} -
-
- - {{news.title}} - -
- - {% endfor %} -
-{% endif %} +{% endif %} \ No newline at end of file diff --git a/themes/modern2/partials/slider.htm b/themes/modern2/partials/slider.htm index ad55722ae..4aad4dbab 100644 --- a/themes/modern2/partials/slider.htm +++ b/themes/modern2/partials/slider.htm @@ -10,23 +10,23 @@ postPage = "post" [blogPosts featuredPosts] pageNumber = "{{ :page }}" -postsPerPage = 8 +featured = 1 +postsPerPage = 4 noPostsMessage = "No posts found" sortOrder = "published_at desc" categoryPage = "category" postPage = "post" -featured = 1 ==
{{'Главное'|_}} -
{% for post in featuredPosts %} {{post.title}} {% endfor %}
+
{% for post in featuredPosts.posts %} {{post.title}} {% endfor %}
- {% for post in posts.slice(0,3) %} + {% for post in blogPosts.posts.slice(0,3) %}
- {% for post in posts.slice(3) %} + {% for post in blogPosts.posts.slice(3) %}
{{post.title}}
@@ -112,4 +112,4 @@ featured = 1
{% endfor %}
-
+
\ No newline at end of file