Test Each Flamingo Theme Snippet

Last modified by Guillaume Delhumeau on 2021/03/18 11:28

color_swatchHelper to test the rendering of each Flamingo Theme
TypeSnippet
CategoryColor theme
Developed by

Guillaume Delhumeau

Rating
0 Votes
LicenseDo What The Fuck You Want To Public License 2

Description

In some occasions, I need to test the rendering of each Flamingo Theme, to verify I haven't broken anything (for example, when I upgrade the version of less4j).

I've written this helper that list every themes and test one of them when I click on it. Then I just need to click on each element, one after the other, and verify that the rendering is OK every time.

Screenshot:

screenshot.png

Code (XWiki Syntax 2.1)

{{velocity}}
= List of the flamingo themes =
Click one of them to test it
#set ($prefRef = $services.model.createDocumentReference('', 'XWiki', 'XWikiPreferences'))
#set ($prefDoc = $xwiki.getDocument($prefRef))
#set ($prefObj = $prefDoc.getObject('XWiki.XWikiPreferences'))
#set ($currentTheme = $prefObj.getValue('colorTheme'))
#set ($xwql = "from doc.object(FlamingoThemesCode.ThemeClass) obj WHERE doc.fullName <> 'FlamingoThemesCode.ThemeTemplate' ORDER BY doc.fullName")
#foreach ($r in $services.query.xwql($xwql).execute())
  #if ($r != $currentTheme)
    * (% class="changeColorThemeLink" %)[[$r>>path:$xwiki.getURL('FlamingoThemes.WebHome', 'view', "action=setTheme&theme=${r}&form_token=${services.csrf.token}")]]
  #else
    * $r (current)
  #end
#end

{{html clean="false"}}
<script language="javascript">
"use strict";
require(['jquery'], function ($) {
  $('.changeColorThemeLink a').click(function (event) {
    event.preventDefault();
    new XWiki.widgets.Notification('Changing flamingo theme', 'inprogress');
    $.ajax($(this).attr('href')).done(function() {
      location.reload();
    }).fail(function(){
      new XWiki.widgets.Notification('Failed to change the flamingo theme', 'error');
    });
  });
});
</script>
{{/html}}
{{/velocity}}
Tags:
     

Get Connected