~ben/web

379eb615d1ada7301606267d33469b6e7af41ba3 — Ben Sima 1 year, 3 months ago 57bf2d1
Use partials on the index page
M Main.hs => Main.hs +4 -4
@@ 12,7 12,6 @@ main = E.setLocaleEncoding E.utf8 >> hakyll rules

rules :: Rules ()
rules = do
    match "templates/*" $ compile templateCompiler
    match "assets/img/*" imageRules
    match "assets/fonts/*/*" fontRules
    match "assets/css/*" cssRules


@@ 34,6 33,7 @@ rules = do
    create ["feeds/reading.xml"] $ readingFeedRules renderAtom
    create ["feeds/reading.rss"] $ readingFeedRules renderRss
    match "tea.org" teaRules
    match "templates/*" $ compile templateCompiler

type RenderFeed
     = FeedConfiguration -> Context String -> [Item String] -> Compiler (Item String)


@@ 119,7 119,7 @@ projectsPage = do
    compile $ do
        projects <- recentFirst =<< loadAll "projects/*"
        let ctx =
                listField "posts" defaultContext (return projects) <>
                listField "projects" defaultContext (return projects) <>
                (constField "title" "Projects") <>
                defaultContext
        makeItem "" >>= loadAndApplyTemplate "templates/projects.html" ctx >>=


@@ 176,11 176,11 @@ clogIndex :: Rules ()
clogIndex = do
    route cleanRoute
    compile $ do
        posts <- recentFirst =<< loadAll "clog/*"
        clogPosts <- recentFirst =<< loadAll "clog/*"
        projects <- recentFirst =<< loadAll "projects/*"
        let ctx =
                listField "projects" defaultContext (return projects) <>
                listField "posts" postCtx (return posts) <>
                listField "clogPosts" postCtx (return clogPosts) <>
                (constField "title" "Ben's code log") <>
                defaultContext
        makeItem "" >>= loadAndApplyTemplate "templates/clog.html" ctx >>=

A templates/clog-post-list.html => templates/clog-post-list.html +8 -0
@@ 0,0 1,8 @@
<ul>
  $for(clogPosts)$
  <li>
    <a href="$url$">$title$</a>
    $if(tldr)$ <p class="tldr">$tldr$</p> $endif$
  </li>
  $endfor$
</ul>

M templates/clog.html => templates/clog.html +3 -10
@@ 2,14 2,7 @@
<p class="subtitle">(a.k.a. "clog")</a>

<div id="clog-index">
<section>
$for(posts)$
    <header>
        <h3>
            <a href="$url$">$title$</a>
        </h3>
    $if(tldr)$ <p class="tldr">$tldr$</p> $endif$
    </header>
$endfor$
</section>
  <section>
    $partial("templates/clog-post-list.html")$
  </section>
</div>

M templates/index.html => templates/index.html +2 -74
@@ 5,82 5,10 @@
<section id="clog-index">
  <h2>Code Log</h2>
  <h3>Projects</h3>
  <p>Some of the software I have written or contributed to.
    See also
    <a href="https://github.com/bsima" target="_blank">github.com/bsima</a>
    and
    <a href="https://git.sr.ht/~ben" target="_blank">git.sr.ht/~ben</a>
  </p>
  <h4>Active</h4>
  <ul>
    $for(projects)$
    $if(active)$
    <li class="a-project">
      <a href="$url$">$title$</a>
      <ul class="sans-serif project-submenu">
        $if(travis)$
        <li>
          <a class="naked" href="https://travis-ci.org/$travis$">
            <img class="badge" src="https://travis-ci.org/$travis$.svg?branch=master"/>
          </a>
        </li>
        $endif$

        $if(link)$
        <li><a class="naked" target="_blank" href="$link$">Link</a></li>
        $endif$

        $if(source)$
        <li><a class="naked" target="_blank" href="$source$">Source</a></li>
        $endif$
      </ul>

      <p class="tldr">$description$</p>
    </li>
    $else$
    $endif$
    $endfor$
  </ul>

  <h4>Past</h4>
  <ul>
    $for(projects)$
    $if(active)$
    $else$
    <li class="a-project">
          <a href="$url$">$title$</a>
          <ul class="sans-serif project-submenu">
            $if(travis)$
            <li>
              <a class="naked" href="https://travis-ci.org/$travis$">
                <img class="badge" src="https://travis-ci.org/$travis$.svg?branch=master"/>
              </a>
            </li>
            $endif$

            $if(link)$
            <li><a class="naked" target="_blank" href="$link$">Link</a></li>
            $endif$

            $if(source)$
            <li><a class="naked" target="_blank" href="$source$">Source</a></li>
            $endif$
          </ul>
          <p class="tldr">$description$</p>
    </li>
    $endif$
    $endfor$
  </ul>
  $partial("templates/project-list.html")$

  <h3>Articles</h3>
  <ul>
  $for(clogPosts)$
  <li>
    <a href="$url$">$title$</a>
    $if(tldr)$ <p class="tldr">$tldr$</p> $endif$
  </li>
  $endfor$
  </ul>
  $partial("templates/clog-post-list.html")$
</section>

<section>

A templates/project-list.html => templates/project-list.html +67 -0
@@ 0,0 1,67 @@
<p>Some of the software I have written or contributed to.
  See also
  <a href="https://github.com/bsima" target="_blank">github.com/bsima</a>
  and
  <a href="https://git.sr.ht/~ben" target="_blank">git.sr.ht/~ben</a>
</p>

<h4>Active</h4>
<ul>
  $for(projects)$
  $if(active)$
  <li class="a-project">
    <a href="$url$">$title$</a>
    <ul class="sans-serif project-submenu">
      $if(travis)$
      <li>
        <a class="naked" href="https://travis-ci.org/$travis$">
          <img class="badge" src="https://travis-ci.org/$travis$.svg?branch=master"/>
        </a>
      </li>
      $endif$

      $if(link)$
      <li><a class="naked" target="_blank" href="$link$">Link</a></li>
      $endif$

      $if(source)$
      <li><a class="naked" target="_blank" href="$source$">Source</a></li>
      $endif$
    </ul>

    <p class="tldr">$description$</p>
  </li>
  $else$
  $endif$
  $endfor$
</ul>

<h4>Past</h4>
<ul>
  $for(projects)$
  $if(active)$
  $else$
  <li class="a-project">
    <a href="$url$">$title$</a>
    <ul class="sans-serif project-submenu">
      $if(travis)$
      <li>
        <a class="naked" href="https://travis-ci.org/$travis$">
          <img class="badge" src="https://travis-ci.org/$travis$.svg?branch=master"/>
        </a>
      </li>
      $endif$

      $if(link)$
      <li><a class="naked" target="_blank" href="$link$">Link</a></li>
      $endif$

      $if(source)$
      <li><a class="naked" target="_blank" href="$source$">Source</a></li>
      $endif$
    </ul>
    <p class="tldr">$description$</p>
  </li>
  $endif$
  $endfor$
</ul>

M templates/projects.html => templates/projects.html +1 -81
@@ 1,83 1,3 @@
<h1>$title$</h1>
<p>This is a showcase of the software I have written or contributed to.
   See also
   <a href="https://github.com/bsima" target="_blank">github.com/bsima</a>
   and
   <a href="https://git.sr.ht/~ben" target="_blank">git.sr.ht/~ben</a>
</p>

<div id="projects">
  <section>
    <h2>Active projects</h2>
    <ul>
      $for(posts)$
      $if(active)$
      <li class="a-project">
        <header>
          <h3>
            <a href="$url$">$title$</a>
          </h3>
        </header>
        <ul class="sans-serif project-submenu">
            $if(travis)$
            <li>
              <a class="naked" href="https://travis-ci.org/$travis$">
                <img class="badge" src="https://travis-ci.org/$travis$.svg?branch=master"/>
              </a>
            </li>
            $endif$

            $if(link)$
            <li><a class="naked" target="_blank" href="$link$">Link</a></li>
            $endif$

            $if(source)$
            <li><a class="naked" target="_blank" href="$source$">Source</a></li>
            $endif$
        </ul>

        <p class="tldr">$description$</p>
      </li>
      $else$
      $endif$
    $endfor$
    </ul>
  </section>

  <section>
    <h2>Past projects</h2>
    <ul>
      $for(posts)$
      $if(active)$
      $else$
      <li class="a-project">
        <header>
          <h3>
            <a href="$url$">$title$</a>
          </h3>
        </header>
        <ul class="sans-serif project-submenu">
            $if(travis)$
            <li>
              <a class="naked" href="https://travis-ci.org/$travis$">
                <img class="badge" src="https://travis-ci.org/$travis$.svg?branch=master"/>
              </a>
            </li>
            $endif$

            $if(link)$
            <li><a class="naked" target="_blank" href="$link$">Link</a></li>
            $endif$

            $if(source)$
            <li><a class="naked" target="_blank" href="$source$">Source</a></li>
            $endif$
        </ul>

        <p class="tldr">$description$</p>
      </li>
      $endif$
      $endfor$
    </ul>
  </section>
</div>
$partial("templates/project-list.html")$

M web.cabal => web.cabal +1 -1
@@ 1,5 1,5 @@
name:           web
version:        5
version:        6
category:       Text
homepage:       https://bsima.me
author:         Ben Sima