{{ define "main" }}

{{/*  search  */}}
{{ if .Site.Params.searchEngines }}
  <section class="search">
    <div class="searchbox">
      {{/*  search list  */}}
      <div id="search-list" class="hide-type-list">
        {{/*  search group  */}}
        <div class="search-group">
          <span id="group-name"></span>
          <div class="search-group-list">
            {{ range .Site.Params.searchEngines }}
              {{ if ne .enabled false }}
                <label for="group-{{ .group }}" onclick="changeSearchGroup(this.innerText.trim())">
                  <span class="tile-lg">
                    <i class="{{ .icon }} u-theme-f"></i>
                  </span>
                  {{- .group -}}
                </label>
              {{ end }}
            {{ end }}
          </div> <!--search-group-list end-->
        </div> <!--search-group end-->
        {{/*  search group ends  */}}

        {{/*  search engines  */}}
        {{ range .Site.Params.searchEngines }}
          {{ if ne .enabled false }}
            <div class="group-items" id="group-{{ .group }}">
              <ul class="search-engines">
                {{ range .items }}
                  {{ if ne .activated false }}
                    <li>
                      <input type="radio" name="engine" id="engine-{{ .name }}" 
                        value="{{ .url | safeURL }}" hidden onchange="changeSearchEngine(this.value)">
                      <label for="engine-{{ .name }}">
                        <span> {{- .name -}} </span>
                      </label>
                    </li>
                  {{ end }}
                {{ end }}
              </ul>
            </div> <!--group-items end-->
          {{ end }}
        {{ end }}
      </div> <!--search-list end-->
      {{/*  search engines ends  */}}

      <form height="50px" action="" method="get" target="_blank" id="super-search-fm" onsubmit="return doSearch()">
        <input autocomplete="off" type="text" id="search-text" style="outline:none" autofocus="">
        <button type="submit" id="search-button"><i class="fa fa-search"></i></button>
      </form>
    </div>
    {{/*  search list ends  */}}
  </section>
{{ end }}
{{/*  search ends  */}}

{{/*  poetry  */}}
{{ if ne .Site.Params.poetry.enabled false }}
  {{ with .Site.Params.poetry }}
    {{ if eq .api "jinrishici" }}
    {{/*  Thanks jinrishici (https://www.jinrishici.com/) for supplying this api */}}
      <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
      <div class="poetry" onclick="getPoetry('{{ .api }}', '')">
        <p id="poetry"><i class="fas fa-spinner u-theme-f"></i></p>
        {{ if .showAuthor }}
          <p id="poetry-author"><i class="fas fa-spinner u-theme-f"></i></p>
        {{ end }}
      </div>
    {{ else }}
    {{/* Thanks hitokoto (https://hitokoto.cn/) for supplying this api */}}
      <div class="poetry" onclick="getPoetry('hitokoto', '{{ .hitokoto }}')">
        <p id="poetry"><i class="fas fa-spinner u-theme-f"></i></p>
        {{ if .showAuthor }}
          <p id="poetry-author"><i class="fas fa-spinner u-theme-f"></i></p>
        {{ end }}
      </div>
    {{ end }}
  {{ end }}
{{ end }}
{{/*  poetry ends  */}}

{{/*  bookmark cards  */}}
<section class="cards">
  {{ range .Site.Params.bookmarks }}
    {{ if ne .enabled false }}
      <div class="card">
        <h3><i class="{{ .icon }}"></i>&nbsp;{{- .group -}}</h3>
        {{/*  bookmarks  */}}
        <ul>
          {{ range .items }}
            {{ if ne .activated false }}
              <li>
                <a onclick="window.open({{ .url | safeURL }}, '_blank');" one-link-mark="yes" rel="nofollow" 
                  tooltip-text="{{ .description }}" onmouseover="showTooltip(this);" onmouseout="hideTooltip();">
                  {{ if .icon }} <i class="{{ .icon }}"></i>&nbsp;{{ end }}
                  {{- .name -}}
                </a>
              </li>
            {{ end }}
          {{ end }}
        </ul>
        {{/*  bookmarks end  */}}
      </div>
    {{ end }}
  {{ end }}
</section>
{{/*  bookmark cards ends  */}}

{{ end }}
