diff --git a/.gitattributes b/.gitattributes index fef2305..b69e94b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ static/js/* -linguist-detectable static/css/sakura/* -linguist-detectable +static/css/soudan.css -linguist-detectable diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1238911..2c5245b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -25,4 +25,8 @@
"+I(e[r].content)+"
\n"},M.fence=function(e,r,t,n,s){var o,i,a,c,l,u=e[r],p=u.info?T(u.info).trim():"",h="",f="";return p&&(h=(a=p.split(/(\s+)/g))[0],f=a.slice(2).join("")),0===(o=t.highlight&&t.highlight(u.content,h,f)||I(u.content)).indexOf(""+o+"
\n"):""+o+"
\n"},M.image=function(e,r,t,n,s){var o=e[r];return o.attrs[o.attrIndex("alt")][1]=s.renderInlineAsText(o.children,t,n),s.renderToken(e,r,t)},M.hardbreak=function(e,r,t){return t.xhtmlOut?"=4))break;s=++n}return e.line=s,(o=e.push("code_block","code",0)).content=e.getLines(r,s,4+e.blkIndent,!1)+"\n",o.map=[r,e.line],!0}],["fence",function(e,r,t,n){var s,o,i,a,c,l,u,p=!1,h=e.bMarks[r]+e.tShift[r],f=e.eMarks[r];if(e.sCount[r]-e.blkIndent>=4)return!1;if(h+3>f)return!1;if(126!==(s=e.src.charCodeAt(h))&&96!==s)return!1;if(c=h,(o=(h=e.skipChars(h,s))-c)<3)return!1;if(u=e.src.slice(c,h),i=e.src.slice(h,f),96===s&&i.indexOf(String.fromCharCode(s))>=0)return!1;if(n)return!0;for(a=r;!(++a>=t)&&!((h=c=e.bMarks[a]+e.tShift[a])<(f=e.eMarks[a])&&e.sCount[a] i;n-=d[n]+1)if((o=r[n]).marker===s.marker&&o.open&&o.end<0&&(c=!1,(o.close||s.open)&&(o.length+s.length)%3==0&&(o.length%3==0&&s.length%3==0||(c=!0)),!c)){l=n>0&&!r[n-1].open?d[n-1]+1:0,d[t]=t-n+l,d[n]=l,s.open=!1,o.end=t,o.close=!1,a=-1,f=-2;break}-1!==a&&(u[s.marker][(s.open?3:0)+(s.length||0)%3]=a)}}}var tr=w.isWhiteSpace,nr=w.isPunctChar,sr=w.isMdAsciiPunct;function or(e,r,t,n){this.src=e,this.env=t,this.md=r,this.tokens=n,this.tokens_meta=Array(n.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}or.prototype.pushPending=function(){var e=new oe("text","",0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending="",e},or.prototype.push=function(e,r,t){this.pending&&this.pushPending();var n=new oe(e,r,t),s=null;return t<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),n.level=this.level,t>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],s={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(s),n},or.prototype.scanDelims=function(e,r){var t,n,s,o,i,a,c,l,u,p=e,h=!0,f=!0,d=this.posMax,m=this.src.charCodeAt(e);for(t=e>0?this.src.charCodeAt(e-1):32;p No comments yet! Be the first to make one.>>0,s=0;sthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},i.isLocal=function(){return!!this.isValid()&&!this._isUTC},i.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},i.isUtc=At,i.isUTC=At,i.zoneAbbr=function(){return this._isUTC?"UTC":""},i.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},i.dates=e("dates accessor is deprecated. Use date instead.",ve),i.months=e("months accessor is deprecated. Use month instead",Ge),i.years=e("years accessor is deprecated. Use year instead",Ie),i.zone=e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),i.isDSTShifted=e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e,t={};return $(t,this),(t=Nt(t))._a?(e=(t._isUTC?l:W)(t._a),this._isDSTShifted=this.isValid()&&0Make a comment
+${commentForm()}
+Comments
+`;
+const md = window.markdownit().disable("image");
+const form = document.getElementById("soudan-comment-form");
+const commentContainer = document.getElementById("soudan-comments");
+const commentContainerHeader = document.getElementById("soudan-comments-header");
+const contentId = document.querySelector("meta[name=\"soudan-content-id\"]").getAttribute("content");
+
+function submitForm(form, e) {
+ let data = {
+ url: window.location.href,
+ comment: { contentId }
+ };
+ new FormData(form).forEach((value, key) => {
+ data.comment[key] = value === "" ? null : value;
+ });
+ if (data.comment.parent) {
+ data.comment.parent = parseInt(data.comment.parent);
+ }
+ fetch(url, {
+ method: "POST",
+ body: JSON.stringify(data),
+ headers: { "Content-Type": "application/json" }
+ })
+ .then(response => {
+ if (!response.ok) {
+ Promsise.reject();
+ }
+ form.querySelector("textarea").value = "";
+ reloadComments();
+ })
+ .catch(error => alert("Something went wrong posting your comment!"))
+ e.preventDefault();
+}
+
+function reloadComments(jump) {
+ fetch(`${url}/${contentId}`)
+ .then(response => {
+ return response.json().then(json => {
+ return response.ok ? json : Promise.reject(json);
+ });
+ })
+ .then(comments => {
+ let commentCount = comments.length;
+ comments.forEach(comment => {
+ if (comment.replies) {
+ commentCount += comment.replies.length;
+ }
+ });
+ commentContainerHeader.innerHTML = `${commentCount} Comment${commentCount == 1 ? "" : "s"}`;
+ let html = "";
+ if (comments.length == 0) {
+ html = "Reply
${commentForm(id)}${replies.innerHTML}`;
+}
+
+reloadComments(true);