use of com.gitblit.models.FeedEntryModel in project gitblit by gitblit.
the class FeedsPanel method viewTree.
protected void viewTree() {
FeedEntryModel entry = getSelectedSyndicatedEntry();
Utils.browse(entry.link.replace("/commit/", "/tree/"));
}
use of com.gitblit.models.FeedEntryModel in project gitblit by gitblit.
the class MessageRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected)
setBackground(table.getSelectionBackground());
else
setBackground(table.getBackground());
messageLabel.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
if (value == null) {
return this;
}
FeedEntryModel entry = (FeedEntryModel) value;
if (gitblit == null) {
// no gitblit client, just display message
messageLabel.setText(entry.title);
} else {
// show message in BOLD if its a new entry
if (entry.published.after(gitblit.getLastFeedRefresh(entry.repository, entry.branch))) {
messageLabel.setText("<html><body><b>" + entry.title);
} else {
messageLabel.setText(entry.title);
}
}
// reset ref label
resetRef(headLabel);
resetRef(branchLabel);
resetRef(remoteLabel);
resetRef(tagLabel);
int parentCount = 0;
if (entry.tags != null) {
for (String tag : entry.tags) {
if (tag.startsWith("ref:")) {
// strip ref:
tag = tag.substring("ref:".length());
} else {
// count parents
if (tag.startsWith("parent:")) {
parentCount++;
}
}
if (tag.equals(entry.branch)) {
// skip current branch label
continue;
}
if (tag.startsWith(Constants.R_HEADS)) {
// local branch
showRef(tag, branchLabel);
} else if (tag.startsWith(Constants.R_REMOTES)) {
// remote branch
showRef(tag, remoteLabel);
} else if (tag.startsWith(Constants.R_TAGS)) {
// tag
showRef(tag, tagLabel);
} else if (tag.equals(Constants.HEAD)) {
// HEAD
showRef(tag, headLabel);
}
}
}
if (parentCount > 1) {
// multiple parents, show merge icon
messageLabel.setIcon(mergeIcon);
} else {
messageLabel.setIcon(blankIcon);
}
return this;
}
use of com.gitblit.models.FeedEntryModel in project gitblit by gitblit.
the class FeedsPanel method viewCommit.
protected void viewCommit() {
FeedEntryModel entry = getSelectedSyndicatedEntry();
Utils.browse(entry.link);
}
use of com.gitblit.models.FeedEntryModel in project gitblit by gitblit.
the class SyndicationUtils method readFeed.
/**
* Reads a Gitblit RSS feed.
*
* @param url
* the url of the Gitblit server
* @param parameters
* the list of RSS parameters
* @param repository
* the repository name
* @param username
* @param password
* @return a list of SyndicationModel entries
* @throws {@link IOException}
*/
private static List<FeedEntryModel> readFeed(String url, List<String> parameters, String repository, String branch, String username, char[] password) throws IOException {
// build url
StringBuilder sb = new StringBuilder();
sb.append(MessageFormat.format("{0}" + Constants.SYNDICATION_PATH + "{1}", url, repository));
if (parameters.size() > 0) {
boolean first = true;
for (String parameter : parameters) {
if (first) {
sb.append('?');
first = false;
} else {
sb.append('&');
}
sb.append(parameter);
}
}
String feedUrl = sb.toString();
URLConnection conn = ConnectionUtils.openReadConnection(feedUrl, username, password);
InputStream is = conn.getInputStream();
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = null;
try {
feed = input.build(new XmlReader(is));
} catch (FeedException f) {
throw new GitBlitException(f);
}
is.close();
List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
for (Object o : feed.getEntries()) {
SyndEntryImpl entry = (SyndEntryImpl) o;
FeedEntryModel model = new FeedEntryModel();
model.repository = repository;
model.branch = branch;
model.title = entry.getTitle();
model.author = entry.getAuthor();
model.published = entry.getPublishedDate();
model.link = entry.getLink();
model.content = entry.getDescription().getValue();
model.contentType = entry.getDescription().getType();
if (entry.getCategories() != null && entry.getCategories().size() > 0) {
List<String> tags = new ArrayList<String>();
for (Object p : entry.getCategories()) {
SyndCategory cat = (SyndCategory) p;
tags.add(cat.getName());
}
model.tags = tags;
}
entries.add(model);
}
return entries;
}
Aggregations