-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add Widget for Chuck Norris quotes #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7e0b197
8b56c63
b3dedb1
0e44d90
74cea45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ Shipyard has support for displaying dynamic content in the form of widgets. Ther | |
| - [Stock Price History](#stock-price-history) | ||
| - [ETH Gas Prices](#eth-gas-prices) | ||
| - [Joke of the Day](#joke) | ||
| - [Chuck Norris quotes](#chucknorris) | ||
| - [XKCD Comics](#xkcd-comics) | ||
| - [Flight Data](#flight-data) | ||
| - [NASA APOD](#astronomy-picture-of-the-day) | ||
|
|
@@ -997,6 +998,36 @@ Renders a programming or generic joke. Data is fetched from the [JokesAPI](https | |
|
|
||
| --- | ||
|
|
||
| ### Chuck Norris quotes | ||
|
|
||
| Renders a Chuck Norris quote. Data is fetched from the [ChuckNorrisAPI](https://api.chucknorris.io/) by @matchilling. All fields are optional. | ||
|
|
||
| <p align="center"><img width="400" src="https://tbd" /></p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add meaningful alt text (and avoid placeholder URLs). The image uses a placeholder URL and lacks an 🧰 Tools🪛 markdownlint-cli2 (0.18.1)1005-1005: Images should have alternate text (alt text) (MD045, no-alt-text) 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In docs/widgets.md around line 1005, the image uses a placeholder URL and has no block until the image is available) and add a meaningful alt
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @khulnasoft-bot, you're right to flag this! The placeholder image should be addressed before merging. For the Chuck Norris widget documentation, I recommend one of these approaches: Option 1: Add a real screenshot (preferred)
<p align="center"><img width="400" src="https://i.ibb.co/[your-image-id]/chuck-norris.png" alt="Chuck Norris widget displaying a quote" /></p>Option 2: Remove the placeholder (temporary) ### Chuck Norris quotes
Renders a Chuck Norris quote. Data is fetched from the [ChuckNorrisAPI](https://api.chucknorris.io/) by @matchilling. All fields are optional.
#### OptionsThis keeps the documentation accessible and avoids dead links until a proper screenshot is available. Looking at other widgets in the file (like the Joke widget just above), they all use properly hosted images with the same hosting service, so following that pattern would maintain consistency. |
||
|
|
||
| #### Options | ||
|
|
||
| **Field** | **Type** | **Required** | **Description** | ||
| --- | --- | --- | --- | ||
| **`categories`** | `string` | _Optional_ | Set the category of jokes to return. Use a string to specify a single category, or an array to pass in multiple options. Available options are: `animal`,`career`,`celebrity`,`dev`,`explicit`,`fashion`,`food`,`history`,`money`,`movie`,`music`,`political`,`religion`,`science`,`sport` and `travel`. An up-to-date list of supported categories can be found [here](https://api.chucknorris.io/jokes/categories). Defaults to not explicitely set and therefore any of the categories can come up. | ||
|
|
||
| #### Example | ||
|
|
||
| ```yaml | ||
| - type: chucknorris | ||
| options: | ||
| categories: history,sport | ||
| ``` | ||
|
|
||
| #### Info | ||
|
|
||
| - **CORS**: 🟢 Enabled | ||
| - **Auth**: 🟢 Not Required | ||
| - **Price**: 🟢 Free | ||
| - **Host**: Managed Instance | ||
| - **Privacy**: _See [matchilling's Privacy Policy](https://api.chucknorris.io/privacy)_ | ||
|
|
||
| --- | ||
|
|
||
| ### XKCD Comics | ||
|
|
||
| Have a laugh with the daily comic from [XKCD](https://xkcd.com/). A classic webcomic website covering everything from Linux, math, romance, science and language. All fields are optional. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| <template> | ||
| <div class="chuckNorris-wrapper"> | ||
| <p class="chuckNorris chuckNorris-line">{{ chuckNorrisLine }}</p> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import axios from 'axios'; | ||
| import WidgetMixin from '@/mixins/WidgetMixin'; | ||
| import { widgetApiEndpoints } from '@/utils/defaults'; | ||
|
|
||
| export default { | ||
| mixins: [WidgetMixin], | ||
| components: {}, | ||
| data() { | ||
| return { | ||
| chuckNorrisLine: null, | ||
| }; | ||
| }, | ||
| computed: { | ||
| /* Format the users preferred categories */ | ||
| categories() { | ||
| let usersChoice = this.options.categories; | ||
| if (!usersChoice) return ''; | ||
| if (Array.isArray(usersChoice)) usersChoice = usersChoice.join(','); | ||
| const categories = ["animal","career","celebrity","dev","explicit","fashion","food","history","money","movie","music","political","religion","science","sport","travel"]; | ||
| if (categories.some((cat) => usersChoice.toLowerCase().includes(cat))) return usersChoice; | ||
| return ''; | ||
| }, | ||
|
FortiShield marked this conversation as resolved.
|
||
| /* Combine data parameters for the API endpoint */ | ||
| endpoint() { | ||
| if (this.categories !== '') return `${widgetApiEndpoints.chuckNorris}?category=${this.categories}`; | ||
| return `${widgetApiEndpoints.chuckNorris}`; | ||
| }, | ||
| }, | ||
| methods: { | ||
| /* Make GET request to ChuckNorris API endpoint */ | ||
| fetchData() { | ||
| axios.get(this.endpoint) | ||
| .then((response) => { | ||
| this.processData(response.data); | ||
| }) | ||
| .catch((dataFetchError) => { | ||
| this.error('Unable to fetch any Chuck Norris quote', dataFetchError); | ||
| }) | ||
| .finally(() => { | ||
| this.finishLoading(); | ||
| }); | ||
| }, | ||
| /* Assign data variables to the returned data */ | ||
| processData(data) { | ||
| this.chuckNorrisLine = data?.value || 'No joke available'; | ||
| }, | ||
|
FortiShield marked this conversation as resolved.
|
||
| }, | ||
| }; | ||
| </script> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .chuckNorris-wrapper { | ||
| p.chuckNorris { | ||
| color: var(--widget-text-color); | ||
| font-size: 1.2rem; | ||
| } | ||
| } | ||
|
|
||
| </style> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the broken table-of-contents anchor.
The link points to
#chucknorris, but the markdown heading renders as#chuck-norris-quotes, so the TOC entry won’t jump to the section. Update the fragment to use#chuck-norris-quotes.🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
32-32: Link fragments should be valid
(MD051, link-fragments)
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In docs/widgets.md around line 32, the TOC entry uses the wrong fragment
'#chucknorris' which doesn't match the rendered heading; update the link target
to '#chuck-norris-quotes' so the table-of-contents anchor matches the heading
and navigates correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khulnasoft-bot, you're absolutely right! The table of contents anchor needs to be corrected.
The issue is that markdown heading anchors are generated by converting the heading text to lowercase and replacing spaces with hyphens. So the heading
### Chuck Norris quotescreates the anchor#chuck-norris-quotes, not#chucknorris.The fix:
Change line 32 from:
To:
This will ensure the table of contents link correctly navigates to the Chuck Norris quotes widget section.