hugo-soresu

My fork of hugo-xmin

git clone git://git.shimmy1996.com/hugo-soresu.git
commit 0e1827821c79c9c52ffab00ce424320153149b1c
parent e98ffee2be26daf61313e452c25a43b04cbaebd2
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Sat, 17 Feb 2018 22:30:22 -0600

Decouple formatting from blog.

Diffstat:
Mlayouts/_default/list.html | 38+++++++++++++++++++++++++++++---------
Mlayouts/_default/single.html | 12+++++++++++-
Mlayouts/_default/terms.html | 13++++++++++---
Alayouts/partials/comment.html | 20++++++++++++++++++++
Alayouts/partials/foot_custom.html | 9+++++++++
Alayouts/partials/head_custom.html | 18++++++++++++++++++
Mlayouts/partials/header.html | 2+-
Alayouts/partials/navi_custom.html | 8++++++++
Astatic/css/isso.css | 230+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mstatic/css/style.css | 5++---
Astatic/js/math-code.js | 20++++++++++++++++++++
11 files changed, 358 insertions(+), 17 deletions(-)
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
@@ -1,18 +1,38 @@
 {{ partial "header.html" . }}
 
 {{if not .IsHome }}
-<h1>{{ .Title }}</h1>
+  {{$title := i18n (lower .Title)}}
+  {{ if eq $title ""}}
+    <h1>{{ .Title }}</h1>
+  {{ else }}
+    <h1>{{ $title }}</h1>
+  {{ end }}
 {{ end }}
 
 {{ .Content }}
 
-<ul>
-  {{ range (where .Data.Pages "Section" "!=" "") }}
-  <li>
-    <span class="date">{{ .Date.Format "2006/01/02" }}</span>
-    <a href="{{ .URL }}">{{ .Title }}</a>
-  </li>
-  {{ end }}
-</ul>
+{{if not .IsHome }}
+  <ul>
+    {{ range (where .Data.Pages "Section" "!=" "") }}
+    <li>
+      <span class="date">{{ .Date.Format "2006/01/02" }}</span>
+      <a href="{{ .URL }}">{{ .Title }}</a>
+      <br>
+      {{.Description}}
+    </li>
+    {{ end }}
+  </ul>
+{{else}}
+  <ul>
+    {{ range first 5 (where .Data.Pages "Section" "!=" "") }}
+    <li>
+      <span class="date">{{ .Date.Format "2006/01/02" }}</span>
+      <a href="{{ .URL }}">{{ .Title }}</a>
+      <br>
+      {{ .Description }}
+    </li>
+    {{ end }}
+  </ul>
+{{ end }}
 
 {{ partial "footer.html" . }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
@@ -2,11 +2,21 @@
 <div class="article-meta">
 <h1><span class="title">{{ .Title }}</span></h1>
 {{ with .Params.author }}<h2 class="author">{{ . }}</h2>{{ end }}
-{{ if .Params.date }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end }}
+{{ if (lt 0 .Params.date) }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end }}
+<p class="terms">
+  {{ range $i := (slice "categories" "tags") }}
+  {{ with ($.Param $i) }}
+  {{ i18n (lower ($i | title)) }} | {{ range $k := . }}<a href="{{ relURL (print "/" $.Site.Language.Lang "/" $i "/" $k | urlize) }}">{{i18n $k}} </a> | {{ end }}
+  <br />
+  {{ end }}
+  {{ end }}
+</p>
 </div>
 
 <main>
 {{ .Content }}
 </main>
 
+<!-- Enable Comments -->
+{{ partial "comment.html" . }}
 {{ partial "footer.html" . }}
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
@@ -1,12 +1,19 @@
 {{ partial "header.html" . }}
 
-<h1>{{ .Title }}</h1>
+{{$title := i18n .Title}}
+{{ if eq $title ""}}
+  <h1>{{ .Title }}</h1>
+{{ else }}
+  <h1>{{ $title }}</h1>
+{{ end }}
+
+{{ .Content }}
 
 <ul class="terms">
   {{ range $key, $value := .Data.Terms }}
   <li>
-    <a href="{{ (print "/" $.Data.Plural "/" $key | urlize) | relURL }}">
-      {{ $key }}
+    <a href="{{ (print "/" $.Site.Language.Lang "/" $.Data.Plural "/" $key | urlize) | relURL }}">
+      {{ i18n $key }}
     </a>
     ({{ len $value }})
   </li>
diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html
@@ -0,0 +1,20 @@
+<!-- Sperate from main body -->
+<hr />
+
+<!-- Isso support -->
+<script data-isso="/isso/"
+        data-isso-css="false"
+        data-isso-lang={{ .Site.Language }}
+        data-isso-reply-to-self="false"
+        data-isso-require-author="true"
+        data-isso-require-email="true"
+        data-isso-max-comments-top="10"
+        data-isso-max-comments-nested="5"
+        data-isso-reveal-on-click="5"
+        data-isso-avatar="true"
+        data-isso-avatar-bg="#ffffff"
+        data-isso-avatar-fg="#710100"
+        data-isso-vote="false"
+        data-vote-levels=""
+        src="/isso/js/embed.min.js"></script>
+<section id="isso-thread"></section>
diff --git a/layouts/partials/foot_custom.html b/layouts/partials/foot_custom.html
@@ -0,0 +1,9 @@
+<!-- MathJax Support -->
+<script src="/js/math-code.js"></script>
+<script async src="/MathJax/MathJax.js?config=TeX-MML-AM_CHTML"></script>
+
+<!-- Translated footer -->
+{{ with i18n "footer" }}
+    <hr/>
+    {{ . | markdownify }}
+{{ end }}
diff --git a/layouts/partials/head_custom.html b/layouts/partials/head_custom.html
@@ -0,0 +1,18 @@
+<!-- Favicon Settings -->
+<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=PY4lvMYpEv">
+<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=PY4lvMYpEv">
+<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=PY4lvMYpEv">
+<link rel="manifest" href="/site.webmanifest?v=PY4lvMYpEv">
+<link rel="mask-icon" href="/safari-pinned-tab.svg?v=PY4lvMYpEv" color="#700000">
+<link rel="shortcut icon" href="/favicon.ico?v=PY4lvMYpEv">
+<meta name="apple-mobile-web-app-title" content="Library of Trantor">
+<meta name="application-name" content="Library of Trantor">
+<meta name="msapplication-TileColor" content="#700000">
+<meta name="theme-color" content="#707070">
+<!-- Title Translation -->
+{{$title := i18n (lower .Title)}}
+{{ if eq $title ""}}
+  <title>{{ .Title }} | {{ .Site.Title }}</title>
+{{ else }}
+  <title>{{ $title }} | {{ .Site.Title }}</title>
+{{ end }}
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
@@ -3,7 +3,7 @@
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>{{ .Title }} | {{ .Site.Title }}</title>
+    <link rel="stylesheet" href="{{ "/css/isso.css" | relURL }}" />
     <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" />
     <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" />
     {{ partial "head_custom.html" . }}
diff --git a/layouts/partials/navi_custom.html b/layouts/partials/navi_custom.html
@@ -0,0 +1,7 @@
+{{ if .IsTranslated }}
+    {{ range .Translations }}
+    <li>
+        <a href="{{ .Permalink }}">{{ .Site.Language.LanguageName }}</a>
+    </li>
+    {{ end}}
+{{ end }}+
\ No newline at end of file
diff --git a/static/css/isso.css b/static/css/isso.css
@@ -0,0 +1,230 @@
+#isso-thread * {
+    -webkit-box-sizing: border-box;
+    -moz-box-sizing: border-box;
+    box-sizing: border-box;
+}
+#isso-thread a {
+    text-decoration: none;
+}
+
+#isso-thread {
+    padding: 0;
+    margin: 0;
+}
+#isso-thread > h4 {
+    color: #555;
+    font-weight: bold;
+}
+#isso-thread .textarea {
+    min-height: 58px;
+    outline: 0;
+}
+#isso-thread .textarea.placeholder {
+    color: #AAA;
+}
+
+.isso-comment {
+    max-width: 68em;
+    padding-top: 0.95em;
+    margin: 0.95em auto;
+}
+.isso-comment:not(:first-of-type),
+.isso-follow-up .isso-comment {
+    border-top: 1px solid rgba(0, 0, 0, 0.1);
+}
+.isso-comment > div.avatar,
+.isso-postbox > .avatar {
+    display: block;
+    float: left;
+    width: 7%;
+    margin: 3px 15px 0 0;
+}
+.isso-postbox > .avatar {
+    float: left;
+    margin: 5px 10px 0 5px;
+    width: 48px;
+    height: 48px;
+    overflow: hidden;
+}
+.isso-comment > div.avatar > svg,
+.isso-postbox > .avatar > svg {
+    max-width: 48px;
+    max-height: 48px;
+    border: 1px solid rgba(0, 0, 0, 0.2);
+    border-radius: 3px;
+    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
+}
+.isso-comment > div.text-wrapper {
+    display: block;
+}
+.isso-comment .isso-follow-up {
+    padding-left: calc(7% + 20px);
+}
+.isso-comment > div.text-wrapper > .isso-comment-header, .isso-comment > div.text-wrapper > .isso-comment-footer {
+    font-size: 0.95em;
+}
+.isso-comment > div.text-wrapper > .isso-comment-header {
+    font-size: 0.85em;
+}
+.isso-comment > div.text-wrapper > .isso-comment-header .spacer {
+    padding: 0 6px;
+}
+.isso-comment > div.text-wrapper > .isso-comment-header .spacer,
+.isso-comment > div.text-wrapper > .isso-comment-header a.permalink,
+.isso-comment > div.text-wrapper > .isso-comment-header .note,
+.isso-comment > div.text-wrapper > .isso-comment-header a.parent {
+    color: gray !important;
+    font-weight: normal;
+    text-shadow: none !important;
+}
+.isso-comment > div.text-wrapper > .isso-comment-header .spacer:hover,
+.isso-comment > div.text-wrapper > .isso-comment-header a.permalink:hover,
+.isso-comment > div.text-wrapper > .isso-comment-header .note:hover,
+.isso-comment > div.text-wrapper > .isso-comment-header a.parent:hover {
+    color: #606060 !important;
+}
+.isso-comment > div.text-wrapper > .isso-comment-header .note {
+    float: right;
+}
+.isso-comment > div.text-wrapper > .isso-comment-header .author {
+    font-weight: bold;
+    color: #555;
+}
+.isso-comment > div.text-wrapper > .textarea-wrapper .textarea {
+    margin-top: 0.2em;
+}
+.isso-comment > div.text-wrapper > div.text p {
+    margin-top: 0.2em;
+}
+.isso-comment > div.text-wrapper > div.text p:last-child {
+    margin-bottom: 0.2em;
+}
+.isso-comment > div.text-wrapper > div.text h1,
+.isso-comment > div.text-wrapper > div.text h2,
+.isso-comment > div.text-wrapper > div.text h3,
+.isso-comment > div.text-wrapper > div.text h4,
+.isso-comment > div.text-wrapper > div.text h5,
+.isso-comment > div.text-wrapper > div.text h6 {
+    font-size: 130%;
+    font-weight: bold;
+}
+.isso-comment > div.text-wrapper > div.textarea-wrapper .textarea {
+    width: 100%;
+    border: 1px solid #f0f0f0;
+    border-radius: 2px;
+    box-shadow: 0 0 2px #888;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer {
+    font-size: 0.80em;
+    color: gray !important;
+    clear: left;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer a {
+    font-weight: bold;
+    text-decoration: none;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer a:hover {
+    color: #111111 !important;
+    text-shadow: #aaaaaa 0 0 1px !important;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer > a {
+    position: relative;
+    top: .2em;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer > a + a {
+    padding-left: 1em;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer .votes {
+    color: gray;
+}
+.isso-comment > div.text-wrapper > .isso-comment-footer .upvote svg,
+.isso-comment > div.text-wrapper > .isso-comment-footer .downvote svg {
+    position: relative;
+    top: .2em;
+}
+.isso-comment .isso-postbox {
+    margin-top: 0.8em;
+}
+
+.isso-postbox {
+    max-width: 68em;
+    margin: 0 auto 2em;
+}
+.isso-postbox > .form-wrapper {
+    display: block;
+    padding: 0;
+}
+.isso-postbox > .form-wrapper > .auth-section,
+.isso-postbox > .form-wrapper > .auth-section .post-action {
+    display: block;
+}
+.isso-postbox > .form-wrapper .textarea {
+    margin: 0 0 .3em;
+    padding: .4em .8em;
+    border-radius: 3px;
+    background-color: #f9f9f9;
+    border: 1px solid rgba(0, 0, 0, 0.2);
+/*    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);*/
+}
+#isso-thread .textarea:focus,
+#isso-thread input:focus {
+    border-color: #710100;
+}
+.isso-postbox > .form-wrapper > .auth-section .input-wrapper {
+    display: inline-block;
+    position: relative;
+    max-width: 25%;
+    margin: 0;
+}
+.isso-postbox > .form-wrapper > .auth-section .input-wrapper input {
+    padding: .3em 10px;
+    max-width: 100%;
+    border-radius: 3px;
+    background-color: #f9f9f9;
+    line-height: 1.5em;
+    border: 1px solid rgba(0, 0, 0, 0.2);
+
+/*    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);*/
+}
+.isso-postbox > .form-wrapper > .auth-section .input-wrapper input:focus {
+    outline: 0;
+    border-color: #700000;
+}
+.isso-postbox > .form-wrapper > .auth-section .post-action {
+    display: inline-block;
+    float: right;
+    margin: 0;
+}
+.isso-postbox > .form-wrapper > .auth-section .post-action > input {
+    padding: 5px;
+    border-radius: 5px;
+    border: 0px;
+    color: #700000;
+    background-color: #eee;
+    cursor: pointer;
+    outline: 0;
+    line-height: 1.5em;
+    text-decoration: none;
+    background: #eee;
+}
+.isso-postbox > .form-wrapper > .auth-section .post-action > input:hover {
+    background-color: #eee;
+}
+.isso-postbox > .form-wrapper > .auth-section .post-action > input:active {
+    background-color: #eee;
+}
+@media screen and (max-width:600px) {
+    .isso-postbox > .form-wrapper > .auth-section .input-wrapper {
+        display: block;
+        max-width: 100%;
+        margin: 0 0 .3em;
+    }
+    .isso-postbox > .form-wrapper > .auth-section .input-wrapper input {
+        width: 100%;
+    }
+    .isso-postbox > .form-wrapper > .auth-section .post-action {
+        display: block;
+        float: none;
+        text-align: right;
+    }
+}
diff --git a/static/css/style.css b/static/css/style.css
@@ -6,17 +6,16 @@ body {
 }
 
 /* header and footer areas */
-.menu { padding: 0; }
+.menu { padding: 0; line-height: 2.2em; }
 .menu li { display: inline-block; }
 .article-meta, .menu a {
-  line-height: 2.4em;
   text-decoration: none;
   background: #eee;
   padding: 5px;
   border-radius: 5px;
 }
 .menu, .article-meta, footer { text-align: center; }
-.title { font-size: 1.1em; }
+.title { font-size: 1.1em; line-height: 1.1em;}
 footer a { text-decoration: none; }
 hr {
   border-style: dashed;
diff --git a/static/js/math-code.js b/static/js/math-code.js
@@ -0,0 +1,20 @@
+(function() {
+  var i, text, code, codes = document.getElementsByTagName('code');
+  for (i = 0; i < codes.length;) {
+    code = codes[i];
+    if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
+      text = code.textContent;
+      if (/^\$[^$]/.test(text) && /[^$]\$$/.test(text)) {
+        text = text.replace(/^\$/, '\\(').replace(/\$$/, '\\)');
+        code.textContent = text;
+      }
+      if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
+          /^\$(.|\s)+\$$/.test(text) ||
+          /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
+        code.outerHTML = code.innerHTML;  // remove <code></code>
+        continue;
+      }
+    }
+    i++;
+  }
+})();