Skip to content

Latest commit

 

History

History
306 lines (218 loc) · 6.33 KB

config.markdown

File metadata and controls

306 lines (218 loc) · 6.33 KB

Configuration

How to use the Config object

To change the default parameters, you have to use the Config class. Create a new instance and pass it to the Reader object like that:

use PicoFeed\Reader\Reader;
use PicoFeed\Config\Config;

$config = new Config;
$config->setClientUserAgent('My custom RSS Reader')
       ->setProxyHostname('127.0.0.1')
       ->setProxyPort(8118);

$reader = new Reader($config);
...

HTTP Client parameters

Connection timeout

  • Method name: setClientTimeout()
  • Default value: 10 seconds
  • Argument value: number of seconds (integer)
$config->setClientTimeout(20); // 20 seconds

User Agent

  • Method name: setClientUserAgent()
  • Default value: PicoFeed (https://github.com/miniflux/picoFeed)
  • Argument value: string
$config->setClientUserAgent('My RSS reader');

Maximum HTTP redirections

  • Method name: setMaxRedirections()
  • Default value: 5
  • Argument value: integer
$config->setMaxRedirections(10);

Maximum HTTP body response size

  • Method name: setMaxBodySize()
  • Default value: 2097152 (2MB)
  • Argument value: value in bytes (integer)
$config->setMaxBodySize(10485760); // 10MB

Proxy hostname

  • Method name: setProxyHostname()
  • Default value: empty
  • Argument value: string
$config->setProxyHostname('proxy.example.org');

Proxy port

  • Method name: setProxyPort()
  • Default value: 3128
  • Argument value: port number (integer)
$config->setProxyPort(8118);

Proxy username

  • Method name: setProxyUsername()
  • Default value: empty
  • Argument value: string
$config->setProxyUsername('myuser');

Proxy password

  • Method name: setProxyPassword()
  • Default value: empty
  • Argument value: string
$config->setProxyPassword('mysecret');

Content grabber

Connection timeout

  • Method name: setGrabberTimeout()
  • Default value: 10 seconds
  • Argument value: number of seconds (integer)
$config->setGrabberTimeout(20); // 20 seconds

User Agent

  • Method name: setGrabberUserAgent()
  • Default value: PicoFeed (https://github.com/miniflux/picoFeed)
  • Argument value: string
$config->setGrabberUserAgent('My content scraper');

Add a rules folder

  • Method name: setGrabberRulesFolder()
  • Default value: null
  • Argument value: string
$config->setGrabberRulesFolder('/path/to/my/grabber/rules');

Parser

Hash algorithm used for item id generation

  • Method name: setParserHashAlgo()
  • Default value: sha256
  • Argument value: any value returned by the function hash_algos() (string)
  • See: http://php.net/hash_algos
$config->setParserHashAlgo('sha1');

Disable item content filtering

  • Method name: setContentFiltering()
  • Default value: true (filtering is enabled by default)
  • Argument value: boolean
$config->setContentFiltering(false);

Timezone

$config->setTimezone('Europe/Paris');

Logging

Timezone

$config->setTimezone('Europe/Paris');

Filter

Set the iframe whitelist (allowed iframe sources)

  • Method name: setFilterIframeWhitelist()
  • Default value: See the Filter class source code
  • Argument value: array
$config->setFilterIframeWhitelist(['http://www.youtube.com', 'http://www.vimeo.com']);

Define HTML integer attributes

  • Method name: setFilterIntegerAttributes()
  • Default value: See the Filter class source code
  • Argument value: array
$config->setFilterIntegerAttributes(['width', 'height']);

Add HTML attributes automatically

  • Method name: setFilterAttributeOverrides()
  • Default value: See the Filter class source code
  • Argument value: array
$config->setFilterAttributeOverrides(['a' => ['target' => '_blank']);

Set the list of required attributes for tags

  • Method name: setFilterRequiredAttributes()
  • Default value: See the Filter class source code
  • Argument value: array
  • Note: If the required attributes are not there, the tag is stripped
$config->setFilterRequiredAttributes(['a' => 'href', 'img' => 'src']);

Set the resource blacklist (Ads blocker)

  • Method name: setFilterMediaBlacklist()
  • Default value: See the Filter class source code
  • Argument value: array
  • Note: Tags are stripped if they have those URLs
$config->setFilterMediaBlacklist(['feeds.feedburner.com', 'share.feedsportal.com']);

Define which attributes are used for external resources

  • Method name: setFilterMediaAttributes()
  • Default value: See the Filter class source code
  • Argument value: array
$config->setFilterMediaAttributes(['src', 'href']);

Define the scheme whitelist

$config->setFilterSchemeWhitelist(['http://', 'ftp://']);

Define the tags and attributes whitelist

  • Method name: setFilterWhitelistedTags()
  • Default value: See the Filter class source code
  • Argument value: array
  • Note: Only those tags are allowed everything else is stripped
$config->setFilterWhitelistedTags(['a' => ['href'], 'img' => ['src', 'title']]);

Define a image proxy url

  • Method name: setFilterImageProxyUrl()
  • Default value: Empty
  • Argument value: string
$config->setFilterImageProxyUrl('http://myproxy.example.org/?url=%s');

Define a image proxy callback

  • Method name: setFilterImageProxyCallback()
  • Default value: null
  • Argument value: Closure
$config->setFilterImageProxyCallback(function ($image_url) {
    $key = hash_hmac('sha1', $image_url, 'secret');
    return 'https://mypublicproxy/'.$key.'/'.urlencode($image_url);
});

Define image proxy protocol restriction

  • Method name: setFilterImageProxyProtocol()
  • Default value: Empty (all protocols)
  • Argument value: string
$config->setFilterImageProxyProtocol('http');