-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.js
59 lines (50 loc) · 2.29 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import ReactDomServer from 'react-dom/server';
import {store,Routes} from './components/application.js';
import { syncHistoryWithStore } from 'react-router-redux'
//import createMemoryHistory from 'history';
import createMemoryHistory from 'history/lib/createMemoryHistory'
import {Yametrika} from './components/metrika.js'
//import {createLocation} from 'history/LocationUtils'
const SSI = {__html:
'<!--# block name="vcard" -->{}<!--# endblock -->' +
'var vcard = <!--# include virtual="/api/json/vcard" stub="vcard" -->;' +
'var roster = <!--# include virtual="/api/json/roster" stub="vcard" -->;'
}
var HTMLWrap = (props) =>
<html>
<head>
<title>Jabber.ru</title>
<meta charSet="utf-8"/>
<meta name="theme-color" content="#233747"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content="Jabber.ru — жаббер сервер, вероятно, крупнейший, старейший и самый надёжный"/>
<link rel="stylesheet" href="/css/flickity.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="/css/fonts.css"/>
</head>
<body className="gradient">
<div id="RC">
{props.children}
</div>
<script dangerouslySetInnerHTML={SSI}></script>
<script dangerouslySetInnerHTML={Yametrika}></script>
<noscript><div><img src="https://mc.yandex.ru/watch/24966088" style={{position:"absolute", left:-9999}} alt="" /></div></noscript>
<script src="/js/bundle.js"></script>
</body>
</html>
const match = ReactRouter.match;
const RouterContext = ReactRouter.RouterContext;
const Provider = ReactRedux.Provider;
const History = syncHistoryWithStore(createMemoryHistory(),store);
const Rs = ReactRouter.createRoutes(Routes);
module.exports = function render(locals, callback) {
const loc = History.createLocation(locals.path);
match( {routes:Rs, location:loc}, (error, redirectLocation, renderProps) => {
callback(null, '<!DOCTYPE html>'+ReactDomServer.renderToStaticMarkup(
<Provider store={store}>
<HTMLWrap>
<RouterContext {...renderProps} />
</HTMLWrap>
</Provider>),
)
})
}