diff --git a/bower.json b/bower.json
index c237e4c..7591cf2 100644
--- a/bower.json
+++ b/bower.json
@@ -22,6 +22,6 @@
"angular-ui-select": "^0.19.4",
"angular-sanitize": "^1.5.8",
"angular-ui-tree": "^2.21.2",
- "Angular-Markdown-Editor": "angular-markdown-editor#*"
+ "angular-markdown-editor-ghiscoding": "^1.0.7"
}
}
diff --git a/public/app/app.js b/public/app/app.js
index c35096f..fac67b1 100644
--- a/public/app/app.js
+++ b/public/app/app.js
@@ -6,15 +6,25 @@ angular.module('warehost', [
'ui.bootstrap',
'ui.select',
'ui.tree',
- 'ui.markdown',
+ 'hc.marked',
+ 'angular-markdown-editor',
'ngTable',
'config',
'session',
'alert'
])
- .config(['$urlRouterProvider','$httpProvider',function($urlRouterProvider,$httpProvider){
+ .config(['$urlRouterProvider','$httpProvider','markedProvider',function($urlRouterProvider,$httpProvider,markedProvider){
$urlRouterProvider.otherwise('/');
$httpProvider.defaults.withCredentials = true;
+ // marked config
+ markedProvider.setOptions({
+ gfm: true,
+ tables: true,
+ sanitize: true
+ });
+
+ // highlight config
+ //hljsServiceProvider.setOptions({});
}]).run(function(session,config,$http) {
$http.get(config.api+'/status').then(function(res){
session.set(res);
diff --git a/public/app/web/page.jade b/public/app/web/page.jade
index 471f6c5..06ac3bd 100644
--- a/public/app/web/page.jade
+++ b/public/app/web/page.jade
@@ -1,15 +1,21 @@
.container
h1 Pages
.row
- .well.col-md-6(ui-tree)
+ .well.col-md-3(ui-tree)
.btn-toolbar
.btn-group
- a.btn.btn-default(ng-click="add(null)")
+ a.btn.btn-default(ng-click="add()")
span.glyphicon.glyphicon-plus
br
.list-group
- .list-group-item(ng-repeat="item in list") {{item.title}}
- form.col-md-6(ng-submit="save()")
+ .list-group-item(ng-repeat="item in data")
+ .angular-ui-tree-handle {{item.title}}
+ .pull-right.btn-group.btn-group-xs
+ a.btn.btn-default(ng-click="edit(item)")
+ span.glyphicon.glyphicon-pencil
+ a.btn.btn-default(ng-click="delete(item)")
+ span.glyphicon.glyphicon-remove
+ form.col-md-9(ng-submit="save()")
h3(ng-if="obj.ID") Edit
h3(ng-if="!obj.ID") New
.form-group
@@ -24,7 +30,5 @@
div(ng-bind-html="item.name | highlight: $select.search")
.form-group
label(for="content") Content
- textarea.form-control(id="content",ui-markdown-editor="{}",ng-model="obj.content")
+ textarea.form-control(id="content",markdown-editor="{hiddenButtons:'cmdImage',addExtraButtons: true, resize: 'vertical'}",ng-model="obj.content",rows="10")
input.btn.btn-default(type="submit",value="Save")
- h3 Preview
- div(ng-bind-markdown="obj.content")
diff --git a/public/app/web/page.js b/public/app/web/page.js
index 3453452..84924e9 100644
--- a/public/app/web/page.js
+++ b/public/app/web/page.js
@@ -2,11 +2,8 @@
angular.module('warehost')
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
- $scope.tableParams = new NgTableParams({
- sorting: { 'invited.username': 'asc' },
- total: 0,
- count: config.table.count
- }, { dataset: [] });
+ $scope.data = [];
+ $scope.menulist = [];
alert.set({});
$scope.obj = {};
@@ -14,29 +11,38 @@ angular.module('warehost')
$scope.obj = {};
}
function load(){
- $http.get(config.api+'/web/'+$stateParams.websiteid+'/page').then(function(res){
- session.set(res);
- $scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
+ $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu/list').then(function(res){
+ $scope.menulist = res.data.data;
+ $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){
+ session.set(res);
+ $scope.data = res.data.data;
+ });
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
- resetObj();
- $scope.isAdding = false;
+ load();
}
}
resetObj();
load();
$scope.edit = function(a){
- $http.put(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID,a.website).then(submitresult);
- };
- $scope.delete = function(a){
- $http.delete(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID).then(submitresult);
+ $scope.obj = a;
};
$scope.add = function(){
- $http.post(config.api+'/web/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
+ $scope.obj = {};
+ }
+ $scope.save = function(){
+ if($scope.obj.ID){
+ $http.put(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+$scope.obj.ID,$scope.obj).then(submitresult);
+ }else{
+ $http.post(config.api+'/web/website/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
+ }
+ };
+ $scope.delete = function(a){
+ $http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+a.ID).then(submitresult);
};
});
diff --git a/public/index.html b/public/index.html
index 2534e4b..3b75687 100644
--- a/public/index.html
+++ b/public/index.html
@@ -18,7 +18,8 @@
-
+
+
@@ -46,9 +47,11 @@
-
-
-
+
+
+
+
+