Wiki source code of Configuration

Version 204.1 by Vincent Massol on 2020/06/30

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 Once you have XWiki [[installed>>Documentation.AdminGuide.Installation.WebHome]] you'll want to configure it. Configuration can be done in 2 ways:
6
7 * by stopping the XWiki instance and editing either the ##xwiki/WEB-INF/xwiki.cfg## file or the ##xwiki/WEB-INF/xwiki.properties## one, and then restarting XWiki. Note that ##xwiki.cfg## was the historical file containing the configuration option but we're moving away from it and in due time all the XWiki configuration options will be found in ##xwiki.properties##
8 * by logging in as a user with admin rights and going to the administration page using the top level menu. You can also go directly to //{{{http://localhost:8080/xwiki/bin/admin/XWiki/XWikiPreferences}}}//. This allows to keep the server running while making the changes.(((
9 {{info}}
10 * Some configurations are only accessible from the ##xwiki.cfg## and ##xwiki.properties## files and have no equivalent on the administration page.
11 * If you're a developer and need to understand how Configuration works in XWiki, check the [[Configuration Module Documentation>>extensions:Extension.Configuration Module]].
12 {{/info}}
13 )))You can verify some basic settings of your XWiki installation (on Tomcat, MySQL) using the [[Check Config and Indexes application>>extensions:Extension.Check Config And Indexes Application]].
14
15 There are various things you can configure:
16
17 = Enable superadmin account =
18
19 Edit the ##xwiki.cfg## file and enable the ##xwiki.superadminpassword## property. For example:
20
21 {{code language="none"}}
22 # Enable to allow superadmin. It is disabled by default as this could be a security breach if
23 # it were set and you forgot about it.
24 xwiki.superadminpassword=system
25 {{/code}}
26
27 When logging in, the username will be "superadmin" and the password will be the one you set in the ##xwiki.superadminpassword## property.
28
29 = Language settings =
30
31 To define the default language for your wiki go to the administration page, click on "Localization", locate the "Default Language" field and select the language you wish to use.
32
33 In addition you can configure your wiki to be multilingual. See the [[I18 user page>>platform:Features.I18N]] for more information.
34
35 Last, you can also force your wiki to display only in one of the languages specified in the settings, by editing your ##WEB-INF/xwiki.cfg## file. Search for the "Internationalization" section, and you should see two commented settings that you can uncomment to fix their value (1 means true, 0 false).
36
37 {{code language="none"}}
38 #-# By default, XWiki chooses the language specified by the client (browser) in the Accept-Language HTTP header. This
39 #-# allows to use the default language of the wiki when the user didn't manually choose a language.
40 # xwiki.language.preferDefault=0
41
42 #-# Force only one of the supported languages to be accepted. Default is true.
43 # xwiki.language.forceSupported=1
44 {{/code}}
45
46 {{warning}}
47 Starting with XWiki {{info}}11.2RC1{{/info}} the option ##xwiki.language.forceSupported## is by default set to true. The option was by default set to false on prior versions.
48 {{/warning}}
49
50 == Algorithm ==
51
52 The algorithm to find the locale to use is the following, in this order:
53 * If the wiki is not multilingual use the wiki default locale (##default_language## xproperty in ##XWikiPreferences## xobject or English if not found).
54 * If the wiki is multilingual
55 ** Try to get the locale passed in the request (looking for a ##language## query string parameter).
56 ** If the language value is ##default## use the wiki default locale. If a parameter is found sets a ##language## cookie to remember the language in use.
57 ** Try to get the locale from the ##language## cookie
58 ** If the default language is preferred (##xwiki.language.preferDefault## from ##xwiki.cfg## or ##preferDefaultLanguage## property from the space preferences (##WebPreferences## xobject) or wiki preferences (##XWikiPreferences## xobject})), and since the user didn't explicitly ask for a language already, then use the wiki default locale.
59 ** Try to use the browser's ##Accept-Language## header sent in HTTP request.
60 ** Fallback to the wiki default locale
61
62 In addition the ##xwiki.language.forceSupported## configuration property (editable in ##xwiki.cfg##) is enabled by default and means that if at any step above the locale found is not in the list of supported locales, then the locale is not set and the algorithm moves to the next step.
63
64 = Date format =
65
66 To define the date format used in the interfaces, go to //Wiki -> Administer Wiki -> Localization//, locate the "Date format" field and enter the date format you wish to use. Examples:
67
68 |=Format|=Result
69 |MMMM dd, HH:mm|January 27, 12:27
70 |yyyy/MM/dd, HH:mm|2009/01/27, 12:27
71 |dd/MM/yyyy, HH:mm|27/01/2009, 12:27
72
73 [[More information about date formatting>>http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html]].
74
75 = Enabling/Disabling Statistics =
76
77 To disable [[the Statistics feature>>extensions:Extension.Statistics Application]] edit your //xwiki.cfg// file and replace the following properties as shown here (to enable statistics, change ##0## to ##1##):
78
79 {{code}}
80 xwiki.stats=0
81 xwiki.stats.default=0
82 {{/code}}
83
84 where:
85
86 * ##xwiki.stats## controls whether statistics are on or off
87 * ##xwiki.stats.default## controls whether statistics are on or off by default for the current Wiki. This is useful in [[Virtual Wiki mode>>Documentation.AdminGuide.Virtualization.WebHome]]. A wiki can decide whether statistics are on or off by setting the "statistics" field in ##XWiki.XWikiPreferences##. If no such field is defined then the default value //xwiki.stats.default// is used.(((
88 {{info}}
89 There's currently no UI to set the statistics on or off for a given subwiki. Thus at the moment you'll need to do 2 things:
90 * Edit ##XWiki.XWikiPreferences## to add a new boolean property to the class, by going to //{{{http://localhost:8080/xwiki/bin/edit/XWiki/XWikiPreferences?editor=class}}}//
91 * Set the ##statistics## property to true by going to //{{{http://localhost:8080/xwiki/bin/edit/XWiki/XWikiPreferences?editor=object}}}// and setting the ##statistics## property to ##true##
92 {{/info}}
93 )))
94
95 = Optional Store Features =
96
97 == Document versioning ==
98
99 One of the key features of a wiki engine is the ability to keep all the history of a document, giving users the ability to see the evolution of a document, but also to revert changes. However, the history of an active wiki continuously grows and is usually much larger than the current version of the data. It is possible to disable the versioning feature in XWiki, which means that less storage space will be used, although it will not be possible to revert the document in case of vandalism.
100
101 To disable versioning edit //xwiki.cfg// and add {{code}}xwiki.store.versioning=0{{/code}}.
102
103 [[Attachment versioning>>Documentation.AdminGuide.Attachments#HVersions]] is also available and turned on by default.
104
105 == Document recycle bin ==
106
107 By default deleted documents are not permanently removed, but are placed in a //recycle bin//, from which they can later be removed or restored. To disable it, edit //xwiki.cfg// and add {{code}}xwiki.recyclebin=0{{/code}}.
108
109 {{info}}
110 Disabling the recycle bin will make it impossible to restore a deleted document, unless a database backup is available.
111 {{/info}}
112
113 By default, a deleted document can be permanently deleted right away by administrators, and after 7 days by regular users. To change these limits, edit //xwiki.cfg// and add:
114
115 {{code}}
116 # Admins must wait 3 days before being allowed to permanently delete
117 xwiki.store.recyclebin.adminWaitDays=3
118 # Normal users must also wait 3 days
119 xwiki.store.recyclebin.waitDays=3
120 {{/code}}
121
122 [[Attachment recycle bin>>Documentation.AdminGuide.Attachments#HDeletion]] is similar.
123
124 = Customizing error pages =
125
126 The screen displayed to the user when an error occurs can be easily customized without modifying the skin in the following cases: when the wiki, document or attachment that is currently looked for does not exist, or when a denied access occurs. You simply need to create the following respective pages in your wiki:
127
128 * ##XWiki.WikiDoesNotExist##,
129 * ##XWiki.DocumentDoesNotExist##,
130 * ##XWiki.AttachmentDoesNotExist##,
131 * ##XWiki.AccessDenied##
132
133 Creating these pages rather than editing the skin's velocity files will save you time during upgrades since you won't need to merge the possibly updated skin files with yours.
134
135 = Customizing the Skin =
136
137 See the [[Skin Guide>>Documentation.AdminGuide.Skins]].
138
139 = Security configuration =
140
141 See the [[Security Guide>>Documentation.AdminGuide.Security]].
142
143 By default the protocol to use to generate external URLs (https, http) is extracted from request to XWiki so most of the time you don't have anything to do if you properly configured your proxy but it's possible to force a specific protocol using ##xwiki.url.protocol## property in //xwiki.cfg//.
144
145 = Customizing Menus =
146
147 The first thing to understand is that menus depend on the skin you're using. If you're using the 1.0 skin it's likely you're using the [[Panels Application>>extensions:Extension.Panels Application]] to provide the different menu panels you see on the left or right of your wikis. Check the [[Panels Application>>extensions:Extension.Panels Application]] to know more on how to configure/modify them.
148
149 = Encoding =
150
151 See the [[Encoding Guide>>Documentation.AdminGuide.Configuration.Encoding.WebHome]].
152
153 = User Authentication =
154
155 See the [[Authentication Guide>>Documentation.AdminGuide.Authentication.WebHome]].
156
157 == Customizing the Verified Registration Page (Since 2.2M2) ==
158
159 The Verified Registration Page is part of the [[Administration Application>>extensions:Extension.Administration Application]] and allows you to require users to fill in a captcha and validates user input on both the server side and the client side using Javascript. The configuration allows you to add fields and validation constraints to the fields which are there.
160
161 Since version 2.3M1 in order to turn on captcha you simply go to the administration page, click "Registration" and you will find a checkbox for turning on captcha along with other registation page related settings.
162
163 For more information about configuring the registration page you can visit the page on the [[Administration Application>>extensions:Extension.Administration Application]].
164
165 = Initial Groups =
166
167 You can set the default groups which new users will automatically be added to by changing the ##xwiki.users.initialGroups## parameter in your [[xwiki.cfg>>Documentation.AdminGuide.Configuration#HSamplexwiki.cfg]] file. To make all new users be added to the groups **XWiki.CoolPeople** and **XWiki.CommunityMembers** you will have to set the ##initialGroups## parameter like this:
168
169 (((
170 {{code language="none"}}
171 xwiki.users.initialGroups=XWiki.CoolPeople, XWiki.CommunityMembers
172 {{/code}}
173 )))
174
175 * Current members will not be automatically be added to these groups, only new members.
176 * The groups have to be created before being specified as initial groups.
177
178 = Logging =
179
180 See the [[Logging page>>Documentation.AdminGuide.Logging]].
181
182 = Configuring Interwiki links =
183
184 [[Interwiki linking>>http://en.wikipedia.org/wiki/InterWiki]] is a short hand syntax for linking to pages on other websites. For example, you could link to http://en.wikipedia.org/wiki/InterWiki just by typing ~[~[InterWiki@WikiPedia]].
185
186 {{info}}
187 Note that different lists have to be maintained to support this function in XWiki Syntax 1.0 and 2.x.
188 {{/info}}
189
190 {{warning}}
191 The link notation for Interwiki links has changed in XWiki Syntax 2.1. Links should look like this in XWiki Syntax 2.1: ~[~[interwiki:WikiPedia:InterWiki~]~].
192 {{/warning}}
193
194 == Interwiki links (XWiki Syntax 1.0) ==
195
196 Since XWiki renders wiki syntax using the [[Radeox>>http://codemonkeyism.com/forking-radeox-a-new-wiki-render-engine/]] engine, it supports Interwiki links in [[much the same way as SnipSnap>>http://snipsnap.org/space/InterWiki+HowTo]].
197
198 To configure Interwiki links on your wiki:
199
200 * Create a file named ##[location from where you start your container]/conf/**intermap.txt**##
201 * Fill ##intermap.txt## with content like:(((
202 {{code}}
203 IMDB http://us.imdb.com/Title?
204 OpenWiki http://openwiki.com/?
205 SourceForge http://sourceforge.net/
206 TWiki http://twiki.org/cgi-bin/view/
207 Why http://clublet.com/c/c/why?
208 Wiki http://c2.com/cgi/wiki?
209 WikiPedia http://www.wikipedia.com/wiki/
210 {{/code}}
211 )))You can of course add your own entries.
212
213 {{warning}}
214 Radeox's parser for ##intermap.txt## is very fragile. A blank line at the bottom of the file is enough to make it fall over.
215 {{/warning}}
216
217 Restart XWiki (you'll need to restart XWiki every time you change ##intermap.txt##) and try out an Interwiki link. If it does not work, check your ##xwiki.log## file. You'll see if ##conf/intermap.txt## could not be found, or if there was an error parsing it.
218
219 == Interwiki links (XWiki Syntax 2.x) ==
220
221 In order to use Interwiki links in the XWiki Syntax 2.x it is necessary to configure the appropriate list in your ##xwiki.properties## file. Look for the following section:
222
223 {{code language="none"}}
224 #-# [Since 2.5M2]
225 #-# InterWiki definitions in the format alias=URL
226 #-# See http://en.wikipedia.org/wiki/Interwiki_links for a definition of an InterWiki link
227 # Some examples:
228 # rendering.interWikiDefinitions = wikipedia = http://en.wikipedia.org/wiki/
229 # rendering.interWikiDefinitions = definition = http://www.yourdictionary.com/
230 {{/code}}
231
232 = Link URLs =
233
234 With parameters, you can specify what type of links will be made by XWiki.
235
236 == Reverse proxy setup ==
237
238 XWiki can and does run behind reverse proxies such as Apache mod_proxy. Usually the only thing needed is to have the ##x-forwarded-host## http header set to the external URL and XWiki will write links correctly.
239
240 Some reverse proxy software does not set this header and with XWiki 3.0M3 or newer, you can use the ##xwiki.home## parameter in single wiki instances (non farm) to achieve the same result.
241
242 * **xwiki.home** - parameter in ##xwiki.cfg## will be used to make all links pointing to the main wiki on the server. If your main wiki is called "xwiki" but you want your users to access it by going to //www.yoursite.tld// instead of //xwiki.yoursite.tld//, you may set the ##xwiki.home## parameter to //{{{http://www.yoursite.tld/}}}//
243 Since XWiki 3.0M3, this parameter will also work for single wiki instances and will be the final authority if the ##x-forwarded-host## parameter is not set.
244
245 * **xwiki.url.protocol** - with the ##xwiki.url.protocol## parameter in ##xwiki.cfg## you can explicitly specify the protocol as https. This is useful if you are running xwiki behind a reverse proxy which converts https into plain http so xwiki only sees http.
246
247 == Short URLs ==
248
249 It's possible to [[configure XWiki to use shorter URLs>>platform:Main.ShortURLs]].
250
251 = Configure the names of database schemas =
252
253 {{info}}Since 1.6M1{{/info}} Sometimes, especially in a complex environment, we need to control the names of database schemes, other than default.
254
255 * **xwiki.db**: name of database schema for the main wiki (including the name of the wiki in a non-virtual environment, otherwise the database name comes from the hibernate configuration file).
256 * **xwiki.db.prefix**: useful mainly for [[virtual wikis>>Documentation.AdminGuide.Virtualization.WebHome]], where we have a separate database schema for each virtual wiki. This prefix is added to the database schema name after usual mapping between wiki names and schemas. Note that this is also applied to the main wiki database name.
257
258 = Controlling Page Tabs =
259
260 You can do this from the [[Administration>>extensions:Extension.Administration Application#HPresentation]].
261
262 If you wish to turn on/off comments/annotations/attachments/history/information tabs only for a single page you just need to [[define some properties in a script in the page>>platform:DevGuide.Scripting#HControllingPageTabs]].
263
264 Last, if you wish to turn them off based on some programmatic rule (such as display them only for Administrators), you should define the properties in the ##layoutExtraVars.vm## template file from your XWiki installation. For example:
265
266 {{code language="none"}}
267 #if (!$hasAdmin)
268 ## Hide tabs
269 #set($displayDocExtra = false)
270 ## Hide viewer shortcuts in the menu
271 #set ($displayShortcuts = false)
272 #end
273 {{/code}}
274
275 = Configure "Version Summary" behavior =
276
277 When you're editing a page you can add a brief description of your changes in the "Version Summary" field by default (look at [[platform:Features.PageEditing#HCommoneditactions]]). You can disable this feature by setting ##xwiki.editcomment=0## in ##xwiki.cfg##.
278
279 When the "Version Summary" feature is enabled, you can also set "Version Summary" to be mandatory by setting //xwiki.editcomment.mandatory=1// in //xwiki.cfg//. This will show a popup window with the request to write a short comment if there is no comment entered. It doesn't allow you to enter an empty comment. If you want a popup, but you also want to be able to enter an empty comment, set //xwiki.editcomment.suggested=1// in //xwiki.cfg//
280
281 If you set "Version Summary" as mandatory or suggested, you can also remove the "Version Summary" field and use only a popup window for writing a comment. Set //xwiki.editcomment.hidden=0// in //xwiki.cfg// to do this.
282
283 You can use the special fields in the //XWikiPreferences// object instead of editing //xwiki.cfg//. These fields are: //editcomment//, //editcomment_mandatory//, //editcomment_suggested// and //editcomment_hidden//.
284
285 = Configuring Directories =
286
287 XWiki uses the following directories:
288
289 * A Temporary directory. It's used for example to cache images after re-sizing them or store attachments after loading them out of the database.
290 * A Permanent directory. It's used for storing data such as extensions and [[filesystem attachments>>Documentation.AdminGuide.Attachments#HFilesystemAttachmentStore28SinceXWikiEnterprise3.0M229]] which must not be deleted and search indexes which are replaceable but laborious to create.
291
292 == Permanent Directory ==
293
294 To set the permanent directory, you have 2 options:
295
296 * Set the ##xwiki.data.dir## system property when starting the JVM (ie. the Servlet Container's JVM, specifically: ##-Dxwiki.data.dir=...##)
297 * Set the ##environment.permanentDirectory## property in your ##xwiki.properties## file
298
299 Make sure to choose a folder different from the XWiki home on which XWiki (which usually means whatever user running the application server in which XWiki is installed) has write access. For example the standard Debian package use ##/var/lib/xwiki/data## which is usually a good fit for many Linux distributions.
300
301 If the location points to a file or a directory to which XWiki does not have write access to, a warning will be printed in the log and the temporary directory will be used as a default. The temporary directory can be periodically cleaned and all its content deleted so it is critical that it is not used for anything else. Thus it's especially important to set the Permanent directory to not point to the temporary directory.
302
303 {{info}}
304 There are 2 ways to find out what's your current permanent directory:
305 * (since XWiki 9.10) Check the XWiki logs and look for the "Using permanent directory" string.
306 * Put the following in a wiki page (using the wiki editor). Beware that you'll need to have programming rights for this to work:(((
307 {{code language="none"}}
308 {{velocity}}
309 $services.component.getInstance('org.xwiki.environment.Environment').getPermanentDirectory()
310 {{/velocity}}
311 {{/code}}
312 )))
313 {{/info}}
314
315 == Temporary Directory ==
316
317 The temporary directory is taken from the Servlet Container's ##javax.servlet.context.tempdir## Servlet Context property and thus must be configured at that level. If it is pointed to a file or directory where XWiki cannot write, it will print a warning in the log and attempt to use the [[##java.io.tmpdir##>>http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getProperties()]] System property. If this is not a writable directory, an exception will be thrown.
318
319 Also note that 3rd party libraries used by XWiki could be using another temporary directory. Usually that would the tmp dir provided by the JVM, i.e. the location pointed to by the [[##java.io.tmpdir##>>http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getProperties()]] System property.
320
321 {{info}}
322 To know the location, put the following in a wiki page (using the wiki editor). Beware that you'll need to have programming rights for this to work:(((
323 {{code language="none"}}
324 {{groovy}}
325 print System.getProperty('java.io.tmpdir')
326 {{/groovy}}
327 {{/code}}
328 )))
329 {{/info}}
330
331 = Configuring WebDAV (since 1.7) =
332
333 WebDAV support has been added to XWiki beginning with XWiki 1.7. It is very important to note that WebDAV is enabled by default.
334
335 == Securing WebDAV Server ==
336
337 XWiki's WebDAV implementation only supports the [[Basic Access Authentication>>http://en.wikipedia.org/wiki/Basic_access_authentication]] scheme for authenticating WebDAV clients. Because of this reason it is highly recommended that you employ a transport level security mechanism like SSL to protect your clients. You may consult your web application container's documentation to see how this can be achieved.
338
339 == Disabling WebDAV ==
340
341 To disable WebDAV support in your XWiki server, simply edit your ##web.xml## file and remove the url-mapping element for mapping webdav requests. The url-mapping element for WebDAV looks like this:
342
343 {{code language="xml"}}
344 <servlet-mapping>
345 <servlet-name>webdav</servlet-name>
346 <url-pattern>/webdav/*</url-pattern>
347 </servlet-mapping>
348 {{/code}}
349
350 = Redirections =
351
352 XWiki supports defining redirections for incoming requests. To activate this feature modify your ##xwiki.cfg## file and set the following property: {{code}}xwiki.preferences.redirect=1{{/code}}.
353 Then for each redirection you want to add, add a ##XWiki.GlobalRedirect## object to your main wiki's ##XWiki.XWikiPreferences## document. The ##XWiki.GlobalRedirect## object has 2 fields: ##pattern## and ##destination##. The URL received is matched on ##pattern## and if there's a match it's replaced with the value from ##destination##. XWiki then redirects to the new URL.
354
355 = Customizing the PDF export Look & Feel =
356
357 {{info}}
358 In the future we'll want to rewrite the PDF/RTF exports as renderers in the new [[Rendering Module architecture>>extensions:Extension.Rendering Module]]. When this happens this section will be upgraded.
359 {{/info}}
360
361 Here's how the PDF and RTF exports currently work:
362 {{image reference="XWikiExport201010290119.png"/}}
363
364 As shown in the diagram you can customize 4 parts:
365
366 * The templates, pdf.vm and the referenced subparts, pdfhtmlheader.vm, pdfheader.vm, pdffooter.vm, pdftoc.vm, pdfcover.vm, which can be overridden by a copy located in a custom skin
367 * The CSS used to render the content as PDF/RTF. There is no pdf.css by default. It could be created in /templates or in a skin; a copy in a skin, override the one located in /templates
368 * The XHTML2FO XSL transformation. The default one, {{scm project="xwiki-platform" path="xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/xhtml2fo.xsl"}}xhtml2fo.xsl{{/scm}}, is packed in core jar but it could be override by a new one in a template or a xhtml2fo.xsl file in WEB-INF/classes directory, if customization needed.
369 * The FOP XSL transformation. The default one, fop.xsl, is also packed in core jar.
370
371 After the export request triggers XWiki ExportAction, the content of your document is parsed by Velocity to get the initial XHTML content. **[[JTidy>>http://jtidy.sourceforge.net/]]**, a HTML/XHTML syntax checker and pretty printer, will clean the initial XHTML to make it XHTML compliant. No customization is possible in this step.
372
373 In order to provide your own customization you need to start by tweaking the default templates (they can also be copied to a new skin) and/or by creating a new [[XWiki Class>>platform:DevGuide.DataModel]]. To do that simply create a new page called //XWiki.PDFClass// and edit it in class mode (for ex. //{{{http://yourserver.com/xwiki/bin/edit/XWiki/PDFClass?editor=class}}}//). Add the following "Text Area" properties as needed (they are all optional so you only need to define the ones you need to use):
374
375 * ##style##: contains the CSS information that will overwrite or complement the default ##pdf.css## values if they exist. **[[css4j>>https://css4j.github.io/]]**, a CSS API implementation for the Javaâ„¢ platform, will take care of this.
376 * ##xhtmlxsl##: contains the XHTML to FO XSL overriding the default one. It is processed by **[[Apache Xalan>>http://xml.apache.org/xalan-j/]]**, a XSLT processor for transforming XML documents into HTML, text, or other XML document types. Since version 3.0M2 (see issue [[XWIKI-5918>>https://jira.xwiki.org/browse/XWIKI-5918||title="Impossible to override XSLT documents used in the PDF export process"]]) this field needs to be the actual content of the customized ##xhtml2fo.xsl##. Note that you can also use velocity in this field (useful to get the content of an attached .xsl file, which comes in very handy when you need to fill in a big file, since the limit of textarea properties is of 60 000 characters)
377 * ##fopxsl##: contains the FOP to PDF/RTF XSL overriding the default one. It is processed by **[[Apache FOP>>http://xmlgraphics.apache.org/fop/]]**.
378
379 {{warning}}
380 The name of the class must be ##XWiki.PDFClass##.
381 {{/warning}}
382
383 The good thing about fop/xsl-fo is that the xsl-fo document is independent of the final result. So we can export the wiki documents into many formats.
384
385 Then create a new page (say ##XWiki.PDFTemplate##) and add the ##XWiki.PDFClass## object to it.
386
387 Last use that page when calling the PDF/RTF export using the ##pdftemplate## parameter as in //{{{http://yourserver/xwiki/bin/export/Space/Page?format=pdf&language=en&pdftemplate=XWiki.PDFTemplate}}}//.
388
389 {{warning}}
390 No template is used by default.
391 {{/warning}}
392
393 {{info}}
394 As mentioned the ##style## property stores CSS code. The field is parsed by the Velocity engine, so you can use the [[current color theme>>extensions:Extension.Color Theme Application#HUsingColorThemesvariables]] to style your PDF. Also, you can insert page break in PDF file with //page-break-before// CSS instruction. For example:
395
396 {{code language="css"}}
397 #template('colorThemeInit.vm')
398 h2 {
399 color: $theme.titleColor;
400 }
401
402 td {
403 border-color: $theme.borderColor;
404 }
405
406 h1, .my_Page_break {
407 page-break-before:always;
408 }
409
410 {{/code}}
411 {{/info}}
412
413 = Override the PDF Templates =
414
415 == Customize the PDF Footer ==
416
417 By default, the PDF footer will display the page number, the last author and the date on which the last modification was performed. In order to also display a customized message, the template ##pdffooter.vm## must be overridden. To do that, edit the skin class (e.g. //{{{http://yourserver/xwiki/bin/edit/XWiki/XWikiSkins?editor=class}}}//) and add a "TextArea" object named ##pdffooter.vm##:
418
419 {{image reference="OverridePDFFooter.png"/}}
420
421 After adding the ##pdffooter.vm## you might want to edit it (clicking on it opens a detailed editor) and e.g. give it a "Pretty name". In this editor, also set the "Editor" property to "pure text" as otherwise the WYSIWYG-Editor will be used:
422
423 {{image reference="OverridePDFFooterEdit1.png"/}}
424
425 Next, edit the skin page (e.g. //{{{http://yourserver/xwiki/bin/edit/XWiki/DefaultSkin?editor=object}}}//) and add the following code to the ##pdffooter.vm## property:
426
427 {{code}}
428 $msg.Page <span class="page-number"></span> - $msg.get('lastmodifiedby')
429 $xwiki.getUserName($tdoc.author, false)
430 $msg.get('lastmodifiedon')
431 $!xwiki.formatDate($tdoc.date)
432 <div>
433 <p>CustomName SAS. All rights reserved. Confidential and proprietary document. Printed Copies are not controlled.</p>
434 </div>
435 {{/code}}
436
437 To see the changes, just export any wiki page:
438
439 {{image reference="OverridePDFFooterFinal.png"/}}
440
441 == Customize the PDF Cover ==
442
443 This could be useful when you want for instance to add the company's logo to the PDF cover. In order to do this, the template ##pdfcover.vm## must be overridden. Just like for the PDF header, a "TextArea" property named ##pdfcover.vm## must be added to the XWiki.XWikiSkins class (e.g. //{{{http://yourserver/xwiki/bin/view/XWiki/XWikiSkins?editor=class}}}//).
444
445 {{image reference="OverridePDFCover.png"/}}
446
447 Next, edit the skin page (e.g. //{{{http://yourserver/xwiki/bin/edit/XWiki/DefaultSkin?editor=object}}}//) and add the following code to the ##pdfcover.vm## property:
448
449 {{code}}
450 <img src="$xwiki.getSkinFile("logo.png")"/>
451
452 <div style="text-align: center; width: 100%;">
453 <h1>
454 #set($title = "$!pdfdoc.display('title', 'rendered')")
455 #if($title == '')
456 $escapetool.xml($!doc.displayTitle)
457 #else
458 $escapetool.xml($title)
459 #end
460 </h1>
461 <br />
462 <br />
463 $!xwiki.getUserName($tdoc.author, false)
464 <br />
465 $!xwiki.formatDate($tdoc.date)
466 </div>
467 {{/code}}
468
469 The last step consists of attaching the image "logo.png" to the skin:
470
471 {{image reference="OverridePDFCoverFinal.png"/}}
472
473 == Override the CSS rules ==
474
475 In order to use your own template when exporting a page as PDF, you need to create a class in the XWiki space and name it PDFClass. Next, edit the page in "Class" mode (e.g. //{{{http://yourserver/xwiki/bin/edit/XWiki/PDFClass?editor=class}}}//) and add the following ##TextArea## properties:
476
477 * ##style##: contains the CSS rules that will override the default ##pdf.css## values; by default, there won't be a ##pdf.css## file on your filesystem, but you can create it in the folder ##\webapps\xwiki\templates\## or specify it in your skin page
478 * ##xhtmlxsl##: contains the XHTML2FO XSL transformation that will override the default one
479 * ##fopxsl##: contains the FOP XSL transformation that will override the default one
480
481 For each property added, make sure to set the ##Content## property metadata to ##PureText## in order to not get the WYSIWYG editor which would make it complex to enter XML/XSL.
482
483 {{image reference="CreatePDFClass.png"/}}
484
485 Then, create the wiki page for which your want to customize the PDF export (e.g. XWiki.PDFTemplate) and add a "XWiki.PDFClass" object to it.
486
487 Supposing your wiki page //Sandbox.TestPage1// contains a table, you have to edit it in "Wiki" mode and add a style parameter as shown below:
488
489 {{code}}
490 (% class="mytable" %)
491 |=Column 1|=Column 2
492 | data|data
493 {{/code}}
494
495 Next, edit the template page (e.g. XWiki.PDFTemplate) in "Objects" mode and write your own CSS rules in the "style" property:
496
497 {{image reference="CreatePDFTemplate.png"/}}
498
499 Because no template is used by default, you need to specify the ##pdftemplate## parameter in the URL in order to use your own template: //{{{http://yourserver/xwiki/bin/export/Sandbox/TestPage1/?format=pdf&pdftemplate=XWiki.PDFTemplate}}}//.
500
501 {{image reference="SandboxTestPage1PDF.png" width="700"/}}
502
503 **Tip**: download the [[PDF class>>attach:XWiki.PDFClass.xar]] and [[PDF template >>attach:XWiki.PDFTemplate.xar]]for this example and test them on your wiki.
504
505 {{info}}
506 Even though RTF export is expected to work the same way, there are still some isues to be solved affecting how CSS properties control the final layout.
507 {{/info}}
508
509 {{warning}}
510 If some CSS styling doesn't work on PDF export, you could check if CSS instruction is supported by XSL-FO on [[Apacheâ„¢ FOP Compliance Page>>https://xmlgraphics.apache.org/fop/compliance.html]].
511 Furthermore, you can not use multiple attributes to select a CSS element (see issue: [[XWIKI-14653>>https://jira.xwiki.org/browse/XWIKI-14653]]).
512 {{/warning}}
513
514 == Override the xhtml2fo.xsl rules ==
515
516 As explained above, the entire code of {{scm project="xwiki-platform" path="xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/xhtml2fo.xsl"}}xhtml2fo.xsl{{/scm}} needs to be copied in the xhtmlxsl textarea and then customized.
517
518 For example, to disable the generation of clickable URLs in the PDF, modify the following section:
519 {{code}} <xsl:template match="html:a[@href]" mode="transform">
520 <fo:basic-link xsl:use-attribute-sets="a-link">
521 <xsl:call-template name="process-a-link"/>
522 </fo:basic-link>
523 </xsl:template>{{/code}}
524 as
525 {{code}} <xsl:template match="html:a[@href]" mode="transform">
526 <fo:inline>
527 <xsl:call-template name="process-a-link"/>
528 </fo:inline>
529 </xsl:template>{{/code}}
530 or disable the generation of clickable URLs for some specific href links in the PDF
531 {{code}} <xsl:template match="html:a[@href]" mode="transform">
532 <xsl:choose>
533 <!-- disable these internal links ("data-parent" attribute start with "#accordion" or href is "#my_anchor") -->
534 <xsl:when test="starts-with(@data-parent,'#accordion') or @href = '#my_anchor'">
535 <fo:inline>
536 <xsl:call-template name="process-a-link"/>
537 </fo:inline>
538 </xsl:when>
539 <xsl:otherwise>
540 <fo:basic-link xsl:use-attribute-sets="a-link">
541 <xsl:call-template name="process-a-link"/>
542 </fo:basic-link>
543 </xsl:otherwise>
544 </xsl:choose>
545
546 </xsl:template>{{/code}}
547
548 == Debugging PDF export ==
549
550 To inspect contents of created XHTML file (and be able to style it) - turn on logging <xwiki>/xwiki/bin/view/AdminGuide/Logging and set //com.xpn.xwiki// level to //DEBUG//. After PDF export action, xwiki log file containing intermediates states XHTML code after theses lines:
551
552 {{code language="none"}}
553 DEBUG c.x.x.p.i.PdfExportImpl - Cleaning HTML: //(show XHTML code without style)//
554 DEBUG c.x.x.p.i.PdfExportImpl - Cleaned XHTML:
555 DEBUG c.x.x.p.i.PdfExportImpl - Applying the following CSS: //(show CSS properties)//
556 DEBUG c.x.x.p.i.PdfExportImpl - HTML with CSS applied: //(show HTML code with CSS properties merged in tag with "style=" )//
557 DEBUG c.x.x.p.i.PdfExportImpl - Final XHTML for export:
558 DEBUG c.x.x.p.i.PdfExportImpl - Intermediary XSL-FO: //(show document with eXtensible Stylesheet Language - Formatting Objects used to generate PDF files)//
559 DEBUG c.x.x.p.i.PdfExportImpl - Final XSL-FO source:
560 and finally DEBUG c.x.x.p.i.PdfExportImpl - PageSequence x-page-sequence generated 3 pages.
561 {{/code}}
562
563 = Configuring Wiki Syntaxes and default Syntax =
564
565 To know how to configure the [[Wiki syntaxes>>platform:Main.XWikiSyntax]] that are available to the user when writing wiki pages, check the [[Rendering Administration Application>>extensions:Extension.Rendering Administration Application]].
566
567 = Title behavior =
568
569 The following configuration parameters (found in ##xwiki.cfg##) can be used to control title behavior:
570
571 {{code language="none"}}
572 #-# Defines whether title handling should be using the compatibility mode or not. When the compatibility
573 #-# mode is active, XWiki will try to extract a title from the document content.
574 #-# If the document's content first header (level 1 or level 2) matches the document's title
575 #-# the first header is stripped.
576 #-# The default value is 0.
577 # xwiki.title.compatibility=1
578
579 #-# Defines the maximum header depth to look for when computing a document's title from its content. If no header
580 #-# equal or lower to the specified depth is found then the computed title falls back to the document name.
581 #-# The default value is 2.
582 # xwiki.title.headerdepth=2
583
584 #-# Defines if setting the title field must be mandatory in the WYSIWYG and Wiki editors. It is mandatory when this
585 #-# property is set to 1. The default value is 0 (not mandatory).
586 # xwiki.title.mandatory=0
587 {{/code}}
588
589 = Link Label Generation =
590
591 Starting with XWiki Syntax 2.0 it's possible to configure how labels are generated by the system when the user doesn't provide one (e.g. ##[[platform:Main.WebHome]]##).
592
593 Her's an extract from the ##xwiki.properties## file which is where this feature is configurable:
594
595 {{code language="none"}}
596 #-# [Since 1.8RC2]
597 #-# Specifies how links labels are displayed when the user doesn't specify the label explicitly.
598 #-# Valid values:
599 #-# %w: wiki name
600 #-# %s: full space name (e.g. space1.space2)
601 #-# Note: Prior to 7.4.2/8.0M2 this was only displaying the last space name
602 #-# %ls: last space name. New in 7.4.2/8.0M2
603 #-# %p: page name
604 #-# %np: nested page name (i.e. will display the space name for Nested Pages). New in 7.4.2/8.0M2
605 #-# %P: page name with spaces between camel case words, i.e. "My Page" if the page name is "MyPage"
606 #-# %NP: nested page name with spaces between camel case words, i.e. "My Page" if the page name is "MyPage".
607 #-# New in 7.4.2/8.0M2
608 #-# %t: page title
609 #-#
610 #-# Note that if the page title is empty or not defined then it defaults to %np. This is also the case
611 #-# if the title cannot be retrieved for the document.
612 #-#
613 #-# The default is "%np". Some examples: "%s.%p", "%w:%s.%p".
614 # rendering.linkLabelFormat = %np
615 {{/code}}
616
617 = Rendering Cache =
618
619 See the [[Performance page>>Documentation.AdminGuide.Performances.WebHome#HRenderingcache]].
620
621 = Allowed Pages for Inactive Users =
622
623 The //xwiki.cfg// configuration file includes a property called ##xwiki.inactiveuser.allowedpages##. This property can be used to build a whitelist of pages that can be read by inactive users. The format that should be used is a comma-separated list of pages that users that are marked as inactive are allowed to see.
624
625 This property is needed due to the fact that in XWiki, some users can be marked as inactive, for example when enabling user email verification in the administration. An inactive user has an account, but the account needs to be validated in order for the user to be able to access the wiki. Access rights do not apply to inactive users (they are recognized neither as XWikiGuest nor as members of XWikiAllGroup).
626
627 {{info}}
628 Inactive users are always allowed to see the //XWiki.AccountValidation// page in order to validate their account.
629 {{/info}}
630
631 = Rendering Transformations =
632
633 You can control which [[Transformations>>rendering:Main.Architecture]] are active (by default the [[Macro>>rendering:Main.Architecture]] and [[Icon>>rendering:Main.Transformations#HIconTransformation]] ones are active by default) by editing ##xwiki.properties##:
634
635 {{code language="none"}}
636 #-# [Since 2.6RC1]
637 #-# Controls what transformations will be executed when rendering content.
638 #-# A transformation modifies the parsed content. For example the Icon transformation replaces some characters with
639 #-# icons, a WikiWord transformation will automatically create links when it finds wiki words, etc.
640 #-# Note that the Macro transformation is a special transformation that replaces macro markers by the result of the
641 #-# macro execution. If you don't list it, macros won't get executed.
642 #-# The default value is: rendering.transformations = macro, icon
643 {{/code}}
644
645 For example if you wish to turn off the Icon Transformation in order to not render emoticons, you'd have to define the following property: {{code language="none"}}rendering.transformations = macro{{/code}}.
646
647 = Securing Groovy Scripts =
648
649 See:
650
651 * The [[Commons Groovy Module>>extensions:Extension.GroovyModuleCommons]]
652 * The [[Platform Groovy Module>>extensions:Extension.GroovyModulePlatform]]
653
654 = Lock Duration =
655
656 By default, when a user starts editing a page, a lock will be set on that page, see [[Page Editing>>Documentation.UserGuide.Features.PageEditing#HLocking]]. The lock is valid by default for 30 minutes, after which it gets invalidated.
657
658 In order to increase this duration, you have 2 options:
659
660 * Add a property named ##lock_Timeout## to your ##xwiki.cfg## configuration file, and set the value in seconds (and restart XWiki). For example for 15 minutes: ##lock_Timeout = 900##.
661 * Or add the configuration in the wiki itself:
662 ** Edit the ##XWiki.XWikiPreferences## document using the class editor
663 ** Add a Number property named ##lock_Timeout## (case sensitive)
664 ** Edit the ##XWiki.XWikiPreferences## document using the object editor
665 ** Find the ##lock_Timeout## property and put the desired number of *seconds* a lock should be valid for
666 ** Don't forget to save the document
667
668 = Editing =
669
670 == Default editor ==
671
672 You can choose the default editor to use from "Configuration > Edit Mode Settings" (see below). You can also configure the default WYSIWYG editor to use ({{info}}XWiki 8.2{{/info}}).
673
674 {{image reference="DefaultEditorStarting30.png" width="45%"/}} {{image reference="default-wysiwyg-config.png" width="45%"/}}
675
676 == Default WYSIWYG editor ==
677
678 See the [[WYSIWYG Editor Configuration>>extensions:Extension.CKEditor Integration.WebHome#HConfiguretheEditor]] page to find out how you can enable or disable editing features.
679
680 == Section Editing ==
681
682 By default section editing is limited to level 1 and level 2 sections. This can be controlled by editing ##xwiki.cfg##:
683
684 {{code}}
685 #-# This parameter controls the depth of sections that have section editing.
686 #-# By default level 1 and level 2 sections have section editing.
687 xwiki.section.depth=2
688 {{/code}}
689
690 You can also enable/disable section editing with:
691
692 {{code}}
693 #-# This parameter will activate the sectional editing.
694 xwiki.section.edit=1
695 {{/code}}
696
697 == Editing Conflicts ==
698
699 The [[Edit Conflict feature>>]] can be disabled ({{info}}XWiki 11.3.2{{/info}} and {{info}}XWiki 11.6RC1{{/info}}) from the ##xwiki.properties## file by setting ##edit.conflictChecking.enabled = false##:
700
701 {{code language='none'}}
702 #-# [Since 11.3.2, 11.6RC1]
703 #-# Indicate if the mechanism to detect and handle edition conflicts should be enabled or not.
704 #-# If disabled, it means that in case of edition conflicts, the latest save will be always take into account, and
705 #-# erase previous data (which can always be recovered in the history of the document).
706 #-# This option is provided because the feature is still experimental and it could be useful is some specific usecases
707 #-# to switch it off. However it is not recommended to do so.
708 #-#
709 #-# The default is:
710 # edit.conflictChecking.enabled = true
711 {{/code}}
712
713 == In-place Editing ==
714
715 To disable the in-place WYSIWYG editing mode (and thus default to the Standalone WYSIWYG editing mode), modify the ##xwiki.properties## file and set ##edit.document.inPlaceEditing.enabled = false## ({{info}}XWiki 12.5{{/info}}):
716
717 {{code language='none'}}
718 #-# [Since 12.5]
719 #-# Indicate if the XWiki documents should be edited in-place, without leaving the view mode, whenever possible (e.g. if
720 #-# the default edit mode for that document and the preferred editor both support in-place editing). When enabled,
721 #-# clicking on the document Edit button makes the document title and content editable in-place, without leaving the
722 #-# view mode. When disabled, clicking on the document Edit button loads the default (stand-alone) edit mode for that
723 #-# document.
724 #-#
725 #-# The default is:
726 # edit.document.inPlaceEditing.enabled = true
727 {{/code}}
728
729 = Sample xwiki.cfg =
730
731 See {{scm path="xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.cfg.vm"}}xwiki.cfg.vm{{/scm}}
732
733 Note that we generate the default ##xwiki.cfg## file from this template file by applying Velocity on it during the build, so all ##$<something>## properties that you see in this file are replaced at build time.
734
735 = Sample xwiki.properties =
736
737 See {{scm path="xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.properties.vm"}}xwiki.properties.vm{{/scm}}
738
739 Note that we generate the default ##xwiki.properties## file from this template file by applying Velocity on it during the build, so all ##$<something>## properties that you see in this file are replaced at build time.

Get Connected