|
@@ -58,7 +58,8 @@ pub fn build(include_drafts: bool) {
|
58
|
58
|
let post = parse_post(entry.path());
|
59
|
59
|
write_post(&cwd, &layout_template, &post_template, &post, &config);
|
60
|
60
|
post
|
61
|
|
- }).collect();
|
|
61
|
+ })
|
|
62
|
+ .collect();
|
62
|
63
|
|
63
|
64
|
write_post_listing(
|
64
|
65
|
&cwd,
|
|
@@ -73,7 +74,8 @@ pub fn build(include_drafts: bool) {
|
73
|
74
|
&vec![cwd.join("css"), cwd.join("js")],
|
74
|
75
|
cwd.join("public"),
|
75
|
76
|
&dir::CopyOptions::new(),
|
76
|
|
- ).expect("Couldn't copy css/js directories");
|
|
77
|
+ )
|
|
78
|
+ .expect("Couldn't copy css/js directories");
|
77
|
79
|
}
|
78
|
80
|
|
79
|
81
|
pub fn new(name: &str) {
|
|
@@ -84,7 +86,8 @@ pub fn new(name: &str) {
|
84
|
86
|
fs::write(
|
85
|
87
|
project_path.join("tlon.toml"),
|
86
|
88
|
format!("site_name = \"{}\"", &name),
|
87
|
|
- ).expect("Could not create tlon.toml");
|
|
89
|
+ )
|
|
90
|
+ .expect("Could not create tlon.toml");
|
88
|
91
|
|
89
|
92
|
for dir in &["drafts", "posts", "public", "templates", "css", "js"] {
|
90
|
93
|
fs::create_dir(&project_path.join(&dir))
|
|
@@ -101,7 +104,8 @@ pub fn new(name: &str) {
|
101
|
104
|
.join("templates")
|
102
|
105
|
.join(format!("{}.html", file)),
|
103
|
106
|
"",
|
104
|
|
- ).expect(&format!("Couldn't write templates/{}.html", file));
|
|
107
|
+ )
|
|
108
|
+ .expect(&format!("Couldn't write templates/{}.html", file));
|
105
|
109
|
}
|
106
|
110
|
}
|
107
|
111
|
|
|
@@ -213,31 +217,38 @@ mod tests {
|
213
|
217
|
fs::write(
|
214
|
218
|
project_dir.join("css").join("style.css"),
|
215
|
219
|
"body { background: blue; }",
|
216
|
|
- ).unwrap();
|
|
220
|
+ )
|
|
221
|
+ .unwrap();
|
217
|
222
|
fs::write(
|
218
|
223
|
project_dir.join("js").join("index.js"),
|
219
|
224
|
"window.onload = function () { alert() }",
|
220
|
|
- ).unwrap();
|
|
225
|
+ )
|
|
226
|
+ .unwrap();
|
221
|
227
|
fs::write(
|
222
|
228
|
project_dir.join("templates").join("layout.html"),
|
223
|
229
|
"<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
|
224
|
|
- ).unwrap();
|
|
230
|
+ )
|
|
231
|
+ .unwrap();
|
225
|
232
|
fs::write(
|
226
|
233
|
project_dir.join("templates").join("post.html"),
|
227
|
234
|
"<article><h1>{{ title }}</h1><div>{{ body }}</div></article>",
|
228
|
|
- ).unwrap();
|
|
235
|
+ )
|
|
236
|
+ .unwrap();
|
229
|
237
|
fs::write(
|
230
|
238
|
project_dir.join("templates").join("post_listing.html"),
|
231
|
239
|
"<ul>{{ post_listing }}</ul>",
|
232
|
|
- ).unwrap();
|
|
240
|
+ )
|
|
241
|
+ .unwrap();
|
233
|
242
|
fs::write(
|
234
|
243
|
project_dir.join("templates").join("post_listing_item.html"),
|
235
|
244
|
"<li><a href=\"/{{ slug }}\">{{ title }}</a></li>",
|
236
|
|
- ).unwrap();
|
|
245
|
+ )
|
|
246
|
+ .unwrap();
|
237
|
247
|
fs::write(
|
238
|
248
|
project_dir.join("posts").join("first-post.md"),
|
239
|
249
|
"# First post\n\nThis is the first post\n\nIt has multiple paragraphs",
|
240
|
|
- ).unwrap();
|
|
250
|
+ )
|
|
251
|
+ .unwrap();
|
241
|
252
|
fs::write(project_dir.join("tlon.toml"), "site_name = \"Test Site\"").unwrap();
|
242
|
253
|
|
243
|
254
|
build(false);
|
|
@@ -257,7 +268,8 @@ mod tests {
|
257
|
268
|
.join("public")
|
258
|
269
|
.join("first-post")
|
259
|
270
|
.join("index.html")
|
260
|
|
- ).unwrap()
|
|
271
|
+ )
|
|
272
|
+ .unwrap()
|
261
|
273
|
.replace("\n", ""),
|
262
|
274
|
);
|
263
|
275
|
|
|
@@ -292,35 +304,43 @@ mod tests {
|
292
|
304
|
fs::write(
|
293
|
305
|
project_dir.join("css").join("style.css"),
|
294
|
306
|
"body { background: blue; }",
|
295
|
|
- ).unwrap();
|
|
307
|
+ )
|
|
308
|
+ .unwrap();
|
296
|
309
|
fs::write(
|
297
|
310
|
project_dir.join("js").join("index.js"),
|
298
|
311
|
"window.onload = function () { alert() }",
|
299
|
|
- ).unwrap();
|
|
312
|
+ )
|
|
313
|
+ .unwrap();
|
300
|
314
|
fs::write(
|
301
|
315
|
project_dir.join("templates").join("layout.html"),
|
302
|
316
|
"<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
|
303
|
|
- ).unwrap();
|
|
317
|
+ )
|
|
318
|
+ .unwrap();
|
304
|
319
|
fs::write(
|
305
|
320
|
project_dir.join("templates").join("post.html"),
|
306
|
321
|
"<article><h1>{{ title }}</h1><div>{{ body }}</div></article>",
|
307
|
|
- ).unwrap();
|
|
322
|
+ )
|
|
323
|
+ .unwrap();
|
308
|
324
|
fs::write(
|
309
|
325
|
project_dir.join("templates").join("post_listing.html"),
|
310
|
326
|
"<ul>{{ post_listing }}</ul>",
|
311
|
|
- ).unwrap();
|
|
327
|
+ )
|
|
328
|
+ .unwrap();
|
312
|
329
|
fs::write(
|
313
|
330
|
project_dir.join("templates").join("post_listing_item.html"),
|
314
|
331
|
"<li><a href=\"/{{ slug }}\">{{ title }}</a></li>",
|
315
|
|
- ).unwrap();
|
|
332
|
+ )
|
|
333
|
+ .unwrap();
|
316
|
334
|
fs::write(
|
317
|
335
|
project_dir.join("posts").join("first-post.md"),
|
318
|
336
|
"# First post\n\nThis is the first post",
|
319
|
|
- ).unwrap();
|
|
337
|
+ )
|
|
338
|
+ .unwrap();
|
320
|
339
|
fs::write(
|
321
|
340
|
project_dir.join("drafts").join("first-draft.md"),
|
322
|
341
|
"# First draft\n\nThis is the first draft",
|
323
|
|
- ).unwrap();
|
|
342
|
+ )
|
|
343
|
+ .unwrap();
|
324
|
344
|
fs::write(project_dir.join("tlon.toml"), "site_name = \"Test Site\"").unwrap();
|
325
|
345
|
|
326
|
346
|
build(true);
|