]> source.dussan.org Git - gitblit.git/commitdiff
Basic Create/Edit Repository. JGit 0.12-stable. Tag icon.
authorJames Moger <james.moger@gitblit.com>
Sat, 23 Apr 2011 23:16:53 +0000 (19:16 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 23 Apr 2011 23:16:53 +0000 (19:16 -0400)
25 files changed:
.classpath
gitblit.properties
src/com/gitblit/GitBlit.java
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/RepositoryPage.java
src/com/gitblit/wicket/models/RepositoryModel.java
src/com/gitblit/wicket/pages/BlobDiffPage.java
src/com/gitblit/wicket/pages/EditRepositoryPage.html [new file with mode: 0644]
src/com/gitblit/wicket/pages/EditRepositoryPage.java [new file with mode: 0644]
src/com/gitblit/wicket/pages/PatchPage.java
src/com/gitblit/wicket/pages/RawPage.java
src/com/gitblit/wicket/pages/RepositoriesPage.html
src/com/gitblit/wicket/pages/RepositoriesPage.java
src/com/gitblit/wicket/pages/SummaryPage.java
src/com/gitblit/wicket/pages/TreePage.java
src/com/gitblit/wicket/panels/HistoryPanel.html
src/com/gitblit/wicket/panels/HistoryPanel.java
src/com/gitblit/wicket/panels/LogPanel.html
src/com/gitblit/wicket/panels/SearchPanel.html
src/com/gitblit/wicket/panels/SearchPanel.java
src/com/gitblit/wicket/panels/TagsPanel.html
src/com/gitblit/wicket/panels/TagsPanel.java
src/com/gitblit/wicket/resources/gitblit.css
src/com/gitblit/wicket/resources/tag_16x16.png [new file with mode: 0644]

index 70505fff0ef30c0a49a1e9b20d45043b08f6d1ac..e1c4e4ae133f26809f399d9bcc4d266f72068acb 100644 (file)
@@ -12,9 +12,9 @@
        <classpathentry kind="lib" path="ext/wicket-1.4.17.jar"/>\r
        <classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.17.jar"/>\r
        <classpathentry kind="lib" path="ext/wicket-extensions-1.4.17.jar"/>\r
-       <classpathentry kind="lib" path="lib/jgit-0.11.3.jar"/>\r
-       <classpathentry kind="lib" path="lib/jgit-http-0.11.3.jar"/>\r
        <classpathentry kind="lib" path="ext/markdownpapers-core-1.0.0.jar"/>\r
        <classpathentry kind="lib" path="ext/googlecharts-1.4.17.jar"/>\r
+       <classpathentry kind="lib" path="lib/jgit-0.12-stable.jar"/>\r
+       <classpathentry kind="lib" path="lib/jgit-http-0.12-stable.jar"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
index 427a9d527ee4b5d3bbe669e8948d440396218c99..4b08135806465600c01f4890a2a7678fe2663afb 100644 (file)
@@ -48,7 +48,7 @@ web.allowAdministration = true
 \r
 # This is the message display above the repositories table.\r
 # This can point to a file with Markdown content.\r
-# specifying "gitblit" uses the internal welcome message.\r
+# Specifying "gitblit" uses the internal welcome message.\r
 web.repositoriesMessage = gitblit\r
 \r
 # Use the client timezone when formatting dates.\r
@@ -63,6 +63,9 @@ web.datetimestampLongFormat = EEEE, MMMM d, yyyy h:mm a z
 # Choose the diff presentation style: gitblt, gitweb, or plain\r
 web.diffStyle = gitblit\r
 \r
+# Control if email addresses are shown in web ui\r
+web.showEmailAddresses = true\r
+\r
 # Generates a line graph of repository activity over time on the Summary page.\r
 # This is a real-time graph so generation may be expensive. \r
 web.generateActivityGraph = true\r
index f285daf4ae33b86de5d4551c86c1c6975aac8828..c412b18a314ec7fcde6171710820e1b169e48f67 100644 (file)
@@ -8,15 +8,12 @@ import java.util.List;
 import javax.servlet.ServletContextEvent;\r
 import javax.servlet.ServletContextListener;\r
 import javax.servlet.http.Cookie;\r
-import javax.servlet.http.HttpServletRequest;\r
 \r
-import org.apache.wicket.Request;\r
 import org.apache.wicket.protocol.http.WebResponse;\r
-import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
 import org.eclipse.jgit.errors.RepositoryNotFoundException;\r
-import org.eclipse.jgit.http.server.resolver.FileResolver;\r
-import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;\r
 import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.transport.resolver.FileResolver;\r
+import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -30,7 +27,7 @@ public class GitBlit implements ServletContextListener {
 \r
        private final Logger logger = LoggerFactory.getLogger(GitBlit.class);\r
 \r
-       private FileResolver repositoryResolver;\r
+       private FileResolver<Void> repositoryResolver;\r
 \r
        private File repositories;\r
 \r
@@ -96,18 +93,41 @@ public class GitBlit implements ServletContextListener {
                response.addCookie(userCookie);\r
        }\r
 \r
+       public void editRepository(RepositoryModel repository, boolean isCreate) {\r
+               Repository r = null;\r
+               if (isCreate) {\r
+                       // create repository\r
+                       logger.info("create repository " + repository.name);\r
+                       r = JGitUtils.createRepository(repositories, repository.name, true);\r
+               } else {\r
+                       // load repository\r
+                       logger.info("edit repository " + repository.name);\r
+                       try {\r
+                               r = repositoryResolver.open(null, repository.name);\r
+                       } catch (RepositoryNotFoundException e) {\r
+                               logger.error("Repository not found", e);\r
+                       } catch (ServiceNotEnabledException e) {\r
+                               logger.error("Service not enabled", e);\r
+                       }\r
+               }               \r
+                               \r
+               // update settings\r
+               JGitUtils.setRepositoryDescription(r, repository.description);\r
+               JGitUtils.setRepositoryOwner(r, repository.owner);\r
+               JGitUtils.setRepositoryUseTickets(r, repository.useTickets);\r
+               JGitUtils.setRepositoryUseDocs(r, repository.useDocs);\r
+               JGitUtils.setRepositoryUseNamedUsers(r, repository.useNamedUsers);\r
+       }\r
+\r
        public List<String> getRepositoryList() {\r
                return JGitUtils.getRepositoryList(repositories, exportAll, storedSettings.getBoolean(Keys.git.nestedRepositories, true));\r
        }\r
 \r
-       public List<RepositoryModel> getRepositories(Request request) {\r
+       public List<RepositoryModel> getRepositories() {\r
                List<String> list = getRepositoryList();\r
-               ServletWebRequest servletWebRequest = (ServletWebRequest) request;\r
-               HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
-\r
                List<RepositoryModel> repositories = new ArrayList<RepositoryModel>();\r
                for (String repo : list) {\r
-                       Repository r = getRepository(req, repo);\r
+                       Repository r = getRepository(repo);\r
                        String description = JGitUtils.getRepositoryDescription(r);\r
                        String owner = JGitUtils.getRepositoryOwner(r);\r
                        Date lastchange = JGitUtils.getLastChange(r);\r
@@ -117,10 +137,10 @@ public class GitBlit implements ServletContextListener {
                return repositories;\r
        }\r
 \r
-       public Repository getRepository(HttpServletRequest req, String repositoryName) {\r
+       public Repository getRepository(String repositoryName) {\r
                Repository r = null;\r
                try {\r
-                       r = repositoryResolver.open(req, repositoryName);\r
+                       r = repositoryResolver.open(null, repositoryName);\r
                } catch (RepositoryNotFoundException e) {\r
                        r = null;\r
                        logger.error("Failed to find repository " + repositoryName);\r
@@ -147,7 +167,7 @@ public class GitBlit implements ServletContextListener {
                        WebXmlSettings webxmlSettings = new WebXmlSettings(contextEvent.getServletContext());\r
                        setupContext(webxmlSettings);\r
                } else {\r
-                       logger.info("GitBlit context already setup by " + storedSettings.toString());   \r
+                       logger.info("GitBlit context already setup by " + storedSettings.toString());\r
                }\r
        }\r
 \r
index cd3e6efef987d53791aaef69bda170b6b24796d0..df7be6bfd983fb3f2c62f67c82a667803cad03f2 100644 (file)
@@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
-import java.io.RandomAccessFile;\r
 import java.text.DateFormat;\r
 import java.text.ParseException;\r
 import java.text.SimpleDateFormat;\r
@@ -17,10 +16,11 @@ import java.util.Map;
 import java.util.Set;\r
 import java.util.concurrent.atomic.AtomicInteger;\r
 \r
+import org.eclipse.jgit.api.Git;\r
 import org.eclipse.jgit.diff.DiffEntry;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.diff.DiffFormatter;\r
 import org.eclipse.jgit.diff.RawTextComparator;\r
-import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.errors.ConfigInvalidException;\r
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;\r
 import org.eclipse.jgit.errors.MissingObjectException;\r
@@ -66,6 +66,11 @@ public class JGitUtils {
        public static final String R_NOTES_COMMITS = R_NOTES + "commits";\r
 \r
        private final static Logger LOGGER = LoggerFactory.getLogger(JGitUtils.class);\r
+       \r
+       public static Repository createRepository(File repositoriesFolder, String name, boolean bare) {\r
+               Git git = Git.init().setDirectory(new File(repositoriesFolder, name)).setBare(bare).call();\r
+               return git.getRepository();\r
+       }\r
 \r
        public static List<String> getRepositoryList(File repositoriesFolder, boolean exportAll, boolean readNested) {\r
                List<String> list = new ArrayList<String>();\r
@@ -80,8 +85,18 @@ public class JGitUtils {
                for (File file : folder.listFiles()) {\r
                        if (file.isDirectory() && !file.getName().equalsIgnoreCase(Constants.DOT_GIT)) {\r
                                // if this is a git repository add it to the list\r
+                               //\r
+                               // first look for standard folder/.git structure\r
                                File gitFolder = new File(file, Constants.DOT_GIT);\r
                                boolean isGitRepository = gitFolder.exists() && gitFolder.isDirectory();\r
+                               \r
+                               // then look for folder.git/HEAD\r
+                               if (!isGitRepository) {\r
+                                       if (file.getName().endsWith(Constants.DOT_GIT_EXT) && new File(file, Constants.HEAD).exists()) {\r
+                                               gitFolder = file;\r
+                                               isGitRepository = true;\r
+                                       }\r
+                               }\r
                                boolean exportRepository = isGitRepository && (exportAll || new File(gitFolder, "git-daemon-export-ok").exists());\r
 \r
                                if (exportRepository) {\r
@@ -124,6 +139,10 @@ public class JGitUtils {
        public static Date getFirstChange(Repository r, String branch) {\r
                try {\r
                        RevCommit commit = getFirstCommit(r, branch);\r
+                       if (commit == null) {\r
+                               // fresh repository\r
+                               return new Date(r.getDirectory().lastModified());                       \r
+                       }\r
                        return getCommitDate(commit);\r
                } catch (Throwable t) {\r
                        LOGGER.error("Failed to determine first change", t);\r
@@ -131,8 +150,12 @@ public class JGitUtils {
                return null;\r
        }\r
 \r
-       public static Date getLastChange(Repository r) {\r
+       public static Date getLastChange(Repository r) {                \r
                RevCommit commit = getCommit(r, Constants.HEAD);\r
+               if (commit == null) {\r
+                       // fresh repository\r
+                       return new Date(r.getDirectory().lastModified());                       \r
+               }\r
                return getCommitDate(commit);\r
        }\r
 \r
@@ -253,6 +276,9 @@ public class JGitUtils {
 \r
        public static List<PathModel> getFilesInPath(Repository r, String basePath, RevCommit commit) {\r
                List<PathModel> list = new ArrayList<PathModel>();\r
+               if (commit == null) {\r
+                       return list;\r
+               }\r
                final TreeWalk walk = new TreeWalk(r);\r
                try {\r
                        walk.addTree(commit.getTree());\r
@@ -708,36 +734,87 @@ public class JGitUtils {
        }\r
 \r
        public static String getRepositoryDescription(Repository r) {\r
-               File dir = r.getDirectory();\r
-               if (dir.exists()) {\r
-                       File description = new File(dir, "description");\r
-                       if (description.exists() && description.length() > 0) {\r
-                               RandomAccessFile raf = null;\r
-                               try {\r
-                                       raf = new RandomAccessFile(description, "r");\r
-                                       byte[] buffer = new byte[(int) description.length()];\r
-                                       raf.readFully(buffer);\r
-                                       return new String(buffer);\r
-                               } catch (Throwable t) {\r
-                               } finally {\r
-                                       try {\r
-                                               raf.close();\r
-                                       } catch (Throwable t) {\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-               return "";\r
+               return getRepositoryConfigString(r, "description");\r
+       }\r
+       \r
+       public static void setRepositoryDescription(Repository r, String value) {\r
+               setRepositoryConfigString(r, "description", value);\r
        }\r
 \r
        public static String getRepositoryOwner(Repository r) {\r
+               return getRepositoryConfigString(r, "owner");\r
+       }\r
+       \r
+       public static void setRepositoryOwner(Repository r, String owner) {\r
+               setRepositoryConfigString(r, "owner", owner);\r
+       }\r
+       \r
+       public static boolean getRepositoryUseTickets(Repository r) {\r
+               return getRepositoryConfigBoolean(r, "useTickets", false);\r
+       }\r
+       \r
+       public static void setRepositoryUseTickets(Repository r, boolean value) {\r
+               setRepositoryConfigBoolean(r, "useTickets", value);\r
+       }\r
+       \r
+       public static boolean getRepositoryUseDocs(Repository r) {\r
+               return getRepositoryConfigBoolean(r, "useDocs", false);\r
+       }\r
+       \r
+       public static void setRepositoryUseDocs(Repository r, boolean value) {\r
+               setRepositoryConfigBoolean(r, "useDocs", value);\r
+       }\r
+       \r
+       public static boolean getRepositoryUseNamedUsers(Repository r) {\r
+               return getRepositoryConfigBoolean(r, "useNamedUsers", false);\r
+       }\r
+       \r
+       public static void setRepositoryUseNamedUsers(Repository r, boolean value) {\r
+               setRepositoryConfigBoolean(r, "useNamedUsers", value);\r
+       }       \r
+       \r
+       public static String getRepositoryConfigString(Repository r, String field) {\r
                StoredConfig c = readConfig(r);\r
                if (c == null) {\r
                        return "";\r
                }\r
-               String o = c.getString("gitweb", null, "owner");\r
+               String o = c.getString("gitblit", null, field);\r
                return o == null ? "" : o;\r
        }\r
+       \r
+       public static void setRepositoryConfigString(Repository r, String field, String value) {\r
+               StoredConfig c = readConfig(r);\r
+               if (c == null) {\r
+                       throw new RuntimeException("Can't find stored config for " + r);\r
+               }\r
+               c.setString("gitblit", null, field, value);\r
+               try {\r
+                       c.save();\r
+               } catch (IOException e) {\r
+                       LOGGER.error("Failed to save repository config field " + field, e);\r
+               }\r
+       }\r
+       \r
+       public static boolean getRepositoryConfigBoolean(Repository r, String field, boolean defaultValue) {\r
+               StoredConfig c = readConfig(r);\r
+               if (c == null) {\r
+                       return defaultValue;\r
+               }\r
+               return c.getBoolean("gitblit", null, field, defaultValue);              \r
+       }\r
+       \r
+       public static void setRepositoryConfigBoolean(Repository r, String field, boolean value) {\r
+               StoredConfig c = readConfig(r);\r
+               if (c == null) {\r
+                       throw new RuntimeException("Can't find stored config for " + r);\r
+               }\r
+               c.setBoolean("gitblit", null, field, value);\r
+               try {\r
+                       c.save();\r
+               } catch (IOException e) {\r
+                       LOGGER.error("Failed to save repository config field " + field, e);\r
+               }               \r
+       }\r
 \r
        private static StoredConfig readConfig(Repository r) {\r
                StoredConfig c = r.getConfig();\r
index cb8953aebd5f20f91c0c35f37a9a88095620004d..d1094bff76dd919dd8fac2220c899b2d345e0b57 100644 (file)
@@ -62,4 +62,6 @@ gb.filesAdded = {0} files added
 gb.filesModified = {0} files modified\r
 gb.filesDeleted = {0} files deleted\r
 gb.filesCopied = {0} files copied\r
-gb.filesRenamed = {0} files renamed
\ No newline at end of file
+gb.filesRenamed = {0} files renamed\r
+gb.missingUsername = Missing Username\r
+gb.edit = edit
\ No newline at end of file
index 979debda611dbba60ab310600a93a9fa03705221..6e0347996b8bc560aef792206ad2edbe5f52d967 100644 (file)
@@ -4,13 +4,10 @@ import java.util.HashMap;
 import java.util.List;\r
 import java.util.Map;\r
 \r
-import javax.servlet.http.HttpServletRequest;\r
-\r
 import org.apache.wicket.Component;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.panel.Fragment;\r
-import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
 import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 import org.eclipse.jgit.lib.Repository;\r
@@ -21,8 +18,8 @@ import org.slf4j.LoggerFactory;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.pages.RepositoriesPage;\r
 import com.gitblit.wicket.pages.SearchPage;\r
 import com.gitblit.wicket.panels.PageLinksPanel;\r
@@ -59,11 +56,7 @@ public abstract class RepositoryPage extends BasePage {
 \r
        protected Repository getRepository() {\r
                if (r == null) {\r
-                       ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();\r
-                       HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
-                       req.getServerName();\r
-\r
-                       Repository r = GitBlit.self().getRepository(req, repositoryName);\r
+                       Repository r = GitBlit.self().getRepository(repositoryName);\r
                        if (r == null) {\r
                                error("Can not load repository " + repositoryName);\r
                                redirectToInterceptPage(new RepositoriesPage());\r
@@ -117,10 +110,15 @@ public abstract class RepositoryPage extends BasePage {
 \r
        \r
        protected Component createPersonPanel(String wicketId, PersonIdent identity, SearchType searchType) {\r
-               if (StringUtils.isEmpty(identity.getName()) || StringUtils.isEmpty(identity.getEmailAddress())) {\r
+               boolean showEmail = GitBlit.self().settings().getBoolean(Keys.web.showEmailAddresses, false);\r
+               if (!showEmail || StringUtils.isEmpty(identity.getName()) || StringUtils.isEmpty(identity.getEmailAddress())) {\r
                        String value = identity.getName();\r
                        if (StringUtils.isEmpty(value)) {\r
-                               value = identity.getEmailAddress();\r
+                               if (showEmail) {\r
+                                       value = identity.getEmailAddress();\r
+                               } else {\r
+                                       value = getString("gb.missingUsername");\r
+                               }\r
                        }\r
                        Fragment partial = new Fragment(wicketId, "partialPersonIdent", this);\r
                        LinkPanel link = new LinkPanel("personName", "list", value, SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType));\r
index 7ce98e0cec25eca75c49e175fc108430ac8ad7f9..a9410b512bc17f6259dae19207f0f735c52201d5 100644 (file)
@@ -6,10 +6,13 @@ import java.util.Date;
 public class RepositoryModel implements Serializable {\r
 \r
        private static final long serialVersionUID = 1L;\r
-       public final String name;\r
-       public final String description;\r
-       public final String owner;\r
-       public final Date lastChange;\r
+       public String name;\r
+       public String description;\r
+       public String owner;\r
+       public Date lastChange;\r
+       public boolean useTickets;\r
+       public boolean useDocs;\r
+       public boolean useNamedUsers;\r
 \r
        public RepositoryModel(String name, String description, String owner, Date lastchange) {\r
                this.name = name;\r
index 99f44db6dc962572cb7748dd97315a215969343f..4bb281c98e7f6ca6e0dd5d9d04c646b016998065 100644 (file)
@@ -9,8 +9,8 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.JGitUtils.DiffOutputType;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.RepositoryPage;\r
 import com.gitblit.wicket.WicketUtils;\r
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html
new file mode 100644 (file)
index 0000000..1e04ed0
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml"  \r
+      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
+      xml:lang="en"  \r
+      lang="en"> \r
+\r
+<body>\r
+<wicket:extend>\r
+       <!-- Push content down to preserve header image -->\r
+       <div style="padding-top:20px"></div>\r
+       \r
+       <!-- Repository Table -->\r
+       <form wicket:id="editForm">\r
+               <table class="plain">\r
+                       <tbody>\r
+                               <tr><th>Name</th><td><input type="text" wicket:id="name" size="30" /></td></tr>\r
+                               <tr><th>Description</th><td><input type="text" wicket:id="description" size="80" /></td></tr>\r
+                               <tr><th>Owner</th><td><input type="text" wicket:id="owner" size="30" /></td></tr>\r
+                               <tr><th>Use Git:Blit Tickets</th><td><input type="checkbox" wicket:id="useTickets"/>distributed Git:Blit ticketing</td></tr>\r
+                               <tr><th>Use Git:Blit Docs</th><td><input type="checkbox" wicket:id="useDocs"/>distributed Git:Blit documentation</td></tr>\r
+                               <tr><th>Named User Access</th><td><input type="checkbox" wicket:id="useNamedUsers"/>not implemented</td></tr>\r
+                               <tr><td colspan="2"><input type="submit" value="Submit"/></td></tr>\r
+                       </tbody>\r
+               </table>\r
+       </form> \r
+</wicket:extend>\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
new file mode 100644 (file)
index 0000000..fab3203
--- /dev/null
@@ -0,0 +1,64 @@
+package com.gitblit.wicket.pages;\r
+\r
+import java.util.Date;\r
+\r
+import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.form.CheckBox;\r
+import org.apache.wicket.markup.html.form.Form;\r
+import org.apache.wicket.markup.html.form.TextField;\r
+import org.apache.wicket.model.CompoundPropertyModel;\r
+\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.wicket.AdminPage;\r
+import com.gitblit.wicket.BasePage;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.models.RepositoryModel;\r
+\r
+@AdminPage\r
+public class EditRepositoryPage extends BasePage {\r
+\r
+       private final boolean isCreate;\r
+\r
+       public EditRepositoryPage() {\r
+               // create constructor\r
+               super();\r
+               isCreate = true;\r
+               setupPage(new RepositoryModel("", "", "", new Date()));\r
+       }\r
+\r
+       public EditRepositoryPage(PageParameters params) {\r
+               // edit constructor\r
+               super(params);\r
+               isCreate = false;\r
+               String repositoryName = WicketUtils.getRepositoryName(params);\r
+               setupPage(new RepositoryModel(repositoryName, "", "", new Date()));\r
+       }\r
+\r
+       protected void setupPage(final RepositoryModel repository) {\r
+               if (isCreate) {\r
+                       super.setupPage("", getString("gb.newRepository"));\r
+               } else {\r
+                       super.setupPage("", getString("gb.edit"));\r
+               }\r
+               CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(repository);\r
+               Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", model) {\r
+\r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       @Override\r
+                       protected void onSubmit() {\r
+                               GitBlit.self().editRepository(repository, isCreate);\r
+                               setRedirect(true);\r
+                               setResponsePage(RepositoriesPage.class);\r
+                       }\r
+               };\r
+               form.add(new TextField<String>("name").setEnabled(isCreate));\r
+               form.add(new TextField<String>("description"));\r
+               form.add(new TextField<String>("owner"));\r
+               form.add(new CheckBox("useTickets"));\r
+               form.add(new CheckBox("useDocs"));\r
+               form.add(new CheckBox("useNamedUsers"));\r
+\r
+               add(form);\r
+       }\r
+}\r
index 45c1bf55d46bb2d71c248cbcef2e59ad9ef4337e..b7dd1a3cb28199e8bf135a6ac57693ff97cafe06 100644 (file)
@@ -1,11 +1,8 @@
 package com.gitblit.wicket.pages;\r
 \r
-import javax.servlet.http.HttpServletRequest;\r
-\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.WebPage;\r
 import org.apache.wicket.markup.html.basic.Label;\r
-import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
@@ -28,11 +25,7 @@ public class PatchPage extends WebPage {
                final String objectId = WicketUtils.getObject(params);\r
                final String blobPath = WicketUtils.getPath(params);\r
 \r
-               ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();\r
-               HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
-               req.getServerName();\r
-\r
-               Repository r = GitBlit.self().getRepository(req, repositoryName);\r
+               Repository r = GitBlit.self().getRepository(repositoryName);\r
                if (r == null) {\r
                        error("Can not load repository " + repositoryName);\r
                        redirectToInterceptPage(new RepositoriesPage());\r
index 4cbf96ca53f52916a289b99eb401c1c1dfd91585..7dd25738abee35fbfb301e1918b0ce4cc7e664fa 100644 (file)
@@ -3,13 +3,10 @@ package com.gitblit.wicket.pages;
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
-import javax.servlet.http.HttpServletRequest;\r
-\r
 import org.apache.wicket.Component;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.WebPage;\r
 import org.apache.wicket.markup.html.basic.Label;\r
-import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
@@ -31,11 +28,7 @@ public class RawPage extends WebPage {
                final String objectId = WicketUtils.getObject(params);\r
                final String blobPath = WicketUtils.getPath(params);\r
 \r
-               ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();\r
-               HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
-               req.getServerName();\r
-\r
-               Repository r = GitBlit.self().getRepository(req, repositoryName);\r
+               Repository r = GitBlit.self().getRepository(repositoryName);\r
                if (r == null) {\r
                        error("Can not load repository " + repositoryName);\r
                        redirectToInterceptPage(new RepositoriesPage());\r
index 798836e00965e3d0e5715a4d8a36033caa3e6bdd..24a344643a564df83ae3d6f1acf0b6673183fc56 100644 (file)
@@ -21,6 +21,7 @@
                        <th wicket:id="orderByDescription"><wicket:message key="gb.description">Description</wicket:message></th>\r
                        <th wicket:id="orderByOwner"><wicket:message key="gb.owner">Owner</wicket:message></th>\r
                        <th wicket:id="orderByDate"><wicket:message key="gb.lastChange">Last Change</wicket:message></th>\r
+                       <th></th>\r
                </tr>\r
                <tbody>\r
                        <tr wicket:id="repository">\r
@@ -28,6 +29,7 @@
                        <td><div class="list" wicket:id="repositoryDescription">[repository description]</div></td>\r
                        <td class="author"><span wicket:id="repositoryOwner">[repository owner]</span></td>\r
                        <td><span wicket:id="repositoryLastChange">[last change]</span></td>\r
+                       <td><a wicket:id="repositoryLinks"><wicket:message key="gb.edit">[edit]</wicket:message></a></td>\r
                        </tr>\r
        </tbody>\r
        </table>\r
index 3ab63667c19d8933c869e0b0556bed0b0b5c4270..4aba988f1f65a2d71abcbf96cedac9f06569b706 100644 (file)
@@ -41,16 +41,16 @@ public class RepositoriesPage extends BasePage {
                super();\r
                setupPage("", "");\r
 \r
-               boolean showAdmin = false;\r
+               final boolean showAdmin;\r
                if (GitBlit.self().settings().getBoolean(Keys.web.authenticateAdminPages, true)) {\r
                        boolean allowAdmin = GitBlit.self().settings().getBoolean(Keys.web.allowAdministration, false);\r
                        showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();\r
                } else {\r
                        showAdmin = GitBlit.self().settings().getBoolean(Keys.web.allowAdministration, false);\r
                }\r
-\r
+               \r
                Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);\r
-               adminLinks.add(new BookmarkablePageLink<Void>("newRepository", RepositoriesPage.class));\r
+               adminLinks.add(new BookmarkablePageLink<Void>("newRepository", EditRepositoryPage.class));\r
                adminLinks.add(new BookmarkablePageLink<Void>("newUser", RepositoriesPage.class));\r
                add(adminLinks.setVisible(showAdmin));\r
 \r
@@ -101,7 +101,7 @@ public class RepositoriesPage extends BasePage {
                }\r
                add(repositoriesMessage);\r
 \r
-               List<RepositoryModel> rows = GitBlit.self().getRepositories(getRequest());\r
+               List<RepositoryModel> rows = GitBlit.self().getRepositories();\r
                DataProvider dp = new DataProvider(rows);\r
                DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repository", dp) {\r
                        private static final long serialVersionUID = 1L;\r
@@ -119,6 +119,8 @@ public class RepositoriesPage extends BasePage {
                                item.add(lastChangeLabel);\r
                                WicketUtils.setCssClass(lastChangeLabel, TimeUtils.timeAgoCss(entry.lastChange));\r
 \r
+                               item.add(new BookmarkablePageLink<Void>("repositoryLinks", EditRepositoryPage.class, WicketUtils.newRepositoryParameter(entry.name)).setVisible(showAdmin));\r
+                               \r
                                WicketUtils.setAlternatingBackground(item, counter);\r
                                counter++;\r
                        }\r
index b20dc64395785b8fb5cc7ca98118b94ce80a1932..3d4a6ef86a79fff1aea8d7f73744737c20f95924 100644 (file)
@@ -9,7 +9,6 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.image.ContextImage;\r
 import org.eclipse.jgit.lib.Repository;\r
-\r
 import org.wicketstuff.googlecharts.AbstractChartData;\r
 import org.wicketstuff.googlecharts.Chart;\r
 import org.wicketstuff.googlecharts.ChartAxis;\r
@@ -20,6 +19,7 @@ import org.wicketstuff.googlecharts.IChartData;
 import org.wicketstuff.googlecharts.LineStyle;\r
 import org.wicketstuff.googlecharts.MarkerType;\r
 import org.wicketstuff.googlecharts.ShapeMarker;\r
+\r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
@@ -83,7 +83,7 @@ public class SummaryPage extends RepositoryPage {
        }\r
 \r
        private void insertActivityGraph(List<Metric> metrics) {\r
-               if (GitBlit.self().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
+               if (metrics.size() > 0 && GitBlit.self().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
                        IChartData data = getChartData(metrics);\r
 \r
                        ChartProvider provider = new ChartProvider(new Dimension(400, 100), ChartType.LINE, data);\r
@@ -96,7 +96,7 @@ public class SummaryPage extends RepositoryPage {
                        provider.addAxis(commitAxis);\r
 \r
                        provider.setLineStyles(new LineStyle[] {new LineStyle(2, 4, 0), new LineStyle(0, 4, 1)});       \r
-                       provider.addShapeMarker(new ShapeMarker(MarkerType.DIAMOND, Color.BLUE, 1, -1, 5));\r
+                       provider.addShapeMarker(new ShapeMarker(MarkerType.CIRCLE, Color.BLUE, 1, -1, 5));\r
                        \r
                        add(new Chart("commitsChart", provider));\r
                } else {\r
index 2177761e28cfd0a98147a157a521e69a6b9f98cc..e29ba421fc6553a03d9b1da2bfc47c000bf7cd51 100644 (file)
@@ -33,10 +33,10 @@ public class TreePage extends RepositoryPage {
                List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);\r
 \r
                // tree page links\r
-               add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, commit.getName(), path)));\r
+               add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)));\r
                add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));\r
 \r
-               add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));\r
+               add(new LinkPanel("shortlog", "title", commit == null ? "" : commit.getShortMessage(), CommitPage.class, newCommitParameter()));\r
 \r
                // breadcrumbs\r
                add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
index 1ed1b58395827b56eb7553261a587a05954113e9..3fa2262ee9ef88d34713189b21661e517856b5e9 100644 (file)
@@ -17,7 +17,7 @@
                <tbody>\r
                        <tr wicket:id="commit">\r
                        <td class="date"><span wicket:id="commitDate">[commit date]</span></td>\r
-                       <td><img wicket:id="commitIcon" /></td>\r
+                       <td class="icon"><img wicket:id="commitIcon" /></td>\r
                        <td class="author"><span wicket:id="commitAuthor">[commit author]</span></td>\r
                        <td><div class="references" wicket:id="commitRefs">[commit refs]</div><span wicket:id="commitShortMessage">[commit short message]</span></td>\r
                        <td class="rightAlign">\r
index da2699898976bcded93c7bbda5415e801aa6a7d3..f8592133719c4085639af60fb798e87cd178b0ad 100644 (file)
@@ -78,7 +78,7 @@ public class HistoryPanel extends BasePanel {
                if (pageResults) {\r
                        // history page\r
                        // show commit page link\r
-                       add(new LinkPanel("header", "title", commit.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, commit.getName())));\r
+                       add(new LinkPanel("header", "title", commit == null ? "" : commit.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));\r
                } else {\r
                        // summary page\r
                        // show history page link\r
@@ -104,7 +104,7 @@ public class HistoryPanel extends BasePanel {
                                LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author, SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, author, SearchType.AUTHOR));\r
                                setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR);\r
                                item.add(authorLink);\r
-                               \r
+\r
                                // merge icon\r
                                if (entry.getParentCount() > 1) {\r
                                        item.add(new ContextImage("commitIcon", "/com/gitblit/wicket/resources/commit_merge_16x16.png"));\r
index 1a6f6f43da41fc9e68d13915adbc41283ab27182..1ca92851a5db49123f34aa899a175576167bba00 100644 (file)
@@ -15,7 +15,7 @@
                        <tr wicket:id="commit">\r
                        <td class="date"><span wicket:id="commitDate">[commit date]</span></td>\r
                        <td class="author"><span wicket:id="commitAuthor">[commit author]</span></td>\r
-                       <td><img wicket:id="commitIcon" /></td>\r
+                       <td class="icon"><img wicket:id="commitIcon" /></td>\r
                        <td><div class="references" wicket:id="commitRefs">[commit refs]</div><span wicket:id="commitShortMessage">[commit short message]</span></td>\r
                        <td class="rightAlign">\r
                                <span class="link">\r
index f8994b9d00336654bbf7f88de775f10a31c66e80..7c8f96f235710fa60166d8f990a6491ce4a823b4 100644 (file)
@@ -15,7 +15,7 @@
                        <tr wicket:id="commit">\r
                        <td class="date"><span wicket:id="commitDate">[commit date]</span></td>\r
                        <td class="author"><span wicket:id="commitAuthor">[commit author]</span></td>\r
-                       <td><img wicket:id="commitIcon" /></td>\r
+                       <td class="icon"><img wicket:id="commitIcon" /></td>\r
                        <td><div class="references" wicket:id="commitRefs">[commit refs]</div><span wicket:id="commitShortMessage">[commit short message]</span></td>\r
                        <td class="rightAlign">\r
                                <span class="link">\r
index 315d47607f52e2e3cab9c91d92e06950de040e05..c7e038d3feed072aab9ac585ca73080d5a849d19 100644 (file)
@@ -16,8 +16,8 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
index 09019cf8b18318be30e393808dc1dc982c5d151d..9f98504dfff5791df426aa88e60ad30528f5111f 100644 (file)
@@ -12,8 +12,9 @@
        <table class="pretty">\r
                <tbody>\r
                <tr wicket:id="tag">\r
-                       <td class="date"><span wicket:id="tagDate">[tag date]</span></td>\r
+                       <td class="date"><span wicket:id="tagDate">[tag date]</span></td>                       \r
                        <td><b><span wicket:id="tagName">[tag name]</span></b></td>\r
+                       <td class="icon"><img wicket:id="tagIcon" /></td>\r
                        <td><span wicket:id="tagDescription">[tag description]</span></td>\r
                        <td class="rightAlign">\r
                                <span wicket:id="tagLinks"></span>\r
index 01616689c02d051018f322c8aecda9842ac66599..40871b1fa0fb4dad629c7e6d0fd596bcb4ab52a6 100644 (file)
@@ -3,6 +3,7 @@ package com.gitblit.wicket.panels;
 import java.util.List;\r
 \r
 import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.image.ContextImage;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.markup.repeater.Item;\r
@@ -51,6 +52,13 @@ public class TagsPanel extends BasePanel {
 \r
                                item.add(WicketUtils.createDateLabel("tagDate", entry.getDate(), getTimeZone()));\r
 \r
+                               // tag icon\r
+                               if (entry.isAnnotatedTag()) {\r
+                                       item.add(new ContextImage("tagIcon", "/com/gitblit/wicket/resources/tag_16x16.png"));\r
+                               } else {\r
+                                       item.add(new ContextImage("tagIcon", "/com/gitblit/wicket/resources/blank.png"));\r
+                               }\r
+                               \r
                                item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getCommitId().getName())));\r
                                String message;\r
                                if (maxCount > 0) {\r
index fa78cec85d0653f0b8ebce7540eaf71403b08a35..451915a9c510c8514ab5cb848b2c5b149e5f3e0d 100644 (file)
@@ -196,14 +196,14 @@ div.commit_message {
 \r
 div.bug_open, span.bug_open {\r
        padding: 2px;\r
-       background-color: #800000;\r
+       background-color: #803333;\r
        color: white;   \r
        text-align: center;\r
 }\r
 \r
 div.bug_resolved, span.bug_resolved {\r
        padding: 2px;\r
-       background-color: #008000;\r
+       background-color: #408040;\r
        color: white;\r
        text-align: center;\r
 }\r
@@ -426,6 +426,16 @@ table.pretty, table.repositories, table.comments {
 table.pretty, table.comments, table.repositories {\r
        width:100%;\r
 }\r
+\r
+table.pretty td.icon {\r
+       padding: 0px;\r
+       width: 20px;\r
+}\r
+\r
+table.pretty td.icon img {\r
+       vertical-align: top;\r
+}\r
+\r
 table.pretty td {\r
        padding: 2px 4px;\r
 }\r
diff --git a/src/com/gitblit/wicket/resources/tag_16x16.png b/src/com/gitblit/wicket/resources/tag_16x16.png
new file mode 100644 (file)
index 0000000..7e75cba
Binary files /dev/null and b/src/com/gitblit/wicket/resources/tag_16x16.png differ