From 47a7628bc60467936cd9debc572e6f45edaf9343 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Fri, 3 Feb 2017 13:10:13 +0100
Subject: [PATCH] [web] Added img shortcode and enabled git-lfs for images in
 web/

---
 .gitattributes                                 |  2 ++
 netlify.toml                                   |  2 +-
 web/README.md                                  | 18 ++++++++++++++++++
 .../elliptic/groundwater-flow-neumann.md       | 14 +++++++-------
 .../elliptic/square_1e2_neumann_gradients.png  |  3 +++
 web/layouts/shortcodes/img.html                | 18 ++++++++++++++++++
 6 files changed, 49 insertions(+), 8 deletions(-)
 create mode 100644 web/content/docs/benchmarks/elliptic/square_1e2_neumann_gradients.png
 create mode 100644 web/layouts/shortcodes/img.html

diff --git a/.gitattributes b/.gitattributes
index c6a8b8ce401..65b95d33415 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,3 +2,5 @@
 *.h   hooks.style=uncrustify
 *.cpp hooks.style=uncrustify
 *.hpp hooks.style=uncrustify
+web/**/*.jpg filter=lfs diff=lfs merge=lfs -text
+web/**/*.png filter=lfs diff=lfs merge=lfs -text
diff --git a/netlify.toml b/netlify.toml
index 8fef81d5b13..4cf8253669b 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -2,4 +2,4 @@
 [build]
   base    = "web"
   publish = "web/public"
-  command = "npm run import && npm run build:release"
+  command = "git lfs fetch && npm run import && npm run build:release"
diff --git a/web/README.md b/web/README.md
index f0daae83528..97305b92acf 100644
--- a/web/README.md
+++ b/web/README.md
@@ -32,6 +32,24 @@ Test by locally serving via [Caddy](https://caddyserver.com):
 - [webpack](https://webpack.github.io/) - Packaging JavaScript
 - [gulp](http://gulpjs.com/) - Automation toolkit
 
+## How-Tos
+
+### Images
+
+Use shortcode `img`:
+
+```
+{{< img src="../square_1e2_neumann_gradients.png" >}}
+```
+
+`src` can be absolute (by preceding with `/`) or relative. The relative path starts at your current URL. If your image is in the same directory as your `.md`-file you have to prefix your path with `../` as in the example above.
+
+Optional parameters:
+
+- `title` - Image caption
+- `class` - CSS class
+- `alt` - Alt text
+
 ## Dump
 
 ### Serve converted meshes with S3
diff --git a/web/content/docs/benchmarks/elliptic/groundwater-flow-neumann.md b/web/content/docs/benchmarks/elliptic/groundwater-flow-neumann.md
index e7d6e81033a..2e7118251e0 100644
--- a/web/content/docs/benchmarks/elliptic/groundwater-flow-neumann.md
+++ b/web/content/docs/benchmarks/elliptic/groundwater-flow-neumann.md
@@ -6,8 +6,6 @@ title = "Groundwater flow (Neumann)"
 
 ## Equations
 
-{{< vis url="square_1e4_pcs_0_ts_1_t_1.000000.vtu" >}}
-
 We start with simple linear homogeneous elliptic problem:
 $$
 \begin{equation}
@@ -23,8 +21,6 @@ where $h$ could be hydraulic head, the subscripts $D$ and $N$ denote the Dirichl
 
 ## Problem specification and analytical solution
 
-{{< vis url="cow.vtp" height="300" >}}
-
 We solve the Laplace equation on a square domain $[0\times 1]^2$ with $k = 1$ w.r.t. the specific boundary conditions:
 
 $$
@@ -112,13 +108,17 @@ A last major part of the output was produced by the linear equation solver (LIS
 The result, written in the `square_1e2_neumann.vtu`, can be visualized with Paraview, for example.
 
 Loading the `.vtu` file in Paraview will show following image:
-{asset:373:img}
+
+{{< vis url="square_1e4_pcs_0_ts_1_t_1.000000.vtu" >}}
 
 Compared to the analytical solution presented above the results are very good but in a single point:
-{asset:374:img}
+
+{{< vis url="cow.vtp" height="300" >}}
 
 Both Dirichlet boundary conditions are satisfied.
 The values of gradients in x direction along the right side and y directions along the top sides of the domain a shown below:
-{asset:375:img}
+
+{{< img src="../square_1e2_neumann_gradients.png" >}}
+
 The homogeneous Neumann boundary condition on the top side is satisfied (ScalarGradient_Y is close to zero).
 The inhomogeneous Neumann boundary condition on the bottom is satisfied only for $y > 0.3$ (where the ScalarGradient_X is close to one) because of incompatible boundary conditions imposed on the bottom right corner of the domain.
diff --git a/web/content/docs/benchmarks/elliptic/square_1e2_neumann_gradients.png b/web/content/docs/benchmarks/elliptic/square_1e2_neumann_gradients.png
new file mode 100644
index 00000000000..0d18cd3ae9d
--- /dev/null
+++ b/web/content/docs/benchmarks/elliptic/square_1e2_neumann_gradients.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:385843adaac40456eb8c3d8a8c1bc9581937ec2e2b966452b2e4079a57ada7c9
+size 19113
diff --git a/web/layouts/shortcodes/img.html b/web/layouts/shortcodes/img.html
new file mode 100644
index 00000000000..78905f1182a
--- /dev/null
+++ b/web/layouts/shortcodes/img.html
@@ -0,0 +1,18 @@
+<!-- img -->
+<figure class="img-responsive{{ with .Get "class" }} {{.}}{{ end }}">
+    {{ with .Get "link"}}<a href="{{.}}">{{ end }}
+        <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
+    {{ if .Get "link"}}</a>{{ end }}
+    {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
+    <figcaption>{{ if isset .Params "title" }}
+        <h4>{{ .Get "title" }}</h4>{{ end }}
+        {{ if or (.Get "caption") (.Get "attr")}}<p>
+        {{ .Get "caption" }}
+        {{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
+            {{ .Get "attr" }}
+        {{ if .Get "attrlink"}}</a> {{ end }}
+        </p> {{ end }}
+    </figcaption>
+    {{ end }}
+</figure>
+<!-- img -->
-- 
GitLab