Browse Source

Getting closer to a new site generator

master
Peter J. Jones 6 years ago
parent
commit
4a4632cf26

+ 3
- 2
.gitignore View File

@@ -1,3 +1,4 @@
www
dist
.sass-cache
cabal-dev
dist
www

+ 3
- 0
.gitmodules View File

@@ -0,0 +1,3 @@
[submodule "vendor/devalot-hakyll"]
path = vendor/devalot-hakyll
url = git://pmade.com/devalot-hakyll

+ 14
- 29
GNUmakefile View File

@@ -1,33 +1,18 @@
ERB_VIEWS = $(shell find views -type f -name *.erb)
MD_VIEWS = $(shell find views -type f -name *.md)
ASSETS = $(shell find assets -type f)
################################################################################
.PHONEY: all setup clean

.PHONEY: all
################################################################################
all:
cabal-dev install
cabal-dev/bin/site rebuild

define VIEW_BUILDER
all: $(dir $(subst views,www,$(1))) $(subst views,www,$(2))

$(dir $(subst views,www,$(1))):
mkdir -p $$@

$(subst views,www,$(2)): $(1)
staticc $(1) > $$@
endef

$(foreach view,$(ERB_VIEWS),$(eval $(call VIEW_BUILDER,$(view),$(subst html.erb,html,$(view)))))
$(foreach view,$(MD_VIEWS),$(eval $(call VIEW_BUILDER,$(view),$(subst html.md,html,$(view)))))

define COPY_ASSETS
all: $(dir $(subst assets,www,$(1))) $(subst assets,www,$(1))

$(dir $(subst assets,www,$(1))):
mkdir -p $$@

$(subst assets,www,$(1)): $(1)
cp -p $$< $$@
endef

$(foreach asset,$(ASSETS),$(eval $(call COPY_ASSETS,$(asset))))
################################################################################
setup:
git submodule update --init
- cabal-dev ghc-pkg unregister devalot-hakyll
cabal-dev add-source vendor/devalot-hakyll

################################################################################
clean:
rm -rf www
cabal-dev clean
rm -rf .cache www

+ 6
- 0
assets/javascript/fadenav.js View File

@@ -0,0 +1,6 @@
angular.module('fadeNav', [])
.directive('fadeIn', function () {
return function (scope, element, attrs) {
alert("here");
};
});

+ 0
- 3
assets/javascripts/logo-only.js View File

@@ -1,3 +0,0 @@
$(document).on('dom:loaded', function () {
$('nav').appear({duration: 1.0, delay: 2.0});
});

+ 0
- 16
assets/javascripts/site.js View File

@@ -1,16 +0,0 @@
$(document).on("dom:loaded", function () {
if (Prototype.Browser.MobileSafari) {
$('footer').setStyle({position: 'relative'});
}

var mailto = $$("a.mailto");
if (mailto.length != 0) {
var hidden = $$('[data-user]')[0].readAttribute('data-user');
var email = hidden + '@pmade.com';
mailto.each(function (e) {
e.writeAttribute('href', 'mailto:' + email);
e.update(email);
});
}
});

+ 0
- 0
contact.md View File


+ 0
- 3
controllers/index.rb View File

@@ -1,3 +0,0 @@
class IndexController < StatiCC::Controller
self.layout = 'logo-only'
end

+ 12
- 0
index.html View File

@@ -0,0 +1,12 @@
<div ng-app="fadeNav">
<div class="biglogo">
<img src="/assets/images/logobg.png"/>
</div>

<div style="display:none" data-fade-in>
<ul>
<li><a href="/labs/index.html">Labs</a></li>
<li><a href="/contact.html">Contact</a></li>
</ul>
</div>
</div>

views/labs/index.html.md → labs/index.md View File


+ 0
- 13
layouts/logo-only.html.erb View File

@@ -1,13 +0,0 @@
<html>
<head>
<title>pmade inc.</title>
<link href="/stylesheets/logo-only.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>
<script type="text/javascript" src="/javascripts/logo-only.js"></script>
</head>
<body>
<%= yield %>
</body>
</html>

+ 0
- 2
layouts/nav.html.erb View File

@@ -1,2 +0,0 @@
<li><a href="/labs">Labs</a></li>
<li><a href="/contact.html">Contact</a></li>

+ 1
- 0
pmade.cabal View File

@@ -14,3 +14,4 @@ executable site
main-is: site.hs
build-depends: base == 4.5.*
, hakyll == 4.1.*
, devalot-hakyll == 0.1.*

+ 0
- 9
script/setup.sh View File

@@ -1,9 +0,0 @@
#!/bin/sh

# Initial set up script
make || exit 1

DIST=$HOME/websites/pmade.com
mkdir -p ${DIST}/www ${DIST}/config
rsync -avu www/ ${DIST}/www/
rsync -avu config/ ${DIST}/config/

+ 41
- 1
site.hs View File

@@ -1,6 +1,46 @@
{-# LANGUAGE OverloadedStrings #-}

--------------------------------------------------------------------------------
module Main where

--------------------------------------------------------------------------------
import Hakyll
import Hakyll.Web.JavaScript (jsCreate)

--------------------------------------------------------------------------------
config :: Configuration
config = defaultConfiguration
{ destinationDirectory = "www"
, storeDirectory = ".cache"
, tmpDirectory = ".cache/tmp"
}

--------------------------------------------------------------------------------
main :: IO ()
main = undefined
main = hakyllWith config $ do

-- Main entry point (index.html).
match "index.html" $ do
route idRoute
compile $ do
getResourceBody
>>= loadAndApplyTemplate "templates/main.html" defaultContext
>>= relativizeUrls

-- Remaining markdown files.
match ("contact.md" .||. "labs/**.md") $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/basic.html" defaultContext
>>= relativizeUrls

-- Mash all the JavaScript files into a single file.
jsCreate "assets/javascript/pmade.js" "assets/javascript/*"

-- Images.
match "assets/images/**" $ do
route idRoute
compile copyFileCompiler

-- Compile the templates.
match "templates/*.html" $ compile templateCompiler

layouts/site.html.erb → templates/basic.html View File

@@ -1,25 +1,24 @@
<html>
<head>
<title><%= @page_title ? @page_title + ' - ' : '' %>pmade inc.</title>
<title>$title$ - pmade inc.</title>
<link href="/stylesheets/style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<script type="text/javascript" src="/javascripts/site.js"></script>
</head>
<body>
<div id="content">
<%= yield %>
</div>
<div id="content">$body$</div>

<div id="footer">
<div id="footer-content">
<ul>
<li><a href="/">Home</a></li>
<%= render('layouts/nav.html.erb') %>
<li><a href="/labs">Labs</a></li>
<li><a href="/contact.html">Contact</a></li>
</ul>

<div class="copyright">
Copyright &copy; <%= Time.now.year %> pmade inc. All rights reserved.
Copyright &copy; 2006-2013 pmade inc. All rights reserved.
</div>
</div>
</div>

+ 15
- 0
templates/main.html View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org">
<head>
<title>pmade inc.</title>
<!-- <link href="/stylesheets/logo-only.css" rel="stylesheet" type="text/css"/> -->
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>
$body$
</body>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.3/angular.min.js"></script>
</html>

+ 1
- 0
vendor/devalot-hakyll

@@ -0,0 +1 @@
Subproject commit 308b1bfbe6250c8604232f020d179f7808e31696

+ 0
- 32
views/contact.html.erb View File

@@ -1,32 +0,0 @@
<% @page_title = 'Contact' -%>

<h1>Contact pmade inc.</h1>

<div class="contact">
<h2>Software Support</h2>
<p>
Coming soon...
</p>
</div>
<div class="contact">
<h2>Mailing Address</h2>
<p>
pmade inc.<br/>
P.O. Box 270265<br/>
Louisville, CO 80027
</p>
</div>

<div class="contact" data-user="pjones">
<h2>Hire pmade inc.</h2>

<p>
+1 (303) 219-0226<br/>
<a href="#" class="mailto"></a></br>
</p>
</div>

<br class="clear"/>

+ 0
- 11
views/index.html.erb View File

@@ -1,11 +0,0 @@
<% @page_title = nil -%>

<div class="biglogo">
<img src="/images/logobg.png"/>
</div>

<div id="nav" style="display:none">
<ul>
<%= render('layouts/nav.html.erb') %>
</ul>
</div>

Loading…
Cancel
Save