| | |
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | import com.gitblit.models.FeedEntryModel;
|
| | | import com.gitblit.models.RefModel;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.SyndicatedEntryModel;
|
| | | import com.gitblit.utils.HttpUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.JGitUtils.SearchType;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.SyndicationUtils;
|
| | |
|
| | |
| | | String repositoryName = url;
|
| | | String objectId = request.getParameter("h");
|
| | | String l = request.getParameter("l");
|
| | | String page = request.getParameter("pg");
|
| | | String searchString = request.getParameter("s");
|
| | | SearchType searchType = SearchType.COMMIT;
|
| | | Constants.SearchType searchType = Constants.SearchType.COMMIT;
|
| | | if (!StringUtils.isEmpty(request.getParameter("st"))) {
|
| | | SearchType type = SearchType.forName(request.getParameter("st"));
|
| | | Constants.SearchType type = Constants.SearchType.forName(request.getParameter("st"));
|
| | | if (type != null) {
|
| | | searchType = type;
|
| | | }
|
| | |
| | | } catch (NumberFormatException x) {
|
| | | }
|
| | | }
|
| | | int offset = 0;
|
| | | if (!StringUtils.isEmpty(page)) {
|
| | | try {
|
| | | offset = length * Integer.parseInt(page);
|
| | | } catch (NumberFormatException x) {
|
| | | }
|
| | | }
|
| | |
|
| | | response.setContentType("application/rss+xml; charset=UTF-8");
|
| | | Repository repository = GitBlit.self().getRepository(repositoryName);
|
| | |
| | | List<RevCommit> commits;
|
| | | if (StringUtils.isEmpty(searchString)) {
|
| | | // standard log/history lookup
|
| | | commits = JGitUtils.getRevLog(repository, objectId, 0, length);
|
| | | commits = JGitUtils.getRevLog(repository, objectId, offset, length);
|
| | | } else {
|
| | | // repository search
|
| | | commits = JGitUtils.searchRevlogs(repository, objectId, searchString, searchType, 0,
|
| | | length);
|
| | | commits = JGitUtils.searchRevlogs(repository, objectId, searchString, searchType,
|
| | | offset, length);
|
| | | }
|
| | | Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository);
|
| | | List<SyndicatedEntryModel> entries = new ArrayList<SyndicatedEntryModel>();
|
| | | List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
|
| | |
|
| | | boolean mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true);
|
| | | String urlPattern;
|
| | |
| | | String gitblitUrl = HttpUtils.getGitblitURL(request);
|
| | | // convert RevCommit to SyndicatedEntryModel
|
| | | for (RevCommit commit : commits) {
|
| | | SyndicatedEntryModel entry = new SyndicatedEntryModel();
|
| | | FeedEntryModel entry = new FeedEntryModel();
|
| | | entry.title = commit.getShortMessage();
|
| | | entry.author = commit.getAuthorIdent().getName();
|
| | | entry.link = MessageFormat.format(urlPattern, gitblitUrl,
|
| | | StringUtils.encodeURL(model.name), commit.getName());
|
| | | entry.published = commit.getCommitterIdent().getWhen();
|
| | | entry.contentType = "text/plain";
|
| | | entry.content = commit.getFullMessage();
|
| | | entry.contentType = "text/html";
|
| | | String message = GitBlit.self().processCommitMessage(model.name,
|
| | | commit.getFullMessage());
|
| | | entry.content = message;
|
| | | entry.repository = model.name;
|
| | | entry.branch = objectId;
|
| | | entry.branch = objectId; |
| | | entry.tags = new ArrayList<String>();
|
| | | |
| | | // add commit id and parent commit ids
|
| | | entry.tags.add("commit:" + commit.getName());
|
| | | for (RevCommit parent : commit.getParents()) {
|
| | | entry.tags.add("parent:" + parent.getName());
|
| | | }
|
| | | |
| | | // add refs to tabs list
|
| | | List<RefModel> refs = allRefs.get(commit.getId());
|
| | | if (refs != null && refs.size() > 0) {
|
| | | List<String> tags = new ArrayList<String>();
|
| | | for (RefModel ref : refs) {
|
| | | tags.add(ref.getName());
|
| | | entry.tags.add("ref:" + ref.getName());
|
| | | }
|
| | | entry.tags = tags;
|
| | | }
|
| | | } |
| | | entries.add(entry);
|
| | | }
|
| | | String feedLink;
|