Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Route filters #783

Merged
merged 4 commits into from
May 13, 2017
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
83 changes: 48 additions & 35 deletions src/components/Audioplayer/RepeatDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import LocaleFormattedMessage from 'components/LocaleFormattedMessage';
const style = require('../style.scss');

class RepeatButton extends Component {

handleToggle = () => {
const { repeat, setRepeat, current } = this.props;

Expand Down Expand Up @@ -41,7 +40,7 @@ class RepeatButton extends Component {
from: current,
to: current + 3
});
}
};

renderRangeAyahs() {
const { chapter, repeat, setRepeat } = this.props;
Expand All @@ -54,7 +53,9 @@ class RepeatButton extends Component {
<LocaleFormattedMessage
id="player.repeat.rangeStart"
defaultMessage="From"
/>{' '}:
/>
{' '}
:
<br />
<FormControl
componentClass="select"
Expand Down Expand Up @@ -88,12 +89,15 @@ class RepeatButton extends Component {
<LocaleFormattedMessage
id="player.repeat.rangeEnd"
defaultMessage="To"
/>{' '}:
/>
{' '}
:
<br />
<FormControl
componentClass="select"
value={repeat.to}
onChange={event => setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })}
onChange={event =>
setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })}
>
{
array.reduce((options, ayah, index) => {
Expand Down Expand Up @@ -123,23 +127,26 @@ class RepeatButton extends Component {
<LocaleFormattedMessage
id="player.currentVerse"
defaultMessage="Ayah"
/>{' '}: <br />
/>
{' '}
:
{' '}
<br />
<FormControl
componentClass="select"
value={repeat.from}
onChange={event => setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
to: parseInt(event.target.value, 10)
})}
onChange={event =>
setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
to: parseInt(event.target.value, 10)
})}
>
{
array.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))
}
{array.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))}
</FormControl>
</div>
);
Expand Down Expand Up @@ -179,7 +186,9 @@ class RepeatButton extends Component {

return (
<div className={`${!repeat.from && style.disabled} row`}>
{repeat.from === repeat.to ? this.renderSingleAyah() : this.renderRangeAyahs()}
{repeat.from === repeat.to
? this.renderSingleAyah()
: this.renderRangeAyahs()}
</div>
);
}
Expand All @@ -194,27 +203,30 @@ class RepeatButton extends Component {
<LocaleFormattedMessage
id="player.repeat.title"
defaultMessage="Repeat"
/>: <br />
/>
:
{' '}
<br />
<FormControl
componentClass="select"
value={repeat.times}
onChange={event => setRepeat({
...repeat,
times: parseInt(event.target.value, 10)
})}
onChange={event =>
setRepeat({
...repeat,
times: parseInt(event.target.value, 10)
})}
>
<option value={'Infinity'}>
{
intl.formatMessage({ id: 'player.repeat.loop', defaultMessage: 'Loop' })
}
{intl.formatMessage({
id: 'player.repeat.loop',
defaultMessage: 'Loop'
})}
</option>
{
times.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))
}
{times.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))}
</FormControl>
</div>
</div>
Expand All @@ -234,7 +246,8 @@ class RepeatButton extends Component {
<LocaleFormattedMessage
id="player.repeat.title"
defaultMessage="TOGGLE REPEAT"
/>{' '}
/>
{' '}
<SwitchToggle
checked={!!repeat.from}
onToggle={this.handleToggle}
Expand Down
14 changes: 12 additions & 2 deletions src/components/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,20 @@ const Footer = () => (
</div>
<div className={`${styles.links} col-md-4 col-sm-12 col-xs-12`}>
<p className="monserrat">
<LocaleFormattedMessage id="nav.aboutQuranProject" defaultMessage="QURAN.COM (ALSO KNOWN AS THE NOBLE QURAN, AL QURAN, HOLY QURAN, KORAN) IS A PRO BONO PROJECT." />.
<LocaleFormattedMessage
id="nav.aboutQuranProject"
defaultMessage="QURAN.COM (ALSO KNOWN AS THE NOBLE QURAN, AL QURAN, HOLY QURAN, KORAN) IS A PRO BONO PROJECT."
/>
.
</p>
<p className="monserrat">
&copy; 2016 Quran.com. <LocaleFormattedMessage id="nav.rightsReserved" defaultMessage="All Rights Reserved" />.
© 2016 Quran.com.
{' '}
<LocaleFormattedMessage
id="nav.rightsReserved"
defaultMessage="All Rights Reserved"
/>
.
</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/locale/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
'local.selectLabel': 'Dil',
'setting.title': 'Ayarlar',
'setting.surahs': 'Sureler',
'setting.verses': 'Ayet\'e git',
'setting.verses': "Ayet'e git",
'setting.reciters.title': 'Hafızlar',
'setting.translations.title': 'Çeviriler',
'setting.translations.removeAll': 'Tümünü kaldır',
Expand Down Expand Up @@ -72,12 +72,12 @@ export default {
'nav.otherLinks': 'Diğer bağlantılar',
'nav.contactUs': 'Bize ulaşın',
'nav.help': 'Yardım & Geri Bildirim',
'nav.aboutQuranProject': 'Quran.com (Kur\'an-ı Kerim) bir pro bono projesidir.', // eslint-disable-line max-len
'nav.aboutQuranProject': "Quran.com (Kur'an-ı Kerim) bir pro bono projesidir.", // eslint-disable-line max-len
'nav.rightsReserved': 'Tüm Hakları Saklıdır',
'nav.mobile': 'Mobil Uygulamalar',
'nav.navigate': 'Bağlantılar', // there is no exact translation for Navigate in Turkish
'nav.legacySite': 'Eski Siteye Git Quran.com',

'login.message': 'Tüm yer işaretlerinizi, notlarınızı ve etkinliklerinizi saklamak için Quran.com\'a giriş yapın.'
'login.message': "Tüm yer işaretlerinizi, notlarınızı ve etkinliklerinizi saklamak için Quran.com'a giriş yapın."
}
};
20 changes: 13 additions & 7 deletions src/redux/actions/audioplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
LOAD,
LOAD_SUCCESS,
LOAD_FAIL,
UPDATE } from 'redux/constants/audioplayer.js';
UPDATE
} from 'redux/constants/audioplayer.js';

export function setCurrentFile(file) {
return {
Expand Down Expand Up @@ -96,14 +97,19 @@ export function update(payload) {
};
}

export function load({ chapterId, verseId, verseKey, audio }) { // eslint-disable-line
export function load({ chapterId, verseId, verseKey, audio }) {
// eslint-disable-line
return {
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
promise: client => client.get(`/api/v3/chapters/${chapterId}/verses/${verseId}/audio_files`, {
params: {
recitation: audio || 7 // NOTE: default, but should never be used
}
}),
promise: client =>
client.get(
`/api/v3/chapters/${chapterId}/verses/${verseId}/audio_files`,
{
params: {
recitation: audio || 7 // NOTE: default, but should never be used
}
}
),
verseKey,
chapterId
};
Expand Down
8 changes: 5 additions & 3 deletions src/redux/modules/lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import {
LOAD as AYAHS_LOAD,
LOAD_SUCCESS as AYAHS_LOAD_SUCCESS,
LOAD_FAIL as AYAHS_LOAD_FAIL,
} from 'redux/constants/verses.js';
LOAD_FAIL as AYAHS_LOAD_FAIL
} from 'redux/constants/verses.js';

import { SET_CURRENT as SURAHS_SET_CURRENT } from 'redux/constants/chapters.js';

Expand Down Expand Up @@ -34,7 +34,9 @@ export default function reducer(state = initialState, action = {}) {

ayah.words.forEach((word) => {
if (lines[`${word.pageNumber}-${word.lineNumber}`]) {
const isInArray = lines[`${word.pageNumber}-${word.lineNumber}`].find((item) => {
const isInArray = lines[
`${word.pageNumber}-${word.lineNumber}`
].find((item) => {
const itemChecksum = `${item.lineNumber}${item.code}${item.verseKey}${item.position}`;
const dataChecksum = `${word.lineNumber}${word.code}${word.verseKey}${item.position}`;

Expand Down
4 changes: 2 additions & 2 deletions src/redux/modules/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SET_USER_AGENT,
LOAD_TRANSLATIONS,
LOAD_TRANSLATIONS_SUCCESS
} from 'redux/constants/options.js';
} from 'redux/constants/options.js';

const initialState = {
isReadingMode: false,
Expand All @@ -14,7 +14,7 @@ const initialState = {
loadingRecitations: false,
loadingTranslations: false,
audio: 7, // Mishari Rashid al-`Afasy
translations: [20], // Sahih International
translations: [20], // Sahih International
tooltip: 'translation',
userAgent: null,
footNote: null,
Expand Down
13 changes: 12 additions & 1 deletion src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
hasAccessToken
} from 'redux/actions/auth';

import checkValidSurah from './utils/checkValidSurah';
import checkValidSurah from './utils/routeFilters';
import App from './containers/App';
import Home from './containers/Home';

Expand Down Expand Up @@ -136,9 +136,20 @@ export default (store) => {
import('./containers/ChapterInfo')
.then(module => cb(null, module.default))
.catch(err => console.trace(err))}
onEnter={checkValidSurah}
/>

<Redirect from="/:chapterId:(:range)" to="/:chapterId(/:range)" />
<Redirect from="/:chapterId/:from::to" to="/:chapterId/:from-:to" />

<Route
path="/:chapterId(/:range).pdf"
getComponents={(nextState, cb) =>
import('./containers/Pdf')
.then(module => cb(null, { main: module.default, nav: 'noscript' }))
.catch(err => console.trace(err))}
onEnter={checkValidSurah}
/>

<Route
path="/:chapterId(/:range).pdf"
Expand Down
Loading