Clean up
This commit is contained in:
parent
21a4d933ba
commit
76f99322f7
10
index.html
10
index.html
@ -6,16 +6,6 @@ $render{"templates/wares"}
|
|||||||
|
|
||||||
<h2>Posts</h2>
|
<h2>Posts</h2>
|
||||||
|
|
||||||
$({{hi = "there"}})[[$hi]]
|
|
||||||
|
|
||||||
$(test1({limit = 2}))[[<p>inline template $title</p>]]
|
|
||||||
$each{test2({limit = 2}), "post"}[[$post]]
|
|
||||||
|
|
||||||
$(list_posts1({limit = 2}))[[<p>$title</p>]]
|
|
||||||
$each{list_posts2({limit = 2}), "post"}[[$post]]
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
$each{list_posts({limit = 5}), "post"}[[$post]]
|
$each{list_posts({limit = 5}), "post"}[[$post]]
|
||||||
|
|
||||||
<h4 style="text-align: center;">
|
<h4 style="text-align: center;">
|
||||||
|
60
site.moon
60
site.moon
@ -69,23 +69,15 @@ template = [[
|
|||||||
</section>
|
</section>
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- use in templates like this
|
-- setup in create function:
|
||||||
-- $each{list_posts({limit = 5}), "post"}[[$post]]
|
--
|
||||||
-- or like this
|
-- sitegen.create =>
|
||||||
-- $each{list_posts(), "post"}[[$post]]
|
-- @list_posts = list_posts @, [template]
|
||||||
|
--
|
||||||
-- can call this two ways. One takes a template, the others uses a template passed
|
-- use in templates:
|
||||||
-- in
|
--
|
||||||
-- $(list_posts({limit = 2}, true))[[<p>$title</p>]]
|
-- `list_posts @` expects $(list_posts({limit = 2}))[[<p>$title</p>]]
|
||||||
-- $each{list_posts({limit = 2}), "post"}[[$post]]
|
-- `list_posts @, template` expects $each{list_posts({limit = 2}), "post"}[[$post]]
|
||||||
|
|
||||||
-- to inline a template, use like this
|
|
||||||
-- @list_posts = list_posts @
|
|
||||||
-- and then call from template like this
|
|
||||||
-- $(list_posts({limit = 2}))[[<p>$title</p>]]
|
|
||||||
-- to pass in a template, use like this
|
|
||||||
-- @list_posts = list_posts @, [[<p>$title</p>]]
|
|
||||||
-- $each{list_posts({limit = 2}), "post"}[[$post]]
|
|
||||||
list_posts = (template) => (args={}) =>
|
list_posts = (template) => (args={}) =>
|
||||||
pages = @site\query_pages { is_a: "post" }
|
pages = @site\query_pages { is_a: "post" }
|
||||||
table.sort pages, (a, b) -> a.source > b.source
|
table.sort pages, (a, b) -> a.source > b.source
|
||||||
@ -103,27 +95,6 @@ list_posts = (template) => (args={}) =>
|
|||||||
|
|
||||||
if template then common.fill_ignoring_pre template, vals else vals
|
if template then common.fill_ignoring_pre template, vals else vals
|
||||||
|
|
||||||
-- call like this from a template: $(get_posts())[[<p>$title</p>]]
|
|
||||||
-- or like this: $(get_posts({limit = 5}))[[<p>$title</p>]]
|
|
||||||
get_posts = (args={}) =>
|
|
||||||
pages = @site\query_pages { is_a: "post" }
|
|
||||||
table.sort pages, (a, b) -> a.source > b.source
|
|
||||||
limit = math.min args.limit or #pages, #pages
|
|
||||||
|
|
||||||
return for page in *pages[1, limit]
|
|
||||||
{ title: title, id: id, publish_date: date, blurb: blurb } = page.meta
|
|
||||||
|
|
||||||
{
|
|
||||||
title: title or titleize_slug id
|
|
||||||
publish_date: date
|
|
||||||
blurb: blurb
|
|
||||||
url: rootname page\url_for!
|
|
||||||
}
|
|
||||||
|
|
||||||
test = (args={}, template) =>
|
|
||||||
vals = { title: "yoayasdf" }
|
|
||||||
if template then common.fill_ignoring_pre template, vals else { vals }
|
|
||||||
|
|
||||||
-- replace '$if' helper function with cosmo's 'cif'
|
-- replace '$if' helper function with cosmo's 'cif'
|
||||||
html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block
|
html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block
|
||||||
-- add a '$titleize' helper function
|
-- add a '$titleize' helper function
|
||||||
@ -133,22 +104,13 @@ documents = (path=".") ->
|
|||||||
files = reverse get_files path
|
files = reverse get_files path
|
||||||
{join(path, file), target(file, "/posts") for file in *files}
|
{join(path, file), target(file, "/posts") for file in *files}
|
||||||
|
|
||||||
test3 = (args, template) =>
|
|
||||||
p two
|
|
||||||
|
|
||||||
sitegen.create =>
|
sitegen.create =>
|
||||||
@site_title = "WebDevCat.me"
|
@site_title = "WebDevCat.me"
|
||||||
@app_name = "stasis"
|
@app_name = "stasis"
|
||||||
@version = "0.2.12"
|
@version = "0.2.12"
|
||||||
@list_posts = list_posts @
|
@list_posts = list_posts @, template
|
||||||
@list_posts1 = list_posts @
|
|
||||||
@list_posts2 = list_posts @, template
|
|
||||||
@get_posts = get_posts
|
|
||||||
@test1 = (args) => test @, args
|
|
||||||
@test2 = (args) => test @, args, [[passed template $title]]
|
|
||||||
@test3 = test3
|
|
||||||
|
|
||||||
add_all = (name="", files) ->
|
add_all = (name, files) ->
|
||||||
for path, target in pairs files
|
for path, target in pairs files
|
||||||
id = extract_id path
|
id = extract_id path
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user