mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
Merge pull request #1046 from PrivateBin/types-jsonld
expose types JSON-LD incl. configured expiration dates
This commit is contained in:
commit
b7f1621bbc
|
@ -425,10 +425,13 @@ class Controller
|
||||||
*/
|
*/
|
||||||
private function _jsonld($type)
|
private function _jsonld($type)
|
||||||
{
|
{
|
||||||
if (
|
if (!in_array($type, array(
|
||||||
$type !== 'paste' && $type !== 'comment' &&
|
'comment',
|
||||||
$type !== 'pastemeta' && $type !== 'commentmeta'
|
'commentmeta',
|
||||||
) {
|
'paste',
|
||||||
|
'pastemeta',
|
||||||
|
'types',
|
||||||
|
))) {
|
||||||
$type = '';
|
$type = '';
|
||||||
}
|
}
|
||||||
$content = '{}';
|
$content = '{}';
|
||||||
|
@ -440,6 +443,13 @@ class Controller
|
||||||
file_get_contents($file)
|
file_get_contents($file)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if ($type === 'types') {
|
||||||
|
$content = str_replace(
|
||||||
|
implode('", "', array_keys($this->_conf->getDefaults()['expire_options'])),
|
||||||
|
implode('", "', array_keys($this->_conf->getSection('expire_options'))),
|
||||||
|
$content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
header('Content-type: application/ld+json');
|
header('Content-type: application/ld+json');
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
|
|
@ -252,6 +252,23 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||||
), $content, 'outputs data correctly');
|
), $content, 'outputs data correctly');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testJsonLdTypes()
|
||||||
|
{
|
||||||
|
$_GET['jsonld'] = 'types';
|
||||||
|
ob_start();
|
||||||
|
new Controller;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
$this->assertEquals(str_replace(
|
||||||
|
'?jsonld=',
|
||||||
|
'/?jsonld=',
|
||||||
|
file_get_contents(PUBLIC_PATH . '/js/types.jsonld')
|
||||||
|
), $content, 'outputs data correctly');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user