-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish the waline3 component develop.
- Loading branch information
Showing
16 changed files
with
351 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* Waline3 comment plugin */ | ||
NexT.plugins.comments.waline3 = function () { | ||
const element = '.waline3-container'; | ||
if (!NexT.CONFIG.waline3 | ||
|| !NexT.utils.checkDOMExist(element)) return; | ||
|
||
const { | ||
emoji, | ||
search, | ||
imguploader, | ||
placeholder, | ||
sofa, | ||
requiredmeta, | ||
serverurl, | ||
wordlimit, | ||
reaction, | ||
reactiontext, | ||
reactiontitle | ||
} = NexT.CONFIG.waline3.cfg; | ||
|
||
const waline_js = NexT.utils.getCDNResource(NexT.CONFIG.waline3.js); | ||
|
||
NexT.utils.lazyLoadComponent(element, () => { | ||
|
||
const waline_css = NexT.utils.getCDNResource(NexT.CONFIG.waline3.css); | ||
NexT.utils.getStyle(waline_css, 'before'); | ||
|
||
let waline_script = ` | ||
let locale = { | ||
placeholder : '${placeholder}', | ||
sofa : '${sofa}', | ||
reactionTitle : '${reactiontitle}' | ||
}; | ||
let recatt = ${JSON.stringify(reactiontext)} | ||
recatt.forEach(function(value, index){ | ||
locale['reaction'+index] = value; | ||
}); | ||
import('${waline_js}').then((Waline) => { | ||
Waline.init({ | ||
locale, | ||
el : '${element}', | ||
emoji : ${emoji}, | ||
search : ${search}, | ||
imageUploader : ${imguploader}, | ||
wordLimit : ${wordlimit}, | ||
requiredMeta : ${JSON.stringify(requiredmeta)}, | ||
reaction : ${reaction}, | ||
serverURL : '${serverurl}', | ||
}); | ||
NexT.utils.hiddeLodingCmp('${element}'); | ||
}); | ||
`; | ||
|
||
NexT.utils.getScript(null, { module: true, textContent: waline_script }); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,66 @@ | ||
/* Page's view & comment counter plugin */ | ||
NexT.plugins.others.counter = function() { | ||
let pageview_js = undefined; | ||
let comment_js = undefined; | ||
NexT.plugins.others.counter = function () { | ||
let pageview_js = undefined; | ||
let comment_js = undefined; | ||
|
||
const post_meta = NexT.CONFIG.postmeta; | ||
const post_meta = NexT.CONFIG.postmeta; | ||
|
||
const views = post_meta.views; | ||
if(views != undefined && views.enable) { | ||
if (views.plugin == 'waline') { | ||
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.js[0]); | ||
NexT.utils.getScript(pageview_js, function(){ | ||
const views = post_meta.views; | ||
if (views != undefined && views.enable) { | ||
let pageview_el = '#pageview-count'; | ||
|
||
switch (views.plugin) { | ||
case 'waline': | ||
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.pagecnt); | ||
NexT.utils.getScript(pageview_js, function () { | ||
Waline.pageviewCount({ | ||
selector : pageview_el, | ||
serverURL: NexT.CONFIG.waline.cfg.serverurl | ||
}); | ||
}); | ||
} | ||
break; | ||
case 'waline3': | ||
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline3.pagecnt); | ||
|
||
let pageview_script = ` | ||
import('${pageview_js}').then((Waline) => { | ||
Waline.pageviewCount({ | ||
selector : '${pageview_el}', | ||
serverURL: '${NexT.CONFIG.waline3.cfg.serverurl}' | ||
}) | ||
}); | ||
`; | ||
NexT.utils.getScript(null, { module: true, textContent: pageview_script }); | ||
break; | ||
} | ||
|
||
const comments = post_meta.comments; | ||
if (comments != undefined && comments.enable) { | ||
if (comments.plugin == 'waline') { | ||
comment_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.js[1]); | ||
NexT.utils.getScript(comment_js, function(){ | ||
} | ||
|
||
const comments = post_meta.comments; | ||
if (comments != undefined && comments.enable) { | ||
let comments_el = '#comments-count'; | ||
switch (comments.plugin) { | ||
case 'waline': | ||
comment_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.commentcnt); | ||
NexT.utils.getScript(comment_js, function () { | ||
Waline.commentCount({ | ||
selector : comments_el, | ||
serverURL: NexT.CONFIG.waline.cfg.serverurl | ||
}); | ||
}); | ||
} | ||
break; | ||
case 'waline3': | ||
comment_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline3.commentcnt); | ||
let comment_script = ` | ||
import('${comment_js}').then((Waline) => { | ||
Waline.commentCount({ | ||
selector : '${comments_el}', | ||
serverURL: '${NexT.CONFIG.waline3.cfg.serverurl}' | ||
}) | ||
}); | ||
`; | ||
NexT.utils.getScript(null, { module: true, textContent: comment_script }); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.