Procházet zdrojové kódy

Create css/js folders and copy them right into /public

master
Dylan Baker před 5 roky
rodič
revize
38a55e6f2f
3 změnil soubory, kde provedl 29 přidání a 1 odebrání
  1. 7
    0
      Cargo.lock
  2. 1
    0
      Cargo.toml
  3. 21
    1
      src/main.rs

+ 7
- 0
Cargo.lock Zobrazit soubor

77
 version = "1.0.1"
77
 version = "1.0.1"
78
 source = "registry+https://github.com/rust-lang/crates.io-index"
78
 source = "registry+https://github.com/rust-lang/crates.io-index"
79
 
79
 
80
+[[package]]
81
+name = "fs_extra"
82
+version = "1.1.0"
83
+source = "registry+https://github.com/rust-lang/crates.io-index"
84
+
80
 [[package]]
85
 [[package]]
81
 name = "fuchsia-zircon"
86
 name = "fuchsia-zircon"
82
 version = "0.3.3"
87
 version = "0.3.3"
244
 dependencies = [
249
 dependencies = [
245
  "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
250
  "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
246
  "comrak 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
251
  "comrak 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
252
+ "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
247
  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
253
  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
248
  "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
254
  "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
249
  "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
255
  "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
334
 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
340
 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
335
 "checksum comrak 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9bd60be8877a3343d25b9a3dadbaf7f02f9ac843b54e663ecef73e29e8b9c6b"
341
 "checksum comrak 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9bd60be8877a3343d25b9a3dadbaf7f02f9ac843b54e663ecef73e29e8b9c6b"
336
 "checksum entities 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
342
 "checksum entities 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
343
+"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
337
 "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
344
 "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
338
 "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
345
 "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
339
 "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
346
 "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"

+ 1
- 0
Cargo.toml Zobrazit soubor

6
 [dependencies]
6
 [dependencies]
7
 clap = "2.32.0"
7
 clap = "2.32.0"
8
 comrak = "0.3"
8
 comrak = "0.3"
9
+fs_extra = "1.1.0"
9
 lazy_static = "1.2.0"
10
 lazy_static = "1.2.0"
10
 regex = "1"
11
 regex = "1"
11
 uuid = { version = "0.7", features = ["v4"] }
12
 uuid = { version = "0.7", features = ["v4"] }

+ 21
- 1
src/main.rs Zobrazit soubor

1
 extern crate clap;
1
 extern crate clap;
2
 extern crate comrak;
2
 extern crate comrak;
3
+extern crate fs_extra;
3
 #[macro_use]
4
 #[macro_use]
4
 extern crate lazy_static;
5
 extern crate lazy_static;
5
 extern crate regex;
6
 extern crate regex;
8
 use std::{env, fs};
9
 use std::{env, fs};
9
 
10
 
10
 use clap::{App, Arg};
11
 use clap::{App, Arg};
12
+use fs_extra::dir;
11
 
13
 
12
 use post::{parse_post, read_posts_dir};
14
 use post::{parse_post, read_posts_dir};
13
 use write::{write_post, write_post_listing};
15
 use write::{write_post, write_post_listing};
57
         &post_item_template,
59
         &post_item_template,
58
         &posts,
60
         &posts,
59
     );
61
     );
62
+
63
+    fs_extra::copy_items(
64
+        &vec![cwd.join("css"), cwd.join("js")],
65
+        cwd.join("public"),
66
+        &dir::CopyOptions::new(),
67
+    ).expect("Couldn't copy css/js directories");
60
 }
68
 }
61
 
69
 
62
 fn new(name: &str) {
70
 fn new(name: &str) {
65
 
73
 
66
     fs::create_dir(&project_path).expect(&format!("Couldn't create directory '{}'", &name));
74
     fs::create_dir(&project_path).expect(&format!("Couldn't create directory '{}'", &name));
67
 
75
 
68
-    for dir in &["posts", "public", "templates"] {
76
+    for dir in &["posts", "public", "templates", "css", "js"] {
69
         fs::create_dir(&project_path.join(&dir))
77
         fs::create_dir(&project_path.join(&dir))
70
             .expect(&format!("Couldn't create {} directory", &dir));
78
             .expect(&format!("Couldn't create {} directory", &dir));
71
     }
79
     }
72
 
80
 
81
+    fs::write(project_path.join("css").join("style.css"), "")
82
+        .expect("Couldn't create css/style.css");
83
+    fs::write(project_path.join("js").join("index.js"), "").expect("Couldn't create js/index.js");
84
+
73
     for file in &["layout", "post_listing", "post", "post_listing_item"] {
85
     for file in &["layout", "post_listing", "post", "post_listing_item"] {
74
         fs::write(
86
         fs::write(
75
             &project_path
87
             &project_path
141
             "",
153
             "",
142
             fs::read_to_string(&project_dir.join("templates").join("post.html")).unwrap()
154
             fs::read_to_string(&project_dir.join("templates").join("post.html")).unwrap()
143
         );
155
         );
156
+        assert_eq!(
157
+            "",
158
+            fs::read_to_string(&project_dir.join("css").join("style.css")).unwrap()
159
+        );
160
+        assert_eq!(
161
+            "",
162
+            fs::read_to_string(&project_dir.join("js").join("index.js")).unwrap()
163
+        );
144
 
164
 
145
         fs::remove_dir_all(project_dir).unwrap();
165
         fs::remove_dir_all(project_dir).unwrap();
146
     }
166
     }

Načítá se…
Zrušit
Uložit