Skip to content

Commit

Permalink
Prepare for release v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Oct 15, 2020
1 parent ce0c843 commit d1daeea
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v0.5.0
## 10/15/2020

1. [](#new)
* Added custom effects for images
* Added settings for image width and height (are required for some custom effects)
* Added a custom sorting for pages (by title, by slug, by date, manual ordering, etc)

# v0.4.0
## 10/09/2020

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ route: '/turbo'
feed_title: null
feed_description: null
content: null
sort_by: default
sort_dir: asc
sort_by: date
sort_dir: desc
image_effects:
resize: false
cropResize: true
Expand Down
7 changes: 4 additions & 3 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Yandex Turbo
slug: yandex-turbo
type: plugin
version: 0.4.0
version: 0.5.0
description: "Generates a special **RSS feed** with blog pages, in accordance with the Yandex.Turbo technology."
icon: rss
author:
Expand Down Expand Up @@ -62,10 +62,11 @@ form:
options:
default: PLUGIN_YANDEX_TURBO.SORT_DEFAULT
title: PLUGIN_YANDEX_TURBO.SORT_TITLE
slug: PLUGIN_YANDEX_TURBO.SORT_SLUG
date: PLUGIN_YANDEX_TURBO.SORT_DATE
modified: PLUGIN_YANDEX_TURBO.SORT_MODIFIED
folder: PLUGIN_YANDEX_TURBO.SORT_FOLDER
publish_date: PLUGIN_YANDEX_TURBO.SORT_PUBLISH_DATE
manual: PLUGIN_YANDEX_TURBO.SORT_MANUAL

sort_dir:
type: select
Expand All @@ -78,7 +79,7 @@ form:
image_effects:
type: checkboxes
label: PLUGIN_YANDEX_TURBO.IMAGE_EFFECTS
description: <a href="https://learn.getgrav.org/16/content/media#image-actions" rel="noopener" target="_blank">Документация</a>
description: PLUGIN_YANDEX_TURBO.IMAGE_EFFECT_DESC
options:
resize: resize
cropResize: cropResize
Expand Down
18 changes: 11 additions & 7 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ en:
SORT_BY: 'Sorting type'
SORT_DEFAULT: 'Default (01.home, 02.advark, etc.)'
SORT_TITLE: 'By title'
SORT_DATE: 'By create/update date (if defined)'
SORT_MODIFIED: 'By date of change'
SORT_FOLDER: 'By folder name'
SORT_PUBLISH_DATE: 'By date of publication (if defined)'
SORT_SLUG: 'By slug'
SORT_DATE: 'By date of creation (if specified)'
SORT_MODIFIED: 'By date of changing'
SORT_PUBLISH_DATE: 'By date of publication (if specified)'
SORT_MANUAL: 'According to the order of the elements in the option above and the sorting direction'
SORT_DIRECTION: 'Sort direction'
DIRECTION_DESC: 'In descending order'
DIRECTION_ASC: 'In ascending order'
IMAGE_EFFECTS: 'Effects applied to images'
IMAGE_EFFECT_DESC: '<a href="https://learn.getgrav.org/16/content/media#image-actions" rel="noopener" target="_blank">Docs</a>'
IMAGE_WIDTH: 'Image width'
IMAGE_HEIGHT: 'Image height'
IMAGE_SIZES_HELP: 'Used together with the resize and cropResize filters.'
Expand All @@ -37,14 +39,16 @@ ru:
SORT_BY: 'Тип сортировки'
SORT_DEFAULT: 'По умолчанию (01.home, 02.advark и т. д.)'
SORT_TITLE: 'По заголовку'
SORT_DATE: 'По дате создания/обновления (если определена)'
SORT_SLUG: 'По слагу'
SORT_DATE: 'По дате создания (если указана)'
SORT_MODIFIED: 'По дате изменения'
SORT_FOLDER: 'По имени папки'
SORT_PUBLISH_DATE: 'По дате публикации (если определена)'
SORT_PUBLISH_DATE: 'По дате публикации (если указана)'
SORT_MANUAL: 'В соответствии с порядком элементов в опции выше и направлением сортировки'
SORT_DIRECTION: 'Направление сортировки'
DIRECTION_DESC: 'По убыванию'
DIRECTION_ASC: 'По возрастанию'
IMAGE_EFFECTS: 'Эффекты, применяемые к изображениям'
IMAGE_EFFECT_DESC: '<a href="https://learn.getgrav.org/16/content/media#image-actions" rel="noopener" target="_blank">Документация</a>'
IMAGE_WIDTH: 'Ширина изображений'
IMAGE_HEIGHT: 'Высота изображений'
IMAGE_SIZES_HELP: 'Используется вместе с фильтрами resize и cropResize.'
Expand Down
4 changes: 2 additions & 2 deletions templates/turbo.rss.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<h1>{{ (item.title ?: site.title)|truncate(240) }}</h1>
{% if item.media %}
{% set first_image = item.media|first %}
{% if image_effects['resize']%}
{% if image_effects['resize'] %}
{% set first_image = first_image.resize(image_width,image_height) %}
{% endif %}
{% if image_effects['cropResize']%}
{% if image_effects['cropResize'] %}
{% set first_image = first_image.cropResize(image_width,image_height) %}
{% endif %}
{% if image_effects['grayscale'] %}
Expand Down
21 changes: 18 additions & 3 deletions yandex-turbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,23 @@ public function onPagesInitialized()
$page = Grav::instance()['page'];

foreach ($content as $key => $route) {
$collection->append($page->evaluate(['@page.children' => $route]));
if ($route === '/') {
$collection->append($page->evaluate(['@page.self' => $route, '@page' => $route]));
} else {
$collection->append($page->evaluate(['@page.self' => $route, '@page.children' => $route]));
}
}
}

$by = $this->config->get('plugins.yandex-turbo.sort_by') ?? 'date';
$dir = $this->config->get('plugins.yandex-turbo.sort_dir') ?? 'desc';
$collection = $collection->published()->routable()->order($by, $dir)->slice(0, 1000);
$options = [$by, $dir];

if ($by === 'manual' && !empty($content)) {
$options = array_merge($options, [$content, SORT_NUMERIC]);
}

$collection = $collection->published()->routable()->order(...$options)->slice(0, 1000);

foreach ($collection as $page) {
$header = $page->header();
Expand All @@ -121,7 +131,12 @@ public function onPagesInitialized()
$entry = new \stdClass();
$entry->title = $page->title();
$entry->link = $page->canonical();
$entry->date = date(DATE_RFC822, $page->date());

$date = $by == 'modified' ? $page->modified() : $page->date();
if ($by == 'publish_date' && !empty($page->publishDate()))
$date = $page->publishDate();

$entry->date = date(DATE_RFC822, $date);

if (!empty($header->metadata['author'])) {
$entry->author = $header->metadata['author'];
Expand Down
4 changes: 2 additions & 2 deletions yandex-turbo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ route: '/turbo'
feed_title: null
feed_description: null
content: null
sort_by: default
sort_dir: asc
sort_by: date
sort_dir: desc
image_effects:
resize: false
cropResize: true
Expand Down

0 comments on commit d1daeea

Please sign in to comment.