Introduce "one click edition" feature.

Now that the documentation has been moved to github
we can add a link above each documentation page that
allows people to directly edit the page on github. When
the page is saved, github automatically creates a new
pull request with the changes.

We should wait that googlebot is configured for our
documentation repository before to merge this change.

Change-Id: I4d20932d4ec05e86b65d25a71c0c51ac03a39e76
diff --git a/src/main/java/com/google/gwt/site/markdown/MDTranslater.java b/src/main/java/com/google/gwt/site/markdown/MDTranslater.java
index 4d2b429..088fdd0 100644
--- a/src/main/java/com/google/gwt/site/markdown/MDTranslater.java
+++ b/src/main/java/com/google/gwt/site/markdown/MDTranslater.java
@@ -74,19 +74,35 @@
           adjustRelativePath(template, relativePath),
           htmlMarkDown,
           adjustRelativePath(toc, relativePath),
-          adjustRelativePath(head, relativePath));
+          adjustRelativePath(head, relativePath),
+          getEditUrl(node.getPath()));
 
       writer.writeHTML(node, html);
     }
 
   }
 
+  private String getEditUrl(String path) {
+    // TODO you should support more than one template
+    if (path.endsWith("markdown/index.md")) {
+      return "";
+    }
+
+    int index = path.indexOf("/src/");
+    return  "<a href=\"https://github.com/gwtproject/gwt-site/edit/master/" + path.substring(index + 1) + "\">Edit Me on " +
+        "github!</a>";
+  }
+
   private String createHeadForNode(MDNode node) {
     return "<link href='css/main.css' rel='stylesheet' type='text/css'>";
   }
 
-  private String fillTemplate(String template, String html, String toc, String head) {
-    return template.replace("$content", html).replace("$toc", toc).replace("$head", head);
+  private String fillTemplate(String template, String html, String toc, String head, String editUrl) {
+    return template
+        .replace("$content", html)
+        .replace("$toc", toc)
+        .replace("$head", head)
+        .replace("$editLink", editUrl);
   }
 
   protected String adjustRelativePath(String html, String relativePath) {
diff --git a/src/main/resources/main.tpl b/src/main/resources/main.tpl
index c227174..62702c0 100644
--- a/src/main/resources/main.tpl
+++ b/src/main/resources/main.tpl
@@ -35,7 +35,6 @@
     <title>GWT Project</title>
   </head>
   <body>
-
 <div id="gwt-header1">
   <div class="gwt-wrap">
     <div class="first"></div>
@@ -73,6 +72,7 @@
     $toc
   </div>
   <div id="gwt-content">
+    <div id="editLink">$editLink</div>
     <div>
     $content
     </div>
diff --git a/src/main/site/css/main.css b/src/main/site/css/main.css
index a232d34..5e55b03 100644
--- a/src/main/site/css/main.css
+++ b/src/main/site/css/main.css
@@ -269,7 +269,7 @@
 }
 
 /* markdown table */
-thead th, tbody td {
+#gwt-content thead th, #gwt-content tbody td {
   padding: 6px 13px;
   border: 1px solid rgb(255, 255, 255);
 }
@@ -826,6 +826,21 @@
    transition: all 0.4s linear;
 }
 
+#editLink {
+  margin-bottom: 15px;
+  width: 100%;
+}
+
+#editLink > a {
+  background: rgb(245, 88, 55);
+  padding: 0.5em;
+  color: white;
+  border-radius: 2px;
+  border: 1px solid rgb(229, 72, 39);
+  float: right;
+  margin-bottom: 15px;
+}
+
 /* tablet */
 @media screen and (max-width: 1024px) {
   .gwt-wrap {