Update
- 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:
parent
ed4bbfeedd
commit
aa1c5473c8
2
blog.txt
2
blog.txt
|
@ -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).
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue