Skip to content

Commit

Permalink
Fixed the GUI setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Apr 22, 2018
1 parent 40555dd commit e209313
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions rapidoid-commons/src/main/java/org/rapidoid/web/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public interface Screen {
/**
* Sets the "<b>cdn</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen cdn(boolean cdn);
Screen cdn(Boolean cdn);

/**
* Gets the "<b>cdn</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
boolean cdn();
Boolean cdn();

/**
* Sets the "<b>navbar</b>" attribute in the MVC model of the response, used for GUI page rendering.
Expand Down
10 changes: 4 additions & 6 deletions rapidoid-commons/src/main/java/org/rapidoid/web/ScreenBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.collection.Coll;
import org.rapidoid.commons.RapidoidInfo;
import org.rapidoid.env.Env;
import org.rapidoid.u.U;

import java.io.OutputStream;
Expand All @@ -45,7 +43,7 @@ public class ScreenBean extends RapidoidThing implements Screen {
private volatile boolean search;
private volatile boolean navbar;
private volatile boolean fluid;
private volatile boolean cdn;
private volatile Boolean cdn;

private final Set<String> js = Coll.synchronizedSet();
private final Set<String> css = Coll.synchronizedSet();
Expand All @@ -65,7 +63,7 @@ public void reset() {
search = false;
navbar = true;
fluid = false;
cdn = Env.production() && !RapidoidInfo.isSnapshot();
cdn = null;

js.clear();
css.clear();
Expand Down Expand Up @@ -181,12 +179,12 @@ public Screen fluid(boolean fluid) {
}

@Override
public boolean cdn() {
public Boolean cdn() {
return cdn;
}

@Override
public Screen cdn(boolean cdn) {
public Screen cdn(Boolean cdn) {
this.cdn = cdn;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
import org.rapidoid.annotation.Since;
import org.rapidoid.buffer.Buf;
import org.rapidoid.collection.Coll;
import org.rapidoid.commons.RapidoidInfo;
import org.rapidoid.config.Conf;
import org.rapidoid.ctx.Ctxs;
import org.rapidoid.ctx.UserInfo;
import org.rapidoid.env.Env;
import org.rapidoid.http.HttpUtils;
import org.rapidoid.http.MediaType;
import org.rapidoid.http.Req;
Expand Down Expand Up @@ -424,6 +426,11 @@ private Screen createScreen() {

screen.assign(req.http().gui());

if (screen.cdn() == null) {
// auto mode
screen.cdn(Env.production() && !RapidoidInfo.isSnapshot());
}

return screen;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ public void openContext() {

App.path(getTestPackageName());

App.setup().http().gui().reset(); // FIXME

verifyNoRoutes();

U.must(Msc.isInsideTest());
Expand Down
2 changes: 0 additions & 2 deletions rapidoid-rest/src/main/java/org/rapidoid/setup/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ private static void reloadAndRunMainClass() {

private static void resetAppStateBeforeRestart() {
App.boot.reset();
App.gui().reset();
App.status = AppStatus.NOT_STARTED;
App.dirty = false;
App.packages = null;
Expand Down Expand Up @@ -263,7 +262,6 @@ public static synchronized void resetGlobalState() {
packages = null;
loader = App.class.getClassLoader();
boot.reset();
gui().reset();
Setups.initDefaults();
AppStarter.reset();
invoked.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class DefaultSetup extends RapidoidInitializer {
private static final Config MAIN_CFG = Msc.isPlatform() ? Conf.RAPIDOID : Conf.ON;
private static final Config ADMIN_CFG = Msc.isPlatform() ? Conf.RAPIDOID_ADMIN : Conf.ADMIN;

private static final Screen gui = new ScreenBean();

final Setup main;
final Setup admin;

Expand All @@ -56,8 +58,6 @@ public class DefaultSetup extends RapidoidInitializer {
HttpRoutesImpl appRoutes = new HttpRoutesImpl("main", appCustomization);
HttpRoutesImpl adminRoutes = onSameServer ? appRoutes : new HttpRoutesImpl("admin", adminCustomization);

Screen gui = new ScreenBean();

main = new Setup("main", MAIN_ZONE, IoC.defaultContext(), MAIN_CFG, appCustomization, appRoutes, gui);
admin = new Setup("admin", ADMIN_ZONE, IoC.defaultContext(), ADMIN_CFG, adminCustomization, adminRoutes, gui);

Expand All @@ -68,6 +68,7 @@ public class DefaultSetup extends RapidoidInitializer {
}

void initDefaults() {
gui.reset();
admin.defaults().roles(Role.ADMINISTRATOR);
}

Expand Down

0 comments on commit e209313

Please sign in to comment.