Hasanah is a VS Code extension that brings the beauty of the Quran and Hadith directly into your coding environment. It displays random Ayahs (Quranic verses) and Hadiths at customizable intervals, helping you stay spiritually connected while you code.
- Random Quranic Verses (Ayahs): Displays random Ayahs in your chosen language.
- Random Hadiths: Shows random Hadiths with author attribution (narrator/compiler), with support for both Arabic and English.
- Customizable Intervals: Set how often you want to see a new Ayah or Hadith.
- Dual Language Support:
- Ayahs: Arabic (
ar) and English (en).- Hadiths: Arabic (
ar) and English (en).
- Hadiths: Arabic (
- Ayahs: Arabic (
- Hijri Date: Quickly get the current Islamic (Hijri) date.
- Specific Ayah Lookup: Fetch a particular Ayah by Surah and Ayah number.
- Auto-Dismiss Notifications: Popups will automatically disappear after a configurable portion of the display interval.
- Offline Duaa: Displays a default Duaa if an internet connection is unavailable.
- Caching: In-memory caching is used for Ayah, Hadith, and Hijri date requests to improve performance.
- Open Visual Studio Code.
- Go to the Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon Mac). - Search for "Hasanah".
- Click Install.
- Reload VS Code if prompted.
You can configure Hasanah through your VS Code settings.
- Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+Pon Mac). - Type
Preferences: Open Settings (UI)and press Enter. - In the search bar, type
Hasanah. - Adjust the following settings:
hasanah.delay: The interval (in minutes) between notifications. Default is20.hasanah.language: The preferred language for Ayahs and Hadiths. Choose betweenar(Arabic) anden(English). Default isar.
Alternatively, you can directly edit your settings.json file:
{
"hasanah.delay": 30,
"hasanah.language": "en"
}Hasanah provides the following commands, accessible via the Command Palette (Ctrl+Shift+P or Cmd+Shift+P):
hasanah: get Ayah: Prompts you to enter a Surah number and Ayah number, then displays the specified Quranic verse.hasanah: get Hijri Date: Displays the current date in the Hijri calendar.
We welcome contributions to make Hasanah even better!
- Node.js (v18+ recommended, check
package.jsonfor specific engine requirements) - Visual Studio Code (v1.93+ recommended, check
package.jsonfor specific engine requirements) - npm (usually comes with Node.js) or Yarn
- Bun (optional, for running tests faster)
- Fork the repository: Click the "Fork" button at the top right of the oovaa/hasanah GitHub page.
- Clone your fork:
git clone https://github.com/oovaa/hasanah.git cd hasanah - Install dependencies:
bun install # or yarn install # or npm install
- Open in VS Code:
code . - Run the extension in a development host:
- Press
F5to open a new VS Code window with the extension loaded (Extension Development Host). - Make changes to the code. The Extension Development Host will usually reload automatically, or you can manually reload it (
Ctrl+RorCmd+R).
- Press
- Test your changes:
- Use the commands provided by the extension.
- Check the debug console for any output or errors.
- Lint your code:
npm run lint
- Run tests:
bun test # or use npm if you don't have bun installed npm test
- Submit a Pull Request:
- Create a new branch for your feature or bug fix.
- Commit your changes with clear and descriptive messages.
- Push your branch to your fork.
- Open a pull request from your fork to the
mainbranch ofoovaa/hasanah. - Provide a detailed description of your changes in the pull request.
A:
- Check your VS Code settings for
hasanah.delayandhasanah.language. Ensure they are correctly configured. - Make sure you have an active internet connection, as Hasanah fetches content online.
- Open the VS Code Developer Tools (Help > Toggle Developer Tools) and check the Console tab for any error messages related to Hasanah.
- Try restarting VS Code.
A: Very long texts might sometimes be truncated by the standard VS Code notification system. We are always looking for ways to improve the display.
A: Hasanah primarily fetches new content (Ayahs and Hadiths) online. If you are offline, it will attempt to display a default Duaa. Full offline caching for a wider range of content is a potential future enhancement.
A: You can usually dismiss VS Code notifications by pressing the Esc key or clicking the "Close" (X) button on the notification. The notifications are also designed to auto-dismiss.
Hasanah includes comprehensive tests to ensure code quality and correctness.
To run all tests:
bun testOr if you prefer npm:
npm testThe test suite includes:
- Hadith Tests: Verifies that hadith retrieval works correctly with proper author attribution
- Cache Tests: Ensures that caching mechanisms work efficiently to reduce API calls
- Main Function Tests: Validates the getText function and error handling
- Integration Tests: Tests the interaction between different modules
All tests use mocked API responses to ensure consistent and reliable test execution.
- Inspired by the "Ayat" extension.
- Special thanks to Abdul Baaki Hudu for the initial English Hadith support.
- APIs used:
- Quran: AlQuran.cloud API
- Arabic Hadith: Hadith API (gading.dev)
- English Hadith: Hadith API (hadithapi.com) (Experimental)
- Hijri Date: Al Adhan API
Hasanah is open-source software licensed under the MIT License.
May this project be a source of barakah (blessings) in your coding journey. π
"So whoever does an atom's weight of good will see it, And whoever does an atom's weight of evil will see it." (Quran 99:7-8)
Enjoy!
A heartfelt thank you to everyone who uses, supports, and contributes to this extension. Your feedback and involvement are invaluable in making Hasanah better. May your coding journey be filled with inspiration, productivity, and spiritual connection.
And a special thank you to you for being part of this community. π©·
Ψ΅Ψ―ΩΨ© Ψ¬Ψ§Ψ±ΩΨ© ΨΉΩ Ψ¬Ω ΩΨΉ Ψ§ΩΩ Ψ³ΩΩ ΩΩΨ ΩΨ³Ψ£ΩΩΩ Ψ§ΩΨ―ΨΉΨ§Ψ‘ ΩΩΩΨΉ Ψ§ΩΩΩ Ψ¨ΩΨ§ ΩΨ¨ΩΩ . π

