Wiki source code of Skin Module
Last modified by Eleni Cojocariu on 2026/09/23 12:16
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | The [[Skin Module>>doc:extensions:Extension.Skin.Module.WebHome]] is the API Java code uses to find a file inside a skin, following the skin's inheritance. It has nothing to say about how a skin looks. | ||
| 2 | |||
| 3 | The entry point is the ##SkinManager## component, which hands out a ##Skin## by id, for the current request or for the instance default. A ##Skin## is a ##ResourceRepository##, so it has a parent and resolves a name to a ##Resource##. Every member of the four roles is listed on the [[Skin API>>doc:documentation.xs.dev.skin.api.WebHome]]. The artifact is ##xwiki-platform-skin-api##, whose sources are in {{scm path="xwiki-platform-core/xwiki-platform-skin/xwiki-platform-skin-api"/}}. | ||
| 4 | |||
| 5 | {{plantuml}} | ||
| 6 | @startuml | ||
| 7 | !theme bluegray | ||
| 8 | skinparam componentStyle rectangle | ||
| 9 | |||
| 10 | component "**SkinManager**\nthe component to inject" as SM | ||
| 11 | component "**Skin**\none skin" as SK | ||
| 12 | component "**ResourceRepository**\nsomewhere to look a name up" as RR | ||
| 13 | component "**Resource**\none file of a skin" as RES | ||
| 14 | |||
| 15 | SM --> SK : getSkin, getCurrentSkin,\ngetDefaultSkin, getDefaultParentSkin | ||
| 16 | RR <|-- SK : a skin is a\nresource repository | ||
| 17 | RR --> RR : parent, walked when\nthe name is not here | ||
| 18 | RR --> RES : getResource walks the chain,\ngetLocalResource does not | ||
| 19 | RES --> RR : getRepository, the skin\nthe file came from | ||
| 20 | @enduml | ||
| 21 | {{/plantuml}} | ||
| 22 | |||
| 23 | The [[three kinds of skin>>doc:documentation.xs.admin.skins.available.WebHome]] each resolve to a class: an id that resolves to an existing page gives a ##WikiSkin##, whose ##XWiki.XWikiSkins## object holds the skin's properties; a ##skins/## folder of the environment holding a ##skin.properties## gives an ##EnvironmentSkin##; anything else falls back to a ##ClassLoaderSkin##, which is how a skin shipped inside a JAR is found. A wiki skin reads a file from a template override object, then from a property of its skin object, then from an attachment of the same page. | ||
| 24 | |||
| 25 | A lookup starts in the skin itself and then walks the parent chain, and the first repository holding the name wins. A skin that names no parent falls back to the default parent skin. Only a filesystem or JAR skin can opt out of that fallback, by setting an empty ##parent## in its ##skin.properties##; a wiki skin whose ##baseskin## is left empty still gets the default parent. | ||
| 26 | |||
| 27 | This module declares the roles and nothing else, and ships no ##components.txt##. The implementations are in ##xwiki-platform-oldcore##, package ##com.xpn.xwiki.internal.skin##, which is where to read how a lookup behaves. | ||
| 28 | |||
| 29 | Skin extensions are a different mechanism, how a page contributes CSS or JavaScript to the response; they are documented on [[Skin Extension Plugin>>doc:extensions:Extension.Skin Extension Plugin]]. Only their two roles are declared in this artifact. |