Skip to content

Commit

Permalink
Copy Static Files
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jul 1, 2018
1 parent 5b2c152 commit 6175d4f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
sitepipe-shake.cabal
*~
.shake/
dist/
18 changes: 14 additions & 4 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
module Main where

import Data.Aeson as A
import qualified Data.Text as T
import Development.Shake hiding (Resource)
import Development.Shake.FilePath
import GHC.Generics (Generic)

-- import Helpers
import SitePipe.Shake
import Text.Mustache hiding ((~>))
import Text.Mustache.Shake

data Post = Post
{ title :: String
Expand All @@ -36,14 +39,21 @@ main :: IO ()
main =
shakeArgs shakeOptions $ do
want ["dist/contents.html"]
"static" ~> do
staticFiles <-
getDirectoryFiles "." ["site//*.css", "site//*.js", "site//*.png"]
need (("dist" </>) . dropDirectory1 <$> staticFiles)
["dist//*.css", "dist//*.png", "dist//*.js"] |%> \out -> do
copyFileChanged ("site" </> dropDirectory1 out) out
"site" ~>
-- postOracle <- simpleJsonCache (const loadPosts)
do
do need ["static", "posts"]
"posts" ~> do
pNames <- postNames
liftIO $ print pNames
need ((\p -> "dist" </> dropDirectory1 p -<.> "html") <$> pNames)
"dist/posts//*.html" %> \out -> do
liftIO $ print out
contents <- readFile' ("site" </> dropDirectory1 out -<.> "md")
Post {content = f} <- markdownReader contents
writeFile' out f
post <- markdownReader contents :: Action Post
template <- compileTemplate' "site/templates/post.html"
writeFile' out . T.unpack $ substitute template (toJSON post)
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
- binary
- bytestring
- containers
- mustache

library:
source-dirs: src
Expand Down
1 change: 0 additions & 1 deletion site/posts/you-own-your-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ Though this system has its own challenges, I believe it solves some major proble
* Extensible. (Once everyone is hosting their own data and the process is standardized in some fashion, new programs and social networks can simply use existing data-stores and people don't need to rebuild their virtual life every 5 years)

*It'll take work, it'll be a tough change, but if we don't demand it, it'll never happen.*

2 changes: 1 addition & 1 deletion site/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<header>
<nav>
<a id="beacon" href="/">
{{> templates/enso.svg}}
{{>site/templates/enso.svg}}
<div id="home-text"> HOME </div>
</a>
</nav>
Expand Down
8 changes: 4 additions & 4 deletions site/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<link rel="alternative" type="application/rss+xml" title="Chris Penner RSS Feed" href="/atom.xml" />
<link rel="icon" type="image/png" href="/images/favicon.png">
<link rel="stylesheet" href="/css/style.css">
{{>templates/head.html}}
{{>site/templates/head.html}}
</head>
<body>
{{> templates/header.html}}
{{>site/templates/header.html}}

<div id="page">
<section class="table-of-contents">
Expand All @@ -26,8 +26,8 @@ <h1>All Posts</h1>
{{/tags}}
</span>
</div>
{{>templates/post-list.html}}
{{>site/templates/post-list.html}}
</section>
</div>

{{> templates/footer.html}}
{{>site/templates/footer.html}}
8 changes: 4 additions & 4 deletions site/templates/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<meta name="description" content="The Personal blog and musings of Chris Penner, a designer, developer and future opsimath.">
<meta name="author" content="Chris Penner">
<meta name=viewport content="width=device-width, initial-scale=1">
{{>templates/meta-data.html}}
{{>site/templates/meta-data.html}}
<title>{{title}}</title>
<link rel="alternate" type="application/atom+xml" title="Chris Penner FP" href="/atom.xml" />
<link rel="icon" type="image/png" href="/images/favicon.png">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/syntax.css">
{{>templates/head.html}}
{{>site/templates/head.html}}
</head>
<body>
{{> templates/header.html}}
{{>site/templates/header.html}}

{{#prevPost}} <a id="leftarrow" class="arrow" href="{{prevPost.url}}">&larr;</a> {{/prevPost}}
{{#nextPost}} <a id="rightarrow" class="arrow" href="{{nextPost.url}}">&rarr;</a> {{/nextPost}}
Expand Down Expand Up @@ -81,4 +81,4 @@

</div>

{{> templates/footer.html}}
{{>site/templates/footer.html}}
6 changes: 3 additions & 3 deletions site/templates/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<link rel="alternative" type="application/rss+xml" title="Chris Penner RSS Feed" href="/feed" />
<link rel="icon" type="image/png" href="/images/favicon.png">
<link rel="stylesheet" href="/css/style.css">
{{>templates/head.html}}
{{>site/templates/head.html}}
</head>
<body>
{{> templates/header.html}}
{{>site/templates/header.html}}

<div id="page">
<section class="table-of-contents">
<h1>{{tag}}</h1>
{{>templates/post-list.html}}
{{>site/templates/post-list.html}}
</section>
</div>

Expand Down

0 comments on commit 6175d4f

Please sign in to comment.