]> source.dussan.org Git - gitblit.git/commitdiff
Added basic rss subscriptions to Manager
authorJames Moger <james.moger@gitblit.com>
Sat, 29 Oct 2011 01:24:02 +0000 (21:24 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 29 Oct 2011 01:24:02 +0000 (21:24 -0400)
20 files changed:
build.xml
docs/00_index.mkd
docs/04_releases.mkd
resources/bullet_feed.png [new file with mode: 0644]
src/com/gitblit/build/Build.java
src/com/gitblit/client/DateCellRenderer.java
src/com/gitblit/client/GitblitClient.java
src/com/gitblit/client/GitblitManager.java
src/com/gitblit/client/GitblitPanel.java
src/com/gitblit/client/GitblitRegistration.java
src/com/gitblit/client/NameRenderer.java
src/com/gitblit/client/RegistrationsDialog.java
src/com/gitblit/client/StatusPanel.java
src/com/gitblit/client/SyndicatedEntryTableModel.java [new file with mode: 0644]
src/com/gitblit/client/Utils.java
src/com/gitblit/models/RepositoryModel.java
src/com/gitblit/models/SyndicatedEntryModel.java [new file with mode: 0644]
src/com/gitblit/utils/SyndicationUtils.java
src/com/gitblit/wicket/GitBlitWebApp.properties
tests/com/gitblit/tests/SyndicationUtilsTest.java

index cdb0ac3930131376a2e36b974f277db9bb7f8d0f..5c3494bdf2a05807d1924f0db437ea731f893800 100644 (file)
--- a/build.xml
+++ b/build.xml
                        <resource file="${basedir}/resources/book_16x16.png" />\r
                        <resource file="${basedir}/resources/bug_16x16.png" />\r
                        <resource file="${basedir}/resources/health_16x16.png" />\r
+                       <resource file="${basedir}/resources/feed_16x16.png" />\r
+                       <resource file="${basedir}/resources/bullet_feed.png" />\r
                        <resource file="${basedir}/resources/blank.png" />\r
                        <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp.properties" />\r
                                \r
index 098507525fb91b0b884b42e16e6959e8cc6b3666..1080f09551172bd4e2e6581db38a6d3f2baedf33 100644 (file)
@@ -52,6 +52,7 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit
 - fixed: Gitblit can now browse the Linux kernel repository (issue 25)\r
 - fixed: Gitblit now runs on Servlet 3.0 webservers (e.g. Tomcat 7, Jetty 8) (issue 23)\r
 - fixed: Set the RSS content type of syndication feeds for Firefox 4 (issue 22)\r
+- fixed: RSS feeds are now properly encoded to UTF-8\r
 - fixed: Null pointer exception if did not set federation strategy (issue 20)\r
 - fixed: Gitblit GO allows SSL renegotiation if running on Java 1.6.0_22 or later\r
 - updated: MarkdownPapers 1.2.4\r
index 50612e610b3853f8d6c4f02363723d46b10a45ab..778fd0e89dbeb9251a986258d68e7634029a2b4c 100644 (file)
@@ -26,6 +26,7 @@
 - fixed: Gitblit can now browse the Linux kernel repository (issue 25)\r
 - fixed: Gitblit now runs on Servlet 3.0 webservers (e.g. Tomcat 7, Jetty 8) (issue 23)\r
 - fixed: Set the RSS content type of syndication feeds for Firefox 4 (issue 22)\r
+- fixed: RSS feeds are now properly encoded to UTF-8\r
 - fixed: Null pointer exception if did not set federation strategy (issue 20)\r
 - fixed: Gitblit GO allows SSL renegotiation if running on Java 1.6.0_22 or later\r
 - updated: MarkdownPapers 1.2.4\r
diff --git a/resources/bullet_feed.png b/resources/bullet_feed.png
new file mode 100644 (file)
index 0000000..c6e5f24
Binary files /dev/null and b/resources/bullet_feed.png differ
index 034efc161eec93d40566ba22d07aaf8769b47a42..4389eaced47caa858118bcf62facbd2925813a77 100644 (file)
@@ -138,6 +138,8 @@ public class Build {
        public static void manager(DownloadListener listener) {\r
                downloadListener = listener;\r
                downloadFromApache(MavenObject.GSON, BuildType.RUNTIME);\r
+               downloadFromApache(MavenObject.ROME, BuildType.RUNTIME);\r
+               downloadFromApache(MavenObject.JDOM, BuildType.RUNTIME);\r
                downloadFromApache(MavenObject.JSCH, BuildType.RUNTIME);\r
 \r
                downloadFromEclipse(MavenObject.JGIT, BuildType.RUNTIME);\r
index f30b05f54dcfd77231d09fa0dceae9db31c700b3..3d0ab15beb7f0c0e569f419d6012b422775be102 100644 (file)
@@ -49,18 +49,23 @@ public class DateCellRenderer extends DefaultTableCellRenderer {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);\r
                if (value instanceof Date) {\r
                        Date date = (Date) value;\r
-                       String timeAgo;\r
-                       String strDate;\r
+                       String title;\r
+                       String dateString;\r
                        if (date.getTime() == 0) {\r
-                               timeAgo = "--";\r
-                               strDate = "never";\r
+                               title = "--";\r
+                               dateString = "never";\r
                        } else {\r
-                               timeAgo = TimeUtils.timeAgo(date);\r
-                               strDate = new SimpleDateFormat(pattern).format((Date) value);\r
+                               title = TimeUtils.timeAgo(date);\r
+                               dateString = new SimpleDateFormat(pattern).format((Date) value);\r
                        }\r
 \r
-                       this.setText(timeAgo);\r
-                       this.setToolTipText(strDate);\r
+                       if ((System.currentTimeMillis() - date.getTime()) > 10 * 24 * 60 * 60 * 1000L) {\r
+                               String tmp = dateString;\r
+                               dateString = title;\r
+                               title = tmp;\r
+                       }\r
+                       this.setText(title);\r
+                       this.setToolTipText(dateString);\r
                }\r
                return this;\r
        }\r
index 9f4dd3e69edc24fee621e7f2af9db31771bceafa..ccde45a4c0aefde53f2b9eb82f91911374ead270 100644 (file)
@@ -19,8 +19,10 @@ import java.io.IOException;
 import java.io.Serializable;\r
 import java.util.ArrayList;\r
 import java.util.Collections;\r
+import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
+import java.util.Set;\r
 \r
 import com.gitblit.GitBlitException.ForbiddenException;\r
 import com.gitblit.GitBlitException.NotAllowedException;\r
@@ -31,8 +33,11 @@ import com.gitblit.models.FederationModel;
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.ServerSettings;\r
 import com.gitblit.models.ServerStatus;\r
+import com.gitblit.models.SyndicatedEntryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.RpcUtils;\r
+import com.gitblit.utils.StringUtils;\r
+import com.gitblit.utils.SyndicationUtils;\r
 \r
 /**\r
  * GitblitClient is a object that retrieves data from a Gitblit server, caches\r
@@ -45,6 +50,8 @@ public class GitblitClient implements Serializable {
 \r
        private static final long serialVersionUID = 1L;\r
 \r
+       protected final GitblitRegistration reg;\r
+\r
        public final String url;\r
 \r
        public final String account;\r
@@ -63,22 +70,35 @@ public class GitblitClient implements Serializable {
 \r
        private final List<FederationModel> federationRegistrations;\r
 \r
+       private final List<SyndicatedEntryModel> syndicatedEntries;\r
+\r
        private ServerStatus status;\r
 \r
-       public GitblitClient(String url, String account, char[] password) {\r
-               this.url = url;\r
-               this.account = account;\r
-               this.password = password;\r
+       public GitblitClient(GitblitRegistration reg) {\r
+               this.reg = reg;\r
+               this.url = reg.url;\r
+               this.account = reg.account;\r
+               this.password = reg.password;\r
 \r
                this.allUsers = new ArrayList<UserModel>();\r
                this.allRepositories = new ArrayList<RepositoryModel>();\r
                this.federationRegistrations = new ArrayList<FederationModel>();\r
+               this.syndicatedEntries = new ArrayList<SyndicatedEntryModel>();\r
        }\r
 \r
        public void login() throws IOException {\r
                refreshRepositories();\r
 \r
                try {\r
+                       // RSS feeds may be disabled by server\r
+                       refreshSubscribedFeeds();\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+               }\r
+               \r
+               try {\r
+                       // credentials may not have administrator access\r
+                       // or server may have disabled rpc management\r
                        refreshUsers();\r
                        refreshSettings();\r
                        allowManagement = true;\r
@@ -91,6 +111,8 @@ public class GitblitClient implements Serializable {
                }\r
 \r
                try {\r
+                       // credentials may not have administrator access\r
+                       // or server may have disabled rpc administration\r
                        refreshStatus();\r
                        allowAdministration = true;\r
                } catch (UnauthorizedException e) {\r
@@ -133,6 +155,7 @@ public class GitblitClient implements Serializable {
                allRepositories.clear();\r
                allRepositories.addAll(repositories.values());\r
                Collections.sort(allRepositories);\r
+               updateSubscribedStates();\r
                return allRepositories;\r
        }\r
 \r
@@ -153,6 +176,110 @@ public class GitblitClient implements Serializable {
                return status;\r
        }\r
 \r
+       public List<SyndicatedEntryModel> refreshSubscribedFeeds() throws IOException {\r
+               Set<SyndicatedEntryModel> allFeeds = new HashSet<SyndicatedEntryModel>();\r
+               if (reg.feeds != null && reg.feeds.size() > 0) {\r
+                       for (String feed : reg.feeds) {\r
+                               String[] values = feed.split(":");\r
+                               String repository = values[0];\r
+                               String branch = null;\r
+                               if (values.length > 1) {\r
+                                       branch = values[1];\r
+                               }\r
+                               List<SyndicatedEntryModel> list = SyndicationUtils.readFeed(url, repository,\r
+                                               branch, -1, account, password);\r
+                               allFeeds.addAll(list);\r
+                       }\r
+               }\r
+               syndicatedEntries.clear();\r
+               syndicatedEntries.addAll(allFeeds);\r
+               Collections.sort(syndicatedEntries);\r
+               return syndicatedEntries;\r
+       }\r
+\r
+       private void updateSubscribedStates() {\r
+               if (reg.feeds != null) {\r
+                       Set<String> subscribedRepositories = new HashSet<String>();\r
+                       for (String feed : reg.feeds) {\r
+                               if (feed.indexOf(':') > -1) {\r
+                                       // strip branch\r
+                                       subscribedRepositories.add(feed.substring(0, feed.indexOf(':')).toLowerCase());\r
+                               } else {\r
+                                       // default branch\r
+                                       subscribedRepositories.add(feed.toLowerCase());\r
+                               }\r
+                       }\r
+                       // set subscribed flag\r
+                       for (RepositoryModel repository : allRepositories) {\r
+                               repository.subscribed = subscribedRepositories.contains(repository.name\r
+                                               .toLowerCase());\r
+                       }\r
+               }\r
+       }\r
+\r
+       public List<SyndicatedEntryModel> getSyndicatedEntries() {\r
+               return syndicatedEntries;\r
+       }\r
+\r
+       public boolean isSubscribed(RepositoryModel repository, String branch) {\r
+               if (reg.feeds != null && reg.feeds.size() > 0) {\r
+                       for (String feed : reg.feeds) {\r
+                               String[] values = feed.split(":");\r
+                               String repositoryName = values[0];\r
+                               if (repository.name.equalsIgnoreCase(repositoryName)) {\r
+                                       return true;\r
+                               }\r
+                               // TODO check branch subscriptions\r
+                               String branchName = null;\r
+                               if (values.length > 1) {\r
+                                       branchName = values[1];\r
+                               }\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+       public boolean subscribe(RepositoryModel repository, String branch) {\r
+               String feed = repository.name;\r
+               if (!StringUtils.isEmpty(branch)) {\r
+                       feed += ":" + branch;\r
+               }\r
+               if (reg.feeds == null) {\r
+                       reg.feeds = new ArrayList<String>();\r
+               }\r
+               reg.feeds.add(feed);\r
+               updateSubscribedStates();\r
+               return true;\r
+       }\r
+\r
+       public boolean unsubscribe(RepositoryModel repository, String branch) {\r
+               String feed = repository.name;\r
+               if (!StringUtils.isEmpty(branch)) {\r
+                       feed += ":" + branch;\r
+               }\r
+               reg.feeds.remove(feed);\r
+               if (syndicatedEntries.size() > 0) {\r
+                       List<SyndicatedEntryModel> toRemove = new ArrayList<SyndicatedEntryModel>();\r
+                       for (SyndicatedEntryModel model : syndicatedEntries) {\r
+                               if (model.repository.equalsIgnoreCase(repository.name)) {\r
+                                       boolean emptyUnsubscribeBranch = StringUtils.isEmpty(branch);\r
+                                       boolean emptyFromBranch = StringUtils.isEmpty(model.branch);\r
+                                       if (emptyUnsubscribeBranch && emptyFromBranch) {\r
+                                               // default branch, remove\r
+                                               toRemove.add(model);\r
+                                       } else if (!emptyUnsubscribeBranch && !emptyFromBranch) {\r
+                                               if (model.branch.equals(branch)) {\r
+                                                       // specific branch, remove\r
+                                                       toRemove.add(model);\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               updateSubscribedStates();\r
+               return true;\r
+       }\r
+\r
        public List<FederationModel> refreshFederationRegistrations() throws IOException {\r
                List<FederationModel> list = RpcUtils.getFederationRegistrations(url, account, password);\r
                federationRegistrations.clear();\r
index f16616a3bf7d04dfdb0fca9d3c1b49e8086399e7..a337040f9dcc76755c56ab768632ac3da8ad6a64 100644 (file)
@@ -31,6 +31,7 @@ import java.net.ConnectException;
 import java.text.MessageFormat;\r
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.Collections;\r
 import java.util.Comparator;\r
 import java.util.Date;\r
@@ -204,11 +205,11 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
                                return;\r
                        }\r
                }\r
-               \r
+\r
                // login\r
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));\r
                final GitblitRegistration registration = reg;\r
-               final GitblitPanel panel = new GitblitPanel(registration);\r
+               final GitblitPanel panel = new GitblitPanel(registration, this);\r
                SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {\r
 \r
                        @Override\r
@@ -303,6 +304,10 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
                                        password = new String(Base64.decode(pw)).toCharArray();\r
                                }\r
                                GitblitRegistration reg = new GitblitRegistration(server, url, account, password);\r
+                               String[] feeds = config.getStringList("servers", server, "feeds");\r
+                               if (feeds != null) {\r
+                                       reg.feeds = new ArrayList<String>(Arrays.asList(feeds));\r
+                               }\r
                                reg.lastLogin = lastLogin;\r
                                registrations.put(reg.name, reg);\r
                        }\r
@@ -333,6 +338,9 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
                        if (reg.lastLogin != null) {\r
                                config.setString("servers", reg.name, "lastLogin", dateFormat.format(reg.lastLogin));\r
                        }\r
+                       if (reg.feeds != null) {\r
+                               config.setStringList("servers", reg.name, "feeds", reg.feeds);\r
+                       }\r
                        config.save();\r
                        return true;\r
                } catch (Throwable t) {\r
index 03ddfb3a1558348ccbb737ac07902b6ff1f687ba..198b24b3c881a38035e9afbafb518620d74120c8 100644 (file)
@@ -58,6 +58,7 @@ import com.gitblit.Constants.RpcRequest;
 import com.gitblit.client.ClosableTabComponent.CloseTabListener;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.SettingModel;\r
+import com.gitblit.models.SyndicatedEntryModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
 \r
@@ -76,6 +77,8 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
 \r
        private final Insets insets = new Insets(margin, margin, margin, margin);\r
 \r
+       private final RegistrationsDialog.RegistrationListener listener;\r
+\r
        private GitblitClient gitblit;\r
 \r
        private JTabbedPane tabs;\r
@@ -96,14 +99,6 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
 \r
        private JButton delRepository;\r
 \r
-       private NameRenderer nameRenderer;\r
-\r
-       private IndicatorsRenderer typeRenderer;\r
-\r
-       private DefaultTableCellRenderer ownerRenderer;\r
-\r
-       private DefaultTableCellRenderer sizeRenderer;\r
-\r
        private TableRowSorter<RepositoriesTableModel> defaultRepositoriesSorter;\r
 \r
        private TableRowSorter<UsersTableModel> defaultUsersSorter;\r
@@ -120,15 +115,19 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
 \r
        private StatusPanel statusPanel;\r
 \r
-       public GitblitPanel(GitblitRegistration reg) {\r
-               this(reg.url, reg.account, reg.password);\r
-       }\r
+       private SyndicatedEntryTableModel syndicationModel;\r
 \r
-       public GitblitPanel(String url, String account, char[] password) {\r
-               this.gitblit = new GitblitClient(url, account, password);\r
+       private HeaderPanel feedsHeader;\r
+\r
+       private JTable syndicationEntriesTable;\r
+\r
+       public GitblitPanel(GitblitRegistration reg, RegistrationsDialog.RegistrationListener listener) {\r
+               this.gitblit = new GitblitClient(reg);\r
+               this.listener = listener;\r
 \r
                tabs = new JTabbedPane(JTabbedPane.BOTTOM);\r
                tabs.addTab(Translation.get("gb.repositories"), createRepositoriesPanel());\r
+               tabs.addTab(Translation.get("gb.recentCommits"), createFeedsPanel());\r
                tabs.addTab(Translation.get("gb.users"), createUsersPanel());\r
                tabs.addTab(Translation.get("gb.settings"), createSettingsPanel());\r
                tabs.addTab(Translation.get("gb.status"), createStatusPanel());\r
@@ -183,20 +182,28 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                        }\r
                });\r
 \r
-               nameRenderer = new NameRenderer();\r
-               typeRenderer = new IndicatorsRenderer();\r
+               final JButton subscribeRepository = new JButton(Translation.get("gb.subscribe") + "...");\r
+               subscribeRepository.setEnabled(false);\r
+               subscribeRepository.addActionListener(new ActionListener() {\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               subscribeRepository(getSelectedRepositories().get(0));\r
+                       }\r
+               });\r
+\r
+               NameRenderer nameRenderer = new NameRenderer(true);\r
+               IndicatorsRenderer typeRenderer = new IndicatorsRenderer();\r
 \r
-               sizeRenderer = new DefaultTableCellRenderer();\r
+               DefaultTableCellRenderer sizeRenderer = new DefaultTableCellRenderer();\r
                sizeRenderer.setHorizontalAlignment(SwingConstants.RIGHT);\r
                sizeRenderer.setForeground(new Color(0, 0x80, 0));\r
 \r
-               ownerRenderer = new DefaultTableCellRenderer();\r
+               DefaultTableCellRenderer ownerRenderer = new DefaultTableCellRenderer();\r
                ownerRenderer.setForeground(Color.gray);\r
                ownerRenderer.setHorizontalAlignment(SwingConstants.CENTER);\r
 \r
                repositoriesModel = new RepositoriesTableModel();\r
                defaultRepositoriesSorter = new TableRowSorter<RepositoriesTableModel>(repositoriesModel);\r
-               repositoriesTable = Utils.newTable(repositoriesModel);\r
+               repositoriesTable = Utils.newTable(repositoriesModel, Utils.DATE_FORMAT);\r
                repositoriesTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
                repositoriesTable.setRowSorter(defaultRepositoriesSorter);\r
                repositoriesTable.getRowSorter().toggleSortOrder(\r
@@ -217,6 +224,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                boolean selected = repositoriesTable.getSelectedRow() > -1;\r
                                browseRepository.setEnabled(singleSelection);\r
                                delRepository.setEnabled(selected);\r
+                               subscribeRepository.setEnabled(singleSelection);\r
                                if (selected) {\r
                                        int viewRow = repositoriesTable.getSelectedRow();\r
                                        int modelRow = repositoriesTable.convertRowIndexToModel(viewRow);\r
@@ -264,6 +272,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                repositoryControls.add(createRepository);\r
                repositoryControls.add(editRepository);\r
                repositoryControls.add(delRepository);\r
+               repositoryControls.add(subscribeRepository);\r
 \r
                JPanel repositoriesPanel = new JPanel(new BorderLayout(margin, margin)) {\r
 \r
@@ -292,6 +301,94 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                }\r
        }\r
 \r
+       private JPanel createFeedsPanel() {\r
+               JButton refreshFeeds = new JButton(Translation.get("gb.refresh"));\r
+               refreshFeeds.addActionListener(new ActionListener() {\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               refreshFeeds();\r
+                       }\r
+               });\r
+\r
+               final JButton viewCommit = new JButton(Translation.get("gb.view"));\r
+               viewCommit.setEnabled(false);\r
+               viewCommit.addActionListener(new ActionListener() {\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               viewCommit();\r
+                       }\r
+               });\r
+\r
+               final JButton viewCommitDiff = new JButton(Translation.get("gb.commitdiff"));\r
+               viewCommitDiff.setEnabled(false);\r
+               viewCommitDiff.addActionListener(new ActionListener() {\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               viewCommitDiff();\r
+                       }\r
+               });\r
+\r
+               final JButton viewTree = new JButton(Translation.get("gb.tree"));\r
+               viewTree.setEnabled(false);\r
+               viewTree.addActionListener(new ActionListener() {\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               viewTree();\r
+                       }\r
+               });\r
+\r
+               JPanel controls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));\r
+               controls.add(refreshFeeds);\r
+               controls.add(viewCommit);\r
+               controls.add(viewCommitDiff);\r
+               controls.add(viewTree);\r
+\r
+               NameRenderer nameRenderer = new NameRenderer();\r
+               syndicationModel = new SyndicatedEntryTableModel();\r
+               feedsHeader = new HeaderPanel(Translation.get("gb.recentCommits"), "feed_16x16.png");\r
+               syndicationEntriesTable = Utils.newTable(syndicationModel, Utils.DATE_FORMAT);\r
+               String name = syndicationEntriesTable\r
+                               .getColumnName(SyndicatedEntryTableModel.Columns.Author.ordinal());\r
+               syndicationEntriesTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
+               syndicationEntriesTable.getColumn(name).setCellRenderer(nameRenderer);\r
+\r
+               syndicationEntriesTable.addMouseListener(new MouseAdapter() {\r
+                       public void mouseClicked(MouseEvent e) {\r
+                               if (e.getClickCount() == 2) {\r
+                                       if (e.isControlDown()) {\r
+                                               viewCommitDiff();\r
+                                       } else {\r
+                                               viewCommit();\r
+                                       }\r
+                               }\r
+                       }\r
+               });\r
+\r
+               syndicationEntriesTable.getSelectionModel().addListSelectionListener(\r
+                               new ListSelectionListener() {\r
+                                       @Override\r
+                                       public void valueChanged(ListSelectionEvent e) {\r
+                                               if (e.getValueIsAdjusting()) {\r
+                                                       return;\r
+                                               }\r
+                                               boolean singleSelection = syndicationEntriesTable.getSelectedRowCount() == 1;\r
+                                               viewCommit.setEnabled(singleSelection);\r
+                                               viewCommitDiff.setEnabled(singleSelection);\r
+                                               viewTree.setEnabled(singleSelection);\r
+                                       }\r
+                               });\r
+\r
+               JPanel panel = new JPanel(new BorderLayout(5, 5)) {\r
+\r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       @Override\r
+                       public Insets getInsets() {\r
+                               return insets;\r
+                       }\r
+               };\r
+               panel.add(feedsHeader, BorderLayout.NORTH);\r
+               panel.add(new JScrollPane(syndicationEntriesTable), BorderLayout.CENTER);\r
+               panel.add(controls, BorderLayout.SOUTH);\r
+               return panel;\r
+       }\r
+\r
        private JPanel createUsersPanel() {\r
                JButton refreshUsers = new JButton(Translation.get("gb.refresh"));\r
                refreshUsers.addActionListener(new ActionListener() {\r
@@ -323,9 +420,10 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                        }\r
                });\r
 \r
+               NameRenderer nameRenderer = new NameRenderer();\r
                usersModel = new UsersTableModel();\r
                defaultUsersSorter = new TableRowSorter<UsersTableModel>(usersModel);\r
-               usersTable = Utils.newTable(usersModel);\r
+               usersTable = Utils.newTable(usersModel, Utils.DATE_FORMAT);\r
                String name = usersTable.getColumnName(UsersTableModel.Columns.Name.ordinal());\r
                usersTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
                usersTable.getColumn(name).setCellRenderer(nameRenderer);\r
@@ -414,10 +512,11 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                        }\r
                });\r
 \r
+               NameRenderer nameRenderer = new NameRenderer();\r
                final SettingPanel settingPanel = new SettingPanel();\r
                settingsModel = new SettingsTableModel();\r
                defaultSettingsSorter = new TableRowSorter<SettingsTableModel>(settingsModel);\r
-               settingsTable = Utils.newTable(settingsModel);\r
+               settingsTable = Utils.newTable(settingsModel, Utils.DATE_FORMAT);\r
                settingsTable.setDefaultRenderer(SettingModel.class, new SettingCellRenderer());\r
                String name = settingsTable.getColumnName(UsersTableModel.Columns.Name.ordinal());\r
                settingsTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
@@ -509,6 +608,9 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                updateRepositoriesTable();\r
                Utils.packColumns(repositoriesTable, 5);\r
 \r
+               updateFeedsTable();\r
+               Utils.packColumns(syndicationEntriesTable, 5);\r
+\r
                if (gitblit.allowManagement()) {\r
                        updateUsersTable();\r
                } else {\r
@@ -550,6 +652,14 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                + gitblit.getRepositories().size() + ")");\r
        }\r
 \r
+       private void updateFeedsTable() {\r
+               syndicationModel.entries.clear();\r
+               syndicationModel.entries.addAll(gitblit.getSyndicatedEntries());\r
+               syndicationModel.fireTableDataChanged();\r
+               feedsHeader.setText(Translation.get("gb.recentCommits") + " ("\r
+                               + gitblit.getSyndicatedEntries().size() + ")");\r
+       }\r
+\r
        private void updateUsersTable() {\r
                usersModel.list.clear();\r
                usersModel.list.addAll(gitblit.getUsers());\r
@@ -811,6 +921,89 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                }\r
        }\r
 \r
+       protected void subscribeRepository(final RepositoryModel repository) {\r
+               if (repository == null) {\r
+                       return;\r
+               }\r
+               // TODO this is lame. need better ui.\r
+               if (gitblit.isSubscribed(repository, null)) {\r
+                       // unsubscribe\r
+                       String msg = MessageFormat.format("Do you want to unsubscribe from {0}?",\r
+                                       repository.name);\r
+                       String[] options = { "no", "yes" };\r
+                       int result = JOptionPane.showOptionDialog(GitblitPanel.this, msg, "Unsubscribe?",\r
+                                       JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,\r
+                                       options[0]);\r
+                       if (result == 1) {\r
+                               if (gitblit.unsubscribe(repository, null)) {\r
+                                       updateFeedsTable();\r
+                                       updateRepositoriesTable();\r
+                                       listener.saveRegistration(repository.name, gitblit.reg);\r
+                               }\r
+                       }\r
+               } else {\r
+                       // subscribe\r
+                       String msg = MessageFormat.format("Do you want to subscribe to {0}?", repository.name);\r
+                       String[] options = { "no", "yes" };\r
+                       int result = JOptionPane.showOptionDialog(GitblitPanel.this, msg, "Subscribe?",\r
+                                       JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,\r
+                                       options[0]);\r
+                       if (result == 1) {\r
+                               if (gitblit.subscribe(repository, null)) {\r
+                                       updateRepositoriesTable();\r
+                                       listener.saveRegistration(repository.name, gitblit.reg);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       protected void refreshFeeds() {\r
+               // TODO change request type here\r
+               GitblitWorker worker = new GitblitWorker(GitblitPanel.this, RpcRequest.LIST_USERS) {\r
+                       @Override\r
+                       protected Boolean doRequest() throws IOException {\r
+                               gitblit.refreshSubscribedFeeds();\r
+                               return true;\r
+                       }\r
+\r
+                       @Override\r
+                       protected void onSuccess() {\r
+                               updateFeedsTable();\r
+                       }\r
+               };\r
+               worker.execute();\r
+       }\r
+\r
+       protected SyndicatedEntryModel getSelectedSyndicatedEntry() {\r
+               int viewRow = syndicationEntriesTable.getSelectedRow();\r
+               int modelRow = syndicationEntriesTable.convertRowIndexToModel(viewRow);\r
+               SyndicatedEntryModel entry = syndicationModel.get(modelRow);\r
+               return entry;\r
+       }\r
+\r
+       protected void viewCommit() {\r
+               SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+               browse(entry.link);\r
+       }\r
+\r
+       protected void viewCommitDiff() {\r
+               SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+               browse(entry.link.replace("/commit/", "/commitdiff/"));\r
+       }\r
+\r
+       protected void viewTree() {\r
+               SyndicatedEntryModel entry = getSelectedSyndicatedEntry();\r
+               browse(entry.link.replace("/commit/", "/tree/"));\r
+       }\r
+\r
+       protected void browse(String url) {\r
+               try {\r
+                       Desktop.getDesktop().browse(new URI(url));\r
+               } catch (Exception x) {\r
+                       x.printStackTrace();\r
+               }\r
+       }\r
+\r
        protected void refreshUsers() {\r
                GitblitWorker worker = new GitblitWorker(GitblitPanel.this, RpcRequest.LIST_USERS) {\r
                        @Override\r
index 0463c12b81a8d57f74552dcc93398006481c458b..cbd4324d1e5c66031d465e5d1dd2817aaa9949c2 100644 (file)
@@ -17,6 +17,7 @@ package com.gitblit.client;
 \r
 import java.io.Serializable;\r
 import java.util.Date;\r
+import java.util.List;\r
 \r
 import com.gitblit.utils.StringUtils;\r
 \r
@@ -36,6 +37,7 @@ public class GitblitRegistration implements Serializable, Comparable<GitblitRegi
        char[] password;\r
        boolean savePassword;\r
        Date lastLogin;\r
+       List<String> feeds;\r
 \r
        public GitblitRegistration(String name, String url, String account, char[] password) {\r
                this.url = url;\r
index 5b1a17364cd7c4efbfdc66728570f3558b82d6dc..ce042555d725b8aa7ab3d26af104136a598cdf57 100644 (file)
@@ -18,9 +18,12 @@ package com.gitblit.client;
 import java.awt.Color;\r
 import java.awt.Component;\r
 \r
+import javax.swing.ImageIcon;\r
 import javax.swing.JTable;\r
 import javax.swing.table.DefaultTableCellRenderer;\r
 \r
+import com.gitblit.models.RepositoryModel;\r
+\r
 /**\r
  * Repository name cell renderer. This renderer shows the group name in a gray\r
  * color and accentuates the repository name in a cornflower blue color.\r
@@ -34,11 +37,24 @@ public class NameRenderer extends DefaultTableCellRenderer {
 \r
        final String groupSpan;\r
 \r
+       private final boolean displayIcon;\r
+\r
+       private final ImageIcon blankIcon;\r
+\r
+       private final ImageIcon subscribedIcon;\r
+\r
        public NameRenderer() {\r
-               this(Color.gray, new Color(0x00, 0x69, 0xD6));\r
+               this(false);\r
+       }\r
+\r
+       public NameRenderer(boolean showIcon) {\r
+               this(Color.gray, new Color(0x00, 0x69, 0xD6), showIcon);\r
        }\r
 \r
-       public NameRenderer(Color group, Color repo) {\r
+       private NameRenderer(Color group, Color repo, boolean showIcon) {\r
+               blankIcon = new ImageIcon(getClass().getResource("/blank.png"));\r
+               subscribedIcon = new ImageIcon(getClass().getResource("/bullet_feed.png"));\r
+               displayIcon = showIcon;\r
                groupSpan = "<span style='color:" + getHexColor(group) + "'>";\r
                setForeground(repo);\r
        }\r
@@ -55,14 +71,26 @@ public class NameRenderer extends DefaultTableCellRenderer {
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,\r
                        boolean hasFocus, int row, int column) {\r
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);\r
-               String name = value.toString();\r
-               int lastSlash = name.lastIndexOf('/');\r
-               if (!isSelected && lastSlash > -1) {\r
-                       String group = name.substring(0, lastSlash + 1);\r
-                       String repo = name.substring(lastSlash + 1);\r
-                       setText("<html><body>" + groupSpan + group + "</span>" + repo);\r
+               if (value instanceof RepositoryModel) {\r
+                       RepositoryModel model = (RepositoryModel) value;\r
+                       String name = value.toString();\r
+                       int lastSlash = name.lastIndexOf('/');\r
+                       if (!isSelected && lastSlash > -1) {\r
+                               String group = name.substring(0, lastSlash + 1);\r
+                               String repo = name.substring(lastSlash + 1);\r
+                               setText("<html><body>" + groupSpan + group + "</span>" + repo);\r
+                       } else {\r
+                               this.setText(name);\r
+                       }\r
+                       if (displayIcon) {\r
+                               if (model.subscribed) {\r
+                                       setIcon(subscribedIcon);\r
+                               } else {\r
+                                       setIcon(blankIcon);\r
+                               }\r
+                       }\r
                } else {\r
-                       this.setText(name);\r
+                       this.setText(value.toString());\r
                }\r
                return this;\r
        }\r
index 0b87bb47587756bbb29679c3b9d03a6eb9832b28..d40e333578eb335d526bc60cd2d19687e3c8d407 100644 (file)
@@ -92,7 +92,7 @@ public class RegistrationsDialog extends JDialog {
        private void initialize() {\r
                NameRenderer nameRenderer = new NameRenderer();\r
                model = new RegistrationsTableModel(registrations);\r
-               registrationsTable = Utils.newTable(model);\r
+               registrationsTable = Utils.newTable(model, Utils.DATE_FORMAT);\r
                registrationsTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
 \r
                String id = registrationsTable\r
index b85d87afb4558b7a719d5cc6021719b00ffa482e..797ae9b93caf0a8428339c4e2673e4ad46bb5dbb 100644 (file)
@@ -92,7 +92,7 @@ public class StatusPanel extends JPanel {
                fieldsPanel.add(createFieldPanel("gb.heapMaximum", heapMaximum));\r
 \r
                model = new PropertiesTableModel();\r
-               JTable propertiesTable = Utils.newTable(model);\r
+               JTable propertiesTable = Utils.newTable(model, Utils.DATE_FORMAT);\r
                String name = propertiesTable.getColumnName(PropertiesTableModel.Columns.Name.ordinal());\r
                NameRenderer nameRenderer = new NameRenderer();\r
                propertiesTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
diff --git a/src/com/gitblit/client/SyndicatedEntryTableModel.java b/src/com/gitblit/client/SyndicatedEntryTableModel.java
new file mode 100644 (file)
index 0000000..4f25c9b
--- /dev/null
@@ -0,0 +1,121 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Date;\r
+import java.util.List;\r
+\r
+import javax.swing.table.AbstractTableModel;\r
+\r
+import com.gitblit.models.SyndicatedEntryModel;\r
+\r
+/**\r
+ * Table model of List<SyndicatedEntryModel>\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class SyndicatedEntryTableModel extends AbstractTableModel {\r
+\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       List<SyndicatedEntryModel> entries;\r
+\r
+       enum Columns {\r
+               Date, Repository, Author, Message;\r
+\r
+               @Override\r
+               public String toString() {\r
+                       return name().replace('_', ' ');\r
+               }\r
+       }\r
+\r
+       public SyndicatedEntryTableModel() {\r
+               this(new ArrayList<SyndicatedEntryModel>());\r
+       }\r
+\r
+       public SyndicatedEntryTableModel(List<SyndicatedEntryModel> entries) {\r
+               setEntries(entries);\r
+       }\r
+\r
+       public void setEntries(List<SyndicatedEntryModel> entries) {\r
+               this.entries = entries;\r
+               Collections.sort(entries);\r
+       }\r
+\r
+       @Override\r
+       public int getRowCount() {\r
+               return entries.size();\r
+       }\r
+\r
+       @Override\r
+       public int getColumnCount() {\r
+               return Columns.values().length;\r
+       }\r
+\r
+       @Override\r
+       public String getColumnName(int column) {\r
+               Columns col = Columns.values()[column];\r
+               switch (col) {\r
+               case Date:\r
+                       return Translation.get("gb.date");\r
+               case Repository:\r
+                       return Translation.get("gb.repository");\r
+               case Author:\r
+                       return Translation.get("gb.author");\r
+               case Message:\r
+                       return Translation.get("gb.message");\r
+               }\r
+               return "";\r
+       }\r
+\r
+       /**\r
+        * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
+        * \r
+        * @param columnIndex\r
+        *            the column being queried\r
+        * @return the Object.class\r
+        */\r
+       public Class<?> getColumnClass(int columnIndex) {\r
+               if (Columns.Date.ordinal() == columnIndex) {\r
+                       return Date.class;\r
+               }\r
+               return String.class;\r
+       }\r
+\r
+       @Override\r
+       public Object getValueAt(int rowIndex, int columnIndex) {\r
+               SyndicatedEntryModel entry = entries.get(rowIndex);\r
+               Columns col = Columns.values()[columnIndex];\r
+               switch (col) {\r
+               case Date:\r
+                       return entry.published;\r
+               case Repository:\r
+                       return entry.repository;\r
+               case Author:\r
+                       return entry.author;\r
+               case Message:\r
+                       return entry.title;\r
+               }\r
+               return null;\r
+       }\r
+\r
+       public SyndicatedEntryModel get(int modelRow) {\r
+               return entries.get(modelRow);\r
+       }\r
+}\r
index 786eb9f29e11a52f10b2fd6c9ce789547c4f8fc2..1f44c32d094fdc00577691d5d0407354e3d19984 100644 (file)
@@ -36,15 +36,19 @@ import javax.swing.table.TableModel;
 import com.gitblit.Constants.RpcRequest;\r
 \r
 public class Utils {\r
+       \r
+       public final static String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm";\r
+       \r
+       public final static String DATE_FORMAT = "yyyy-MM-dd";\r
 \r
-       public static JTable newTable(TableModel model) {\r
+       public static JTable newTable(TableModel model, String datePattern) {\r
                JTable table = new JTable(model);\r
                table.setCellSelectionEnabled(false);\r
                table.setRowSelectionAllowed(true);\r
                table.getTableHeader().setReorderingAllowed(false);\r
                table.setGridColor(new Color(0xd9d9d9));\r
                table.setBackground(Color.white);\r
-               table.setDefaultRenderer(Date.class, new DateCellRenderer(null, Color.orange.darker()));\r
+               table.setDefaultRenderer(Date.class, new DateCellRenderer(datePattern, Color.orange.darker()));\r
                return table;\r
        }\r
 \r
index 9a774fbd2d04d531a0b780dedf30590a2170f6af..af420612947764da50950138048831bbb7f71ad4 100644 (file)
@@ -55,6 +55,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        public String frequency;\r
        public String origin;\r
        public String size;\r
+       public boolean subscribed;\r
 \r
        public RepositoryModel() {\r
                this("", "", "", new Date(0));\r
diff --git a/src/com/gitblit/models/SyndicatedEntryModel.java b/src/com/gitblit/models/SyndicatedEntryModel.java
new file mode 100644 (file)
index 0000000..a1c1221
--- /dev/null
@@ -0,0 +1,59 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.models;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+\r
+/**\r
+ * SyndicationEntryModel represents an entry in a syndication (RSS) feed.\r
+ * \r
+ * @author James Moger\r
+ */\r
+public class SyndicatedEntryModel implements Serializable, Comparable<SyndicatedEntryModel> {\r
+\r
+       public String repository;\r
+       public String branch;\r
+       public String title;\r
+       public String author;\r
+       public Date published;\r
+       public String link;\r
+       public String content;\r
+       public String contentType;\r
+\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       public SyndicatedEntryModel() {\r
+       }\r
+\r
+       @Override\r
+       public int compareTo(SyndicatedEntryModel o) {\r
+               return o.published.compareTo(published);\r
+       }\r
+\r
+       @Override\r
+       public int hashCode() {\r
+               return link.hashCode();\r
+       }\r
+\r
+       @Override\r
+       public boolean equals(Object o) {\r
+               if (o instanceof SyndicatedEntryModel) {\r
+                       return hashCode() == o.hashCode();\r
+               }\r
+               return false;\r
+       }\r
+}\r
index 3664a1816d684acec460c8cf2a8bb56c5a78b9a7..2237774eec99d546e0591cc7ff024c9d2bddef8e 100644 (file)
@@ -27,6 +27,8 @@ import java.util.List;
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
 import com.gitblit.Constants;\r
+import com.gitblit.GitBlitException;\r
+import com.gitblit.models.SyndicatedEntryModel;\r
 import com.sun.syndication.feed.synd.SyndContent;\r
 import com.sun.syndication.feed.synd.SyndContentImpl;\r
 import com.sun.syndication.feed.synd.SyndEntry;\r
@@ -64,6 +66,7 @@ public class SyndicationUtils {
 \r
                SyndFeed feed = new SyndFeedImpl();\r
                feed.setFeedType("rss_2.0");\r
+               feed.setEncoding("UTF-8");\r
                feed.setTitle(title);\r
                feed.setLink(MessageFormat.format("{0}/summary/{1}", hostUrl,\r
                                StringUtils.encodeURL(repository)));\r
@@ -84,15 +87,14 @@ public class SyndicationUtils {
                        entry.setPublishedDate(commit.getCommitterIdent().getWhen());\r
 \r
                        SyndContent content = new SyndContentImpl();\r
-                       content.setType("text/html");\r
-                       String html = StringUtils.escapeForHtml(commit.getFullMessage(), false);\r
-                       content.setValue(StringUtils.breakLinesForHtml(html));\r
+                       content.setType("text/plain");\r
+                       content.setValue(commit.getFullMessage());\r
                        entry.setDescription(content);\r
                        entries.add(entry);\r
                }\r
                feed.setEntries(entries);\r
 \r
-               OutputStreamWriter writer = new OutputStreamWriter(os);\r
+               OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");\r
                SyndFeedOutput output = new SyndFeedOutput();\r
                output.output(feed, writer);\r
                writer.close();\r
@@ -112,12 +114,11 @@ public class SyndicationUtils {
         *            is used.\r
         * @param username\r
         * @param password\r
-        * @return the JSON message as a string\r
+        * @return a list of SyndicationModel entries\r
         * @throws {@link IOException}\r
         */\r
-       public static SyndFeed readFeed(String url, String repository, String branch,\r
-                       int numberOfEntries, String username, char[] password) throws IOException,\r
-                       FeedException {\r
+       public static List<SyndicatedEntryModel> readFeed(String url, String repository, String branch,\r
+                       int numberOfEntries, String username, char[] password) throws IOException {\r
                String feedUrl;\r
                if (StringUtils.isEmpty(branch)) {\r
                        // no branch specified\r
@@ -142,8 +143,27 @@ public class SyndicationUtils {
                URLConnection conn = ConnectionUtils.openReadConnection(feedUrl, username, password);\r
                InputStream is = conn.getInputStream();\r
                SyndFeedInput input = new SyndFeedInput();\r
-               SyndFeed feed = input.build(new XmlReader(is));\r
+               SyndFeed feed = null;\r
+               try {\r
+                       feed = input.build(new XmlReader(is));\r
+               } catch (FeedException f) {\r
+                       throw new GitBlitException(f);\r
+               }\r
                is.close();\r
-               return feed;\r
+               List<SyndicatedEntryModel> entries = new ArrayList<SyndicatedEntryModel>();\r
+               for (Object o : feed.getEntries()) {\r
+                       SyndEntryImpl entry = (SyndEntryImpl) o;\r
+                       SyndicatedEntryModel model = new SyndicatedEntryModel();\r
+                       model.repository = repository;\r
+                       model.branch = branch;\r
+                       model.title = entry.getTitle();\r
+                       model.author = entry.getAuthor();\r
+                       model.published = entry.getPublishedDate();\r
+                       model.link = entry.getLink();\r
+                       model.content = entry.getDescription().getValue();\r
+                       model.contentType = entry.getDescription().getType();\r
+                       entries.add(model);\r
+               }\r
+               return entries;\r
        }\r
 }\r
index 267fb5642d40d3ac3250bed36b8721009159234b..e16b44db7f1942609efe0cc9ff9a44d79d03cd76 100644 (file)
@@ -175,4 +175,7 @@ gb.heapAllocated = allocated heap
 gb.heapUsed = used heap\r
 gb.free = free\r
 gb.version = version\r
-gb.releaseDate = release date
\ No newline at end of file
+gb.releaseDate = release date\r
+gb.date = date\r
+gb.recentCommits = recent commits\r
+gb.subscribe = subscribe
\ No newline at end of file
index 33d7dbd2027b00d258367cb10c1980d29199f3f0..6084b990d467aa8758d2efb9a1919d499059d3e6 100644 (file)
@@ -23,10 +23,9 @@ import junit.framework.TestCase;
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
-import com.gitblit.client.GitblitFeed;\r
+import com.gitblit.models.SyndicatedEntryModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.SyndicationUtils;\r
-import com.sun.syndication.feed.synd.SyndFeed;\r
 \r
 public class SyndicationUtilsTest extends TestCase {\r
 \r
@@ -44,10 +43,10 @@ public class SyndicationUtilsTest extends TestCase {
        }\r
 \r
        public void testFeedRead() throws Exception {\r
-               GitblitFeed reader = new GitblitFeed("https://localhost:8443", "ticgit.git", "master");\r
-               SyndFeed feed = reader.update(5, "admin", "admin".toCharArray());\r
+               List<SyndicatedEntryModel> feed = SyndicationUtils.readFeed("https://localhost:8443",\r
+                               "ticgit.git", "master", 5, "admin", "admin".toCharArray());\r
                assertTrue(feed != null);\r
-               assertTrue(feed.getEntries().size() > 0);\r
-               assertEquals(5, feed.getEntries().size());\r
+               assertTrue(feed.size() > 0);\r
+               assertEquals(5, feed.size());\r
        }\r
 }
\ No newline at end of file