From 7479e8f13d570ba9e61e2e183e2ec75ca43e596e Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sat, 15 Feb 2014 21:09:30 -0800 Subject: [PATCH] put page specific styles and scripts in _data.json files --- harp.json | 4 +- public/_data.json | 6 + public/_layout.ejs | 67 ++++++++-- public/archive.ejs | 15 ++- public/css/mobile.css | 2 +- public/css/projects.css | 14 ++ public/js/projects.js | 252 +++++++++++++++++------------------ public/js/store.js | 11 +- public/projects/_data.json | 24 ++++ public/projects/_project.ejs | 14 +- public/projects/index.ejs | 46 ++----- 11 files changed, 249 insertions(+), 206 deletions(-) diff --git a/harp.json b/harp.json index ae90585..3bc6d2e 100644 --- a/harp.json +++ b/harp.json @@ -3,8 +3,6 @@ "site": "samhuri.net", "author": "Sami Samhuri", "email": "sami@samhuri.net", - "url": "http://samhuri.net", - "styles": [], - "scripts": [] + "url": "http://samhuri.net" } } \ No newline at end of file diff --git a/public/_data.json b/public/_data.json index 1e83ea8..e9e69a9 100644 --- a/public/_data.json +++ b/public/_data.json @@ -2,6 +2,12 @@ "title": "samhuri.net", "subtitle": "words mean things", "url": "http://samhuri.net", + "styles": [ + "/css/style.css" + ], + "scripts": [ + + ], "latest": { "title": "Structure of an Ember app", "date": "February 3, 2014", diff --git a/public/_layout.ejs b/public/_layout.ejs index 1f52204..7ea22e8 100644 --- a/public/_layout.ejs +++ b/public/_layout.ejs @@ -1,22 +1,61 @@ +<% allScripts = [] -%> +<% allStyles = [] -%> +<% var ctx = public -%> +<% var n = current.path.length -%> +<% for (var i in current.path) { -%> +<% var path = current.path[i] -%> +<% if (ctx._data) { -%> +<% if (ctx._data.scripts || ctx._data._scripts) { -%> +<% allScripts = allScripts.concat(ctx._data.scripts || ctx._data._scripts) -%> +<% } -%> +<% if (ctx._data.styles || ctx._data._styles) { -%> +<% allStyles = allStyles.concat(ctx._data.styles || ctx._data._styles) -%> +<% } -%> +<% if (ctx._data[path] && ctx._data[path].scripts) { -%> +<% allScripts = allScripts.concat(ctx._data[path].scripts) -%> +<% } -%> +<% if (ctx._data[path] && ctx._data[path].styles) { -%> +<% allStyles = allStyles.concat(ctx._data[path].styles) -%> +<% } -%> +<% } -%> +<% ctx = ctx[path] -%> +<% } -%> + - <% if (typeof title != 'undefined') { %> - <%= title %> - <%= site %> - <% } else { %> - <%= site %> - <% } %> +<% if (typeof title != 'undefined') { -%> + <%= title %> - <%= site %> +<% } else { -%> + <%= site %> +<% } -%> - - <% for (var i in styles) { %> - - <% } %> + +<% for (var i in allStyles) { -%> + +<% } -%> + + + @@ -26,10 +65,10 @@ <%- yield %> @@ -38,9 +77,9 @@ Copyright © 2006 - <%= new Date().getFullYear() %> <%= author %> - <% for (var i in scripts) { %> - - <% } %> +<% for (var i in allScripts) { -%> + +<% } -%> - - - - - diff --git a/public/projects/index.ejs b/public/projects/index.ejs index 039987f..c2756fd 100644 --- a/public/projects/index.ejs +++ b/public/projects/index.ejs @@ -1,5 +1,3 @@ - - @@ -8,20 +6,6 @@ - Fork me on GitHub @@ -60,31 +44,23 @@ - -