<commit_before>package com.bloatit.web.html.pages.master;

import java.io.IOException;
import java.util.Locale;

import com.bloatit.web.annotations.Message;
import com.bloatit.web.annotations.ParamContainer;
import com.bloatit.web.exceptions.RedirectException;
import com.bloatit.web.html.HtmlBranch;
import com.bloatit.web.html.HtmlElement;
import com.bloatit.web.html.HtmlNode;
import com.bloatit.web.html.HtmlTagText;
import com.bloatit.web.html.HtmlText;
import com.bloatit.web.html.components.PlaceHolderElement;
import com.bloatit.web.html.components.standard.HtmlDiv;
import com.bloatit.web.html.components.standard.HtmlGenericElement;
import com.bloatit.web.html.components.standard.HtmlLink;
import com.bloatit.web.html.pages.master.HtmlNotification.Level;
import com.bloatit.web.server.Context;
import com.bloatit.web.server.HttpResponse;
import com.bloatit.web.server.Linkable;
import com.bloatit.web.server.Notification;
import com.bloatit.web.server.Session;
import com.bloatit.web.utils.annotations.Messages;
import com.bloatit.web.utils.url.IndexPageUrl;
import com.bloatit.web.utils.url.Url;

public abstract class Page extends HtmlElement implements Linkable {

    private final HtmlBranch content;
    private HtmlBranch notifications;
    private final PlaceHolderElement notificationBlock;
    private final Url thisUrl;
    protected final Session session;

    public Page(final Url url) {
        super();
        this.thisUrl = url;
        content = new HtmlDiv().setId("body_content");
        notifications = null;
        notificationBlock = new PlaceHolderElement();
        session = Context.getSession();
    }

    @Override
    public final void writeToHttp(HttpResponse response) throws RedirectException, IOException {
        create();
        response.writePage(this);
    }

    public final void create() throws RedirectException {
        super.add(new HtmlTagText("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
        super.add(new HtmlTagText("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"));
        final HtmlBranch html = new HtmlGenericElement("html");

        super.add(html);
        html.addAttribute("xmlns", "http://www.w3.org/1999/xhtml");

        html.add(new Header(getTitle(), getCustomCss()));
        html.add(doGenerateBody());

        // Display waiting notifications
        addWaitingNotifications();

        // Set the last stable page into the session
        if (isStable()) {
            session.setTargetPage(null);
            session.setLastStablePage(thisUrl);
        }
        doCreate();
    }

    @SuppressWarnings("unused")
    protected void doCreate() throws RedirectException {
        // Nothing. You can override it or not.
    }

    private HtmlElement doGenerateBody() {

        final HtmlGenericElement body = new HtmlGenericElement("body");

        final HtmlBranch page = new HtmlDiv("page").setId("page");
        body.add(page);

        final HtmlBranch header = new HtmlDiv("header").setId("header");

        header.add(new TopBar());
        header.add(generateTitle());

        page.add(header);

        final HtmlBranch center = new HtmlDiv().setId("center");
        page.add(center);

        final HtmlBranch centerColumn = new HtmlDiv().setId("center_column");
        center.add(centerColumn);

        content.add(notifications);
        centerColumn.add(new Menu()).add(content);

        page.add(new Footer());

        return body;
    }

    protected abstract String getTitle();

    public abstract boolean isStable();

    public final String getName() {
        if (getClass().getAnnotation(ParamContainer.class) != null) {
            return getClass().getAnnotation(ParamContainer.class).value();
        }
        return getClass().getName().toLowerCase(Locale.ENGLISH);<commit_msg>fix the previous fix ... (on notifications)<commit_after>package com.bloatit.web.html.pages.master;

import java.io.IOException;
import java.util.Locale;

import com.bloatit.web.annotations.Message;
import com.bloatit.web.annotations.ParamContainer;
import com.bloatit.web.exceptions.RedirectException;
import com.bloatit.web.html.HtmlBranch;
import com.bloatit.web.html.HtmlElement;
import com.bloatit.web.html.HtmlNode;
import com.bloatit.web.html.HtmlTagText;
import com.bloatit.web.html.HtmlText;
import com.bloatit.web.html.components.PlaceHolderElement;
import com.bloatit.web.html.components.standard.HtmlDiv;
import com.bloatit.web.html.components.standard.HtmlGenericElement;
import com.bloatit.web.html.components.standard.HtmlLink;
import com.bloatit.web.html.pages.master.HtmlNotification.Level;
import com.bloatit.web.server.Context;
import com.bloatit.web.server.HttpResponse;
import com.bloatit.web.server.Linkable;
import com.bloatit.web.server.Notification;
import com.bloatit.web.server.Session;
import com.bloatit.web.utils.annotations.Messages;
import com.bloatit.web.utils.url.IndexPageUrl;
import com.bloatit.web.utils.url.Url;

public abstract class Page extends HtmlElement implements Linkable {

    private final HtmlBranch content;
    private HtmlBranch notifications;
    private final PlaceHolderElement notificationBlock;
    private final Url thisUrl;
    protected final Session session;

    public Page(final Url url) {
        super();
        this.thisUrl = url;
        content = new HtmlDiv().setId("body_content");
        notifications = null;
        notificationBlock = new PlaceHolderElement();
        session = Context.getSession();
    }

    @Override
    public final void writeToHttp(HttpResponse response) throws RedirectException, IOException {
        create();
        response.writePage(this);
    }

    public final void create() throws RedirectException {
        super.add(new HtmlTagText("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
        super.add(new HtmlTagText("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"));
        final HtmlBranch html = new HtmlGenericElement("html");

        super.add(html);
        html.addAttribute("xmlns", "http://www.w3.org/1999/xhtml");

        html.add(new Header(getTitle(), getCustomCss()));
        html.add(doGenerateBody());

        // Display waiting notifications
        addWaitingNotifications();

        // Set the last stable page into the session
        if (isStable()) {
            session.setTargetPage(null);
            session.setLastStablePage(thisUrl);
        }
        doCreate();
    }

    @SuppressWarnings("unused")
    protected void doCreate() throws RedirectException {
        // Nothing. You can override it or not.
    }

    private HtmlElement doGenerateBody() {

        final HtmlGenericElement body = new HtmlGenericElement("body");

        final HtmlBranch page = new HtmlDiv("page").setId("page");
        body.add(page);

        final HtmlBranch header = new HtmlDiv("header").setId("header");

        header.add(new TopBar());
        header.add(generateTitle());

        page.add(header);

        final HtmlBranch center = new HtmlDiv().setId("center");
        page.add(center);

        final HtmlBranch centerColumn = new HtmlDiv().setId("center_column");
        center.add(centerColumn);

        content.add(notificationBlock);
        centerColumn.add(new Menu()).add(content);

        page.add(new Footer());

        return body;
    }

    protected abstract String getTitle();

    public abstract boolean isStable();

    public final String getName() {
        if (getClass().getAnnotation(ParamContainer.class) != null) {
            return getClass().getAnnotation(ParamContainer.class).value();
        }
        return getClass().getName().toLowerCase(Locale.ENGLISH);
{'fraction_non_alphanumeric': 0.12077855117298272, 'fraction_numerical': 0.0041247744263985565, 'mean_word_length': 3.3009977827050996, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 2, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '677088', 'n_tokens_mistral': 2290, 'n_tokens_neox': 2235, 'n_words': 452}