-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: hybrid headers, context and browser extension more in depth (#50)
* chore: update and pin dependencies * docs: add a separate page for the browser extension * docs: excludeBy option in register
- Loading branch information
Showing
9 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
package-lock=false | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Browser extension | ||
--- | ||
|
||
Developing layouts and podlets mostly works the same way as other web servers. Still, there are a couple of scenarios where the built-in developer tools in your browser can fall a bit short. The Podium Developer Tools browser extension can help. | ||
|
||
## Download the browser extension | ||
|
||
The Podium browser extension is available for Firefox and Chromium-based browsers. | ||
|
||
- [Firefox](https://addons.mozilla.org/en-US/firefox/addon/podium-developer-tools/) | ||
- [Chromium](https://chromewebstore.google.com/detail/podium-development-extens/jdlcejoeifgnnnckhnhapbmgieajaipl) based browsers | ||
|
||
## Using the browser extension | ||
|
||
First, you may have to allow the extension to run on the page you're debugging. In Firefox this is shown with a mark by the extensions drawer, and on the extension itself. | ||
|
||
![](/img/browser-extension-permissions.png) | ||
|
||
The extension adds two new panes to your browser's developer tools that cover two main use-cases. You may have to open an overflow menu to see them. | ||
|
||
![](/img/browser-extension-devtools-panes.png) | ||
|
||
### The Podium Context pane | ||
|
||
This pane is used when developing podlets to change the default values set on the [Podium context](/docs/guides/context). Say you want to test how your podlet behaves when given a different `deviceType` value. You could make changes in code, restart the server and then do your test, or you can use the extension and it's [partner middleware](https://github.com/podium-lib/dev-tool/tree/main/packages/server) to quickly swap values at runtime. | ||
|
||
### The Podium Headers pane | ||
|
||
This pane helps you set HTTP headers on requests to the server. It's mainly designed for use with Podium layouts, but can be used to set any header for any server. It comes with presets for [hybrid HTTP headers](/docs/guides/hybrid#hybrid-http-headers), but you can add and remove any headers you might need. | ||
|
||
## Missing a feature? | ||
|
||
If you have ideas for additional features that would help you develop and debug Podium applications, please [open an issue in the dev-tool repo](https://github.com/podium-lib/dev-tool/issues). If an issue allready exists, give it a thumbs-up. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,19 +14,43 @@ Layouts and podlets need to be able to adapt to requests from a hybrid web view. | |
|
||
### Hybrid HTTP headers | ||
|
||
:::tip | ||
|
||
Get the [browser extension](/docs/guides/browser-extension) to make it easier to set the hybrid HTTP headers when developing locally. | ||
|
||
::: | ||
|
||
| Header | Example | Description | | ||
| ------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------- | | ||
| `x-podium-app-id` | `[email protected]` | To identify clients in logs | | ||
| `x-podium-base-font-size` | `1rem` | To set base font size variable in CSS based on accessibility settings in the native host. | | ||
| `x-podium-device-type` | `hybrid-ios`, `hybrid-android` | To give hints to the server what should be included in the response. | | ||
| `Authorization` | `Bearer eyJhbGciOiJIU...` | Optional. Signifies a logged-in user. | | ||
|
||
#### Podium developer tools extension | ||
### Podium context | ||
|
||
Requests that include the hybrid HTTP headers have their values added to the Podium context, in addition to the [default context variables](/docs/guides/context#default-context-variables). | ||
|
||
| Header | Context name | Description | | ||
| ------------------------- | -------------- | --------------------------------------------------------------------- | | ||
| `x-podium-app-id` | `appId` | | | ||
| `x-podium-base-font-size` | `baseFontSize` | | | ||
| `x-podium-device-type` | `deviceType` | Overrides the value that would otherwise be derived from `User-Agent` | | ||
|
||
Get the extension to make it easier to set these HTTP headers when developing locally: | ||
### Conditionally fetch podlets | ||
|
||
In a hybrid web view setting your layout may want to exclude things like the header and footer. These are likely podlets, and Podium has an option when you register podlets to exclude them by device type. | ||
|
||
```js | ||
const headerPodlet = layout.client.register({ | ||
name: "header", | ||
uri: "http://header/manifest.json", | ||
excludeBy: { | ||
deviceType: ["hybrid-ios", "hybrid-android"], | ||
}, | ||
}); | ||
``` | ||
|
||
- [Firefox](https://addons.mozilla.org/en-US/firefox/addon/podium-developer-tools/) | ||
- [Chromium](https://chromewebstore.google.com/detail/podium-development-extens/jdlcejoeifgnnnckhnhapbmgieajaipl) based browsers | ||
In this case, if a request has the `x-podium-device-type: hybrid-ios` HTTP header, Podium will serve an empty response to the `headerPodlet.fetch()` call. | ||
|
||
## Client-side communcication | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.