Commit graph

127 commits

Author SHA1 Message Date
logmanoriginal
705b9daa0b bridge: Refactor bridge factory to non-static class
The bridge factory can be based on the abstract factory class if it
wasn't static. This allows for higher abstraction and makes future
extensions possible. Also, not all parts of RSS-Bridge need to work
on the same instance of the bridge factory.

References #1001
2019-06-18 18:55:32 +02:00
logmanoriginal
e2e0ced055 [Bridge] Improve performance for correctly written whitelist.txt
If the bridge name matches exactly, it is not necessary to perform
a strtolower compare of bridges. In some situations this can lead
to much faster response times (depending on the amount of bridges
in whitelist.txt).
2019-06-06 20:59:33 +02:00
logmanoriginal
d4e867f240 core: Move default bridges to whitelist.default.txt
Default bridges are currently statically defined in index.php, which
is not the right place if we want to keep responsibilities separated.

This commit introduces a new file whitelist.default.txt that holds
the default bridges and which is loaded automatically, if whitelist.txt
doesn't exist.

Due to this it is also no longer necessary to have write permission
for the root directory.

References #1001
2019-06-06 20:53:46 +02:00
logmanoriginal
32d4da8b76 [Bridge] Fix failed to open stream when reading non-existing whitelist 2019-02-04 17:35:40 +01:00
logmanoriginal
88b0656954 bridge: Rename listBridge to getBridgeNames 2018-11-15 19:43:23 +01:00
logmanoriginal
66b11b8c41 [Bridge] Fix typo 2018-11-15 19:38:14 +01:00
logmanoriginal
6e70d461e1 [Bridge] Add function isBridgeName
This function returns true if the provided name is a valid
bridge name.
2018-11-15 19:33:56 +01:00
logmanoriginal
0a92b5d29b [Bridge] Refactor Bridge::create to improve readability 2018-11-15 19:31:31 +01:00
logmanoriginal
e3849f45ab [Bridge] Use slashes to enclose regex 2018-11-15 19:30:33 +01:00
logmanoriginal
3d9c4a3718 [Bridge] Improve working directory handling
- Initialize with null to prevent leaking configurations
- Check if the working directory is a directory
- Store the real path instead of raw data
- Add final path separator as expected by Bridge::create
2018-11-15 19:28:56 +01:00
logmanoriginal
5f146a257e [Bridge] Change visibility from private to protected 2018-11-15 19:24:43 +01:00
logmanoriginal
936688e08c [Bridge] Fix typos 2018-11-15 19:22:32 +01:00
logmanoriginal
4b5372638c [Bridge] Use self:: instead of Bridge:: inside the class 2018-11-15 19:19:04 +01:00
logmanoriginal
6f4a8f4d03 [Bridge] Rename to in setWorkingDir 2018-11-15 19:17:18 +01:00
logmanoriginal
39652bb050 [Bridge] Rename to 2018-11-15 19:16:37 +01:00
logmanoriginal
fcac5b8b92 [Bridge] Cleanup documentation and exception messages 2018-11-15 19:15:08 +01:00
logmanoriginal
6f7b56cba8 bridge: Rename setDir and getDir to setWorkingDir and getWorkingDir 2018-11-15 19:07:33 +01:00
logmanoriginal
4a6b3654eb [Bridge] Add and rewrite documentation compatible to phpDocumentor
This is the first step in adding documentation to the core library
of RSS-Bridge. The documentation is not yet extracted by phpdoc,
yet may prove useful to anyone interested in starting with RSS-Bridge.
2018-11-13 20:28:17 +01:00
logmanoriginal
c15b25a07d core: Fix PHPCS violations 2018-11-13 18:27:05 +01:00
logmanoriginal
007ee4d858 [Bridge] Fix broken bridge initialization
Commit e26d61e introduced a bug that causes the error message "The
bridge you [sic!] looking for does not exist." if the bridge name
specified in the query ends on "Bridge"
(i.e. '&bridge=SoundcloudBridge'), while other queries work fine
(i.e. '&bridge=Soundcloud').

This commit fixes that issue by sanitizing the bridge name before
creating the class.

References #922
2018-11-13 17:36:06 +01:00
Thomas Dalichow
dd95ec6200 core: Fix grammar (#923) 2018-11-13 17:24:36 +01:00
logmanoriginal
3bb3353897 [Bridge] Use static variable in listBridges()
This prevents the function from re-loading the same data over and over
again. Instead the same data is returned on each call, during a single
request.
2018-11-10 22:31:40 +01:00
logmanoriginal
e26d61ec0a core: Refactor bridge whitelisting
- Move all whitelisting functionality inside Bridge.php
- Set default whitelist once in index.php using Bridge::setWhitelist()
- Include bridge sanitizing inside Bridge.php
    Bridge::sanitizeBridgeName($name)

Bridge.php now maintains the whitelist internally.
2018-11-10 22:26:58 +01:00
logmanoriginal
4b7fea5ebc [RssBridge] Include interfaces once 2018-11-06 19:23:32 +01:00
logmanoriginal
62c190d841 [Bridge] Remove superfuous variables and statements 2017-08-06 00:04:07 +02:00
logmanoriginal
84d2c02a09 whitelist: Do case-insensitive whitelist matching
Matching whitelisted bridges using a case-insensitive match makes
sense for following reasons:

- Wrong upper/lower case spelling in the whitelist is not easily
discovered. Example: Misspelling 'Youtube' as 'YouTube' will not
show the 'Youtube' bridge (while it is expected to show)

- Two bridges with the same name but different letter casing are
discouraged to prevent confusion and keep the project compatible
with Windows machines
2017-08-06 00:01:32 +02:00
logmanoriginal
a4b9611e66 [phpcs] Add missing rules
- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
2017-07-29 19:55:12 +02:00
logmanoriginal
6943abd9c2 [Bridge] Fix whitelist check 2016-09-11 14:02:02 +02:00
logmanoriginal
ab16af631e [core] Apply some fixes 2016-09-10 21:01:02 +02:00
logmanoriginal
62eec43980 [core] Apply common indentation
All files are now using tabs for indentation
2016-09-10 20:41:11 +02:00
logmanoriginal
298dc49c67 [lib] Split Bridge/Cache/Format into one file per class
The files have grown to a size where it is necessary to search
for a class in a file. This commit splits the content into one
file per class. RSS-Bridge will require implementations and
the implementations will require (once) the interfaces.
2016-09-05 18:05:19 +02:00
logmanoriginal
acde8a2cea [Bridge] Support 'dc:date' for RSS 2.0 parser 2016-09-04 13:46:57 +02:00
logmanoriginal
546c0036df [Bridge] Rename class RssExpander to FeedExpander
This class no is not RSS only anymore
2016-09-04 13:28:12 +02:00
logmanoriginal
39788485ea [Bridge] Rename 'parseRSSItem' to 'parseItem' 2016-09-04 13:26:17 +02:00
logmanoriginal
149b64879e [Bridge] Support 'dc' namespace for RSS 1.0 2016-09-04 13:05:17 +02:00
logmanoriginal
8fa0b9660f [Bridge] Fix ATOM feed uri detection 2016-09-04 12:40:42 +02:00
logmanoriginal
bf20a2f687 [Bridge] Remove uneccesary debug message 2016-09-04 12:34:56 +02:00
logmanoriginal
51a3a75aac [Bridge] Add RSS 1.0 and 2.0 parser 2016-09-04 12:32:56 +02:00
logmanoriginal
f781965825 [Bridge] Add RSS 0.91 parser 2016-09-04 11:45:14 +02:00
logmanoriginal
0e5775012f [Bridge] Rename parameter 'name' to 'url' 2016-09-04 11:01:13 +02:00
logmanoriginal
2aa9b8f026 [Bridge] Extend RssExpander to load ATOM formats 2016-09-03 22:17:36 +02:00
logmanoriginal
a8883523f4 [Bridge] Pass 'queriedContext' as parameter to 'setInputs'
This makes clear that 'setInputs' depends on the 'queriedContext'
2016-09-02 20:05:18 +02:00
logmanoriginal
d1ff23c7ba [Bridge] Fix incorrect switch variable 2016-09-02 19:53:59 +02:00
logmanoriginal
04bddd0758 [Bridge] Apply default value while setting inputs 2016-09-02 19:52:47 +02:00
logmanoriginal
5f3d60276a [Bridge] Use original input values to guess context 2016-09-02 19:46:58 +02:00
logmanoriginal
4bc4e03d7b [Bridge] Change order of variable declaration 2016-09-02 19:03:51 +02:00
logmanoriginal
41d3aa0695 [Bridge] Change scope of member variable 'inputs' 2016-09-02 19:01:57 +02:00
logmanoriginal
48db1693a1 [Bridge] Use member variable instead of local variable 2016-09-02 18:59:55 +02:00
logmanoriginal
c2e411ba82 [Bridge] Add function to set inputs 2016-09-02 18:38:07 +02:00
logmanoriginal
37f269cf53 [Bridge] Remove unused variable 2016-09-02 18:12:37 +02:00