sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0

add blog post + bugfix

This commit is contained in:
Martin Geno 2017-03-21 18:16:32 +01:00
parent f07e4bece5
commit d8378c4073
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
10 changed files with 144 additions and 34 deletions

View File

@ -253,6 +253,14 @@ module.exports = function (grunt) {
'*.*'
]
},
{
expand: true,
cwd: 'public/bower_components/font-awesome/fonts',
dest: 'build/fonts',
src: [
'*.*'
]
},
{
expand: true,
cwd: '.tmp/img',

View File

@ -23,9 +23,33 @@
i (http(s)://DOMAIN/{{blog.url.path}})
input.form-control(id="url",ng-model="blog.url.path")
.form-group
label(for="posturl") Post URL Schema
label(for="posturl") Post url schema
.input-group
.input-group-addon http(s)://DOMAIN/{{blog.url.path}}
select.form-control(ng-model="blog.posturl",ng-options="item.key as item.label for item in posturlOptions")
.form-group
label(for="content") Content
div(id="content",text-angular,ta-text-editor-class="clearfix border-around" ta-html-editor-class="border-around",ng-model="blog.content")
// .form-group
.checkbox
label
input(type="checkbox",ng-model="blog.preview_enable")
| Preview image
.form-group
.checkbox
label
input(type="checkbox",ng-model="blog.author_enable")
| Show author
.form-group
.checkbox
label
input(type="checkbox",ng-model="blog.createat_enable")
| Show create at
.form-group
.checkbox
label
input(type="checkbox",ng-model="blog.timerange_enable")
| Manage timerange in post
input.btn.btn-default(type="submit",value="Save")
input.btn.btn-danger(ng-if="blog.ID",value="Delete",ng-click="delete(blog)")

View File

@ -2,6 +2,10 @@
angular.module('warehost')
.controller('BlogWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
$scope.posturlOptions = [
{key:0, label: '/title'},
{key:1, label: '/year/month/title'}
];
$scope.bloglist = [];
alert.set({});
$scope.blog = {};
@ -16,17 +20,21 @@ angular.module('warehost')
resetBlog();
$scope.bloglist = res.data.data;
var blog;
for(blog in $scope.bloglist){
if(blog.ID === $stateParams.blogid) {
$scope.blog = blog;
for(var i in $scope.bloglist){
blog = $scope.bloglist[i];
if(blog.ID === Number($stateParams.blogid)) {
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$stateParams.blogid).then(setBlog);
return;
}
}
if($scope.bloglist.length > 0 && $stateParams.blogid !== '-1'){
$scope.blog = $scope.bloglist[0];
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.bloglist[0].ID).then(setBlog);
}
});
}
function setBlog(res) {
$scope.blog = res.data.data;
}
function submitresult(res){
session.set(res);
alert.set(res);

View File

@ -1,31 +1,46 @@
h2 Posts
.row
.well.col-md-3
.btn-toolbar
.btn-group
a.btn.btn-default(ng-click="add()")
.col-md-3
.panel.panel-default
.panel-heading All
a.pull-right.btn.btn-default.btn-xs(ng-click="add()")
span.glyphicon.glyphicon-plus
br
.list-group
.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
table.table
tr(ng-repeat="item in blog.posts")
td {{item.title}}
td
.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
h3(ng-if="post.ID") Edit
h3(ng-if="!post.ID") New
.form-group
label(for="title") Title
input.form-control(id="title",ng-model="obj.title")
input.form-control(id="title",ng-model="post.title")
.form-group(ng-if="blog.author_enable")
label(for="author") Author
input.form-control(id="author",ng-model="post.author")
.form-group(ng-if="blog.createat_enable")
label(for="date") Create at
input.form-control(id="date",ng-model="post.createat")
.form-group(ng-if="blog.timerange_enable")
label(for="timerange") Timerange
.row
.col-md-6
.input-group
.input-group-addon start
input.form-control(id="timerange",ng-model="post.start")
.col-md-6
.input-group
.input-group-addon end
input.form-control(id="timerange",ng-model="post.end")
.form-group
label(for="url") URL
br
i (http(s)://DOMAIN/{{obj.url.path}})
input.form-control(id="url",ng-model="obj.url.path")
label(for="summary") Summary
div(id="summary",text-angular,ta-text-editor-class="clearfix border-around",ta-html-editor-class="border-around",ng-model="post.summary")
.form-group
label(for="content") Content
div(id="content",text-angular,ta-text-editor-class="clearfix border-around" ta-html-editor-class="border-around",ng-model="obj.content")
div(id="content",text-angular,ta-text-editor-class="clearfix border-around",ta-html-editor-class="border-around",ng-model="post.content")
input.btn.btn-default(type="submit",value="Save")

View File

@ -0,0 +1,45 @@
'use strict';
angular.module('warehost')
.controller('BlogPostWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
alert.set({});
$scope.post = {};
$scope.websiteid = $stateParams.websiteid;
function reset(){
$scope.post = {};
}
function load(){
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID).then(function(res){
session.set(res);
reset();
$scope.blog = res.data.data;
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
load();
}
}
reset();
$rootScope.$on('warehost.session',load);
$scope.edit = function(a){
$scope.post = a;
};
$scope.add = function(){
$scope.post = {};
};
$scope.save = function(){
if($scope.post.ID){
$http.patch(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID+'/post/'+$scope.post.ID, $scope.post).then(submitresult);
}else{
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID+'/post', $scope.post).then(submitresult);
}
};
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID+'/post/'+a.ID).then(submitresult);
};
});

View File

@ -64,7 +64,7 @@ angular.module('warehost')
views:{
'posts':{
templateUrl: 'app/web/blogpost.html',
controller:'BlogWebCtrl'
controller:'BlogPostWebCtrl'
}
}
})

View File

@ -4,7 +4,7 @@
.row
.col-md-3
.panel.panel-default
.panel-heading Pages
.panel-heading All
a.pull-right.btn.btn-default.btn-xs(ng-click="add()")
span.glyphicon.glyphicon-plus
table.table

View File

@ -35,9 +35,18 @@ angular.module('warehost')
url.obj.url = null;
$scope.urllist.push(url);
});
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu').then(function(res){
session.set(res);
$scope.data = res.data.data;
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog').then(function(res){
res.data.data.forEach(function (d) {
var url = d.url;
url.type = 'blog';
url.obj = d;
url.obj.url = null;
$scope.urllist.push(url);
});
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu').then(function(res){
session.set(res);
$scope.data = res.data.data;
});
});
});
}

View File

@ -2,7 +2,7 @@
angular.module('config', [])
.factory('config', function() {
return {
api: 'http://[::1]:8080',
api: 'https://api.warehost.de',
table: {
count: 25
}

View File

@ -7,7 +7,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title>Warehost v2</title>
<title>Warehost</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
@ -22,7 +22,7 @@
<!-- endbower -->
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/bootswatch/united/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" />
<!-- endbuild -->
<!-- build:css({.tmp,public}) app/app.css -->
<link rel="stylesheet" href="app/app.css">
@ -77,6 +77,7 @@
<script src="app/setting.js"></script>
<script src="app/user.js"></script>
<script src="app/web/blog.js"></script>
<script src="app/web/blogpost.js"></script>
<script src="app/web/domain.js"></script>
<script src="app/web/index.js"></script>
<script src="app/web/list.js"></script>