Sat, 11 Jul 2009 02:56:08 +0100
Move config into util.lua
6
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | -- Takes "Why I like fish" and returns "why-i-like-fish" |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | function make_short_title(long_title) |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | local short_title = long_title:gsub("%W+", "-"):lower():sub(1,45) |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | if #long_title:gsub("%W+", "-") > 45 then |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | short_title = short_title:gsub("%-%w+$", ""); |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | end |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | return short_title; |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | end |
8 | 10 | |
11 | -- Config -- | |
12 | ||
13 | dofile(arg[1] or ".blogrc") | |
14 | ||
15 | posts_dir = posts_dir or "_posts/" | |
16 | layouts_dir = layouts_dir or "_layouts/" | |
17 | output_dir = output_dir or "./" | |
18 | -- - -- - -- | |
19 | ||
20 | -- Append '/' to end of posts_dir if necessary | |
21 | posts_dir = posts_dir:gsub("([^/])$", "%1/") | |
22 | ||
23 | -- Append '/' to end of output_dir if necessary | |
24 | output_dir = output_dir:gsub("([^/])$", "%1/") | |
25 | ||
26 | -- Append '/' to end of base_url if necessary | |
27 | base_url = base_url:gsub("([^/])$", "%1/") | |
28 |