added git basic commit
This commit is contained in:
parent
2a653295b4
commit
4b82e37236
16
db.js
16
db.js
@ -7,6 +7,12 @@ var Bookshelf = require('bookshelf');
|
|||||||
var async = require('async');
|
var async = require('async');
|
||||||
var textile = require('textile-js')
|
var textile = require('textile-js')
|
||||||
|
|
||||||
|
var promisify = require("promisify-node");
|
||||||
|
|
||||||
|
var fse = promisify(require("fs-extra"));
|
||||||
|
fse.ensureDir = promisify(fse.ensureDir);
|
||||||
|
|
||||||
|
|
||||||
var nodegit = require("nodegit")
|
var nodegit = require("nodegit")
|
||||||
|
|
||||||
var Markdown = textile //Markdown = require('js-markdown-extra').Markdown
|
var Markdown = textile //Markdown = require('js-markdown-extra').Markdown
|
||||||
@ -43,7 +49,9 @@ function pathFromDir() {
|
|||||||
return Path.join(__dirname, "pages");
|
return Path.join(__dirname, "pages");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function repoPath(name) {
|
||||||
|
return Path.join( name + ".markdown");
|
||||||
|
}
|
||||||
function fullPath(files) {
|
function fullPath(files) {
|
||||||
var paths = []
|
var paths = []
|
||||||
for (var i= 0; i < files.length; i++)
|
for (var i= 0; i < files.length; i++)
|
||||||
@ -142,18 +150,20 @@ exports.editPage = function (name, callback) {
|
|||||||
// Saving is simple. Just put the markdown in the file
|
// Saving is simple. Just put the markdown in the file
|
||||||
exports.savePage = function (name, value, callback) {
|
exports.savePage = function (name, value, callback) {
|
||||||
var pathFile = pathFromNameMd(name);
|
var pathFile = pathFromNameMd(name);
|
||||||
|
var repos_relative = repoPath(name);
|
||||||
FS.writeFile(pathFile, value.replace(/\r/g,""), function (){
|
FS.writeFile(pathFile, value.replace(/\r/g,""), function (){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
console.log(pathFile)
|
||||||
var repo;
|
var repo;
|
||||||
var index;
|
var index;
|
||||||
var oid;
|
var oid;
|
||||||
|
|
||||||
nodegit.Repository.open(Path.resolve(__dirname, "pages/.git"))
|
nodegit.Repository.open(Path.resolve(__dirname, "pages/.git"))
|
||||||
.then(function(repoResult) {
|
.then(function(repoResult) {
|
||||||
|
console.log(repoResult)
|
||||||
repo = repoResult;
|
repo = repoResult;
|
||||||
})
|
})
|
||||||
.then(function (){
|
.then(function (){
|
||||||
@ -165,7 +175,7 @@ exports.savePage = function (name, value, callback) {
|
|||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// this file is in the root of the directory and doesn't need a full path
|
// this file is in the root of the directory and doesn't need a full path
|
||||||
return index.addByPath(name);
|
return index.addByPath(repos_relative);
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// this will write both files to the index
|
// this will write both files to the index
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
h3. [THSF]:/less/is/more/test/test/test
|
h3. [THSF]:/less/is/more/test/test/test /test /test test test test
|
||||||
|
|
||||||
|
|
||||||
h4. 14-17/05/2015 Toulouse France
|
h4. 14-17/05/2015 Toulouse France
|
||||||
|
Loading…
Reference in New Issue
Block a user