Skip to content

Commit

Permalink
docs: add @slangroom/location examples
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed Oct 17, 2024
1 parent 1fd9615 commit fab3f5a
Show file tree
Hide file tree
Showing 46 changed files with 237 additions and 0 deletions.
72 changes: 72 additions & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,78 @@
<<< @/../examples/json-schema/validate.keys.json{json}
:::

## location plugin examples

### assign the current location
::: code-group
<<< @/../examples/location/assign.slang{3 gherkin:line-numbers}
<<< @/../examples/location/assign.data.json{json}
<<< @/../examples/location/assign.keys.json{json}
:::

### go back in history
::: code-group
<<< @/../examples/location/go_back.slang{3 gherkin:line-numbers}
<<< @/../examples/location/go_back.data.json{json}
<<< @/../examples/location/go_back.keys.json{json}
:::

### go forward in history
::: code-group
<<< @/../examples/location/go_forward.slang{3 gherkin:line-numbers}
<<< @/../examples/location/go_forward.data.json{json}
<<< @/../examples/location/go_forward.keys.json{json}
:::

### go to a specific page in history
::: code-group
<<< @/../examples/location/go_to_index.slang{3 gherkin:line-numbers}
<<< @/../examples/location/go_to_index.data.json{json}
<<< @/../examples/location/go_to_index.keys.json{json}
:::

### get the history length
::: code-group
<<< @/../examples/location/history_length.slang{3 gherkin:line-numbers}
<<< @/../examples/location/history_length.data.json{json}
<<< @/../examples/location/history_length.keys.json{json}
:::

### get the current location
::: code-group
<<< @/../examples/location/location.slang{9 gherkin:line-numbers}
<<< @/../examples/location/location.data.json{json}
<<< @/../examples/location/location.keys.json{json}
:::

### open the url in a new window
::: code-group
<<< @/../examples/location/new_window.slang{3 gherkin:line-numbers}
<<< @/../examples/location/new_window.data.json{json}
<<< @/../examples/location/new_window.keys.json{json}
:::

### redirect to the url
::: code-group
<<< @/../examples/location/redirect.slang{3 gherkin:line-numbers}
<<< @/../examples/location/redirect.data.json{json}
<<< @/../examples/location/redirect.keys.json{json}
:::

### reload the page
::: code-group
<<< @/../examples/location/reload.slang{3 gherkin:line-numbers}
<<< @/../examples/location/reload.data.json{json}
<<< @/../examples/location/reload.keys.json{json}
:::

### replace the current location
::: code-group
<<< @/../examples/location/replace.slang{3 gherkin:line-numbers}
<<< @/../examples/location/replace.data.json{json}
<<< @/../examples/location/replace.keys.json{json}
:::

## oauth plugin examples

### add data to authorization details
Expand Down
1 change: 1 addition & 0 deletions docs/examples/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let examplesDoc = `\n# Slangroom examples\n\n`;
'helpers',
'http',
'json-schema',
'location',
'oauth',
'pocketbase',
'qrcode',
Expand Down
22 changes: 22 additions & 0 deletions docs/statements/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ neither the open/connect part nor the parameters part are present.
| ------------ | --------------------- | ------------- |
| | json_data,json_schema | validate json |

## location plugin
| open/connect | params | phrase |
| ------------ | ------ | -------------------------------------- |
| | | get the current location |
| | | get the current location href |
| | | get the current location protocol |
| | | get the current location host |
| | | get the current location hostname |
| | | get the current location port |
| | | get the current location pathname |
| | | get the current location search params |
| | | get the current location hash |
| | | reload the current page |
| | url | replace the current location |
| | url | assign the current location |
| | url | redirect to the url |
| | | go back in history |
| | | go forward in history |
| | index | go to a specific page in history |
| | | get the history length |
| | url | open the url in a new window |

## oauth plugin
| open/connect | params | phrase |
| ------------ | ------------------------------------- | ------------------------------------ |
Expand Down
2 changes: 2 additions & 0 deletions docs/statements/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {git} from "@slangroom/git";
import {helpers} from "@slangroom/helpers";
import {http} from "@slangroom/http";
import {JSONSchema} from "@slangroom/json-schema";
import {location} from "@slangroom/location";
import {oauth} from "@slangroom/oauth";
import {pocketbase} from "@slangroom/pocketbase";
import {qrcode} from "@slangroom/qrcode";
Expand Down Expand Up @@ -61,6 +62,7 @@ const generateTable = (plugin, name) => {
[helpers, 'helpers'],
[http, 'http'],
[JSONSchema, 'json-schema'],
[location, 'location'],
[oauth, 'oauth'],
[pocketbase, 'pocketbase'],
[qrcode, 'qrcode'],
Expand Down
1 change: 1 addition & 0 deletions docs/statements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@slangroom/helpers": "workspace:^",
"@slangroom/http": "workspace:^",
"@slangroom/json-schema": "workspace:^",
"@slangroom/location": "workspace:^",
"@slangroom/oauth": "workspace:^",
"@slangroom/pocketbase": "workspace:^",
"@slangroom/qrcode": "workspace:^",
Expand Down
3 changes: 3 additions & 0 deletions examples/location/assign.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"url": "https://example.com"
}
1 change: 1 addition & 0 deletions examples/location/assign.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/assign.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "assign the current location",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/assign.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send url 'url' and assign the current location

Given nothing
Then print data
1 change: 1 addition & 0 deletions examples/location/go_back.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions examples/location/go_back.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/go_back.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "go back in history",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/go_back.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I go back in history

Given nothing
Then print data
1 change: 1 addition & 0 deletions examples/location/go_forward.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions examples/location/go_forward.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/go_forward.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "go forward in history",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/go_forward.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I go forward in history

Given nothing
Then print data
3 changes: 3 additions & 0 deletions examples/location/go_to_index.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"index": -1
}
1 change: 1 addition & 0 deletions examples/location/go_to_index.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/go_to_index.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "go to a specific page in history",
"highlight": 3
}
6 changes: 6 additions & 0 deletions examples/location/go_to_index.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given send index 'index' and I go to a specific page in history

Given nothing
Then print data
1 change: 1 addition & 0 deletions examples/location/history_length.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions examples/location/history_length.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/history_length.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "get the history length",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/history_length.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I get the history length and output into 'history_length'

Given I have a 'number' named 'history_length'
Then print data
1 change: 1 addition & 0 deletions examples/location/location.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions examples/location/location.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/location.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "get the current location",
"highlight": "9"
}
12 changes: 12 additions & 0 deletions examples/location/location.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Rule unknown ignore

# this reutrn the window.location object
# singular element of location can be obtained by adding
# the reuqest element, i.e. href, protocol, host, hostname, port,
# pathname, search params, hash, after 'location' like
# Given I get the current location href and output into 'result'

Given I get the current location and output into 'location'

Given I have a 'string dictionary' named 'location'
Then print data
3 changes: 3 additions & 0 deletions examples/location/new_window.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"url": "https://example.com"
}
1 change: 1 addition & 0 deletions examples/location/new_window.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/new_window.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "open the url in a new window",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/new_window.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send url 'url' and open the url in a new window

Given nothing
Then print data
3 changes: 3 additions & 0 deletions examples/location/redirect.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"url": "https://example.com"
}
1 change: 1 addition & 0 deletions examples/location/redirect.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/redirect.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "redirect to the url",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/redirect.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send url 'url' and redirect to the url

Given nothing
Then print data
1 change: 1 addition & 0 deletions examples/location/reload.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions examples/location/reload.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/reload.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "reload the page",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/reload.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I reload the current page

Given nothing
Then print data
3 changes: 3 additions & 0 deletions examples/location/replace.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"url": "https://example.com"
}
1 change: 1 addition & 0 deletions examples/location/replace.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions examples/location/replace.meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "replace the current location",
"highlight": "3"
}
6 changes: 6 additions & 0 deletions examples/location/replace.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send url 'url' and replace the current location

Given nothing
Then print data
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fab3f5a

Please sign in to comment.