Skip to content

Commit

Permalink
fix: Trim / from staticAssetsPathUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk committed Jul 19, 2022
1 parent 38d1481 commit 563654e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $supportedFeedTypes = array(
);
```

And `$staticAssetsPathUrl` (if required) should be set to the URL path of the directory containing the CSP static asset files (contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip), using the assets archive in this version of the PHP package), without a trailing slash (/).
And `$staticAssetsPathUrl` (if required) should be set to the URL path of the directory containing the CSP static asset files (contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip), using the assets archive in this version of the PHP package).


### API
Expand All @@ -106,7 +106,7 @@ And `$staticAssetsPathUrl` (if required) should be set to the URL path of the di

Returns a string corresponding to the compiled HTML, based on the `datasetsite.mustache`, the provided `$settings`, and `$supportedFeedTypes`.

If `$staticAssetsPathUrl` is provided, the [CSP-compatible template](https://developer.openactive.io/publishing-data/dataset-sites#template-hosting-options) is rendered. In this case you must ensure that you are serving the contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip) at this location, using the assets archive in this version of the PHP package. Note that `$staticAssetsPathUrl` must not have a trailing slash (/).
If `$staticAssetsPathUrl` is provided, the [CSP-compatible template](https://developer.openactive.io/publishing-data/dataset-sites#template-hosting-options) is rendered. In this case you must ensure that you are serving the contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip) at this location, using the assets archive in this version of the PHP package.

`$settings` must contain the following keys:

Expand Down Expand Up @@ -143,7 +143,7 @@ And `$supportedFeedTypes` must be an `array` of `FeedType` constants, which auto

Returns a string corresponding to the compiled HTML, based on the `datasetsite.mustache`, the provided [`$settings`](#settings), `$dataDownloads` and `$dataFeedDescriptions`.

If `$staticAssetsPathUrl` is provided, the [CSP-compatible template](https://developer.openactive.io/publishing-data/dataset-sites#template-hosting-options) is rendered. In this case you must ensure that you are serving the contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip) at this location, using the assets archive in this version of the PHP package. Note that `$staticAssetsPathUrl` must not have a trailing slash (/).
If `$staticAssetsPathUrl` is provided, the [CSP-compatible template](https://developer.openactive.io/publishing-data/dataset-sites#template-hosting-options) is rendered. In this case you must ensure that you are serving the contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip) at this location, using the assets archive in this version of the PHP package.

The `$dataDownloads` argument must be an `array` of `\OpenActive\Models\OA\DataDownload` objects, which each describe an available open data feed.

Expand All @@ -159,7 +159,7 @@ $dataFeedDescriptions = array(

Returns a string corresponding to the compiled HTML, based on the `datasetsite.mustache`, and the provided `$dataset`.

If `$staticAssetsPathUrl` is provided, the [CSP-compatible template](https://developer.openactive.io/publishing-data/dataset-sites#template-hosting-options) is rendered. In this case you must ensure that you are serving the contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip) at this location, using the assets archive in this version of the PHP package. Note that `$staticAssetsPathUrl` must not have a trailing slash (/).
If `$staticAssetsPathUrl` is provided, the [CSP-compatible template](https://developer.openactive.io/publishing-data/dataset-sites#template-hosting-options) is rendered. In this case you must ensure that you are serving the contents of the [CSP compatible static assets archive](/src/datasetsite-csp.static.zip) at this location, using the assets archive in this version of the PHP package.

The `$dataset` argument must be an object of type `\OpenActive\Models\OA\Dataset`, and must contain the properties required to render the dataset site.

Expand Down
8 changes: 4 additions & 4 deletions src/TemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
*
* @param array $settings
* @param FeedType[] $supportedFeedTypes
* @param string $staticAssetsPathUrl The location of the self-hosted assets for the CSP-compatible template. If set, the CSP-compatible template will be used. Note this value must not have a trailing slash (/).
* @param string $staticAssetsPathUrl The location of the self-hosted assets for the CSP-compatible template. If set, the CSP-compatible template will be used.
* @return string Rendered template
*/
public function renderSimpleDatasetSite($settings, $supportedFeedTypes, $staticAssetsPathUrl = null)
Expand Down Expand Up @@ -101,7 +101,7 @@ function($feedConfiguration) {
* @param array $settings
* @param DataDownload[] $dataDownloads
* @param string[] $dataFeedDescriptions
* @param string $staticAssetsPathUrl The location of the self-hosted assets for the CSP-compatible template. If set, the CSP-compatible template will be used. Note this value must not have a trailing slash (/).
* @param string $staticAssetsPathUrl The location of the self-hosted assets for the CSP-compatible template. If set, the CSP-compatible template will be used.
* @return string Rendered template
*/
public function renderSimpleDatasetSiteFromDataDownloads(
Expand Down Expand Up @@ -193,7 +193,7 @@ public function renderSimpleDatasetSiteFromDataDownloads(
* Render the template from a given OpenActive dataset model.
*
* @param \OpenActive\Models\Dataset $dataset The OpenActive model.
* @param string $staticAssetsPathUrl The location of the self-hosted assets for the CSP-compatible template. If set, the CSP-compatible template will be used. Note this value must not have a trailing slash (/).
* @param string $staticAssetsPathUrl The location of the self-hosted assets for the CSP-compatible template. If set, the CSP-compatible template will be used.
* @return string Rendered template
*/
public function renderDatasetSite($dataset, $staticAssetsPathUrl = null)
Expand All @@ -214,7 +214,7 @@ public function renderDatasetSite($dataset, $staticAssetsPathUrl = null)
$templateFilename = "/datasetsite.mustache";
} else {
$templateFilename = "/datasetsite-csp.mustache";
$data["staticAssetsPathUrl"] = $staticAssetsPathUrl;
$data["staticAssetsPathUrl"] = rtrim($staticAssetsPathUrl, "/");
}

// Get relevant template from FS
Expand Down

0 comments on commit 563654e

Please sign in to comment.