| 1 | -- Takes "Why I like fish" and returns "why-i-like-fish" |
| 2 | function make_short_title(long_title) |
| 3 | local short_title = long_title:gsub("%W+", "-"):lower():sub(1,45) |
| 4 | if #long_title:gsub("%W+", "-") > 45 then |
| 5 | short_title = short_title:gsub("%-%w+$", ""); |
| 6 | end |
| 7 | return (short_title:gsub("%W+$", ""):gsub("^%W+", "")); |
| 8 | end |
| 9 | |
| 10 | -- Config -- |
| 11 | local conffile = ".blogrc"; |
| 12 | for i=1,#arg do |
| 13 | if arg[i] == "-c" or arg[i] == "--config" then |
| 14 | table.remove(arg, i); |
| 15 | conffile = arg[i] or conffile; |
| 16 | table.remove(arg, i); |
| 17 | break; |
| 18 | end |
| 19 | end |
| 20 | dofile(conffile) |
| 21 | |
| 22 | posts_dir = posts_dir or "_posts/" |
| 23 | layouts_dir = layouts_dir or "_layouts/" |
| 24 | output_dir = output_dir or "./" |
| 25 | -- - -- - -- |
| 26 | |
| 27 | -- Append '/' to end of posts_dir if necessary |
| 28 | posts_dir = posts_dir:gsub("([^/])$", "%1/") |
| 29 | |
| 30 | -- Append '/' to end of output_dir if necessary |
| 31 | output_dir = output_dir:gsub("([^/])$", "%1/") |
| 32 | |
| 33 | -- Append '/' to end of base_url if necessary |
| 34 | base_url = base_url:gsub("([^/])$", "%1/") |