From b7646f8a02db486a08c9b2951966aa8fdaf0ba7a Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 04 Nov 2011 17:16:29 -0400
Subject: [PATCH] Updated to MarkdownPapers 1.2.5
---
src/com/gitblit/client/GitblitClient.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java
index 74e0e08..dcc7dfc 100644
--- a/src/com/gitblit/client/GitblitClient.java
+++ b/src/com/gitblit/client/GitblitClient.java
@@ -38,6 +38,7 @@
import com.gitblit.models.SyndicatedEntryModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.RpcUtils;
+import com.gitblit.utils.StringUtils;
import com.gitblit.utils.SyndicationUtils;
/**
@@ -50,6 +51,8 @@
public class GitblitClient implements Serializable {
private static final long serialVersionUID = 1L;
+
+ private static final Date NEVER = new Date(0);
protected final GitblitRegistration reg;
@@ -94,6 +97,7 @@
}
public void login() throws IOException {
+ refreshSettings();
refreshAvailableFeeds();
refreshRepositories();
@@ -108,7 +112,6 @@
// credentials may not have administrator access
// or server may have disabled rpc management
refreshUsers();
- refreshSettings();
allowManagement = true;
} catch (UnauthorizedException e) {
} catch (ForbiddenException e) {
@@ -130,7 +133,6 @@
} catch (IOException e) {
e.printStackTrace();
}
-
}
public boolean allowManagement() {
@@ -143,6 +145,33 @@
public boolean isOwner(RepositoryModel model) {
return account != null && account.equalsIgnoreCase(model.owner);
+ }
+
+ public String getURL(String action, String repository, String objectId) {
+ boolean mounted = settings.get(Keys.web.mountParameters).getBoolean(true);
+ StringBuilder sb = new StringBuilder();
+ sb.append(url);
+ sb.append('/');
+ sb.append(action);
+ sb.append('/');
+ if (mounted) {
+ // mounted url/action/repository/objectId
+ sb.append(StringUtils.encodeURL(repository));
+ if (!StringUtils.isEmpty(objectId)) {
+ sb.append('/');
+ sb.append(objectId);
+ }
+ return sb.toString();
+ } else {
+ // parameterized url/action/&r=repository&h=objectId
+ sb.append("?r=");
+ sb.append(repository);
+ if (!StringUtils.isEmpty(objectId)) {
+ sb.append("&h=");
+ sb.append(objectId);
+ }
+ return sb.toString();
+ }
}
public ServerSettings getSettings() {
@@ -213,12 +242,14 @@
Set<SyndicatedEntryModel> allEntries = new HashSet<SyndicatedEntryModel>();
if (reg.feeds.size() > 0) {
for (FeedModel feed : reg.feeds) {
- feed.lastRefresh = new Date();
+ feed.lastRefreshDate = feed.currentRefreshDate;
+ feed.currentRefreshDate = new Date();
List<SyndicatedEntryModel> entries = SyndicationUtils.readFeed(url,
- feed.repository, feed.branch, feed.maxRetrieval, account, password);
+ feed.repository, feed.branch, -1, account, password);
allEntries.addAll(entries);
}
}
+ reg.cacheFeeds();
syndicatedEntries.clear();
syndicatedEntries.addAll(allEntries);
Collections.sort(syndicatedEntries);
@@ -241,6 +272,18 @@
}
}
+ public Date getLastFeedRefresh(String repository, String branch) {
+ FeedModel feed = new FeedModel();
+ feed.repository = repository;
+ feed.branch = branch;
+ if (reg.feeds.contains(feed)) {
+ int idx = reg.feeds.indexOf(feed);
+ feed = reg.feeds.get(idx);
+ return feed.lastRefreshDate;
+ }
+ return NEVER;
+ }
+
public boolean isSubscribed(RepositoryModel repository) {
return subscribedRepositories.contains(repository.name.toLowerCase());
}
--
Gitblit v1.9.1