Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit fbc2555

Browse files
committed
initial import
1 parent 6f5a968 commit fbc2555

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+6947
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/app/bundle/**/*.js
2+
.DS_Store

app/components/link-blog.vue

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
3+
<div class="uk-form-row">
4+
<label for="form-link-blog" class="uk-form-label">{{ 'View' | trans }}</label>
5+
<div class="uk-form-controls">
6+
<select id="form-link-blog" class="uk-width-1-1" v-model="link" options="postOptions"></select>
7+
</div>
8+
</div>
9+
10+
</template>
11+
12+
<script>
13+
14+
module.exports = {
15+
16+
link: {
17+
label: 'Blog'
18+
},
19+
20+
props: ['link'],
21+
22+
data: function () {
23+
return {
24+
posts: []
25+
}
26+
},
27+
28+
created: function () {
29+
this.$resource('api/blog/post').get({limit: 100}, function (data) {
30+
this.$set('posts', data.posts);
31+
});
32+
},
33+
34+
ready: function() {
35+
this.link = '@blog';
36+
},
37+
38+
computed: {
39+
40+
postOptions: function () {
41+
return [{text: this.$trans('Posts View'), value: '@blog'}].concat({label: this.$trans('Posts'), options: _.map(this.posts, function (post) {
42+
return {text: post.title, value: '@blog/id?id='+post.id};
43+
})});
44+
}
45+
46+
}
47+
48+
};
49+
50+
window.Links.components['link-blog'] = module.exports;
51+
52+
</script>

app/components/node-blog.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
3+
<div class="uk-form-horizontal">
4+
5+
<partial name="settings"></partial>
6+
7+
</div>
8+
9+
</template>
10+
11+
<script>
12+
13+
module.exports = {
14+
15+
inherit: true,
16+
17+
section: {
18+
label: 'Settings',
19+
priority: 0,
20+
active: '^blog$'
21+
}
22+
23+
};
24+
25+
window.Site.components['node-blog'] = module.exports;
26+
27+
</script>

app/views/admin/comment-index.js

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
module.exports = {
2+
3+
data: function () {
4+
return _.merge({
5+
posts: [],
6+
comments: false,
7+
pages: 0,
8+
count: '',
9+
selected: [],
10+
user: window.$pagekit.user,
11+
replyComment: {},
12+
editComment: {}
13+
}, window.$data);
14+
},
15+
16+
created: function () {
17+
18+
this.Comments = this.$resource('api/blog/comment/:id');
19+
this.config.filter = _.extend({filter: {search: '', status: ''}}, this.config.filter);
20+
21+
UIkit.init(this.$el);
22+
},
23+
24+
watch: {
25+
26+
'config.page': 'load',
27+
28+
'config.filter': {
29+
handler: function () {
30+
this.load(0);
31+
},
32+
deep: true
33+
}
34+
35+
},
36+
37+
computed: {
38+
39+
statusOptions: function () {
40+
41+
var options = _.map(this.$data.statuses, function (status, id) {
42+
return {text: status, value: id};
43+
});
44+
45+
return [{label: this.$trans('Filter by'), options: options}];
46+
}
47+
48+
},
49+
50+
methods: {
51+
52+
active: function (comment) {
53+
return this.selected.indexOf(comment.id) != -1;
54+
},
55+
56+
submit: function () {
57+
this.save(this.editComment.id ? this.editComment : this.replyComment);
58+
},
59+
60+
save: function (comment) {
61+
return this.Comments.save({id: comment.id}, {comment: comment}, function () {
62+
this.load();
63+
this.$notify('Comment saved.');
64+
}, function (data) {
65+
this.$notify(data, 'danger');
66+
});
67+
},
68+
69+
status: function (status) {
70+
71+
var comments = this.getSelected();
72+
73+
comments.forEach(function (comment) {
74+
comment.status = status;
75+
});
76+
77+
this.Comments.save({id: 'bulk'}, {comments: comments}, function () {
78+
this.load();
79+
this.$notify('Comments saved.');
80+
});
81+
},
82+
83+
remove: function () {
84+
this.Comments.delete({id: 'bulk'}, {ids: this.selected}, function () {
85+
this.load();
86+
this.$notify('Comment(s) deleted.');
87+
});
88+
},
89+
90+
load: function (page) {
91+
92+
page = page !== undefined ? page : this.$get('config.page');
93+
94+
this.cancel();
95+
96+
this.Comments.query({filter: this.config.filter, post: this.config.post && this.config.post.id || 0, page: page, limit: this.config.limit}, function (data) {
97+
this.$set('posts', data.posts);
98+
this.$set('comments', data.comments);
99+
this.$set('pages', data.pages);
100+
this.$set('count', data.count);
101+
this.$set('config.page', page);
102+
this.$set('selected', []);
103+
});
104+
},
105+
106+
getSelected: function () {
107+
var vm = this;
108+
return this.comments.filter(function (comment) {
109+
return vm.selected.indexOf(comment.id) !== -1;
110+
});
111+
},
112+
113+
getStatusText: function (comment) {
114+
return this.statuses[comment.status];
115+
},
116+
117+
cancel: function (e) {
118+
119+
if (e) {
120+
e.preventDefault();
121+
e.stopPropagation();
122+
}
123+
124+
this.$set('replyComment', {});
125+
this.$set('editComment', {});
126+
}
127+
128+
},
129+
130+
components: {
131+
132+
'row': {
133+
inherit: true,
134+
template: '<component is="{{ editComment.id !== comment.id ? \'default-row\' : \'edit-row\' }}"></component>'
135+
},
136+
137+
'default-row': {
138+
139+
inherit: true,
140+
template: '#default-row',
141+
142+
computed: {
143+
144+
post: function () {
145+
return _.find(this.posts, 'id', this.comment.post_id) || {};
146+
}
147+
148+
},
149+
150+
methods: {
151+
152+
reply: function () {
153+
this.cancel();
154+
this.$set('replyComment', {parent_id: this.comment.id, post_id: this.comment.post_id, author: this.user.name, email: this.user.email});
155+
},
156+
157+
edit: function () {
158+
this.cancel();
159+
this.$set('editComment', _.merge({}, this.comment));
160+
},
161+
162+
toggleStatus: function () {
163+
this.comment.status = this.comment.status === 1 ? 0 : 1;
164+
this.save(this.comment);
165+
}
166+
167+
}
168+
169+
},
170+
171+
'edit-row': {
172+
173+
inherit: true,
174+
template: '#edit-row'
175+
176+
}
177+
178+
}
179+
180+
};
181+
182+
jQuery(function () {
183+
184+
(new Vue(module.exports)).$mount('#comments');
185+
186+
});

app/views/admin/post-edit.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var App = Vue.extend({
2+
3+
data: function() {
4+
return {
5+
data: window.$data,
6+
post: window.$data.post
7+
}
8+
},
9+
10+
created: function () {
11+
this.resource = this.$resource('api/blog/post/:id');
12+
},
13+
14+
computed: {
15+
16+
statuses: function() {
17+
return _.map(this.data.statuses, function(status, id) { return { text: status, value: id }; } );
18+
},
19+
20+
authors: function() {
21+
return this.data.authors.map(function(user) { return { text: user.username, value: user.id }; });
22+
}
23+
24+
},
25+
26+
methods: {
27+
28+
save: function (e) {
29+
e.preventDefault();
30+
31+
this.resource.save({ id: this.post.id }, { post: this.post, id: this.post.id }, function (data) {
32+
33+
if (!this.post.id) {
34+
window.history.replaceState({}, '', this.$url.route('admin/blog/post/edit', {id: data.post.id}))
35+
}
36+
37+
this.$set('post', data.post);
38+
39+
this.$notify('Post saved.');
40+
41+
}, function (data) {
42+
this.$notify(data, 'danger');
43+
});
44+
}
45+
46+
}
47+
48+
});
49+
50+
jQuery(function () {
51+
new App().$mount('#post');
52+
});
53+
54+
module.exports = App;

0 commit comments

Comments
 (0)