- Added support for URL as source
- Using `preg_split` instead of explode as it wouldn't separate the
entries for me.
- Updated the pattern to include the correct ID format.
This commit is contained in:
Paul (hxii) Glushak 2021-02-02 10:19:50 +02:00
parent ed4bbfeedd
commit aa1c5473c8
2 changed files with 8 additions and 3 deletions

View File

@ -1 +1 @@
2020-10-01T08:05:33Z ac7c64 Welcome to picoblog. For updates and such, visit [https://0xff.nu/picoblog](https://0xff.nu/picoblog).
2020-10-01T08:05:33Z (#MWZkYw) Welcome to picoblog. For updates and such, visit [https://0xff.nu/picoblog](https://0xff.nu/picoblog).

View File

@ -47,7 +47,7 @@ class PicoBlog
}
/**
* Read source file
* Read source file/URL
*
* @return boolean true if successful, false if not
*/
@ -58,6 +58,11 @@ class PicoBlog
if (!empty($this->rawentries)) {
return true;
}
} elseif ($url = filter_var($this->sourcefile, FILTER_VALIDATE_URL)) {
$this->rawentries = preg_split('/\x0A/', file_get_contents($url));
if (!empty($this->rawentries)) {
return true;
}
}
throw new \Exception("{$this->sourcefile} is empty! Aborting.");
return false;
@ -76,7 +81,7 @@ class PicoBlog
$pattern = '/^(?<date>[^\t]+)\t(?<entry>.+)/';
break;
case 'picoblog':
$pattern = '/^(?<date>[^\t]+)\t#(?<id>[a-zA-Z0-9]{6})\t(?<entry>.+)/';
$pattern = '/^(?<date>[^\t]+)\t\(#(?<id>[a-zA-Z0-9]{6,7})\)\t(?<entry>.+)/';
break;
}
foreach ($entries as $i => $entry) {