1
0
Fork 0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-05-10 01:03:00 +03:00

[Documentation] Move all wiki pages into the repo and make it pretty ()

This commit is contained in:
Bocki 2022-03-22 21:33:29 +01:00 committed by GitHub
parent 16470e8119
commit 76f5de3d0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 4215 additions and 0 deletions

View file

@ -0,0 +1,24 @@
Create a new file in the `formats/` folder (see [Folder structure](../04_For_Developers/03_Folder_structure.md)).
The file must be named according to following specification:
* It starts with the type
* The file name must end with 'Format'
* The file type must be PHP, written in small letters (seriously!) ".php"
**Examples:**
Type | Filename
-----|---------
Atom | AtomFormat.php
Html | HtmlFormat.php
The file must start with the PHP tags and end with an empty line. The closing tag `?>` is [omitted](http://php.net/basic-syntax.instruction-separation).
Example:
```PHP
<?PHP
// PHP code here
// This line is empty (just imagine it!)
```

View file

@ -0,0 +1,146 @@
The `FormatInterface`interface defines functions that need to be implemented by all formats:
* [display](#the-display-function)
* [stringify](#the-stringify-function)
* [setItems](#the-setitems-function)
* [getItems](#the-getitems-function)
* [setCharset](#the-setcharset-function)
* [getCharset](#the-getcharset-function)
* [setExtraInfos](#the-setextrainfos-function)
* [getExtraInfos](#the-getextrainfos-function)
* [getMimeType](#the-getmimetype-function)
Find a [template](#template) at the end of this file
# Functions
## The `display` function
The `display` function shows the contents to the user and must return the object instance.
```PHP
display(): self
```
## The `stringify` function
The `stringify` function returns the items received by [`setItems`](#the-setitem-function) as string.
```PHP
stringify(): string
```
## The `setItems` function
The `setItems` function receives an array of items generated by the bridge and must return the object instance. Each item represents an entry in the feed. For more information refer to the [collectData](../05_Bridge_API/02_BridgeAbstract.md#collectdata) function.
```PHP
setItems(array $items): self
```
## The `getItems` function
The `getItems` function returns the items previously set by the [`setItems`](#the-setitems-function) function. If no items where set previously this function returns an error.
```PHP
getItems(): array
```
## The `setCharset` function
The `setCharset` function receives the character set value as string and returns the object instance.
```PHP
setCharset(string): self
```
## The `getCharset` function
The `getCharset` function returns the character set value.
```PHP
getCharset(): string
```
## The `setExtraInfos` function
The `setExtraInfos` function receives an array of elements with additional information to generate format outputs and must return the object instance.
```PHP
setExtraInfos(array $infos): self
```
Currently supported information are:
Name | Description
-----|------------
`name` | Defines the name as generated by the bridge
`uri` | Defines the URI of the feed as generated by the bridge
## The `getExtraInfos` function
The `getExtraInfos` function returns the information previously set via the [`setExtraInfos`](#the-setextrainfos-function) function.
```PHP
getExtraInfos(): array
```
## The `getMimeType` function
The `getMimeType` function returns the expected [MIME type](https://en.wikipedia.org/wiki/Media_type#Common_examples) of the format's output.
```PHP
getMimeType(): string
```
# Template
This is a bare minimum template for a format:
```PHP
<?php
class MyTypeFormat implements FormatInterface {
private $items;
private $charset;
private $extraInfos;
public function stringify(){
// Implement your code here
return ''; // Return items as string
}
public function display(){
// Implement your code here
echo $this->stringify();
return $this;
}
public function setItems(array $items){
$this->items = $items;
return $this;
}
public function getItems(){
return $this->items;
}
public function setCharset($charset){
$this->charset = $charset;
return $this;
}
public function getCharset(){
return $this->charset;
}
public function setExtraInfos(array $infos){
$this->extraInfos = $infos;
return $this;
}
public function getExtraInfos(){
return $this->extraInfos;
}
}
// Imaginary empty line!
```

View file

@ -0,0 +1,40 @@
The `FormatAbstract` class implements the [`FormatInterface`](../08_Format_API/02_FormatInterface.md) interface with basic functional behavior and adds common helper functions for new formats:
* [setContentType](#the-setcontenttype-function)
* [callContentType](#the-callcontenttype-function)
* [sanitizeHtml](#the-sanitizehtml-function)
* [array_trim](#the-array_trim-function)
# Functions
## The `setContentType` function
The `setContentType` function receives a string defining the content type for the HTML header and must return the object instance.
```PHP
setContentType(string): self
```
## The `callContentType` function
The `callContentType` function applies the content type to the header data and must return the object instance.
```PHP
callContentType(): self
```
## The `sanitizeHtml` function
The `sanitizeHtml` function receives an HTML formatted string and returns the string with disabled `<script>`, `<iframe>` and `<link>` tags.
```PHP
sanitizeHtml(string $html): string
```
## The `array_trim` function
The `array_trim` function receives an array of strings and returns the same array with all elements trimmed (like using the `trim` function on all elements)
```PHP
array_trim(array $elements): array
```

View file

@ -0,0 +1,3 @@
A _Format_ is an class that allows **RSS-Bridge** to turn items from a bridge into an RSS-feed format. It is developed in a PHP file located in the `formats/` folder (see [Folder structure](../04_For_Developers/03_Folder_structure.md)) and either implements the [FormatInterface](../08_Format_API/02_FormatInterface.md) interface or extends the [FormatAbstract](../08_Format_API/03_FormatAbstract.md) class.
For more information about how to create a new _Format_, read [How to create a new Format?](./01_How_to_create_a_new_format.md)