@Override public void handle(Page page, TemplateContext local, TemplateContext global) { Homepage homepage = homepage(page.getSite()); if (homepage == null || !homepage.isHomepageActivated()) { return; // TODO we might want 404 here } global.put("homepage", homepage); Person owner = homepage.getPerson(); global.put("owner", owner); if (homepage.getShowCurrentAttendingExecutionCourses()) { SortedSet<Attends> attendedCoursesByName = new TreeSet<Attends>(Attends.ATTENDS_COMPARATOR_BY_EXECUTION_COURSE_NAME); attendedCoursesByName.addAll(homepage.getPerson().getCurrentAttends()); global.put("attendingCourses", attendedCoursesByName); } List<? extends PartyContact> emails = owner.getEmailAddresses(); global.put("visibleEmails", getSortedFilteredContacts(emails)); List<? extends PartyContact> phones = owner.getPhones(); global.put( "visiblePersonalPhones", getSortedFilteredContacts(phones, PartyContactType.PERSONAL)); global.put("visibleWorkPhones", getSortedFilteredContacts(phones, PartyContactType.WORK)); List<? extends PartyContact> mobilePhones = owner.getMobilePhones(); global.put("visibleMobilePhones", getSortedFilteredContacts(mobilePhones)); List<? extends PartyContact> websites = owner.getWebAddresses(); global.put("visibleWebsites", getSortedFilteredContacts(websites)); }
@Override public void handle(Page page, TemplateContext componentContext, TemplateContext global) { PostMetadata metadata = metadata(page.getSite()); String staticDir = page.getSite().getStaticDirectory(); global.put("announcements", postsForCategory(page.getSite().categoryForSlug("announcement"))); global.put("events", postsForCategory(page.getSite().categoryForSlug("event"))); global.put( "backgroundImage", metadata.getAsString("backgroundImage").orElse(staticDir + "/images/bolonha_bck.gif")); global.put( "mainImage", metadata.getAsString("mainImage").orElse(staticDir + "/images/bolonha.gif")); global.put("link", metadata.getAsString("link").orElse("http://www.bolonha.ist.eu")); global.put("showIntroduction", metadata.getAsBoolean("showIntroduction").orElse(true)); global.put("repeatType", metadata.getAsString("repeatType").orElse("repeat-x")); global.put("color", metadata.getAsString("color").orElse("#019AD7")); global.put("showBanner", metadata.getAsBoolean("showBanner").orElse(true)); global.put("weight", metadata.getAsNumber("weight").orElse(100)); global.put("weightPercentage", metadata.getAsNumber("weightPercentage").orElse(100)); global.put("showPersonalizedLogo", metadata.getAsBoolean("showPersonalizedLogo").orElse(false)); global.put("showAnnouncements", metadata.getAsBoolean("showAnnouncements").orElse(true)); global.put("showEvents", metadata.getAsBoolean("showEvents").orElse(true)); pageForCategory(page.getSite(), "announcement") .ifPresent( announcementsPage -> { global.put("announcementsUrl", announcementsPage.getAddress()); }); pageForCategory(page.getSite(), "event") .ifPresent( eventsPage -> { global.put("eventsUrl", eventsPage.getAddress()); }); }
protected Site site(Page page) { if (page.getSite().getOwner() != null) { return page.getSite(); } throw new ResourceNotFoundException(); }