We have build a proxy that uses one special user (let’s call him XWiki.ProxyReadonly) with oidc.skipped=true&basicauth=1 that is allowed to only read the wiki. That is to provide the wiki on places where no internet is available.
We want to use some special styling mostly to hide some buttons.
My first approach was to use SSX that is used only for XWiki.ProxyReadonly. But it’s not working this way.
#set($currentUserReference = $services.user.getCurrentUserReference())
#set($currentUser = $xwiki.getDocument($currentUserReference))
$currentUser
Code above does not output XWiki.ProxyReadonly as it would in the original wiki but it’s outputting nothing.
A second approach serving css depending on the url won’t work either.
$doc.getExternalURL()
This will output either wiki-prod or wiki-test but not wiki-readonly-proxy.
Currently we are using this:
/*
- $currentUser returns NOTHING - the user can't be identified after the proxy
- not the best check, but it works for now
- the URL is not wiki-readonly-proxy but unfortunately wiki-prod or wiki-test
- therefore, a check on the URL is unfortunately not possible
*/
#set($currentUserReference = $services.user.getCurrentUserReference())
#set($currentUser = $xwiki.getDocument($currentUserReference))
#if(!$currentUser)
/* remove notification bell */
#tmNotifications {
display: none;
}
/* remove user avatar */
#xwikimainmenu li.navbar-avatar {
display: none;
}
/* remove like button */
#contentcolumn .like-container {
display: none;
}
/* remove watch-button - was in notification bell before */
#watchButton {
display: none;
}
/* now add a padding */
form#globalsearch {
padding-right: 15px;
}
#end
It works but I don’t find it satisfactory. And I’m not sure if it’s future proof. Perhaps there are still pitfalls lurking somewhere that we cannot see at present.
Any idea for a better solution?
Regards, Simpel