Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PasteBin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIERRON Laurent
PasteBin
Commits
b7f1621b
Unverified
Commit
b7f1621b
authored
2 years ago
by
El RIDO
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1046 from PrivateBin/types-jsonld
expose types JSON-LD incl. configured expiration dates
parents
e84a8694
3a4e5ed0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Controller.php
+14
-4
14 additions, 4 deletions
lib/Controller.php
tst/JsonApiTest.php
+17
-0
17 additions, 0 deletions
tst/JsonApiTest.php
with
31 additions
and
4 deletions
lib/Controller.php
+
14
−
4
View file @
b7f1621b
...
...
@@ -425,10 +425,13 @@ class Controller
*/
private
function
_jsonld
(
$type
)
{
if
(
$type
!==
'paste'
&&
$type
!==
'comment'
&&
$type
!==
'pastemeta'
&&
$type
!==
'commentmeta'
)
{
if
(
!
in_array
(
$type
,
array
(
'comment'
,
'commentmeta'
,
'paste'
,
'pastemeta'
,
'types'
,
)))
{
$type
=
''
;
}
$content
=
'{}'
;
...
...
@@ -440,6 +443,13 @@ class Controller
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
(
'Access-Control-Allow-Origin: *'
);
...
...
This diff is collapsed.
Click to expand it.
tst/JsonApiTest.php
+
17
−
0
View file @
b7f1621b
...
...
@@ -252,6 +252,23 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
),
$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
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment