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

Commit 8024a19

Browse files
authored
Add production fix for survey (#1189)
* Add production fix for survey * changes * changes * api url change * change to client
1 parent 548d4e7 commit 8024a19

File tree

6 files changed

+107
-53
lines changed

6 files changed

+107
-53
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
NODE_ENV=development
22
PORT=8000
3-
API_URL=http://staging.quran.com:3000
3+
API_URL=http://api.quran.com
44
ONE_QURAN_URL=http://localhost:3030
55
SEGMENTS_KEY=
66
SENTRY_KEY_CLIENT=

src/client.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import useScroll from 'react-router-scroll';
1010
import { ReduxAsyncConnect } from 'redux-connect';
1111
import { syncHistoryWithStore } from 'react-router-redux';
1212
import { AppContainer } from 'react-hot-loader';
13+
import { ThemeProvider } from 'styled-components';
1314

1415
import debug from 'debug';
1516

1617
import config from './config';
18+
import theme from './theme';
1719
import ApiClient from './helpers/ApiClient';
1820
import createStore from './redux/create';
1921
import routes from './routes';
@@ -47,16 +49,18 @@ match(
4749
{ history, routes: routes(store) },
4850
(error, redirectLocation, renderProps) => {
4951
const component = (
50-
<Router
51-
{...renderProps}
52-
render={props => (
53-
<ReduxAsyncConnect
54-
{...props}
55-
helpers={{ client }}
56-
render={applyRouterMiddleware(useScroll())}
57-
/>
58-
)}
59-
/>
52+
<ThemeProvider theme={theme}>
53+
<Router
54+
{...renderProps}
55+
render={props => (
56+
<ReduxAsyncConnect
57+
{...props}
58+
helpers={{ client }}
59+
render={applyRouterMiddleware(useScroll())}
60+
/>
61+
)}
62+
/>
63+
</ThemeProvider>
6064
);
6165

6266
const mountNode = document.getElementById('app');

src/config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ const config = {
4040
{ name: 'description', content: description },
4141
{
4242
name: 'keywords',
43-
content: "quran, koran, qur'an, kareem, قران, القرآن, قران كريم, القران الكريم, surah, yasin, yaseen, kahf, mulk, rahman, muslim, islam, Allah"
43+
content:
44+
"quran, koran, qur'an, kareem, قران, القرآن, قران كريم, القران الكريم, surah, yasin, yaseen, kahf, mulk, rahman, muslim, islam, Allah"
4445
}, // eslint-disable-line max-l en
4546
{ name: 'Charset', content: 'UTF-8' },
4647
{ name: 'Distribution', content: 'Global' },
4748
{ name: 'Rating', content: 'General' },
4849
{
4950
name: 'viewport',
50-
content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
51+
content:
52+
'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
5153
},
5254
{
5355
name: 'google-site-verification',
@@ -62,17 +64,16 @@ const config = {
6264
{ property: 'og:locale', content: 'en_US' },
6365
{ property: 'og:title', content: title },
6466
{ property: 'og:description', content: description },
65-
{ property: 'og:url', content: 'https://quran.com' },
67+
6668
{ property: 'og:type', content: 'website' },
67-
{ name: 'twitter:card', content: 'summary' },
69+
{ name: 'twitter:card', content: 'summary_large_image' },
6870
{ name: 'twitter:title', content: title },
6971
{ name: 'twitter:description', content: description },
7072
{
7173
name: 'twitter:image',
7274
content: 'https://quran.com/images/thumbnail.png'
7375
},
74-
{ name: 'twitter:image:width', content: '200' },
75-
{ name: 'twitter:image:height', content: '200' },
76+
7677
{
7778
name: 'google-play-app',
7879
content: 'app-id=com.quran.labs.androidquran'
@@ -198,7 +199,8 @@ const config = {
198199
/* SEO: https://developers.google.com/structured-data/site-name#markup_requirements */
199200
script: [
200201
{
201-
src: 'https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.en',
202+
src:
203+
'https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.en',
202204
async: '',
203205
defer: ''
204206
},

src/containers/ChapterInfo/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ const ChapterInfo = ({ chapter, info }) => (
2323
<Helmet
2424
{...makeHeadTags({
2525
title: `Surah ${chapter.nameSimple} [${chapter.chapterNumber}]`,
26-
description: `${info ? info.shortText : ''} This Surah has ${chapter.versesCount} verses and resides between pages ${chapter.pages[0]} to ${chapter.pages[1]} in the Quran.` // eslint-disable-line max-len
26+
image: `https://quran-og-image.vercel.app/${chapter.chapterNumber}`,
27+
description: `${info ? info.shortText : ''} This Surah has ${
28+
chapter.versesCount
29+
} verses and resides between pages ${chapter.pages[0]} to ${
30+
chapter.pages[1]
31+
} in the Quran.` // eslint-disable-line max-len
2732
})}
2833
script={[
2934
{

src/containers/Surah/index.js

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ class Surah extends Component {
8080
}
8181

8282
componentDidMount() {
83-
const { verses, options: { audio } } = this.props;
83+
const {
84+
verses,
85+
options: { audio }
86+
} = this.props;
8487

8588
Object.values(verses).forEach((verse) => {
8689
this.props.actions.audio.load({
@@ -95,7 +98,10 @@ class Surah extends Component {
9598
// TODO: Should this belong here?
9699
componentWillReceiveProps(nextProps) {
97100
if (this.props.options.audio !== nextProps.options.audio) {
98-
const { verses, options: { audio } } = nextProps;
101+
const {
102+
verses,
103+
options: { audio }
104+
} = nextProps;
99105

100106
Object.values(verses).forEach((verse) => {
101107
this.props.actions.audio.load({
@@ -178,6 +184,18 @@ class Surah extends Component {
178184
return `Surah ${chapter.nameSimple} [${chapter.chapterNumber}]`;
179185
}
180186

187+
// Generates the url for the open graph image
188+
ogImage() {
189+
const { params, chapter } = this.props;
190+
const hasAyahNumber = params.range && !isNaN(params.range);
191+
192+
if (hasAyahNumber) {
193+
return `https://quran-og-image.vercel.app/${chapter.chapterNumber}/${params.range}`;
194+
}
195+
196+
return `https://quran-og-image.vercel.app/${chapter.chapterNumber}`;
197+
}
198+
181199
description() {
182200
const { params, verses, chapter, info } = this.props;
183201

@@ -211,7 +229,11 @@ class Surah extends Component {
211229
return `Surat ${chapter.nameSimple} [verse ${params.range}]`;
212230
}
213231

214-
return `${info ? info.shortText : ''} This Surah has ${chapter.versesCount} verses and resides between pages ${chapter.pages[0]} to ${chapter.pages[1]} in the Quran.`; // eslint-disable-line max-len
232+
return `${info ? info.shortText : ''} This Surah has ${
233+
chapter.versesCount
234+
} verses and resides between pages ${chapter.pages[0]} to ${
235+
chapter.pages[1]
236+
} in the Quran.`; // eslint-disable-line max-len
215237
}
216238

217239
renderNoAyah() {
@@ -243,15 +265,18 @@ class Surah extends Component {
243265

244266
// If single verse, eh. /2/30
245267
if (isSingleAyah) {
246-
const to = this.getFirst() + 10 > chapter.versesCount
247-
? chapter.versesCount
248-
: this.getFirst() + 10;
268+
const to =
269+
this.getFirst() + 10 > chapter.versesCount
270+
? chapter.versesCount
271+
: this.getFirst() + 10;
249272

250273
return (
251274
<ul className="pager">
252275
<li className="text-center">
253276
<Link
254-
to={`/${chapter.chapterNumber}/${this.getFirst()}-${to}?translations=${translations}`}
277+
to={`/${
278+
chapter.chapterNumber
279+
}/${this.getFirst()}-${to}?translations=${translations}`}
255280
>
256281
<LocaleFormattedMessage
257282
id="chapter.index.continue"
@@ -270,18 +295,20 @@ class Surah extends Component {
270295
isLoading={isLoading}
271296
endComponent={
272297
<ul className="pager">
273-
{chapter.chapterNumber > 1 &&
298+
{chapter.chapterNumber > 1 && (
274299
<li className="previous">
275300
<Link
276-
to={`/${chapter.chapterNumber * 1 - 1}?translations=${translations}`}
301+
to={`/${chapter.chapterNumber * 1 -
302+
1}?translations=${translations}`}
277303
>
278304
279305
<LocaleFormattedMessage
280306
id="chapter.previous"
281307
defaultMessage="Previous Surah"
282308
/>
283309
</Link>
284-
</li>}
310+
</li>
311+
)}
285312
<li className="text-center">
286313
<Link
287314
to={`/${chapter.chapterNumber}?translations=${translations}`}
@@ -292,18 +319,20 @@ class Surah extends Component {
292319
/>
293320
</Link>
294321
</li>
295-
{chapter.chapterNumber < 114 &&
322+
{chapter.chapterNumber < 114 && (
296323
<li className="next">
297324
<Link
298-
to={`/${chapter.chapterNumber * 1 + 1}?translations=${translations}`}
325+
to={`/${chapter.chapterNumber * 1 +
326+
1}?translations=${translations}`}
299327
>
300328
<LocaleFormattedMessage
301329
id="chapter.next"
302330
defaultMessage="Next Surah"
303331
/>
304332
305333
</Link>
306-
</li>}
334+
</li>
335+
)}
307336
</ul>
308337
}
309338
loadingComponent={<Loader isActive={isLoading} style={LoaderStyle} />}
@@ -376,7 +405,8 @@ class Surah extends Component {
376405
<Helmet
377406
{...makeHeadTags({
378407
title: this.title(),
379-
description: this.description()
408+
description: this.description(),
409+
image: this.ogImage()
380410
})}
381411
script={[
382412
{
@@ -427,12 +457,13 @@ class Surah extends Component {
427457
</div>
428458
</div>
429459
</div>
430-
{__CLIENT__ &&
460+
{__CLIENT__ && (
431461
<Audioplayer
432462
chapter={chapter}
433463
startVerse={Object.values(verses)[0]}
434464
onLoadAyahs={this.handleLazyLoadAyahs}
435-
/>}
465+
/>
466+
)}
436467
</div>
437468
);
438469
}

src/helpers/Html.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,39 @@ const Html = ({ store, component, assets }) => {
2525
type="text/css"
2626
/>
2727
))}
28-
{Object.keys(assets.styles).length === 0
29-
? <style
28+
{Object.keys(assets.styles).length === 0 ? (
29+
<style
3030
dangerouslySetInnerHTML={{
3131
__html: require('../../src/styles/bootstrap.config')
3232
}}
3333
/>
34-
: null}
34+
) : null}
35+
<script
36+
dangerouslySetInnerHTML={{
37+
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
38+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
39+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
40+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
41+
})(window,document,'script','dataLayer','GTM-M3VQW9V');`
42+
}}
43+
/>
3544
</head>
3645
<body>
37-
<div id="app" dangerouslySetInnerHTML={{ __html: content }} />
38-
<style
46+
{/* Google Tag Manager (noscript) */}
47+
<noscript
3948
dangerouslySetInnerHTML={{
40-
__html: '.async-hide { opacity: 0 !important}'
49+
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M3VQW9V"
50+
height="0" width="0" style="display:none;visibility:hidden"></iframe>`
4151
}}
4252
/>
43-
<script
53+
54+
<div id="app" dangerouslySetInnerHTML={{ __html: content }} />
55+
<style
4456
dangerouslySetInnerHTML={{
45-
__html: `(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
46-
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
47-
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
48-
})(window,document.documentElement,'async-hide','dataLayer',4000,
49-
{'GTM-PNMFTW3':true});`
57+
__html: '.async-hide { opacity: 0 !important}'
5058
}}
5159
/>
60+
5261
<script
5362
dangerouslySetInnerHTML={{
5463
__html: `(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -74,22 +83,25 @@ const Html = ({ store, component, assets }) => {
7483
}}
7584
charSet="UTF-8"
7685
/>
77-
{process.env.NODE_ENV === 'production' &&
86+
{process.env.NODE_ENV === 'production' && (
7887
<script
7988
dangerouslySetInnerHTML={{
8089
__html: `/*<![CDATA[*/window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("https://assets.zendesk.com/embeddable_framework/main.js","quran.zendesk.com");/*]]>*/`
8190
}}
82-
/>}
83-
{process.env.NODE_ENV === 'production' &&
91+
/>
92+
)}
93+
{process.env.NODE_ENV === 'production' && (
8494
<script
8595
dangerouslySetInnerHTML={{
8696
__html: `
8797
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\\/\\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);mixpanel.init("d3f9b2f15c4bf0509e85845b56921034");
8898
`
8999
}}
90-
/>}
91-
{process.env.NODE_ENV === 'production' &&
92-
<script src="https://cdn.ravenjs.com/3.0.4/raven.min.js" />}
100+
/>
101+
)}
102+
{process.env.NODE_ENV === 'production' && (
103+
<script src="https://cdn.ravenjs.com/3.0.4/raven.min.js" />
104+
)}
93105
{Object.keys(assets.javascript)
94106
.filter(script => !assets.javascript[script].includes('-chunk'))
95107
.map((script, i) => (

0 commit comments

Comments
 (0)