Jelajahi Sumber

Optim: multi files organisation

febbweiss 10 tahun lalu
induk
melakukan
37908bdb9f
10 mengubah file dengan 99 tambahan dan 111 penghapusan
  1. 10 0
      client/body.html
  2. 3 0
      client/head.html
  3. 23 0
      client/nav.html
  4. 0 39
      client/projects.html
  5. 1 72
      client/projects.js
  6. 0 0
      client/style.css
  7. 1 0
      client/subscriptions.js
  8. 21 0
      lib/methods.js
  9. 37 0
      lib/projects.js
  10. 3 0
      server/publications.js

+ 10 - 0
client/body.html

@@ -0,0 +1,10 @@
+<template name="layout">
+  {{> nav}}
+  <div class="container-fluid">
+    {{> yield }}
+  </div>
+</template>
+
+<template name="home">
+  <h1>Welcome to Project deployer</h1>
+</template>

+ 3 - 0
client/head.html

@@ -0,0 +1,3 @@
+<head>
+  <title>project-deployer</title>
+</head>

+ 23 - 0
client/nav.html

@@ -0,0 +1,23 @@
+<template name="nav">
+  <nav class="navbar navbar-default">
+    <div class="container-fluid">
+      <div class="navbar-header">
+        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
+          <span class="sr-only">Toggle navigation</span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+        </button>
+        <a class="navbar-brand" href="/">Project deployer</a>
+      </div>
+      
+      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+        <ul class="nav navbar-nav">
+          <li class="active">
+            <a href="/management">Projects <span class="sr-only">(current)</span></a>
+          </li>
+        </ul>
+      </div>
+    </div>
+  </nav>
+</template>

+ 0 - 39
project-deployer.html → client/projects.html

@@ -1,42 +1,3 @@
-<head>
-  <title>project-deployer</title>
-</head>
-
-<template name="layout">
-  {{> nav}}
-  <div class="container-fluid">
-    {{> yield }}
-  </div>
-</template>
-
-<template name="nav">
-  <nav class="navbar navbar-default">
-    <div class="container-fluid">
-      <div class="navbar-header">
-        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
-          <span class="sr-only">Toggle navigation</span>
-          <span class="icon-bar"></span>
-          <span class="icon-bar"></span>
-          <span class="icon-bar"></span>
-        </button>
-        <a class="navbar-brand" href="/">Project deployer</a>
-      </div>
-      
-      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
-        <ul class="nav navbar-nav">
-          <li class="active">
-            <a href="/management">Projects <span class="sr-only">(current)</span></a>
-          </li>
-        </ul>
-      </div>
-    </div>
-  </nav>
-</template>
-
-<template name="home">
-  <h1>Welcome to Project deployer</h1>
-</template>
-
 <template name="management">
   <div class="row">
     <div class="col-sm-6">

+ 1 - 72
project-deployer.js → client/projects.js

@@ -1,44 +1,3 @@
-Projects = new Mongo.Collection('projects');
-
-ProjectService = {
-  insert: function(label, git_url, public_url, commands, callback) {
-    Projects.insert({
-      label: label,
-      git_url: git_url,
-      public_url: public_url,
-      commands: commands
-    }, callback);
-  },
-  
-  update: function(id, label, git_url, public_url ,commands) {
-    Projects.update(
-      id, 
-      { $set: { 
-        label: label,
-        git_url: git_url,
-        public_url: public_url,
-        commands: commands
-        } 
-      }
-    );
-  },
-  
-  delete: function(id) {
-    Projects.remove(id);
-  },
-  
-  get: function(id) {
-    return Projects.findOne({_id: id});
-  },
-  
-  list: function() {
-    return Projects.find({}, {sort: {label: 1}});
-  }
-};
-
-if (Meteor.isClient) {
-  Meteor.subscribe('projects');
-
   Template.management.helpers({
     projects: function () {
       return ProjectService.list();
@@ -102,34 +61,4 @@ if (Meteor.isClient) {
         Session.set('projectToEdit', result);
       });
     },
-  });
-  
-}
-
-if (Meteor.isServer) {
-  Meteor.publish('projects', function() {
-      return Projects.find({});
-  });
-}
-
-Meteor.methods({
-  listProjects: function() {
-    return ProjectService.list();
-  },
-  
-  getProject: function(id) {
-    return ProjectService.get(id);
-  },
-  
-  addProject: function(label, git_url, public_url ,commands) {
-    ProjectService.insert(label, git_url, public_url ,commands);
-  },
-  
-  editProject: function(id, label, git_url, public_url ,commands) {
-    ProjectService.update(id, label, git_url, public_url ,commands);
-  },
-  
-  deleteProject: function(id) {
-    ProjectService.delete(id);
-  }
-});
+  });

+ 0 - 0
project-deployer.css → client/style.css


+ 1 - 0
client/subscriptions.js

@@ -0,0 +1 @@
+Meteor.subscribe('projects');

+ 21 - 0
lib/methods.js

@@ -0,0 +1,21 @@
+Meteor.methods({
+  listProjects: function() {
+    return ProjectService.list();
+  },
+  
+  getProject: function(id) {
+    return ProjectService.get(id);
+  },
+  
+  addProject: function(label, git_url, public_url ,commands) {
+    ProjectService.insert(label, git_url, public_url ,commands);
+  },
+  
+  editProject: function(id, label, git_url, public_url ,commands) {
+    ProjectService.update(id, label, git_url, public_url ,commands);
+  },
+  
+  deleteProject: function(id) {
+    ProjectService.delete(id);
+  }
+});

+ 37 - 0
lib/projects.js

@@ -0,0 +1,37 @@
+Projects = new Mongo.Collection('projects');
+
+ProjectService = {
+  insert: function(label, git_url, public_url, commands, callback) {
+    Projects.insert({
+      label: label,
+      git_url: git_url,
+      public_url: public_url,
+      commands: commands
+    }, callback);
+  },
+  
+  update: function(id, label, git_url, public_url ,commands) {
+    Projects.update(
+      id, 
+      { $set: { 
+        label: label,
+        git_url: git_url,
+        public_url: public_url,
+        commands: commands
+        } 
+      }
+    );
+  },
+  
+  delete: function(id) {
+    Projects.remove(id);
+  },
+  
+  get: function(id) {
+    return Projects.findOne({_id: id});
+  },
+  
+  list: function() {
+    return Projects.find({}, {sort: {label: 1}});
+  }
+};

+ 3 - 0
server/publications.js

@@ -0,0 +1,3 @@
+Meteor.publish('projects', function() {
+  return ProjectService.list();
+});