showForm: true,
showSubmit: false,
+ disablePost: false,
message: "",
createdUrl: "",
currentTopics: [],
var props = {
item: {
type: Object,
- default: function () {return new Contents();}
+ default: function () {return new Contents();},
},
+ showEditor: {
+ type: Boolean,
+ default: false,
+ }
};
var watch = {
}
function editable() {
- return (vm.user.uid == this.item.uid);
+ return (this.vm.user.uid == this.item.uid);
}
function url() {
}
function showPreview(event) {
+ if (!articleItem.token) {
+ grecaptcha.execute();
+ statusBar.init();
+ statusBar.loading("checking if you are not a bot...");
+ }
+
var url = this.urls[this.item.content_type];
var postData = {};
Object.keys(this.item).forEach(k => {
}
function postItem(event) {
+ if (!user.is_login && !articleItem.token) {
+ return;
+ }
+
+ // load captcha
this.message = "";
var url = this.urls[this.item.content_type];
var postData = {};
postData.tags_string = this.tagsString;
postData.related_urls = this.relatedUrls;
+ if (articleItem.token) {
+ postData.recaptcha_token = articleItem.token;
+ }
+
this.$http.post(url, {item: postData, action: 'post'}).then(
(response) => { // success
this.message = "";
// end of methods
function created() {
+ if (this.showEditor) {
+ editing = 1;
+ }
+
+ // story edit mode
if (page.type == 'story' && page.stoid) {
this.cancelable = 1;
// load story data
var url = "/api/v1/story?stoid=" + page.stoid;
loadItem(this, url);
}
+
+ // submission to story mode
if (this.item.submission_id) {
- vue.item.author = vue.item.author || user.nickname;
+ this.item.author = this.item.author || user.nickname;
// load submission data
var url = "/api/v1/submission?subid=" + this.item.submission_id;
this.$http.get(url).then(
(resp) => { // succeed
this.title = resp.body.item.title;
this.introtext = resp.body.item.drafttext;
- initItem(this);
+ initEditor(this);
},
(resp) => { //failed
this.message = resp.body.message;
- initItem();
+ initEditor(this);
});
}
+
+ // submission edit mode
+ if (this.item.content_type == 'submission') {
+ initEditor(this);
+ }
}
function loadItem(vue, url) {
}
}
vue.createtime = nsUtil.decodeDateTime(vue.item.createtime);
- var tagnames = vue.item.tags.map(x => {return x.tagname});
- vue.tagsString = tagnames.join(" ");
+ if (vue.item.tags) {
+ var tagnames = vue.item.tags.map(x => {return x.tagname});
+ vue.tagsString = tagnames.join(" ");
+ } else {
+ vue.tagsString = "";
+ }
+
updateTopics.call(vue);
}
- Vue.component('article-item', {
+ Vue.component('article-item', {
template: '#article-item-template',
props: props,
data: data,
articleItem.init();
+function recaptchaDone(token) {
+ statusBar.hide();
+ articleItem.token = token;
+ console.log(token);
+}
+
<link rel="stylesheet" type="text/css" href="[% NS.static_content('css/bootstrap.css'); %]" />
<link rel="stylesheet" type="text/css" media="screen, projection" href="[% NS.static_content('css/main.css'); %]" />
<script src="/bootstrap/js/bootstrap.min.js" ></script>
-
+
[%- IF production -%]
<script src="/vue/vue.min.js"></script>
<script src="/vue/vue-resource.min.js"></script>
<script src="/js/escape-html.js" ></script>
<script src="[% NS.static_content('js/siteconfig.js'); %]" ></script>
+ [%- IF use_captcha && !user.is_login -%]
+ <script src="https://www.google.com/recaptcha/api.js"></script>
+ [%- END -%]
</head>