-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (27 loc) · 864 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
var electron = require('electron');
var remote = electron.remote;
var fileUtil = remote.require('./lib/fileUtil');
var matched = location.search.match(/baseDir=([^&]*)/);
var baseDir = matched && decodeURIComponent(matched[1]);
var ngModule = angular.module('readUs', []);
ngModule.controller('MainController', function ($scope) {
var main = this;
// Get README.md
main.getFile = function(file) {
main.fileText = fileUtil.getAsText(file.filepath);
};
fileUtil.fetchReadmeList(baseDir, function (err, fileList) {
if(err) console.error(err);
$scope.$apply(function () {
main.fileList = fileList;
});
});
});
ngModule.directive('mdPreview', function () {
return function ($scope, $elem, $attrs) {
$scope.$watch($attrs.mdPreview, function(source) {
$elem.html(marked(source));
});
};
});