org.unbescape.html.HtmlEscape Java Examples
The following examples show how to use
org.unbescape.html.HtmlEscape.
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: PrincipalAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 6 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String type = iProcessableElementTag.getAttributeValue("type"); final String property = iProcessableElementTag.getAttributeValue("property"); final String text = ShiroFacade.getPrincipalText(type, property); final String elementCompleteName = iProcessableElementTag.getElementCompleteName(); final IModelFactory modelFactory = iTemplateContext.getModelFactory(); final IModel model = modelFactory.createModel(); model.add(modelFactory.createOpenElementTag(elementCompleteName)); model.add(modelFactory.createText(HtmlEscape.escapeHtml5(text))); model.add(modelFactory.createCloseElementTag(elementCompleteName)); iElementTagStructureHandler.replaceWith(model, false); }
Example #2
Source File: ReferencedFromCodeCommentPanel.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); CodeComment comment = getModelObject(); if (SecurityUtils.canReadCode(comment.getProject())) { PageParameters params = ProjectBlobPage.paramsOf(comment); String url = RequestCycle.get().urlFor(ProjectBlobPage.class, params).toString(); String title = String.format("<a href='%s'>%s</a>", url, HtmlEscape.escapeHtml5(comment.getMark().getPath())); add(new Label("title", title).setEscapeModelStrings(false)); } else { add(new Label("title", comment.getMark().getPath())); } }
Example #3
Source File: GroupPage.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new SideBar("groupSidebar", null) { @Override protected Component newHead(String componentId) { String content = "<i class='fa fa-group'></i> " + HtmlEscape.escapeHtml5(getGroup().getName()); return new Label(componentId, content).setEscapeModelStrings(false); } @Override protected List<? extends Tab> newTabs() { return GroupPage.this.newTabs(); } }); }
Example #4
Source File: UserCardPanel.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); WebMarkupContainer container = new WebMarkupContainer("container"); add(container); container.add(new UserAvatar("avatar", userId, displayName)); StringBuilder builder = new StringBuilder(); builder.append("<div>" + HtmlEscape.escapeHtml5(displayName) + "</div>"); if (userId == null) { builder.append("<i>No OneDev account</i>"); } else if (User.SYSTEM_ID.equals(userId)) { builder.append("<i>System Account</i>"); } else { User user = OneDev.getInstance(UserManager.class).load(userId); builder.append("<i>@" + HtmlEscape.escapeHtml5(user.getName()) + "</i>"); } container.add(new Label("info", builder.toString()).setEscapeModelStrings(false)); }
Example #5
Source File: TextDiffPanel.java From onedev with MIT License | 5 votes |
private void appendBlame(StringBuilder builder, int oldLineNo, int newLineNo) { BlameCommit commit; if (newLineNo != -1) commit = Preconditions.checkNotNull(blameInfo.newBlame.get(newLineNo)); else commit = Preconditions.checkNotNull(blameInfo.oldBlame.get(oldLineNo)); if (diffMode == DiffViewMode.UNIFIED && !commit.getHash().equals(blameInfo.lastCommitHash) || diffMode == DiffViewMode.SPLIT && newLineNo != -1 && !commit.getHash().equals(blameInfo.lastNewCommitHash) || diffMode == DiffViewMode.SPLIT && oldLineNo != -1 && !commit.getHash().equals(blameInfo.lastOldCommitHash)) { CommitDetailPage.State state = new CommitDetailPage.State(); state.revision = commit.getHash(); state.whitespaceOption = change.getWhitespaceOption(); PageParameters params = CommitDetailPage.paramsOf(projectModel.getObject(), state); String url = urlFor(CommitDetailPage.class, params).toString(); if (diffMode == DiffViewMode.UNIFIED) { builder.append(String.format("<td class='blame noselect'><a class='hash' href='%s' data-hash='%s'>%s</a><span class='date'>%s</span><span class='author'>%s</span></td>", url, commit.getHash(), GitUtils.abbreviateSHA(commit.getHash()), DateUtils.formatDate(commit.getCommitter().getWhen()), HtmlEscape.escapeHtml5(commit.getAuthor().getName()))); } else { builder.append(String.format("<td class='abbr blame noselect'><a class='hash' href='%s' data-hash='%s'>%s</a></td>", url, commit.getHash(), GitUtils.abbreviateSHA(commit.getHash()))); } } else { if (diffMode == DiffViewMode.UNIFIED) { builder.append("<td class='blame noselect'><div class='same-as-above'>...</div></td>"); } else { builder.append("<td class='abbr blame noselect'><div class='same-as-above'>...</div></td>"); } } blameInfo.lastCommitHash = commit.getHash(); if (newLineNo != -1) blameInfo.lastNewCommitHash = commit.getHash(); if (oldLineNo != -1) blameInfo.lastOldCommitHash = commit.getHash(); }
Example #6
Source File: BuildProcessor.java From onedev with MIT License | 5 votes |
@Override protected String toHtml(ProjectScopedNumber referenceable, String referenceText) { CharSequence url = RequestCycle.get().urlFor( BuildDashboardPage.class, BuildDashboardPage.paramsOf(referenceable)); Build build = OneDev.getInstance(BuildManager.class).find(referenceable); if (build != null && build.getVersion() != null) referenceText += " (" + HtmlEscape.escapeHtml5(build.getVersion()) + ")"; return String.format("<a href='%s' class='build reference' data-reference='%s'>%s</a>", url, referenceable.toString(), referenceText); }
Example #7
Source File: SourceViewPanel.java From onedev with MIT License | 5 votes |
private String getJsonOfBlameInfos(boolean blamed) { String jsonOfBlameInfos; if (blamed) { List<BlameInfo> blameInfos = new ArrayList<>(); String commitHash = context.getCommit().name(); BlameCommand cmd = new BlameCommand(context.getProject().getGitDir()); cmd.commitHash(commitHash).file(context.getBlobIdent().path); for (BlameBlock blame: cmd.call()) { BlameInfo blameInfo = new BlameInfo(); blameInfo.commitDate = DateUtils.formatDate(blame.getCommit().getCommitter().getWhen()); blameInfo.authorName = HtmlEscape.escapeHtml5(blame.getCommit().getAuthor().getName()); blameInfo.hash = blame.getCommit().getHash(); blameInfo.abbreviatedHash = GitUtils.abbreviateSHA(blame.getCommit().getHash(), 7); CommitDetailPage.State state = new CommitDetailPage.State(); state.revision = blame.getCommit().getHash(); if (context.getBlobIdent().path != null) state.pathFilter = PatternSet.quoteIfNecessary(context.getBlobIdent().path); PageParameters params = CommitDetailPage.paramsOf(context.getProject(), state); blameInfo.url = RequestCycle.get().urlFor(CommitDetailPage.class, params).toString(); blameInfo.ranges = blame.getRanges(); blameInfos.add(blameInfo); } try { jsonOfBlameInfos = OneDev.getInstance(ObjectMapper.class).writeValueAsString(blameInfos); } catch (JsonProcessingException e) { throw new RuntimeException(e); } } else { jsonOfBlameInfos = "undefined"; } return jsonOfBlameInfos; }
Example #8
Source File: BuildChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(Build choice, JSONWriter writer) throws JSONException { writer .key("id").value(choice.getId()) .key("number").value(choice.getNumber()) .key("jobName").value(HtmlEscape.escapeHtml5(choice.getJobName())); if (choice.getVersion() != null) writer.key("version").value(HtmlEscape.escapeHtml5(choice.getVersion())); }
Example #9
Source File: IssueChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(Issue choice, JSONWriter writer) throws JSONException { writer .key("id").value(choice.getId()) .key("number").value(choice.getNumber()) .key("title").value(HtmlEscape.escapeHtml5(choice.getTitle())); }
Example #10
Source File: EmptyValueLabel.java From onedev with MIT License | 5 votes |
private static String getNameOfEmptyValue(AnnotatedElement element) { NameOfEmptyValue nameOfEmptyValue = element.getAnnotation(NameOfEmptyValue.class); if (nameOfEmptyValue != null) return HtmlEscape.escapeHtml5(nameOfEmptyValue.value()); else return "Not defined"; }
Example #11
Source File: PersonCardPanel.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); WebMarkupContainer container = new WebMarkupContainer("container"); add(container); container.add(new UserAvatar("avatar", personIdent)); StringBuilder builder = new StringBuilder(); builder.append("<div>" + HtmlEscape.escapeHtml5(personIdent.getName()) + " <i>(" + gitRole + ")</i></div>"); if (StringUtils.isBlank(personIdent.getEmailAddress())) { if (personIdent.getName().equals(OneDev.NAME)) builder.append("<i>System Account</i>"); else builder.append("<i>No OneDev Account</i>"); } else { User user = OneDev.getInstance(UserManager.class).findByEmail(personIdent.getEmailAddress()); if (user != null) builder.append("<i>@" + HtmlEscape.escapeHtml5(user.getName()) + "</i>"); else builder.append("<i>No OneDev Account</i>"); } container.add(new Label("info", builder.toString()).setEscapeModelStrings(false)); }
Example #12
Source File: PullRequestChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(PullRequest choice, JSONWriter writer) throws JSONException { writer .key("id").value(choice.getId()) .key("number").value(choice.getNumber()) .key("title").value(HtmlEscape.escapeHtml5(choice.getTitle())); }
Example #13
Source File: MilestoneChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(Milestone choice, JSONWriter writer) throws JSONException { writer.key("id").value(choice.getId()).key("name").value(HtmlEscape.escapeHtml5(choice.getName())); writer.key("statusName").value(choice.getStatusName()); if (choice.isClosed()) writer.key("statusClass").value("label-success"); else writer.key("statusClass").value("label-warning"); }
Example #14
Source File: RevisionPicker.java From onedev with MIT License | 5 votes |
@Override public IModel<?> getBody() { String iconClass; String label; if ("master".equals(revision)) { // default to use master branch when project is empty label = "master"; iconClass = "fa fa-code-fork"; } else if (revision != null) { ProjectAndRevision projectAndRevision = new ProjectAndRevision(projectModel.getObject(), revision); label = projectAndRevision.getBranch(); if (label != null) { iconClass = "fa fa-code-fork"; } else { label = projectAndRevision.getTag(); if (label != null) { iconClass = "fa fa-tag"; } else { label = revision; if (ObjectId.isId(label)) label = GitUtils.abbreviateSHA(label); iconClass = "fa fa-ext fa-commit"; } } label = HtmlEscape.escapeHtml5(label); } else { label = "Choose Revision"; iconClass = ""; } return Model.of(String.format("<i class='%s'></i> <span>%s</span> <i class='fa fa-caret-down'></i>", iconClass, label)); }
Example #15
Source File: AbstractUserChoiceProvider.java From onedev with MIT License | 4 votes |
@Override public void toJson(User choice, JSONWriter writer) throws JSONException { writer.key("id").value(choice.getId()).key("name").value(HtmlEscape.escapeHtml5(choice.getDisplayName())); String avatarUrl = OneDev.getInstance(AvatarManager.class).getAvatarUrl(choice); writer.key("avatar").value(avatarUrl); }
Example #16
Source File: AbstractGroupChoiceProvider.java From onedev with MIT License | 4 votes |
@Override public void toJson(Group choice, JSONWriter writer) throws JSONException { writer.key("id").value(choice.getId()).key("name").value(HtmlEscape.escapeHtml5(choice.getName())); }
Example #17
Source File: BranchPicker.java From onedev with MIT License | 4 votes |
@Override public IModel<?> getBody() { return Model.of(String.format("<i class='fa fa-code-fork'></i> <span>%s</span> <i class='fa fa-caret-down'></i>", branch!=null?HtmlEscape.escapeHtml5(branch):"<i>choose</i>")); }
Example #18
Source File: RevisionSelector.java From onedev with MIT License | 4 votes |
private Component newItem(String itemId, String itemValue) { String ref; if (itemValue.startsWith(COMMIT_FLAG)) ref = itemValue.substring(COMMIT_FLAG.length()); else if (itemValue.startsWith(ADD_FLAG)) ref = itemValue.substring(ADD_FLAG.length()); else ref = itemValue; AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("link") { @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new ConfirmLeaveListener()); } @Override public void onClick(AjaxRequestTarget target) { if (itemValue.startsWith(ADD_FLAG)) { onCreateRef(target, ref); } else { selectRevision(target, ref); } } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (!itemValue.startsWith(ADD_FLAG)) { String url = getRevisionUrl(ref); if (url != null) tag.put("href", url); } } }; if (itemValue.startsWith(COMMIT_FLAG)) { link.add(new Label("label", ref)); link.add(AttributeAppender.append("class", "icon commit")); } else if (itemValue.startsWith(ADD_FLAG)) { String label; if (branchesActive) label = "<div class='name'>Create branch <b>" + HtmlEscape.escapeHtml5(ref) + "</b></div>"; else label = "<div class='name'>Create tag <b>" + HtmlEscape.escapeHtml5(ref) + "</b></div>"; label += "<div class='revision'>from " + HtmlEscape.escapeHtml5(revision) + "</div>"; link.add(new Label("label", label).setEscapeModelStrings(false)); link.add(AttributeAppender.append("class", "icon add")); } else if (ref.equals(revision)) { link.add(new Label("label", ref)); link.add(AttributeAppender.append("class", "icon current")); } else { link.add(new Label("label", ref)); } WebMarkupContainer item = new WebMarkupContainer(itemId); item.setOutputMarkupId(true); item.add(AttributeAppender.append("data-value", HtmlEscape.escapeHtml5(itemValue))); item.add(link); return item; }
Example #19
Source File: ProjectPicker.java From onedev with MIT License | 4 votes |
@Override public IModel<?> getBody() { return Model.of(String.format("<i class='fa fa-ext fa-repo'></i> <span>%s</span> <i class='fa fa-caret-down'></i>", HtmlEscape.escapeHtml5(getCurrent().getName()))); }
Example #20
Source File: PageUtils.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 4 votes |
private static String buildBaseUrl(final ITemplateContext context, Collection<String> excludeParams) { // URL defined with pagination-url tag final String url = (String) context.getVariable(Keys.PAGINATION_URL_KEY); if (url == null && context instanceof IWebContext) { // Creates url from actual request URI and parameters final StringBuilder builder = new StringBuilder(); final IWebContext webContext = (IWebContext) context; final HttpServletRequest request = webContext.getRequest(); // URL base path from request builder.append(request.getRequestURI()); Map<String, String[]> params = request.getParameterMap(); Set<Entry<String, String[]>> entries = params.entrySet(); boolean firstParam = true; for (Entry<String, String[]> param : entries) { // Append params not excluded to basePath String name = param.getKey(); if (!excludeParams.contains(name)) { if (firstParam) { builder.append(Q_MARK); firstParam = false; } else { builder.append(AND); } // Iterate over all values to create multiple values per // parameter String[] values = param.getValue(); Collection<String> paramValues = Arrays.asList(values); Iterator<String> it = paramValues.iterator(); while (it.hasNext()) { String value = it.next(); builder.append(name).append(EQ).append(value); if (it.hasNext()) { builder.append(AND); } } } } // Escape to HTML content return HtmlEscape.escapeHtml4Xml(builder.toString()); } return url == null ? EMPTY : url; }
Example #21
Source File: AbstractProjectChoiceProvider.java From onedev with MIT License | 4 votes |
@Override public void toJson(Project choice, JSONWriter writer) throws JSONException { writer.key("id").value(choice.getId()); writer.key("name"); writer.value(HtmlEscape.escapeHtml5(choice.getName())); }
Example #22
Source File: Text.java From Skype4J with Apache License 2.0 | 2 votes |
/** * Creates a new RichText component * * @param text The plain text to wrap in the RichText object * @return A new RichText object */ public static RichText rich(String text) { return new RichText(parseEmojis(HtmlEscape.escapeHtml5Xml(text))); }
Example #23
Source File: Text.java From Skype4J with Apache License 2.0 | 2 votes |
/** * Creates a new PlainText component with the given text * * @param text The text to use * @return The PlainText object representing the text */ public static PlainText plain(String text) { Validate.notNull(text, "The message cannot be null"); return new PlainText(parseEmojis(HtmlEscape.escapeHtml5Xml(text))); }