Skip to content
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

Update hyrule-compendium-search extension #12109

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions extensions/hyrule-compendium-search/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# Hyrule Compendium Changelog

## [0.3 | Icons Everywhere!] - 2024-04-26
<!-- ---------------------------------------------------------------- -->

## [Release **v1.0** | Introducing Broad Search!]

#### New Features:
- Added the **`Broad Search`** command [🎉](raycast://extensions/raycast/raycast/confetti). It allows you to see a grid with the multiple results of your search instead of only the first one, which is what `Get Entry` does.
- Added [icons](https://zeldawiki.wiki/wiki/Category:Breath_of_the_Wild_Sprites) for `Special Effects` in `Materials` and `Creatures`.
- Added [icons](https://zeldawiki.wiki/wiki/Category:Breath_of_the_Wild_Sprites) for the `Hearts Recovered` property in `Materials` and `Creatures` depending on the ammount of hearts recovered (also removed the text saying how many hearts).
- Added Icons for weapon `Attack` and shield `Guard`

#### Bug Fixes:
- Changed the icon for the Treasure Chest that said *Treasures*, it used to be the same icon as the `Treasures` catergory but is now a monochrome rupee.
- Changed the icon for the Blupee that said *Rupees*, it used to be the green rupee icon but is now a monochrome rupee.
- Changed the style of the entry description to now be standard markdown text instead of a code block.

<!-- ---------------------------------------------------------------- -->

## [v0.3 | Icons Everywhere!] - 2024-04-26

#### New Features:
- Added icons for `category` and all `drops` for entries that have them. Icons are taken from the [Zelda Wiki sprite sheet](https://zeldawiki.wiki/wiki/Category:Breath_of_the_Wild_Sprites).

#### Bug Fixes:
- Fixed bug where if the `drops` property for an entry is `null` instead of an empty array, it no longer throws an error.

#### Roadmap:
- Add icons for `special effects` and `hearts recovered` so that they dont look so boring and are easier to recognize
- Add a new command named **Broad Search** _(name due to change)_ that allows you to perform a broader search and view all the results, instead of just the first one, which is the current behavior of the **Get Entry** command.
<!-- ---------------------------------------------------------------- -->

## [0.2 | Fixed materials and creatures bug] - 2023-12-03
## [v0.2 | Fixed materials and creatures bug] - 2023-12-03

Fixed certain materials and creatures that had either 0 hearts recovered or no cooking effect displaying the 0 or "" cooking effect. They now dont display their respective empty Details

## [0.1 | Added Hyrule Compendium] - 2023-12-03
<!-- ---------------------------------------------------------------- -->

## [v0.1 | Added Hyrule Compendium] - 2023-12-03

Initial version code
12 changes: 5 additions & 7 deletions extensions/hyrule-compendium-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This extension allows you to conveniently search and access information from the BotW Hyrule Compendium.

![Hinox compendium entry](metadata/hyrule-compendium-search-5.png)
![Grid compendium view](metadata/hyrule-compendium-search-8.png)

It uses the Hyrule Compendium API by [Aarav Borthakur](https://github.com/gadhagod).

You can find the API [here](https://gadhagod.github.io/Hyrule-Compendium-API/#/).
Expand All @@ -14,13 +17,8 @@ Available categories:

The extension uses fuzzy search (fuse.js) to search for the entry you inputted, it doesent matter if you made a typo or didn't use the complete name, it still works!

<a title="Install hyrule-compendium-search Raycast Extension" href="https://www.raycast.com/MackoMaxo/hyrule-compendium-search"><img src="https://www.raycast.com/MackoMaxo/hyrule-compendium-search/[email protected]?v=1.1" height="64" alt="install hyrula compendium search" style="height: 64px;"></a>
<br>
┌─┬─┐<br>
│ │ │<br>
├─┼─┤<br>
│ │ │<br>
└─┴─┘
All icons for `drops`, `category`, `hearts recovered`, and `special effects` are all taken from the [Zelda Wiki sprite sheet](https://zeldawiki.wiki/wiki/Category:Breath_of_the_Wild_Sprites).

<a title="Install hyrule-compendium-search Raycast Extension" href="https://www.raycast.com/MackoMaxo/hyrule-compendium-search" style="height: 64px;"><img src="https://www.raycast.com/MackoMaxo/hyrule-compendium-search/[email protected]?v=1.1" height="64px" alt="install hyrula compendium search" style="height: 64px;"></a>

P.S: This is my first extension so please provide any feedback!
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
12 changes: 6 additions & 6 deletions extensions/hyrule-compendium-search/package-lock.json

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

12 changes: 10 additions & 2 deletions extensions/hyrule-compendium-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@
"required": true
}
]
},
{
"name": "broadSearch",
"title": "Search Entries",
"subtitle": "Search Hyrule Compendium Broadly",
"description": "Do a broader search by seeing all results for your search in a grid",
"mode": "view",
"icon": "command-icon.png"
}
],
"dependencies": {
"@raycast/api": "^1.63.0",
"@raycast/api": "^1.72.0",
"@raycast/utils": "^1.10.1",
"fuse.js": "^7.0.0"
},
Expand All @@ -49,4 +57,4 @@
"lint": "ray lint",
"publish": "npx @raycast/api@latest publish"
}
}
}
93 changes: 93 additions & 0 deletions extensions/hyrule-compendium-search/src/broadSearch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Action, ActionPanel, LaunchType, Grid, launchCommand } from "@raycast/api";
import names from "./names.json";
import { useFetch } from "@raycast/utils";

interface CreatureResponse {
isLoading: boolean;
data?: object;
}

interface Category {
category: string;
}

export default function Command() {
const miniBosses = [
"hinox",
"blue-maned lynel",
"white-maned lynel",
"silver lynel",
"talus",
"moldu",
"scout",
"stalker",
"skywatcher",
"turret",
];

function checkType(entry: string) {
if (entry.includes("ganon") || entry.includes("kohga")) {
return "boss";
} else {
for (let i = 0; i < miniBosses.length; i++) {
if (entry.includes(miniBosses[i])) {
return "miniboss";
}
}
return "";
}
}

function checkCategory(entry: string) {
const { data } = useFetch<CreatureResponse>(
`https://botw-compendium.herokuapp.com/api/v3/compendium/entry/${entry.replace(/ /g, "_")}`,
);

const category = data?.data as Category;

const bossOrNot: string = checkType(entry);

if (category?.category == "monsters") {
return ["monster", "monsters", "mob", "mob", "enemy", "enemies", bossOrNot];
} else if (category?.category == "equipment") {
return ["weapon", "weapons", "equipment", bossOrNot];
} else if (category?.category == "creatures") {
return ["animals", "animal", "mob", "mobs", "creature", "creatures", "bug", "bugs", bossOrNot];
} else if (category?.category == "materials") {
return ["material", "fruit", "food", "flower", bossOrNot];
}
}

return (
<Grid navigationTitle="Search Entries" searchBarPlaceholder="Search for entries...">
{names.map((item) => (
<Grid.Item
key={item}
// content={{ source: `https://botw-compendium.herokuapp.com/api/v3/compendium/entry/${item.replace(/ /g, "_")}/image` }}
content={{
source: `https://media.assets.so/?url=https://botw-compendium.herokuapp.com/api/v3/compendium/entry/${item.replace(
/ /g,
"_",
)}/image&w=128&f=webp`,
}}
title={item.replace(/(^|\s)\S/g, (match: string) => match.toUpperCase())}
keywords={checkCategory(item)}
actions={
<ActionPanel>
<Action
title="Select"
onAction={async () => {
await launchCommand({
name: "getEntry",
type: LaunchType.UserInitiated,
arguments: { entryName: item },
});
}}
/>
</ActionPanel>
}
/>
))}
</Grid>
);
}
62 changes: 54 additions & 8 deletions extensions/hyrule-compendium-search/src/getEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ ${entry?.description}
<Detail.Metadata.TagList.Item text={"None"} />
</Detail.Metadata.TagList>
);
} else if (entry?.drops[0] == "treasures") {
return (
<Detail.Metadata.TagList title="Drops">
<Detail.Metadata.TagList.Item
text={"Treasures"}
key={"treasures"}
icon={{ source: `materialIcons/treasureIcon.png` }}
/>
</Detail.Metadata.TagList>
);
} else {
return (
<Detail.Metadata.TagList title="Drops">
Expand All @@ -108,11 +118,25 @@ ${entry?.description}
}
} else if (category?.category == "equipment") {
if (entry?.properties.attack > 100000) {
return <Detail.Metadata.Label title="Attack" text={"∞"} />;
return (
<Detail.Metadata.Label title="Attack" icon={{ source: "materialIcons/attack.png" }} text={"∞"} />
);
} else if (entry?.properties.attack > 0) {
return <Detail.Metadata.Label title="Attack" text={entry?.properties.attack.toString()} />;
return (
<Detail.Metadata.Label
title="Attack"
icon={{ source: "materialIcons/attack.png" }}
text={entry?.properties.attack.toString()}
/>
);
} else if (entry?.properties.defense > 0) {
return <Detail.Metadata.Label title="Defense" text={entry?.properties.defense.toString()} />;
return (
<Detail.Metadata.Label
title="Defense"
icon={{ source: "materialIcons/guard.png" }}
text={entry?.properties.defense.toString()}
/>
);
} else {
if (entry?.name == "shock arrow") {
return (
Expand Down Expand Up @@ -163,7 +187,11 @@ ${entry?.description}
return (
<>
<Detail.Metadata.Label title="Cooking Effect" text={"None"} />
<Detail.Metadata.Label title="Hearts Recovered" text={entry?.hearts_recovered.toString()} />
<Detail.Metadata.Label
title="Hearts Recovered"
icon={{ source: `materialIcons/${entry?.hearts_recovered.toString()}.png` }}
// text={entry?.hearts_recovered.toString()}
/>
</>
);
} else {
Expand All @@ -172,22 +200,33 @@ ${entry?.description}
<>
<Detail.Metadata.Label
title="Cooking Effect"
icon={{ source: `materialIcons/${entry?.cooking_effect}.png` }}
text={entry?.cooking_effect.replace(/(^|\s)\S/g, (match: string) =>
match.toUpperCase(),
)}
/>
{/* <Detail.Metadata.Label
title="Hearts Recovered"
icon={{ source: `materialIcons/${entry?.hearts_recovered.toString()}.png` }}
text={entry?.hearts_recovered.toString()}
/> */}
</>
);
} else {
return (
<>
<Detail.Metadata.Label
title="Cooking Effect"
icon={{ source: `materialIcons/${entry?.cooking_effect}.png` }}
text={entry?.cooking_effect.replace(/(^|\s)\S/g, (match: string) =>
match.toUpperCase(),
)}
/>
<Detail.Metadata.Label title="Hearts Recovered" text={entry?.hearts_recovered.toString()} />
<Detail.Metadata.Label
title="Hearts Recovered"
icon={{ source: `materialIcons/${entry?.hearts_recovered.toString()}.png` }}
// text={entry?.hearts_recovered.toString()}
/>
</>
);
}
Expand All @@ -199,6 +238,7 @@ ${entry?.description}
<>
<Detail.Metadata.Label
title="Cooking Effect"
icon={{ source: `materialIcons/${entry?.cooking_effect}.png` }}
text={entry?.cooking_effect.replace(/(^|\s)\S/g, (match: string) =>
match.toUpperCase(),
)}
Expand All @@ -208,20 +248,26 @@ ${entry?.description}
} else {
if (entry?.cooking_effect == "") {
return (
<Detail.Metadata.Label title="Hearts Recovered" text={entry?.hearts_recovered.toString()} />
<Detail.Metadata.Label
title="Hearts Recovered"
icon={{ source: `materialIcons/${entry?.hearts_recovered.toString()}.png` }}
// text={entry?.hearts_recovered.toString()}
/>
);
} else {
return (
<>
<Detail.Metadata.Label
title="Cooking Effect"
icon={{ source: `materialIcons/${entry?.cooking_effect}.png` }}
text={entry?.cooking_effect.replace(/(^|\s)\S/g, (match: string) =>
match.toUpperCase(),
)}
/>
<Detail.Metadata.Label
title="Hearts Recovered"
text={entry?.hearts_recovered.toString()}
icon={{ source: `materialIcons/${entry?.hearts_recovered.toString()}.png` }}
// text={entry?.hearts_recovered.toString()}
/>
</>
);
Expand All @@ -234,7 +280,7 @@ ${entry?.description}
<Detail.Metadata.TagList title="Drops">
<Detail.Metadata.TagList.Item
text={"Rupees"}
icon={{ source: "materialIcons/green rupee.png" }}
icon={{ source: "materialIcons/Treasures.png" }}
/>
</Detail.Metadata.TagList>
</>
Expand Down