Webiyo

This page was generated using Webiyo. See its source code and unit tests.

org/webiyo/examples/sourceforge/HomePage.java

package org.webiyo.examples.sourceforge;

import org.webiyo.web.HtmlWriter;
import org.webiyo.web.Location;

import java.io.IOException;

import static org.webiyo.web.Att.cssClass;
import static org.webiyo.xml.dtds.Html.H3;
import static org.webiyo.xml.dtds.Html.H2;
import static org.webiyo.xml.dtds.Html.DIV;

class HomePage extends Page {

    private News news;

    public HomePage(Project project) throws IOException {
        super(project);
        this.news = project.loadNews();
    }

    public Location getLocation() {
        return SiteMap.HOME;
    }
    
    // end of public methods

    protected void renderRightSide(HtmlWriter out) throws IOException {
        out.startTag(DIV, cssClass("project-description"));
        out.text(news.getProjectDescription());
        out.endTag(DIV);

        renderNews(out);
    }
    
    // end of protected methods

    private void renderNews(HtmlWriter out) throws IOException {
        out.startTag(DIV, cssClass("news"));
        out.text(H2, "Project News");
        for (NewsItem item : news) {
            renderNewsItem(item, out);
        }
        out.endTag(DIV);
    }

    private void renderNewsItem(NewsItem item, HtmlWriter out) throws IOException {
        out.startTag(DIV, cssClass("news-item"));
        out.text(H3, item.getTitle());
        item.getBody().render(out);
        out.endTag(DIV);
    }

}

SourceForge