Process bugtraq configuration in markup document rendering
1 files renamed
8 files modified
| | |
| | | loglinkregex = "(?:pull request|pull|pr)\\s*[-#]?[0-9]+"
|
| | | logregex = "\\d+"
|
| | | loglinktext = "pull request #%BUGID%"
|
| | | [bugtraq "tickets"]
|
| | | url = "https://dev.gitblit.com/tickets/gitblit.git/%BUGID%"
|
| | | loglinkregex = "(?:ticket)\\s*[-#]?[0-9]+"
|
| | | logregex = "\\d+"
|
| | | loglinktext = "ticket #%BUGID%"
|
| | | |
| | |
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.servlet.AuthenticationFilter.AuthenticatedRequest;
|
| | | import com.gitblit.utils.BugtraqProcessor;
|
| | | import com.gitblit.utils.HttpUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.MessageProcessor;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.SyndicationUtils;
|
| | |
|
| | |
| | | offset, length);
|
| | | }
|
| | | Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository, model.showRemoteBranches);
|
| | | MessageProcessor processor = new MessageProcessor(settings);
|
| | | BugtraqProcessor processor = new BugtraqProcessor(settings);
|
| | |
|
| | | // convert RevCommit to SyndicatedEntryModel
|
| | | for (RevCommit commit : commits) {
|
File was renamed from src/main/java/com/gitblit/utils/MessageProcessor.java |
| | |
| | | import com.syntevo.bugtraq.BugtraqFormatter; |
| | | import com.syntevo.bugtraq.BugtraqFormatter.OutputHandler; |
| | | |
| | | public class MessageProcessor { |
| | | public class BugtraqProcessor { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | private final IStoredSettings settings; |
| | | |
| | | public MessageProcessor(IStoredSettings settings) { |
| | | public BugtraqProcessor(IStoredSettings settings) { |
| | | this.settings = settings; |
| | | } |
| | | |
| | |
| | | switch (model.commitMessageRenderer) { |
| | | case MARKDOWN: |
| | | try { |
| | | String prepared = processCommitMessageRegex(repository, model.name, text); |
| | | String prepared = processTextRegex(repository, model.name, text); |
| | | return MarkdownUtils.transformMarkdown(prepared); |
| | | } catch (Exception e) { |
| | | logger.error("Failed to render commit message as markdown", e); |
| | |
| | | */ |
| | | public String processPlainCommitMessage(Repository repository, String repositoryName, String text) { |
| | | String html = StringUtils.escapeForHtml(text, false); |
| | | html = processCommitMessageRegex(repository, repositoryName, html); |
| | | html = processTextRegex(repository, repositoryName, html); |
| | | return StringUtils.breakLinesForHtml(html); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Apply globally or per-repository specified regex substitutions to the |
| | | * commit message. |
| | | * Returns an processed version of the text with any global or |
| | | * repository-specific regular expression substitution applied. |
| | | * |
| | | * @param repository |
| | | * @param repositoryName |
| | | * @param text |
| | | * @return the processed commit message |
| | | * @return processed version of the text |
| | | */ |
| | | protected String processCommitMessageRegex(Repository repository, String repositoryName, String text) { |
| | | public String processText(Repository repository, String repositoryName, String text) { |
| | | String html = processTextRegex(repository, repositoryName, text); |
| | | return html; |
| | | } |
| | | |
| | | /** |
| | | * Apply globally or per-repository specified regex substitutions to the |
| | | * text. |
| | | * |
| | | * @param repository |
| | | * @param repositoryName |
| | | * @param text |
| | | * @return the processed text |
| | | */ |
| | | protected String processTextRegex(Repository repository, String repositoryName, String text) { |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | // global regex keys |
| | | if (settings.getBoolean(Keys.regex.global, false)) { |
| | |
| | | item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent())); |
| | | item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef |
| | | .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils())); |
| | | item.add(new Label("noteContent", messageProcessor().processPlainCommitMessage(getRepository(), repositoryName, |
| | | item.add(new Label("noteContent", bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, |
| | | entry.content)).setEscapeModelStrings(false)); |
| | | } |
| | | }; |
| | |
| | | item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
|
| | | item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef
|
| | | .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
|
| | | item.add(new Label("noteContent", messageProcessor().processPlainCommitMessage(getRepository(), repositoryName,
|
| | | item.add(new Label("noteContent", bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName,
|
| | | entry.content)).setEscapeModelStrings(false));
|
| | | }
|
| | | };
|
| | |
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | |
|
| | | import com.gitblit.utils.BugtraqProcessor;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | BugtraqProcessor bugtraq = new BugtraqProcessor(app().settings());
|
| | | markupText = bugtraq.processText(getRepository(), repositoryName, markupText);
|
| | |
|
| | | Fragment fragment;
|
| | | MarkupDocument markupDoc = processor.parse(repositoryName, getBestCommitId(commit), documentPath, markupText);
|
| | | if (MarkupSyntax.PLAIN.equals(markupDoc.syntax)) {
|
| | |
| | | import com.gitblit.servlet.SyndicationServlet;
|
| | | import com.gitblit.tickets.TicketIndexer.Lucene;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.BugtraqProcessor;
|
| | | import com.gitblit.utils.DeepCopier;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.MessageProcessor;
|
| | | import com.gitblit.utils.RefLogUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | |
| | | return getClass();
|
| | | }
|
| | |
|
| | | protected MessageProcessor messageProcessor() {
|
| | | return new MessageProcessor(app().settings());
|
| | | protected BugtraqProcessor bugtraqProcessor() {
|
| | | return new BugtraqProcessor(app().settings());
|
| | | }
|
| | |
|
| | | private Map<String, PageRegistration> registerPages() {
|
| | |
| | |
|
| | | protected void addFullText(String wicketId, String text) {
|
| | | RepositoryModel model = getRepositoryModel();
|
| | | String content = messageProcessor().processCommitMessage(r, model, text);
|
| | | String content = bugtraqProcessor().processCommitMessage(r, model, text);
|
| | | String html;
|
| | | switch (model.commitMessageRenderer) {
|
| | | case MARKDOWN:
|
| | |
| | | add(new Label("ticketTopic").setVisible(false));
|
| | | } else {
|
| | | // process the topic using the bugtraq config to link things
|
| | | String topic = messageProcessor().processPlainCommitMessage(getRepository(), repositoryName, ticket.topic);
|
| | | String topic = bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, ticket.topic);
|
| | | add(new Label("ticketTopic", topic).setEscapeModelStrings(false));
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public void populateItem(final Item<String> labelItem) {
|
| | | String content = messageProcessor().processPlainCommitMessage(getRepository(), repositoryName, labelItem.getModelObject());
|
| | | String content = bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, labelItem.getModelObject());
|
| | | Label label = new Label("label", content);
|
| | | label.setEscapeModelStrings(false);
|
| | | TicketLabel tLabel = app().tickets().getLabel(getRepositoryModel(), labelItem.getModelObject());
|