-
-
Notifications
You must be signed in to change notification settings - Fork 573
/
index.js
227 lines (215 loc) · 7.5 KB
/
index.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**
* Config.
* @module config
*/
import { parse as parseUrl } from 'url';
import { defaultWidget, widgetMapping } from './Widgets';
import {
layoutViews,
contentTypesViews,
defaultView,
errorViews,
layoutViewsNamesMapping,
} from './Views';
import { nonContentRoutes } from './NonContentRoutes';
import {
groupBlocksOrder,
requiredBlocks,
blocksConfig,
initialBlocks,
initialBlocksFocus,
} from './Blocks';
import { components } from './Components';
import { loadables } from './Loadables';
import { workflowMapping } from './Workflows';
import { contentIcons } from './ContentIcons';
import { styleClassNameConverters, styleClassNameExtenders } from './Style';
import {
controlPanelsIcons,
filterControlPanels,
filterControlPanelsSchema,
} from './ControlPanels';
import { richtextEditorSettings, richtextViewSettings } from './RichTextEditor';
import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons';
import ConfigRegistry from '@plone/volto/registry';
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || '3000';
const apiPath =
process.env.RAZZLE_API_PATH ||
(__DEVELOPMENT__ ? `http://${host}:${port}` : '');
const getServerURL = (url) => {
if (!url) return;
const apiPathURL = parseUrl(url);
return `${apiPathURL.protocol}//${apiPathURL.hostname}${
apiPathURL.port ? `:${apiPathURL.port}` : ''
}`;
};
// Sensible defaults for publicURL
// if RAZZLE_PUBLIC_URL is present, use it
// if in DEV, use the host/port combination by default
// if in PROD, assume it's RAZZLE_API_PATH server name (no /api or alikes) or fallback
// to DEV settings if RAZZLE_API_PATH is not present
const publicURL =
process.env.RAZZLE_PUBLIC_URL ||
(__DEVELOPMENT__
? `http://${host}:${port}`
: getServerURL(process.env.RAZZLE_API_PATH) || `http://${host}:${port}`);
const serverConfig =
typeof __SERVER__ !== 'undefined' && __SERVER__
? require('./server').default
: {};
let config = {
settings: {
host,
port,
// The URL Volto is going to be served (see sensible defaults above)
publicURL,
apiPath,
apiExpanders: [
// Add the following expanders for only issuing a single request.
// https://6.docs.plone.org/volto/configuration/settings-reference.html#term-apiExpanders
// {
// match: '',
// GET_CONTENT: ['breadcrumbs', 'navigation', 'actions', 'types'],
// },
],
// Internal proxy to bypass CORS *while developing*. NOT intended for production use.
// In production is recommended you use a Seamless mode deployment using a web server in
// front of both the frontend and the backend so you can bypass CORS safely.
// https://6.docs.plone.org/volto/deploying/seamless-mode.html
devProxyToApiPath:
process.env.RAZZLE_DEV_PROXY_API_PATH ||
process.env.RAZZLE_INTERNAL_API_PATH ||
process.env.RAZZLE_API_PATH ||
'http://localhost:8080/Plone', // Set it to '' for disabling the proxy
// proxyRewriteTarget Set it for set a custom target for the proxy or overide the internal VHM rewrite
// proxyRewriteTarget: '/VirtualHostBase/http/localhost:8080/Plone/VirtualHostRoot/_vh_api'
// proxyRewriteTarget: 'https://myvoltositeinproduction.com'
proxyRewriteTarget: process.env.RAZZLE_PROXY_REWRITE_TARGET || undefined,
// apiPath: process.env.RAZZLE_API_PATH || 'http://localhost:8000', // for Volto reference
// apiPath: process.env.RAZZLE_API_PATH || 'http://localhost:8081/db/web', // for guillotina
actions_raising_api_errors: ['GET_CONTENT', 'UPDATE_CONTENT'],
internalApiPath: process.env.RAZZLE_INTERNAL_API_PATH || undefined,
websockets: process.env.RAZZLE_WEBSOCKETS || false,
// TODO: legacyTraverse to be removed when the use of the legacy traverse is deprecated.
legacyTraverse: process.env.RAZZLE_LEGACY_TRAVERSE || false,
cookieExpires: 15552000, //in seconds. Default is 6 month (15552000)
nonContentRoutes,
richtextEditorSettings, // Part of draftjs support, to be removed
richtextViewSettings, // Part of draftjs support, to be removed
imageObjects: ['Image'],
reservedIds: ['login', 'layout', 'plone', 'zip', 'properties'],
downloadableObjects: ['File'], //list of content-types for which the direct download of the file will be carried out if the user is not authenticated
viewableInBrowserObjects: [], //ex: ['File']. List of content-types for which the file will be displayed in browser if the user is not authenticated
listingPreviewImageField: 'image', // deprecated from Volto 14 onwards
openExternalLinkInNewTab: false,
notSupportedBrowsers: ['ie'],
defaultPageSize: 25,
isMultilingual: false,
supportedLanguages: ['en'],
defaultLanguage: 'en',
navDepth: 1,
expressMiddleware: serverConfig.expressMiddleware, // BBB
defaultBlockType: 'slate',
verticalFormTabs: false,
useEmailAsLogin: false,
persistentReducers: ['blocksClipboard'],
initialReducersBlacklist: [], // reducers in this list won't be hydrated in windows.__data
asyncPropsExtenders: [], // per route asyncConnect customizers
contentIcons: contentIcons,
loadables,
lazyBundles: {
cms: [
'prettierStandalone',
'prettierParserHtml',
'prismCore',
'toastify',
'reactSelect',
'reactBeautifulDnd',
// 'diffLib',
],
draftEditor: [
'immutableLib',
'draftJs',
'draftJsLibIsSoftNewlineEvent',
'draftJsFilters',
'draftJsInlineToolbarPlugin',
'draftJsImportHtml',
'draftJsBlockBreakoutPlugin',
],
},
appExtras: [],
maxResponseSize: 2000000000, // This is superagent default (200 mb)
maxFileUploadSize: null,
serverConfig,
storeExtenders: [],
showTags: true,
controlpanels: [],
controlPanelsIcons,
filterControlPanels,
filterControlPanelsSchema,
externalRoutes: [
// URL to be considered as external
// {
// match: {
// path: '/news',
// exact: false,
// strict: false,
// },
// url(payload) {
// return payload.location.pathname;
// },
// },
],
showSelfRegistration: false,
contentMetadataTagsImageField: 'image',
hasWorkingCopySupport: false,
maxUndoLevels: 200, // undo history size for the main form
addonsInfo: addonsInfo,
workflowMapping,
errorHandlers: [], // callables for unhandled errors
styleClassNameConverters,
hashLinkSmoothScroll: false,
styleClassNameExtenders,
querystringSearchGet: false,
blockSettingsTabFieldsetsInitialStateOpen: true,
excludeLinksAndReferencesMenuItem: false,
containerBlockTypes: ['gridBlock'],
},
experimental: {
addBlockButton: {
enabled: false,
},
},
widgets: {
...widgetMapping,
default: defaultWidget,
},
views: {
layoutViews,
contentTypesViews,
defaultView,
errorViews,
layoutViewsNamesMapping,
},
blocks: {
requiredBlocks,
blocksConfig,
groupBlocksOrder,
initialBlocks,
initialBlocksFocus,
showEditBlocksInBabelView: false,
},
addonRoutes: [],
addonReducers: {},
components,
};
ConfigRegistry.settings = config.settings;
ConfigRegistry.experimental = config.experimental;
ConfigRegistry.blocks = config.blocks;
ConfigRegistry.views = config.views;
ConfigRegistry.widgets = config.widgets;
ConfigRegistry.addonRoutes = config.addonRoutes;
ConfigRegistry.addonReducers = config.addonReducers;
ConfigRegistry.components = config.components;
applyAddonConfiguration(ConfigRegistry);