Giter Site home page Giter Site logo

yandex-turbo-pages's Introduction

PHP7 Yandex Turbo Pages RSS feed generator

Latest Stable Version Total Downloads Latest Unstable Version composer.lock PHPPackages Rank PHPPackages Referenced By StandWithUkraine
Travis CI Build Status
Scrutinizer CI Build Status Scrutinizer Code Quality Code Coverage

Russian version of README you can find here: README_RU.md.

Yandex Turbo Pages valid RSS feed generator for PHP 7+. In this version type hinting used, so you need at least PHP 7.0.

Version for PHP 5.4 you can find here.

Examples

This example you can find in examples/example.php

// creates Feed with all needed namespaces
$feed = new Feed();

// creates Channel with description and one ad from Yandex Ad Network
$channel = new Channel();
$channel
    ->title('Channel Title')
    ->link('http://blog.example.com')
    ->description('Channel Description')
    ->language('ru')
    ->adNetwork(Channel::AD_TYPE_YANDEX, 'RA-123456-7', 'first_ad_place')
    ->appendTo($feed);

// adds Google Analytics to feed
$googleCounter = new Counter(Counter::TYPE_GOOGLE_ANALYTICS, 'XX-1234567-89');
$googleCounter->appendTo($channel);

// adds Yandex Metrika to feed
$yandexCounter = new Counter(Counter::TYPE_YANDEX, 12345678);
$yandexCounter->appendTo($channel);

// creates first page of feed with link and enabled turbo, description and other content, and appends this page to channel
$item = new Item();
$item
    ->title('Thirst page!')
    ->link('http://www.example.com/page1.html')
    ->author('John Smith')
    ->category('Technology')
    ->turboContent('Some content here!<br>Second content string.')
    ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->appendTo($channel);

// creates list of related pages
$relatedItemsList = new RelatedItemsList();

// adds link to first related page
$relatedItem = new RelatedItem('Related article 1', 'http://www.example.com/related1.html');
$relatedItem->appendTo($relatedItemsList);

// adds link to second related page with image
$relatedItem = new RelatedItem('Related article 2', 'http://www.example.com/related2.html',
    'http://www.example.com/related2.jpg');
$relatedItem->appendTo($relatedItemsList);

// appends list of related links to first page
$relatedItemsList
    ->appendTo($item);

// creates another one page with disabled turbo
$item = new Item(false);
$item
    ->title('Second page!')
    ->link('http://www.example.com/page2.html')
    ->author('John Smith')
    ->category('Technology')
    ->turboContent('Yet another content here!')
    ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->appendTo($channel);

// displays the generated feed
echo $feed;

For generating content for turbo items you can use Content helper. For example:

// generate header
$menuArray = [
    ['url' => 'http://example/page1.html', 'title' => 'Page title 1'],
    ['url' => 'http://example/page2.html', 'title' => 'Page title 2']
];
$header = Content::header('Main title', 'Second title',
    'http://example.com/image1.jpg', 'Image description', $menuArray);

At this time you can use helpers for generate next elements:

  • page header including menu;
  • image;
  • images gallery;
  • share buttons;
  • link or phone button;
  • comments;
  • rating;
  • accordion;
  • video from own server;
  • video from external server;
  • ad block position element;
  • media-content with slider;
  • additional content block;
  • search input;
  • modal contact form;
  • inline contact form.

Examples of using helpers you can find in examples/content_helpers.php.

Installing

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of yandex-turbo-pages

php composer.phar require sokolnikov911/yandex-turbo-pages

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

You can then later update yandex-turbo-pages using composer:

composer.phar update

Requirements

This Yandex Trurbo Pages RSS feed generator requires at least PHP 7.0 (yeahh, type hinting!).

License

License

This library is licensed under the MIT License.

yandex-turbo-pages's People

Contributors

sokolnikov911 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yandex-turbo-pages's Issues

Добавить обработку блоков

Channel -> yandex:logo
Channel -> lastBuildDate
Channel -> turbo:analytics type="custom" url=""
Channel -> ttl
Channel -> image (url, title, link)

Item -> guid
Item -> pdalink
item -> yandex:genre
item -> yandex:full-text

ну, как вариант, передайте ownership репозитория, у нас сейчас активно оно используется, допилю.

Использование в другом проекте

Добрый день, могу ли я использовать ваши наработки внутри своего плагина для WordPress, который создает ленту для турбо-страниц?

Есть какие-то требования или определённая лицензия?

Не увидел в классе, может ли он генерить тег img для header айтема.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.