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

Add flexible formatting options for Audio and Quote display #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "noor",
"name": "Noor",
"version": "0.0.6",
"version": "0.0.7",
"minAppVersion": "0.15.0",
"description": "Aims to help Muslims stay enlightened with Islam, Quran, Hadith, and Sunnah",
"author": "MKSherbini",
Expand Down
24 changes: 20 additions & 4 deletions src/api/QuranApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,29 @@ export class QuranApi {
this.fetchData(surah, this.plugin.settings.translationOption, ayah)
]);

return `<audio src="${arabicResponse.ayahs![0].audio}" controls>
<p> Audio tag not supported </p>
</audio>
> [!Quote] ${this.getSurahTitle(arabicResponse)} - [[${arabicResponse.number}:${arabicResponse.ayahs![0].numberInSurah}](https://surahquran.com/english.php?sora=${arabicResponse.number}&aya=${arabicResponse.ayahs![0].numberInSurah})]
const qoute = `> [!Quote] ${this.getSurahTitle(arabicResponse)} - [[${arabicResponse.number}:${arabicResponse.ayahs![0].numberInSurah}](https://surahquran.com/english.php?sora=${arabicResponse.number}&aya=${arabicResponse.ayahs![0].numberInSurah})]
>
> ${arabicResponse.ayahs![0].text}${this.getTranslation(translationResponse)}
`;

const audio = `<audio src="${arabicResponse.ayahs![0].audio}" controls>
<p> Audio tag not supported </p>
</audio>
`;

const emptyNewLine = this.plugin.settings.insertEmptyLineBetweenQuoteAudio ? '&nbsp;' : '';

return this.plugin.settings.audioPosition == "audioAbove"
? `${audio}

${emptyNewLine}

${qoute}`
: `${qoute}

${emptyNewLine}

${audio}`;
}

private getSurahTitle(arabicResponse: Surah) {
Expand Down
35 changes: 34 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {languageNames} from "./constants/languages";

export interface NoorPluginSettings {
dhikrFilepath: string;
audioPosition: string;
insertEmptyLineBetweenQuoteAudio: boolean;
reciter: string;
showTranslation: boolean;
translationLanguage: string;
Expand All @@ -16,6 +18,8 @@ export interface NoorPluginSettings {

export const DEFAULT_SETTINGS: NoorPluginSettings = {
dhikrFilepath: 'dhikr.md',
audioPosition: 'audioAbove',
insertEmptyLineBetweenQuoteAudio: false,
reciter: 'ar.abdulbasitmurattal',
showTranslation: true,
translationLanguage: 'en',
Expand Down Expand Up @@ -70,8 +74,37 @@ export class NoorSettingTab extends PluginSettingTab {
})
)

containerEl.createEl('h3', {text: 'Quran Settings'});
new Setting(containerEl)
.setName('Audio Position Preference')
.setDesc('Choose whether audio should appear above or below the quote.')
.addDropdown((dropdown) => {
dropdown
.addOptions({
'audioAbove': 'Audio Above Quote',
'quoteAbove': 'Quote Above Audio'
})
.setValue(this.plugin.settings.audioPosition)
.onChange(async (value) => {
this.plugin.settings.audioPosition = value;
await this.plugin.saveSettings();
this.display();
});
});

new Setting(containerEl)
.setName('Space between Quote and Audio')
.setDesc('Add an empty line between the Quran quote and the audio element')
.addToggle((toggle) => {
toggle
.setValue(this.plugin.settings.insertEmptyLineBetweenQuoteAudio)
.onChange(async (value) => {
this.plugin.settings.insertEmptyLineBetweenQuoteAudio = value;
await this.plugin.saveSettings();
this.display();
});
});

containerEl.createEl('h3', {text: 'Quran Settings'});
new Setting(containerEl)
.setName('Reciter')
.setDesc('Which reciter voice to use')
Expand Down