diff --git a/src/components/Audioplayer/RepeatDropdown/index.js b/src/components/Audioplayer/RepeatDropdown/index.js index 250714cea..064b2f7ec 100644 --- a/src/components/Audioplayer/RepeatDropdown/index.js +++ b/src/components/Audioplayer/RepeatDropdown/index.js @@ -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; @@ -41,7 +40,7 @@ class RepeatButton extends Component { from: current, to: current + 3 }); - } + }; renderRangeAyahs() { const { chapter, repeat, setRepeat } = this.props; @@ -54,7 +53,9 @@ class RepeatButton extends Component { {' '}: + /> + {' '} + :
{' '}: + /> + {' '} + :
setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })} + onChange={event => + setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })} > { array.reduce((options, ayah, index) => { @@ -123,23 +127,26 @@ class RepeatButton extends Component { {' '}:
+ /> + {' '} + : + {' '} +
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) => ( - - )) - } + {array.map((ayah, index) => ( + + ))} ); @@ -179,7 +186,9 @@ class RepeatButton extends Component { return (
- {repeat.from === repeat.to ? this.renderSingleAyah() : this.renderRangeAyahs()} + {repeat.from === repeat.to + ? this.renderSingleAyah() + : this.renderRangeAyahs()}
); } @@ -194,27 +203,30 @@ class RepeatButton extends Component { :
+ /> + : + {' '} +
setRepeat({ - ...repeat, - times: parseInt(event.target.value, 10) - })} + onChange={event => + setRepeat({ + ...repeat, + times: parseInt(event.target.value, 10) + })} > - { - times.map((ayah, index) => ( - - )) - } + {times.map((ayah, index) => ( + + ))} @@ -234,7 +246,8 @@ class RepeatButton extends Component { {' '} + /> + {' '} (

- . + + .

- © 2016 Quran.com. . + © 2016 Quran.com. + {' '} + + .

diff --git a/src/locale/tr.js b/src/locale/tr.js index a409e0ef3..4890663a9 100644 --- a/src/locale/tr.js +++ b/src/locale/tr.js @@ -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', @@ -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." } }; diff --git a/src/redux/actions/audioplayer.js b/src/redux/actions/audioplayer.js index 87ad25490..053797570 100644 --- a/src/redux/actions/audioplayer.js +++ b/src/redux/actions/audioplayer.js @@ -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 { @@ -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 }; diff --git a/src/redux/modules/lines.js b/src/redux/modules/lines.js index ef648e4d0..b6deff14c 100644 --- a/src/redux/modules/lines.js +++ b/src/redux/modules/lines.js @@ -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'; @@ -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}`; diff --git a/src/redux/modules/options.js b/src/redux/modules/options.js index e9ee5ce0f..3eadf43cc 100644 --- a/src/redux/modules/options.js +++ b/src/redux/modules/options.js @@ -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, @@ -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, diff --git a/src/routes.js b/src/routes.js index 417b02f57..01624117b 100644 --- a/src/routes.js +++ b/src/routes.js @@ -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'; @@ -136,9 +136,20 @@ export default (store) => { import('./containers/ChapterInfo') .then(module => cb(null, module.default)) .catch(err => console.trace(err))} + onEnter={checkValidSurah} /> + + + + import('./containers/Pdf') + .then(module => cb(null, { main: module.default, nav: 'noscript' })) + .catch(err => console.trace(err))} + onEnter={checkValidSurah} + /> { const client = new ApiClient(req); const urls = []; - client.get('/api/v3/chapters').then((response) => { - response.chapters.forEach((chapter) => { - Array(chapter.verses_count).fill().forEach((_, index) => { - const verseId = index + 1; + client + .get('/api/v3/chapters') + .then((response) => { + response.chapters.forEach((chapter) => { + Array(chapter.verses_count).fill().forEach((_, index) => { + const verseId = index + 1; + + urls.push({ + url: `/${chapter.id}/${verseId}`, + changefreq: 'weekly', + priority: 1 + }); + + urls.push({ + url: `/${chapter.id}/${verseId}-${verseId + 9}`, + changefreq: 'weekly', + priority: 1 + }); + }); urls.push({ - url: `/${chapter.id}/${verseId}`, + url: `/${chapter.id}`, changefreq: 'weekly', priority: 1 }); urls.push({ - url: `/${chapter.id}/${verseId}-${verseId + 9}`, + url: `/${chapter.id}/info/ur`, changefreq: 'weekly', priority: 1 }); - }); - - urls.push({ - url: `/${chapter.id}`, - changefreq: 'weekly', - priority: 1 - }); - urls.push({ - url: `/${chapter.id}/info`, - changefreq: 'weekly', - priority: 1 - }); - - urls.push({ - url: `/${chapter.id}/info/ur`, - changefreq: 'weekly', - priority: 1 - }); + urls.push({ + url: `/${chapter.id}/info/ml`, + changefreq: 'weekly', + priority: 1 + }); - urls.push({ - url: `/${chapter.id}/info/ml`, - changefreq: 'weekly', - priority: 1 - }); + urls.push({ + url: `/${chapter.id}/info/ta`, + changefreq: 'weekly', + priority: 1 + }); - urls.push({ - url: `/${chapter.id}/info/ta`, - changefreq: 'weekly', - priority: 1 + urls.push({ + url: `/${chapter.id}/info/en`, + changefreq: 'weekly', + priority: 1 + }); }); - urls.push({ - url: `/${chapter.id}/info/en`, - changefreq: 'weekly', - priority: 1 + const xml = sitemap.createSitemap({ + hostname: 'https://quran.com', + cacheTime: 600000, // 600 sec cache period + urls: [ + ...urls, + { url: '/about', changefreq: 'monthly', priority: 0.3 }, + { url: '/contactus', changefreq: 'monthly', priority: 0.3 }, + { url: '/contact', changefreq: 'monthly', priority: 0.3 }, + { url: '/donations', changefreq: 'monthly', priority: 0.3 }, + { url: '/contributions', changefreq: 'monthly', priority: 0.3 }, + { url: '/search', changefreq: 'weekly', priority: 0.8 } + ] }); - }); - - const xml = sitemap.createSitemap({ - hostname: 'https://quran.com', - cacheTime: 600000, // 600 sec cache period - urls: [ - ...urls, - { url: '/about', changefreq: 'monthly', priority: 0.3 }, - { url: '/contactus', changefreq: 'monthly', priority: 0.3 }, - { url: '/contact', changefreq: 'monthly', priority: 0.3 }, - { url: '/donations', changefreq: 'monthly', priority: 0.3 }, - { url: '/contributions', changefreq: 'monthly', priority: 0.3 }, - - { url: '/search', changefreq: 'weekly', priority: 0.8 } - ] - }); - res.header('Content-Type', 'application/xml'); - res.send(xml.toString()); - }).catch(err => console.trace(err)); // eslint-disable-line + res.header('Content-Type', 'application/xml'); + res.send(xml.toString()); + }) + .catch(err => console.trace(err)); // eslint-disable-line }); }; diff --git a/src/utils/checkValidSurah.js b/src/utils/checkValidSurah.js deleted file mode 100644 index 28268220d..000000000 --- a/src/utils/checkValidSurah.js +++ /dev/null @@ -1,20 +0,0 @@ -export default function isValidSurah(nextState, replaceState) { - const chapterId = parseInt(nextState.params.chapterId, 10); - - if (isNaN(chapterId) || chapterId > 114 || chapterId < 1) { - replaceState('/error/invalid-surah'); - } - - if (nextState.params.range) { - if (nextState.params.range.includes('-')) { - const [from, to] = nextState.params.range.split('-').map(num => parseInt(num, 10)); - - if (from > to) { - replaceState(`/${chapterId}/${to}-${from}`); - } else if (from === to) { - replaceState(`/${chapterId}/${from}`); - } - // TODO: Add check to make sure the range is within the ayah limit - } - } -} diff --git a/src/utils/routeFilters.js b/src/utils/routeFilters.js new file mode 100644 index 000000000..8a27d63f0 --- /dev/null +++ b/src/utils/routeFilters.js @@ -0,0 +1,53 @@ +function replaceChapterOrRange(params) { + const chapterId = params.chapterId; + const verseId = params.range; + + return ( + chapterId.length !== + parseInt(chapterId, 10).toString().length || + verseId && verseId.length !== parseInt(verseId, 10).toString().length + ); +} + +export default function isValidSurah(nextState, replaceState) { + const chapterId = parseInt(nextState.params.chapterId, 10); + if (isNaN(chapterId) || chapterId > 114 || chapterId < 1) { + replaceState('/error/invalid-surah'); + } + + if (nextState.params.range) { + if (nextState.params.range.includes('-')) { + const [_from, _to] = nextState.params.range.split('-').map(num => num); + const [from, to] = nextState.params.range + .split('-') + .map(num => parseInt(num, 10)); + + if (from > to) { + replaceState(`/${chapterId}/${to}-${from}${nextState.location.search}`); + } else if (from === to) { + replaceState(`/${chapterId}/${from}`); + } else if ( + _from.length !== from.toString().length || + _to.length !== to.toString().length + ) { + replaceState(`/${chapterId}/${from}-${to}${nextState.location.search}`); + } + // TODO: Add check to make sure the range is within the ayah limit + } else { + const verseId = parseInt(nextState.params.range, 10); + + if (replaceChapterOrRange(nextState.params)) { + let location = `${nextState.location.pathname}${nextState.location.search}`; + location = location.replace( + /\/([0-9]+)\/([0-9]+)/, + `/${chapterId}/${verseId}` + ); + replaceState(location); + } + } + } else if (replaceChapterOrRange(nextState.params)) { + let location = `${nextState.location.pathname}${nextState.location.search}`; + location = location.replace(/\/([0-9]+)/, `/${chapterId}`); + replaceState(location); + } +}