play.twirl.api.Html Java Examples

The following examples show how to use play.twirl.api.Html. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotificationController.java    From htwplus with MIT License 6 votes vote down vote up
/**
    * Returns all notifications for current user.
    *
    * @return Html rendered instance
    */
   @Transactional(readOnly = true)
public static Html getNotifications() {
	Account account = Component.currentAccount();
	
	if (account == null) {
		return new Html("Das wird nichts");
	}

       List<Notification> list = null;
       try {
           list = NotificationManager.findByAccountIdUnread(account.id);
       } catch (Throwable throwable) { throwable.printStackTrace(); }

       List<Integer> countedNotifications = NotificationController.countNotifications(list);
       return views.html.Notification.menuitem.render(list, countedNotifications.get(0),
               NotificationManager.countUnreadNotificationsForAccountId(account.id)
       );
}
 
Example #2
Source File: AbstractBoxGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Html renderViewSubmission(ProgrammingSubmission submission, SubmissionSource submissionSource, String authorName, String problemAlias, String problemName, String gradingLanguageName, String contestName) {
    String errorMessage = null;
    GradingResultDetails details = null;
    if (submission.getLatestVerdict().getCode().equals("!!!")) {
        errorMessage = submission.getLatestDetails();
        details = null;
    } else if (submission.getLatestDetails() != null){
        errorMessage = null;
        try {
            details = MAPPER.readValue(submission.getLatestDetails(), GradingResultDetails.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    return blackBoxViewSubmissionView.render(submission, errorMessage, details, submissionSource.getSubmissionFiles(), authorName, problemAlias, problemName, gradingLanguageName, contestName);
}
 
Example #3
Source File: FunctionalWithSubtasksGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<FunctionalWithSubtasksGradingConfigForm> castForm = (Form<FunctionalWithSubtasksGradingConfigForm>) form;

    return functionalWithSubtasksGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #4
Source File: BundleItemController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private Result showCreateItem(Problem problem, String itemType, Html html, long page, String orderBy, String orderDir, String filterString) {
    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(html);
    template.markBreadcrumbLocation(Messages.get("problem.bundle.item.create"), routes.BundleItemController.createItem(problem.getId(), itemType, page, orderBy, orderDir, filterString));
    template.setPageTitle("Problem - Bundle - Items - Create");

    return renderTemplate(template, problemService, problem);
}
 
Example #5
Source File: BundleItemController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private Result showEditItem(Problem problem, BundleItem bundleItem, Html html, Set<String> allowedLanguages) {
    HtmlTemplate template = getBaseHtmlTemplate();
    template.setContent(html);
    appendStatementLanguageSelection(template, ProblemControllerUtils.getCurrentStatementLanguage(), allowedLanguages, org.iatoki.judgels.sandalphon.problem.base.routes.ProblemController.switchLanguage(problem.getId()));
    template.markBreadcrumbLocation(Messages.get("problem.bundle.item.update"), routes.BundleItemController.editItem(problem.getId(), bundleItem.getJid()));
    template.setPageTitle("Problem - Bundle - Item - Update");

    return renderTemplate(template, problemService, problem);
}
 
Example #6
Source File: FunctionalGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<FunctionalGradingConfigForm> castForm = (Form<FunctionalGradingConfigForm>) form;

    return functionalGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #7
Source File: AbstractJudgelsController.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
protected static Result getResult(LazyHtml content, int statusCode) {
    HtmlCompressor htmlCompressor = new HtmlCompressor();
    Html compressedContent = new Html(htmlCompressor.compress(content.render().body()));
    switch (statusCode) {
        case Http.Status.OK:
            return Results.ok(compressedContent);
        case Http.Status.NOT_FOUND:
            return Results.notFound(compressedContent);
        default:
            return Results.badRequest(compressedContent);
    }
}
 
Example #8
Source File: LazyHtml.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
public Html render(int level) {
    Html content = baseContent;

    for (HtmlTransformation transformation : transformations) {
        content = transformation.apply(content);
    }

    return content;
}
 
Example #9
Source File: InteractiveGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<InteractiveGradingConfigForm> castForm = (Form<InteractiveGradingConfigForm>) form;

    return interactiveGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #10
Source File: OutputOnlyGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<OutputOnlyGradingConfigForm> castForm = (Form<OutputOnlyGradingConfigForm>) form;

    return outputOnlyGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #11
Source File: BatchGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<BatchGradingConfigForm> castForm = (Form<BatchGradingConfigForm>) form;

    return batchGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #12
Source File: OutputOnlyWithSubtasksGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<OutputOnlyWithSubtasksGradingConfigForm> castForm = (Form<OutputOnlyWithSubtasksGradingConfigForm>) form;

    return outputOnlyWithSubtasksGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #13
Source File: BatchWithSubtasksGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<BatchWithSubtasksGradingConfigForm> castForm = (Form<BatchWithSubtasksGradingConfigForm>) form;

    return batchWithSubtasksGradingConfigView.render(castForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #14
Source File: InteractiveWithSubtasksGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Html renderUpdateGradingConfig(Form<?> form, Call postUpdateGradingConfigCall, List<FileInfo> testDataFiles, List<FileInfo> helperFiles) {
    @SuppressWarnings("unchecked")
    Form<InteractiveWithSubtasksGradingConfigForm> interactiveForm = (Form<InteractiveWithSubtasksGradingConfigForm>) form;

    return interactiveWithSubtasksGradingConfigView.render(interactiveForm, postUpdateGradingConfigCall, testDataFiles, helperFiles);
}
 
Example #15
Source File: AbstractHtmlContentRenderer.java    From commercetools-sunrise-java with Apache License 2.0 5 votes vote down vote up
private Html renderHtml(final PageData pageData, @Nullable final String templateName, @Nullable final CmsPage cmsPage) {
    final String content;
    if (templateName != null) {
        final TemplateContext templateContext = new TemplateContext(pageData, userLanguage.locales(), cmsPage);
        content = templateEngine.render(templateName, templateContext);
    } else {
        LOGGER.warn("HTML renderer used without template, probably this is not what you intended");
        content = pageData.toString();
    }
    return new Html(content);
}
 
Example #16
Source File: ItemMultipleChoiceAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html renderViewHtml(BundleItem bundleItem, String conf) {
    return itemMultipleChoiceView.render(bundleItem, new Gson().fromJson(conf, ItemMultipleChoiceConf.class));
}
 
Example #17
Source File: AbstractBoxGradingEngineAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html renderViewStatement(String postSubmitUri, ProblemStatement statement, GradingConfig config, String engine, Set<String> allowedGradingLanguageNames, String reasonNotAllowedToSubmit) {
    return blackBoxViewStatementView.render(postSubmitUri, statement, config, engine, allowedGradingLanguageNames, reasonNotAllowedToSubmit);
}
 
Example #18
Source File: DefaultRecoverPasswordMessageEditorProviderTest.java    From commercetools-sunrise-java with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    when(dummyEmailContentFactory.create(notNull())).thenReturn(new RecoverPasswordEmailContent());
    when(formDataWithValidEmail.email()).thenReturn(RECIPIENT_FIELD);
    when(emailContentRendererWithSomeContent.render(notNull(), notNull())).thenReturn(completedFuture(new Html(CONTENT_FIELD)));
}
 
Example #19
Source File: ItemMultipleChoiceConfAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html getConfHtml(Form form, Call target, String submitLabel) {
    return itemMultipleChoiceConfView.render(form, target, submitLabel);
}
 
Example #20
Source File: ItemShortAnswerConfAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html getConfHtml(Form form, Call target, String submitLabel) {
    return itemShortAnswerConfView.render(form, target, submitLabel);
}
 
Example #21
Source File: ItemEssayAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html renderViewHtml(BundleItem bundleItem, String conf) {
    return itemEssayView.render(bundleItem, new Gson().fromJson(conf, ItemEssayConf.class));
}
 
Example #22
Source File: HomeController.java    From tutorials with MIT License 4 votes vote down vote up
public Result applyHtml() {
    return ok(Html.apply("<h1>This text will appear as a heading 1</h1>"));
}
 
Example #23
Source File: HtmlTemplate.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
public void setContent(Html content) {
    this.content = new LazyHtml(content);
}
 
Example #24
Source File: ItemShortAnswerAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html renderViewHtml(BundleItem bundleItem, String conf) {
    return itemShortAnswerView.render(bundleItem, new Gson().fromJson(conf, ItemShortAnswerConf.class));
}
 
Example #25
Source File: ItemStatementConfAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html getConfHtml(Form form, Call target, String submitLabel) {
    return itemStatementConfView.render(form, target, submitLabel);
}
 
Example #26
Source File: ItemEssayConfAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html getConfHtml(Form form, Call target, String submitLabel) {
    return itemEssayConfView.render(form, target, submitLabel);
}
 
Example #27
Source File: HtmlTemplate.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
public void setWarning(Html warning) {
    this.warning = warning;
}
 
Example #28
Source File: ItemStatementAdapter.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Html renderViewHtml(BundleItem bundleItem, String conf) {
    return itemStatementView.render(bundleItem, new Gson().fromJson(conf, ItemStatementConf.class));
}
 
Example #29
Source File: LazyHtml.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
public Html render() {
    return render(0);
}
 
Example #30
Source File: LazyHtml.java    From judgels with GNU General Public License v2.0 4 votes vote down vote up
public LazyHtml(Html baseContent) {
    this.baseContent = baseContent;
    this.transformations = Lists.newArrayList();
}