Commit a2812d933a51c65979720163b096c0cc5ecbb962

Thomas de Grivel 2022-01-26T15:41:30

document git installation

diff --git a/lib/kmxgit_web/controllers/page_controller.ex b/lib/kmxgit_web/controllers/page_controller.ex
index 0e2a080..ca7dec7 100644
--- a/lib/kmxgit_web/controllers/page_controller.ex
+++ b/lib/kmxgit_web/controllers/page_controller.ex
@@ -20,7 +20,12 @@ defmodule KmxgitWeb.PageController do
     conn
     |> put_resp_content_type("text/text")
     |> resp(200, a)
-  end    
+  end
+
+  def doc_git_install(conn, _) do
+    conn
+    |> render(:doc_git_install)
+  end
 
   def du_ks(path) do
     {out, status} = System.cmd("du", ["-ks", path], stderr_to_stdout: true)
diff --git a/lib/kmxgit_web/router.ex b/lib/kmxgit_web/router.ex
index 7a3c3e9..158c667 100644
--- a/lib/kmxgit_web/router.ex
+++ b/lib/kmxgit_web/router.ex
@@ -47,7 +47,13 @@ defmodule KmxgitWeb.Router do
     post   "/_confirm/:token", UserConfirmationController, :update
 
     get "/_avatar/:login/:size/avatar.png", UserController, :avatar
-  end
+
+    scope "/_doc" do
+      scope "/git" do
+        get "/install", PageController, :doc_git_install
+      end
+    end
+end
 
     ## Authentication routes
 
diff --git a/lib/kmxgit_web/templates/page/doc_git_install.html.heex b/lib/kmxgit_web/templates/page/doc_git_install.html.heex
new file mode 100644
index 0000000..95a614d
--- /dev/null
+++ b/lib/kmxgit_web/templates/page/doc_git_install.html.heex
@@ -0,0 +1,40 @@
+<div class="container-fluid">
+  <h1><%= gettext "Git installation documentation" %></h1>
+  <h2>1. <%= gettext "Install git" %></h2>
+  <p>
+    <%= gettext "Options" %> :
+    <ol>
+      <li>apt (Debian, Ubuntu)</li>
+      <li>homebrew (Linux, Mac)</li>
+      <li>pkg (OpenBSD)</li>
+      <li><%= gettext "sources" %></li>
+      <li><%= gettext "binaries" %> (Linux, Mac, Windows)</li>
+    </ol>
+  </p>
+  <h3><a href="#using-apt" id="using-apt">1.1 <%= gettext "Install git using apt" %> (Debian, Ubuntu)</a></h3>
+  <pre><code>$ sudo apt install git</code></pre>
+
+  <h3><a href="#using-homebrew" id="using-homebrew">1.2 <%= gettext "Install git using brew" %> (Linux, Mac)</a></h3>
+  <pre><code>$ brew install git</code></pre>
+
+  <h3><a href="#using-pkg" id="using-pkg">1.3 <%= gettext "Install git using pkg" %> (OpenBSD)</a></h3>
+  <pre><code>$ doas pkg_add git</code></pre>
+
+  <h3><a href="#using-sources" id="using-sources">1.4 <%= gettext "Install git from sources" %></a></h3>
+  <%= gettext "Download sources from" %> <a href="https://github.com/git/git/tags" target="_blank">https://github.com/git/git/tags</a>
+
+  <pre><code>$ tar xzf git-*.tar.gz
+$ cd git-*
+$ make
+$ sudo make install</code></pre>
+
+  <h3><a href="#using-binaries" id="using-binaries">1.5 <%= gettext "Install git from binaries" %> (Linux, Mac, Windows)</a></h3>
+  <p>
+    <%= gettext "Please see" %> <a href="https://git-scm.com/downloads" target="_blank">https://git-scm.com/downloads</a>.
+  </p>
+
+  <h2><%= link gettext("Links"), to: "#links", id: "links" %></h2>
+  <%= render("git_links.html", assigns) %>
+</div>
+
+<br/>
diff --git a/lib/kmxgit_web/templates/page/git_links.html.heex b/lib/kmxgit_web/templates/page/git_links.html.heex
new file mode 100644
index 0000000..c977d2f
--- /dev/null
+++ b/lib/kmxgit_web/templates/page/git_links.html.heex
@@ -0,0 +1,7 @@
+<p>
+  <%= gettext("If you need more help with git, please see :") %>
+  <ul>
+    <li><a href="https://git-scm.com/doc"><%= gettext("the official git documentation") %></a></li>
+    <li><a href="https://stackoverflow.com/questions/tagged/git"><%= gettext("StackOverflow about git") %></a></li>
+  </ul>
+</p>
diff --git a/lib/kmxgit_web/templates/page/index.html.heex b/lib/kmxgit_web/templates/page/index.html.heex
index 6784f78..f6a1578 100644
--- a/lib/kmxgit_web/templates/page/index.html.heex
+++ b/lib/kmxgit_web/templates/page/index.html.heex
@@ -19,6 +19,9 @@
       <pre><%= render("ssh_keys_fingerprint.txt") %></pre>
 
       <h3><%= link gettext("Help"), to: "#help", id: "help" %></h3>
+      <p>
+        <%= link gettext("Install git"), to: Routes.page_path(@conn, :doc_git_install) %>
+      </p>
       <div class="highlight">
         <pre><code><span class="c1"># <%= gettext "Clone repository user/path/to/repo if repo does not exist" %> :</span>
 git clone <b><%= @git_ssh_url %>:user/path/to/repo.git</b>