Browse code

added git basic commit

ang-st authored on 06/06/2015 02:58:25
Showing 2 changed files
... ...
@@ -7,6 +7,12 @@ var Bookshelf = require('bookshelf');
7 7
 var async = require('async');
8 8
 var textile = require('textile-js')
9 9
 
10
+var promisify = require("promisify-node");
11
+
12
+var fse = promisify(require("fs-extra"));
13
+fse.ensureDir = promisify(fse.ensureDir);
14
+
15
+
10 16
 var nodegit = require("nodegit")
11 17
 
12 18
 var Markdown =  textile //Markdown = require('js-markdown-extra').Markdown
... ...
@@ -43,7 +49,9 @@ function pathFromDir() {
43 43
   return Path.join(__dirname, "pages");
44 44
 }
45 45
 
46
-
46
+function repoPath(name) {
47
+  return Path.join( name + ".markdown");
48
+}
47 49
 function fullPath(files) {
48 50
   var paths = []
49 51
   for (var i= 0; i < files.length; i++)
... ...
@@ -142,18 +150,20 @@ exports.editPage = function (name, callback) {
142 142
 // Saving is simple.  Just put the markdown in the file
143 143
 exports.savePage = function (name, value, callback) {
144 144
   var pathFile = pathFromNameMd(name);
145
+  var repos_relative = repoPath(name); 
145 146
   FS.writeFile(pathFile, value.replace(/\r/g,""), function (){
146 147
               
147 148
               
148 149
               
149 150
              
150
-  
151
+  console.log(pathFile)
151 152
   var repo;
152 153
   var index;
153 154
   var oid;
154 155
 
155 156
   nodegit.Repository.open(Path.resolve(__dirname, "pages/.git"))
156 157
     .then(function(repoResult) {
158
+        console.log(repoResult)
157 159
         repo = repoResult;
158 160
     })
159 161
     .then(function (){ 
... ...
@@ -165,7 +175,7 @@ exports.savePage = function (name, value, callback) {
165 165
     })
166 166
     .then(function() {
167 167
      // this file is in the root of the directory and doesn't need a full path
168
-      return index.addByPath(name);
168
+      return index.addByPath(repos_relative);
169 169
     })
170 170
     .then(function() {
171 171
   // this will write both files to the index
... ...
@@ -1,3 +1,4 @@
1
-h3. [THSF]:/less/is/more/test/test/test
1
+h3. [THSF]:/less/is/more/test/test/test /test /test test test test
2
+
2 3
 
3 4
 h4. 14-17/05/2015 Toulouse France