Переглянути джерело

Move css/ and js/ to assets/

master
Dylan Baker 5 роки тому
джерело
коміт
4ce4e68df5
3 змінених файлів з 10 додано та 37 видалено
  1. 2
    0
      Cargo.lock
  2. 3
    7
      src/lib.rs
  3. 5
    30
      tests/integration_test.rs

+ 2
- 0
Cargo.lock Переглянути файл

1
+# This file is automatically @generated by Cargo.
2
+# It is not intended for manual editing.
1
 [[package]]
3
 [[package]]
2
 name = "aho-corasick"
4
 name = "aho-corasick"
3
 version = "0.6.9"
5
 version = "0.6.9"

+ 3
- 7
src/lib.rs Переглянути файл

100
     );
100
     );
101
 
101
 
102
     fs_extra::copy_items(
102
     fs_extra::copy_items(
103
-        &vec![cwd.join("css"), cwd.join("js")],
103
+        &vec![cwd.join("assets")],
104
         cwd.join("public"),
104
         cwd.join("public"),
105
         &dir::CopyOptions::new(),
105
         &dir::CopyOptions::new(),
106
     )
106
     )
107
-    .expect("Couldn't copy css/js directories");
107
+    .expect("Couldn't copy assets directory");
108
 }
108
 }
109
 
109
 
110
 pub fn new(name: &str, cwd: &path::Path) {
110
 pub fn new(name: &str, cwd: &path::Path) {
123
         "pages",
123
         "pages",
124
         "public",
124
         "public",
125
         "templates",
125
         "templates",
126
-        "css",
126
+        "assets",
127
         "js",
127
         "js",
128
     ] {
128
     ] {
129
         fs::create_dir(&project_path.join(&dir))
129
         fs::create_dir(&project_path.join(&dir))
130
             .expect(&format!("Couldn't create {} directory", &dir));
130
             .expect(&format!("Couldn't create {} directory", &dir));
131
     }
131
     }
132
 
132
 
133
-    fs::write(project_path.join("css").join("style.css"), "")
134
-        .expect("Couldn't create css/style.css");
135
-    fs::write(project_path.join("js").join("index.js"), "").expect("Couldn't create js/index.js");
136
-
137
     let default_layout_template = format!(
133
     let default_layout_template = format!(
138
         "<html>
134
         "<html>
139
   <head>
135
   <head>

+ 5
- 30
tests/integration_test.rs Переглянути файл

13
     let project_dir = temp_dir.path().join(&uuid);
13
     let project_dir = temp_dir.path().join(&uuid);
14
 
14
 
15
     fs::create_dir(&project_dir).unwrap();
15
     fs::create_dir(&project_dir).unwrap();
16
-    fs::create_dir(&project_dir.join("css")).unwrap();
16
+    fs::create_dir(&project_dir.join("assets")).unwrap();
17
     fs::create_dir(&project_dir.join("drafts")).unwrap();
17
     fs::create_dir(&project_dir.join("drafts")).unwrap();
18
-    fs::create_dir(&project_dir.join("js")).unwrap();
19
     fs::create_dir(&project_dir.join("pages")).unwrap();
18
     fs::create_dir(&project_dir.join("pages")).unwrap();
20
     fs::create_dir(&project_dir.join("posts")).unwrap();
19
     fs::create_dir(&project_dir.join("posts")).unwrap();
21
     fs::create_dir(&project_dir.join("public")).unwrap();
20
     fs::create_dir(&project_dir.join("public")).unwrap();
23
     fs::create_dir(&project_dir.join("templates")).unwrap();
22
     fs::create_dir(&project_dir.join("templates")).unwrap();
24
 
23
 
25
     fs::write(
24
     fs::write(
26
-        project_dir.join("css").join("style.css"),
25
+        project_dir.join("assets").join("style.css"),
27
         "body { background: blue; }",
26
         "body { background: blue; }",
28
     )
27
     )
29
     .unwrap();
28
     .unwrap();
30
-    fs::write(
31
-        project_dir.join("js").join("index.js"),
32
-        "window.onload = function () { alert() }",
33
-    )
34
-    .unwrap();
35
     fs::write(
29
     fs::write(
36
         project_dir.join("templates").join("layout.html"),
30
         project_dir.join("templates").join("layout.html"),
37
         "<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
31
         "<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
112
 
106
 
113
     assert_eq!(
107
     assert_eq!(
114
         "body { background: blue; }",
108
         "body { background: blue; }",
115
-        fs::read_to_string(project_dir.join("public").join("css").join("style.css")).unwrap()
116
-    );
117
-
118
-    assert_eq!(
119
-        "window.onload = function () { alert() }",
120
-        fs::read_to_string(project_dir.join("public").join("js").join("index.js")).unwrap()
109
+        fs::read_to_string(project_dir.join("public").join("assets").join("style.css")).unwrap()
121
     );
110
     );
122
 }
111
 }
123
 
112
 
130
     fs::create_dir(&project_dir).unwrap();
119
     fs::create_dir(&project_dir).unwrap();
131
     env::set_current_dir(&project_dir).unwrap();
120
     env::set_current_dir(&project_dir).unwrap();
132
 
121
 
133
-    fs::create_dir(&project_dir.join("css")).unwrap();
122
+    fs::create_dir(&project_dir.join("assets")).unwrap();
134
     fs::create_dir(&project_dir.join("drafts")).unwrap();
123
     fs::create_dir(&project_dir.join("drafts")).unwrap();
135
-    fs::create_dir(&project_dir.join("js")).unwrap();
136
     fs::create_dir(&project_dir.join("pages")).unwrap();
124
     fs::create_dir(&project_dir.join("pages")).unwrap();
137
     fs::create_dir(&project_dir.join("posts")).unwrap();
125
     fs::create_dir(&project_dir.join("posts")).unwrap();
138
     fs::create_dir(&project_dir.join("public")).unwrap();
126
     fs::create_dir(&project_dir.join("public")).unwrap();
140
     fs::create_dir(&project_dir.join("templates")).unwrap();
128
     fs::create_dir(&project_dir.join("templates")).unwrap();
141
 
129
 
142
     fs::write(
130
     fs::write(
143
-        project_dir.join("css").join("style.css"),
131
+        project_dir.join("assets").join("style.css"),
144
         "body { background: blue; }",
132
         "body { background: blue; }",
145
     )
133
     )
146
     .unwrap();
134
     .unwrap();
147
-    fs::write(
148
-        project_dir.join("js").join("index.js"),
149
-        "window.onload = function () { alert() }",
150
-    )
151
-    .unwrap();
152
     fs::write(
135
     fs::write(
153
         project_dir.join("templates").join("layout.html"),
136
         project_dir.join("templates").join("layout.html"),
154
         "<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
137
         "<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
288
             .replace("\n", "")
271
             .replace("\n", "")
289
             .replace("  ", "")
272
             .replace("  ", "")
290
     );
273
     );
291
-    assert_eq!(
292
-        "",
293
-        fs::read_to_string(&project_dir.join("css").join("style.css")).unwrap()
294
-    );
295
-    assert_eq!(
296
-        "",
297
-        fs::read_to_string(&project_dir.join("js").join("index.js")).unwrap()
298
-    );
299
     assert_eq!(
274
     assert_eq!(
300
         format!("site_name = \"{}\"", &uuid),
275
         format!("site_name = \"{}\"", &uuid),
301
         fs::read_to_string(&project_dir.join("casaubon.toml")).unwrap()
276
         fs::read_to_string(&project_dir.join("casaubon.toml")).unwrap()

Завантаження…
Відмінити
Зберегти