diff --git a/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java b/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java index db668d7a..25bf087b 100644 --- a/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java +++ b/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java @@ -27,6 +27,7 @@ import org.cobbzilla.util.handlebars.HandlebarsUtil; import org.cobbzilla.util.io.FileUtil; import org.cobbzilla.util.io.regex.RegexFilterReader; import org.cobbzilla.util.io.regex.RegexReplacementFilter; +import org.cobbzilla.util.string.LocaleUtil; import org.cobbzilla.util.system.Bytes; import org.cobbzilla.wizard.cache.redis.RedisService; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +41,8 @@ import java.util.Map; import static bubble.ApiConstants.HOME_DIR; import static bubble.rule.RequestModifierRule.ICON_JS_TEMPLATE; import static bubble.rule.RequestModifierRule.ICON_JS_TEMPLATE_NAME; -import static org.cobbzilla.util.daemon.ZillaRuntime.*; +import static org.cobbzilla.util.daemon.ZillaRuntime.die; +import static org.cobbzilla.util.daemon.ZillaRuntime.empty; import static org.cobbzilla.util.io.FileUtil.abs; import static org.cobbzilla.util.io.FileUtil.basename; import static org.cobbzilla.util.io.regex.RegexReplacementFilter.DEFAULT_PREFIX_REPLACEMENT_WITH_MATCH; @@ -157,7 +159,7 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { final RequestModifierConfig modConfig = requestModConfig(); final String replacement = DEFAULT_PREFIX_REPLACEMENT_WITH_MATCH + scriptOpen(filterRequest, modConfig.getScriptOpenNonce(), modConfig.getScriptOpenNoNonce()) - + getBubbleJs(filterRequest.getId(), filterCtx, bubbleJsTemplate, defaultSiteTemplate, siteJsInsertionVar, showIcon) + + getBubbleJs(filterRequest, filterCtx, bubbleJsTemplate, defaultSiteTemplate, siteJsInsertionVar, showIcon) + getScriptClose(); final RegexReplacementFilter filter = new RegexReplacementFilter(getInsertionRegex(), replacement); @@ -179,13 +181,13 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { return new ReaderInputStream(reader, UTF8cs); } - protected String getBubbleJs(String requestId, + protected String getBubbleJs(FilterHttpRequest filterRequest, Map filterCtx, String bubbleJsTemplate, String defaultSiteTemplate, String siteJsInsertionVar, boolean showIcon) { - final Map ctx = getBubbleJsContext(requestId, filterCtx); + final Map ctx = getBubbleJsContext(filterRequest, filterCtx); if (!empty(siteJsInsertionVar) && !empty(defaultSiteTemplate)) { final String siteJs = HandlebarsUtil.apply(getHandlebars(), getSiteJsTemplate(defaultSiteTemplate), ctx); @@ -208,6 +210,8 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { public static final String CTX_BUBBLE_APP_NAME = "BUBBLE_APP_NAME"; public static final String CTX_ICON_JS = "ICON_JS"; public static final String CTX_APP_CONTROLS_Z_INDEX = "APP_CONTROLS_Z_INDEX"; + public static final String CTX_ACCOUNT_LOCALE = "ACCOUNT_LOCALE"; + public static final String CTX_ACCOUNT_LANG = "ACCOUNT_LANG"; public static final int PAGE_ONREADY_INTERVAL = 50; public static final int APP_CONTROLS_Z_INDEX = 2147483640; @@ -215,7 +219,8 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { private String getPagePrefix(String requestId) { return "__bubble_page_"+sha256_hex(requestId); } private String getJsPrefix(String requestId) { return "__bubble_js_"+sha256_hex(requestId+"_"+getClass().getName()); } - protected Map getBubbleJsContext(String requestId, Map filterCtx) { + protected Map getBubbleJsContext(FilterHttpRequest filterRequest, Map filterCtx) { + final String requestId = filterRequest.getId(); final Map ctx = new HashMap<>(); ctx.put(CTX_PAGE_PREFIX, getPagePrefix(requestId)); ctx.put(CTX_JS_PREFIX, getJsPrefix(requestId)); @@ -226,6 +231,11 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { ctx.put(CTX_BUBBLE_SITE_NAME, getSiteName(matcher)); ctx.put(CTX_BUBBLE_APP_NAME, app.getName()); ctx.put(CTX_BUBBLE_DATA_ID, getDataId(requestId)); + + String locale = filterRequest.getAccount().getLocale(); + if (empty(locale)) locale = configuration.getDefaultLocale(); + ctx.put(CTX_ACCOUNT_LOCALE, locale); + ctx.put(CTX_ACCOUNT_LANG, LocaleUtil.getLang(locale)); return ctx; } diff --git a/bubble-server/src/main/java/bubble/rule/bblock/BubbleBlockRuleDriver.java b/bubble-server/src/main/java/bubble/rule/bblock/BubbleBlockRuleDriver.java index c6dee270..d1508c64 100644 --- a/bubble-server/src/main/java/bubble/rule/bblock/BubbleBlockRuleDriver.java +++ b/bubble-server/src/main/java/bubble/rule/bblock/BubbleBlockRuleDriver.java @@ -384,8 +384,8 @@ public class BubbleBlockRuleDriver extends TrafficAnalyticsRuleDriver implements private static final String CTX_BUBBLE_BLACKLIST = "BUBBLE_BLACKLIST_JSON"; private static final String CTX_BUBBLE_WHITELIST = "BUBBLE_WHITELIST_JSON"; - @Override protected Map getBubbleJsContext(String requestId, Map filterCtx) { - final Map ctx = super.getBubbleJsContext(requestId, filterCtx); + @Override protected Map getBubbleJsContext(FilterHttpRequest filterRequest, Map filterCtx) { + final Map ctx = super.getBubbleJsContext(filterRequest, filterCtx); final BubbleBlockConfig bubbleBlockConfig = getRuleConfig(); if (bubbleBlockConfig.inPageBlocks()) { final BlockDecision decision = (BlockDecision) filterCtx.get(FILTER_CTX_DECISION); diff --git a/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs b/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs index 6469317e..80e7ec3f 100644 --- a/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs +++ b/bubble-server/src/main/resources/bubble/rule/social/block/JsUserBlockerRuleDriver.js.hbs @@ -153,8 +153,10 @@ function {{JS_PREFIX}}_show_app_details() { } detailsDiv.style.display = 'block'; // add rows for blocked users... - blocks = blocks.slice(); // copy first, then sort - blocks.sort(); + blocks = blocks.slice(); // copy first, then sort case insensitive using user's locale + blocks.sort(function (a, b) { + return a.localeCompare(b, '{{ACCOUNT_LANG}}', {'sensitivity': 'base'}); + }); if ({{JS_PREFIX}}_unblocked_users_needs_refresh) { const refreshControl = document.createElement('a'); refreshControl.addEventListener("click", function (e) { diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index 3de70e3b..f4e97cba 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit 3de70e3b1e5109a0d1bf41e8d6e73358236d5e8f +Subproject commit f4e97cba4c2a47622ef648b4c94dee04e4ba4805