]> source.dussan.org Git - gitblit.git/commitdiff
Use markdown for welcome message. Simplify login page appearance.
authorJames Moger <james.moger@gitblit.com>
Fri, 22 Apr 2011 01:46:47 +0000 (21:46 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 22 Apr 2011 01:46:47 +0000 (21:46 -0400)
gitblit.properties
src/com/gitblit/wicket/LoginPage.html
src/com/gitblit/wicket/pages/RepositoriesPage.html
src/com/gitblit/wicket/pages/RepositoriesPage.java
src/com/gitblit/wicket/resources/welcome.mkd [new file with mode: 0644]

index 48515a15880430bd6d79b0ea898ebf6cb7a042c1..427a9d527ee4b5d3bbe669e8948d440396218c99 100644 (file)
@@ -47,8 +47,9 @@ web.siteName =
 web.allowAdministration = true\r
 \r
 # This is the message display above the repositories table.\r
-# This can point to a file with HTML content.\r
-web.repositoriesMessage = Welcome to Git:Blit!<br>A quick and easy way to host your own Git repositories.<br>Built with <a href="http://eclipse.org/jgit">JGit</a>, <a href="http://wicket.apache.org">Wicket</a>, <a href="http://https://github.com/wicketstuff/core/wiki/GoogleCharts">WicketStuff googlecharts</a>, <a href="http://markdown.tautua.org">MarkdownPapers</a>, <a href="http://eclipse.org/jetty">Jetty</a>, <a href="http://www.slf4j.org">SLF4J</a>, <a href="http://logging.apache.org/log4j">Log4j</a>, <a href="http://code.google.com/p/google-code-prettify/">google-code-prettify</a>, and <a href="http://jcommander.org">JCommander</a>.\r
+# This can point to a file with Markdown content.\r
+# specifying "gitblit" uses the internal welcome message.\r
+web.repositoriesMessage = gitblit\r
 \r
 # Use the client timezone when formatting dates.\r
 # This uses AJAX to determine the browser's timezone and enables Wicket \r
index 41e2a267dd747834dbc3e8c08ae1f520b099d67a..f38e01ddff56ec5e9a47b0927ce24c22b53e1392 100644 (file)
        \r
        <body onload="document.getElementById('username').focus();">\r
                <div>\r
-                       <div style="text-align:center;">\r
+                       <div style="padding-top: 10px;text-align:center;">\r
                                <wicket:link>\r
-                                       <img src="resources/gitblt2.png" alt="Git:Blit"/><br/>\r
+                                       <img src="resources/gitblt_25.png" alt="Git:Blit"/><br/>\r
                                </wicket:link>\r
-                               <span style="font-weight:bold;" wicket:id="name">[name]</span><br/>\r
+                               <div style="padding-top:30px;font-weight:bold;" wicket:id="name">[name]</div>\r
                        </div>\r
 \r
                        <form style="text-align:center;" wicket:id="loginForm">\r
index 9bcb9b802e32e20215212e9cb6e0ab57cd9d667a..798836e00965e3d0e5715a4d8a36033caa3e6bdd 100644 (file)
@@ -3,12 +3,17 @@
       xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
       xml:lang="en"  \r
       lang="en"> \r
+<wicket:head>\r
+  <wicket:link>\r
+       <link href="/com/gitblit/wicket/resources/markdown.css" type="text/css" rel="stylesheet" />\r
+  </wicket:link>\r
+</wicket:head>\r
 \r
 <body>\r
 <wicket:extend>\r
        <div wicket:id="adminPanel">[admin links]</div>\r
        \r
-       <div class="repositories_message" wicket:id="repositoriesMessage">[repositories message]</div>\r
+       <div class="markdown" wicket:id="repositoriesMessage">[repositories message]</div>\r
                \r
        <table class="repositories">\r
                <tr>\r
index a0f7299f59bf347d4c3fa8fff7b9ab5e9b98ceae..3ab63667c19d8933c869e0b0556bed0b0b5c4270 100644 (file)
@@ -1,10 +1,16 @@
 package com.gitblit.wicket.pages;\r
 \r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+import java.io.StringWriter;\r
 import java.util.Collections;\r
 import java.util.Comparator;\r
 import java.util.Iterator;\r
 import java.util.List;\r
 \r
+import org.apache.wicket.Component;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;\r
 import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;\r
@@ -16,9 +22,12 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.model.IModel;\r
 import org.apache.wicket.model.Model;\r
+import org.apache.wicket.resource.ContextRelativeResource;\r
+import org.tautua.markdownpapers.Markdown;\r
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.TimeUtils;\r
 import com.gitblit.wicket.BasePage;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
@@ -45,7 +54,52 @@ public class RepositoriesPage extends BasePage {
                adminLinks.add(new BookmarkablePageLink<Void>("newUser", RepositoriesPage.class));\r
                add(adminLinks.setVisible(showAdmin));\r
 \r
-               add(new Label("repositoriesMessage", GitBlit.self().settings().getString(Keys.web.repositoriesMessage, "")).setEscapeModelStrings(false));\r
+               // Load the markdown welcome message\r
+               String messageSource = GitBlit.self().settings().getString(Keys.web.repositoriesMessage, "gitblit");\r
+               String message = "";\r
+               if (messageSource.equalsIgnoreCase("gitblit")) {\r
+                       // Read default welcome message\r
+                       try {\r
+                               ContextRelativeResource res = new ContextRelativeResource("/com/gitblit/wicket/resources/welcome.mkd");\r
+                               InputStream is = res.getResourceStream().getInputStream();\r
+                               InputStreamReader reader = new InputStreamReader(is);\r
+                               StringWriter writer = new StringWriter();\r
+                               Markdown markdown = new Markdown();\r
+                               markdown.transform(reader, writer);\r
+                               message = writer.toString().trim();\r
+                               reader.close();\r
+                               writer.close();\r
+                       } catch (Throwable t) {\r
+                               message = "Failed to read default welcome message!";\r
+                               error(message, t);\r
+                       }\r
+               } else {\r
+                       // Read user-supplied welcome message\r
+                       if (!StringUtils.isEmpty(messageSource)) {\r
+                               File file = new File(messageSource);\r
+                               if (file.exists()) {\r
+                                       try {\r
+                                               FileReader reader = new FileReader(file);\r
+                                               StringWriter writer = new StringWriter();\r
+                                               Markdown markdown = new Markdown();\r
+                                               markdown.transform(reader, writer);\r
+                                               message = writer.toString().trim();\r
+                                               reader.close();\r
+                                               writer.close();\r
+                                       } catch (Throwable t) {\r
+                                               message = "Failed to read " + file;\r
+                                               error(message, t);\r
+                                       }\r
+                               } else {\r
+                                       message = messageSource + " is not a valid file.";\r
+                               }\r
+                       }\r
+               }\r
+               Component repositoriesMessage = new Label("repositoriesMessage", message).setEscapeModelStrings(false);\r
+               if (!showAdmin) {\r
+                       WicketUtils.setCssStyle(repositoriesMessage, "padding-top:10px");\r
+               }\r
+               add(repositoriesMessage);\r
 \r
                List<RepositoryModel> rows = GitBlit.self().getRepositories(getRequest());\r
                DataProvider dp = new DataProvider(rows);\r
diff --git a/src/com/gitblit/wicket/resources/welcome.mkd b/src/com/gitblit/wicket/resources/welcome.mkd
new file mode 100644 (file)
index 0000000..a38cbb5
--- /dev/null
@@ -0,0 +1,5 @@
+## Welcome to Git:Blit ##\r
+\r
+A quick and easy way to host your own Git repositories.\r
+\r
+Built with [JGit](http://eclipse.org/jgit) [Wicket](http://wicket.apache.org) [WicketStuff GoogleCharts](https://github.com/wicketstuff/core/wiki/GoogleCharts) [MarkdownPapers](http://markdown.tautua.org) [Jetty](http://eclipse.org/jetty) [SLF4J](http://www.slf4j.org) [Log4j](http://logging.apache.org/log4j) [google-code-prettify](http://code.google.com/p/google-code-prettify) [JCommander](http://jcommander.org)
\ No newline at end of file