Browse Source

W4.6: removed insecure, refactored code to folders.

Frederic G. MARAND 9 năm trước cách đây
mục cha
commit
d41bc4c2d2
10 tập tin đã thay đổi với 29 bổ sung18 xóa
  1. 0 1
      .meteor/packages
  2. 0 1
      .meteor/versions
  3. 0 0
      client/image_share.css
  4. 0 0
      client/image_share.html
  5. 0 0
      client/main.js
  6. 17 0
      lib/collections.js
  7. 0 0
      server/server.js
  8. 12 0
      server/startup.js
  9. 0 1
      shared/image_share.js
  10. 0 15
      startup.js

+ 0 - 1
.meteor/packages

@@ -5,7 +5,6 @@
 # but you can also edit it by hand.
 
 autopublish
-insecure
 twbs:bootstrap
 standard-minifiers
 meteor-base

+ 0 - 1
.meteor/versions

@@ -35,7 +35,6 @@ html-tools@1.0.5
 htmljs@1.0.5
 http@1.1.1
 id-map@1.0.4
-insecure@1.0.4
 jquery@1.11.4
 launch-screen@1.0.4
 less@2.5.1

+ 0 - 0
image_share.css → client/image_share.css


+ 0 - 0
image_share.html → client/image_share.html


+ 0 - 0
client/client.js → client/main.js


+ 17 - 0
lib/collections.js

@@ -0,0 +1,17 @@
+Images = new Mongo.Collection("images");
+
+// Set up security on images collection.
+Images.allow({
+  insert: function (userId, doc) {
+    if (userId && userId === doc.createdBy) {
+      console.log("Image insert allowed for " + userId, doc);
+      return true;
+    }
+    else {
+      return false;
+    }
+  },
+  remove: function (userId, doc) {
+    return true;
+  }
+});

+ 0 - 0
server/server.js


+ 12 - 0
server/startup.js

@@ -0,0 +1,12 @@
+Meteor.startup(function () {
+  if (Images.find().count() === 0) {
+    for (let i = 1; i < 23; i++) {
+      Images.insert({
+        "img_src": "img_" + i + ".jpg",
+        "img_alt": "image number " + i
+      });
+    } // end of for insert images
+    // count the images!
+    console.log("startup.js says: " + Images.find().count());
+  } // end of if have no images.
+});

+ 0 - 1
shared/image_share.js

@@ -1 +0,0 @@
-Images = new Mongo.Collection("images");

+ 0 - 15
startup.js

@@ -1,15 +0,0 @@
-if (Meteor.isServer) {
-  Meteor.startup(function () {
-    if (Images.find().count() === 0) {
-      for (let i = 1; i < 23; i++) {
-        Images.insert({
-          "img_src": "img_" + i + ".jpg",
-          "img_alt": "image number " + i
-        });
-      } // end of for insert images
-      // count the images!
-      console.log("startup.js says: " + Images.find().count());
-    } // end of if have no images.
-  });
-
-}