diff --git a/frontend/app.js b/frontend/app.js index ef6d33e..507390b 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -249,4 +249,4 @@ Use slot props instead: ${JSON.stringify(he,null,2)} when navigating to "${X.fullPath}". A redirect must contain a name or path. This will break in production.`),new Error("Invalid redirect");return rt({query:X.query,hash:X.hash,params:"path"in he?{}:X.params},he)}}function T(X,ce){let ie=k=j(X),he=g.value,Ce=X.state,$e=X.force,He=X.replace===!0,F=C(ie);if(F)return T(rt(Y(F),{state:typeof F=="object"?rt({},Ce,F.state):Ce,force:$e,replace:He}),ce||ie);let $=ie;$.redirectedFrom=ce;let Q;return!$e&&Lh(s,he,ie)&&(Q=Kn(16,{to:$,from:he}),S(he,he,!0,!1)),(Q?Promise.resolve(Q):V($,he)).catch(re=>oo(re)?oo(re,2)?re:P(re):ne(re,$,he)).then(re=>{if(re){if(oo(re,2))return Lh(s,j(re.to),$)&&ce&&(ce._count=ce._count?ce._count+1:1)>30?(Ye(`Detected a possibly infinite redirection in a navigation guard when going from "${he.fullPath}" to "${$.fullPath}". Aborting to avoid a Stack Overflow. Are you always returning a new location within a navigation guard? That would lead to this error. Only return when redirecting or aborting, that should fix this. This might break in production if not fixed.`),Promise.reject(new Error("Infinite redirect in navigation guard"))):T(rt({replace:He},Y(re.to),{state:typeof re.to=="object"?rt({},Ce,re.to.state):Ce,force:$e}),ce||$)}else re=q($,he,!0,He,Ce);return Z($,he,re),re})}function z(X,ce){let ie=p(X,ce);return ie?Promise.reject(ie):Promise.resolve()}function A(X){let ce=_e.values().next().value;return ce&&typeof ce.runWithContext=="function"?ce.runWithContext(X):X()}function V(X,ce){let ie,[he,Ce,$e]=n3(X,ce);ie=Bu(he.reverse(),"beforeRouteLeave",X,ce);for(let F of he)F.leaveGuards.forEach($=>{ie.push(Ao($,X,ce))});let He=z.bind(null,X,ce);return ie.push(He),Ge(ie).then(()=>{ie=[];for(let F of u.list())ie.push(Ao(F,X,ce));return ie.push(He),Ge(ie)}).then(()=>{ie=Bu(Ce,"beforeRouteUpdate",X,ce);for(let F of Ce)F.updateGuards.forEach($=>{ie.push(Ao($,X,ce))});return ie.push(He),Ge(ie)}).then(()=>{ie=[];for(let F of $e)if(F.beforeEnter)if(lr(F.beforeEnter))for(let $ of F.beforeEnter)ie.push(Ao($,X,ce));else ie.push(Ao(F.beforeEnter,X,ce));return ie.push(He),Ge(ie)}).then(()=>(X.matched.forEach(F=>F.enterCallbacks={}),ie=Bu($e,"beforeRouteEnter",X,ce),ie.push(He),Ge(ie))).then(()=>{ie=[];for(let F of c.list())ie.push(Ao(F,X,ce));return ie.push(He),Ge(ie)}).catch(F=>oo(F,8)?F:Promise.reject(F))}function Z(X,ce,ie){m.list().forEach(he=>A(()=>he(X,ce,ie)))}function q(X,ce,ie,he,Ce){let $e=p(X,ce);if($e)return $e;let He=ce===So,F=no?history.state:{};ie&&(he||He?d.replace(X.fullPath,rt({scroll:He&&F&&F.scroll},Ce)):d.push(X.fullPath,Ce)),g.value=X,S(X,ce,ie,He),P()}let L;function U(){L||(L=d.listen((X,ce,ie)=>{if(!Ke.listening)return;let he=j(X),Ce=C(he);if(Ce){T(rt(Ce,{replace:!0}),he).catch(oa);return}k=he;let $e=g.value;no&&Jy(Mh($e.fullPath,ie.delta),Vs()),V(he,$e).catch(He=>oo(He,12)?He:oo(He,2)?(T(He.to,he).then(F=>{oo(F,20)&&!ie.delta&&ie.type===ia.pop&&d.go(-1,!1)}).catch(oa),Promise.reject()):(ie.delta&&d.go(-ie.delta,!1),ne(He,he,$e))).then(He=>{He=He||q(he,$e,!1),He&&(ie.delta&&!oo(He,8)?d.go(-ie.delta,!1):ie.type===ia.pop&&oo(He,20)&&d.go(-1,!1)),Z(he,$e,He)}).catch(oa)}))}let N=ta(),G=ta(),J;function ne(X,ce,ie){P(X);let he=G.list();return he.length?he.forEach(Ce=>Ce(X,ce,ie)):(Ye("uncaught error during route navigation:"),console.error(X)),Promise.reject(X)}function Ne(){return J&&g.value!==So?Promise.resolve():new Promise((X,ce)=>{N.add([X,ce])})}function P(X){return J||(J=!X,U(),N.list().forEach(([ce,ie])=>X?ie(X):ce()),N.reset()),X}function S(X,ce,ie,he){let{scrollBehavior:Ce}=t;if(!no||!Ce)return Promise.resolve();let $e=!ie&&e1(Mh(X.fullPath,0))||(he||!ie)&&history.state&&history.state.scroll||null;return Ss().then(()=>Ce(X,ce,$e)).then(He=>He&&Qy(He)).catch(He=>ne(He,X,ce))}let fe=X=>d.go(X),Le,_e=new Set,Ke={currentRoute:g,listening:!0,addRoute:O,removeRoute:H,hasRoute:R,getRoutes:I,resolve:j,options:t,push:v,replace:w,go:fe,back:()=>fe(-1),forward:()=>fe(1),beforeEach:u.add,beforeResolve:c.add,afterEach:m.add,onError:G.add,isReady:Ne,install(X){let ce=this;X.component("RouterLink",$1),X.component("RouterView",G1),X.config.globalProperties.$router=ce,Object.defineProperty(X.config.globalProperties,"$route",{enumerable:!0,get:()=>wo(g)}),no&&!Le&&g.value===So&&(Le=!0,v(d.location).catch(Ce=>{Ye("Unexpected error when starting the router:",Ce)}));let ie={};for(let Ce in So)Object.defineProperty(ie,Ce,{get:()=>g.value[Ce],enumerable:!0});X.provide(Wu,ce),X.provide(ig,Pi(ie)),X.provide(Vu,g);let he=X.unmount;_e.add(X),X.unmount=function(){_e.delete(X),_e.size<1&&(k=So,L&&L(),L=null,g.value=So,Le=!1,J=!1),he()},no&&X1(X,ce,o)}};function Ge(X){return X.reduce((ce,ie)=>ce.then(()=>A(ie)),Promise.resolve())}return Ke}function n3(t,o){let n=[],s=[],d=[],u=Math.max(o.matched.length,t.matched.length);for(let c=0;cNo(k,m))?s.push(m):n.push(m));let g=t.matched[c];g&&(o.matched.find(k=>No(k,g))||d.push(g))}return[n,s,d]}var $s={data(){return{navContent:""}},methods:{loadNav(){return fetch("/_content/_navigation").then(t=>t.json()).then(t=>{this.navContent=t.content.split(` -`).filter(o=>o&&!o.match(/^!/))}).catch(t=>{console.error(t)})}},mounted(){this.loadNav()},name:"WikiApp"};var i3={class:"navbar navbar-expand-lg bg-body-tertiary mb-3"},a3={class:"container-fluid"},s3=kt("button",{class:"navbar-toggler",type:"button","data-bs-toggle":"collapse","data-bs-target":"#navbarSupportedContent","aria-controls":"navbarSupportedContent","aria-expanded":"false","aria-label":"Toggle navigation"},[kt("span",{class:"navbar-toggler-icon"})],-1),l3={id:"navbarSupportedContent",class:"collapse navbar-collapse"},d3={class:"navbar-nav me-auto mb-2 mb-lg-0"};function mg(t,o,n,s,d,u){let c=Un("router-link"),m=Un("router-view");return mr(),Br("div",null,[kt("nav",i3,[kt("div",a3,[wt(c,{class:"navbar-brand",to:{name:"home"}},{default:$n(()=>[Ps(" Wiki ")]),_:1}),s3,kt("div",l3,[kt("ul",d3,[(mr(!0),Br(Bt,null,Bm(d.navContent,g=>(mr(),Br("li",{key:g,class:"nav-item"},[wt(c,{class:"nav-link",to:{name:"view",params:{page:g}}},{default:$n(()=>[Ps(Ld(g),1)]),_:2},1032,["to"])]))),128))])])])]),wt(m)])}$s.render=mg;$s.__file="src/app.vue";var hg=$s;var _b=gp(kb()),bl={data(){return{editor:null}},methods:{loadPage(t){return console.debug(`Loading ${t}...`),fetch(`/_content/${t}`).then(o=>o.status===404?{content:`# ${t}`}:o.json()).then(o=>{this.editor&&(this.editor.toTextArea(),this.editor=null),this.editor=new _b.default({element:this.$refs.editor,forceSync:!0,indentWithTabs:!1,initialValue:o.content})}).catch(o=>{o.response&&o.response.status===404||console.error(o)})},save(){return fetch(`/_content/${this.$route.params.page}`,{body:JSON.stringify({content:this.$refs.editor.value}),method:"POST"}).then(()=>{this.$router.push({name:"view",params:{page:this.$route.params.page}})}).catch(t=>{console.error(t)})}},mounted(){this.loadPage(this.$route.params.page)},name:"WikiEdit",watch:{$route(t,o){t.params.page!==o.params.page&&this.loadPage(t.params.page)}}};var tk={class:"container"},rk={class:"row"},ok={class:"col"},nk={ref:"editor"};function Eb(t,o,n,s,d,u){return mr(),Br("div",tk,[kt("div",rk,[kt("div",ok,[kt("textarea",nk,null,512),kt("button",{class:"btn btn-primary",onClick:o[0]||(o[0]=(...c)=>u.save&&u.save(...c))}," Save ")])])])}bl.render=Eb;bl.__file="src/edit.vue";var Db=bl;var Ab=gp(Sb()),wl={data(){return{render:""}},emits:["rendered"],name:"WikiMarkdown",props:{content:{default:"",type:String},prerender:{default:null,type:Function}},watch:{content(t){let o=t;this.prerender&&(o=this.prerender(o));let n=new Ab.default.Converter;this.render=n.makeHtml(o),this.$emit("rendered")}}};var ik=["innerHTML"];function Nb(t,o,n,s,d,u){return mr(),Br(Bt,null,[Rs(" eslint-disable-next-line vue/no-v-html "),kt("div",{innerHTML:d.render},null,8,ik)],2112)}wl.render=Nb;wl.__file="src/markdown.vue";var Tb=wl;var xl={components:{mdRender:Tb},data(){return{content:""}},methods:{intLinkClick(t){let o=t.target;return this.$router.push({name:"view",params:{page:o.dataset.page}}),!1},loadPage(t){return console.debug(`Loading ${t}...`),fetch(`/_content/${t}`).then(o=>{if(o.status===404){this.$router.push({name:"edit",params:{page:t}});return}return o.json()}).then(o=>{o&&(this.content=o.content)}).catch(o=>{console.error(o)})},prerender(t){return t=t.replace(new RegExp(/\[\[([^\]]+)\]\]/,"g"),'$1'),t},rendered(){window.setTimeout(()=>{let t=this.$refs.content.getElementsByClassName("intLink");for(let o of t)o.onclick=this.intLinkClick;Prism.highlightAll()},100)}},mounted(){this.loadPage(this.$route.params.page)},name:"WikiView",watch:{$route(t,o){t.params.page!==o.params.page&&this.loadPage(t.params.page)}}};var ak={class:"container"},sk={class:"row"},lk={ref:"content",class:"col relAnchor"},dk=kt("i",{class:"fas fa-edit"},null,-1);function Ob(t,o,n,s,d,u){let c=Un("router-link"),m=Un("md-render");return mr(),Br("div",ak,[kt("div",sk,[kt("div",lk,[t.$route.params.page?(mr(),Eu(c,{key:0,class:"btn btn-secondary btn-sm editBtn",to:{name:"edit",params:{page:t.$route.params.page}}},{default:$n(()=>[dk]),_:1},8,["to"])):Rs("v-if",!0),wt(m,{content:d.content,prerender:u.prerender,onRendered:u.rendered},null,8,["content","prerender","onRendered"])],512)])])}xl.render=Ob;xl.__file="src/view.vue";var Lb=xl;var uk=[{component:Lb,name:"view",path:"/:page"},{component:Db,name:"edit",path:"/:page/edit"},{name:"home",path:"/",redirect:"/Home"}],Fb=pg({history:Xh(),mode:"history",routes:uk}),Mb=Eh({name:"WikiMain",render(){return sn(hg)},router:Fb});Mb.use(Fb);Mb.mount("#app");})(); +`).filter(o=>o&&!o.match(/^!/))}).catch(t=>{console.error(t)})}},mounted(){this.loadNav()},name:"WikiApp"};var i3={class:"navbar navbar-expand-lg bg-body-tertiary mb-3"},a3={class:"container-fluid"},s3=kt("button",{class:"navbar-toggler",type:"button","data-bs-toggle":"collapse","data-bs-target":"#navbarSupportedContent","aria-controls":"navbarSupportedContent","aria-expanded":"false","aria-label":"Toggle navigation"},[kt("span",{class:"navbar-toggler-icon"})],-1),l3={id:"navbarSupportedContent",class:"collapse navbar-collapse"},d3={class:"navbar-nav me-auto mb-2 mb-lg-0"};function mg(t,o,n,s,d,u){let c=Un("router-link"),m=Un("router-view");return mr(),Br("div",null,[kt("nav",i3,[kt("div",a3,[wt(c,{class:"navbar-brand",to:{name:"home"}},{default:$n(()=>[Ps(" Wiki ")]),_:1}),s3,kt("div",l3,[kt("ul",d3,[(mr(!0),Br(Bt,null,Bm(d.navContent,g=>(mr(),Br("li",{key:g,class:"nav-item"},[wt(c,{class:"nav-link",to:{name:"view",params:{page:g}}},{default:$n(()=>[Ps(Ld(g),1)]),_:2},1032,["to"])]))),128))])])])]),wt(m)])}$s.render=mg;$s.__file="src/app.vue";var hg=$s;var _b=gp(kb()),bl={data(){return{editor:null}},methods:{loadPage(t){return console.debug(`Loading ${t}...`),fetch(`/_content/${t}`).then(o=>o.status===404?{content:`# ${t}`}:o.json()).then(o=>{this.editor&&(this.editor.toTextArea(),this.editor=null),this.editor=new _b.default({element:this.$refs.editor,forceSync:!0,indentWithTabs:!1,initialValue:o.content})}).catch(o=>{o.response&&o.response.status===404||console.error(o)})},save(){return fetch(`/_content/${this.$route.params.page}`,{body:JSON.stringify({content:this.$refs.editor.value}),method:"POST"}).then(()=>{this.$router.push({name:"view",params:{page:this.$route.params.page}})}).catch(t=>{console.error(t)})}},mounted(){this.loadPage(this.$route.params.page)},name:"WikiEdit",watch:{$route(t,o){t.params.page!==o.params.page&&this.loadPage(t.params.page)}}};var tk={class:"container"},rk={class:"row"},ok={class:"col"},nk={ref:"editor"};function Eb(t,o,n,s,d,u){return mr(),Br("div",tk,[kt("div",rk,[kt("div",ok,[kt("textarea",nk,null,512),kt("button",{class:"btn btn-primary",onClick:o[0]||(o[0]=(...c)=>u.save&&u.save(...c))}," Save ")])])])}bl.render=Eb;bl.__file="src/edit.vue";var Db=bl;var Ab=gp(Sb()),wl={data(){return{render:""}},emits:["rendered"],name:"WikiMarkdown",props:{content:{default:"",type:String},prerender:{default:null,type:Function}},watch:{content(t){let o=t;this.prerender&&(o=this.prerender(o));let n=new Ab.default.Converter({tables:!0});n.setFlavor("github"),this.render=n.makeHtml(o),this.$emit("rendered")}}};var ik=["innerHTML"];function Nb(t,o,n,s,d,u){return mr(),Br(Bt,null,[Rs(" eslint-disable-next-line vue/no-v-html "),kt("div",{innerHTML:d.render},null,8,ik)],2112)}wl.render=Nb;wl.__file="src/markdown.vue";var Tb=wl;var xl={components:{mdRender:Tb},data(){return{content:""}},methods:{intLinkClick(t){let o=t.target;return this.$router.push({name:"view",params:{page:o.dataset.page}}),!1},loadPage(t){return console.debug(`Loading ${t}...`),fetch(`/_content/${t}`).then(o=>{if(o.status===404){this.$router.push({name:"edit",params:{page:t}});return}return o.json()}).then(o=>{o&&(this.content=o.content)}).catch(o=>{console.error(o)})},prerender(t){return t=t.replace(new RegExp(/\[\[([^\]]+)\]\]/,"g"),'$1'),t},rendered(){window.setTimeout(()=>{let t=this.$refs.content.getElementsByClassName("intLink");for(let o of t)o.onclick=this.intLinkClick;Prism.highlightAll()},100)}},mounted(){this.loadPage(this.$route.params.page)},name:"WikiView",watch:{$route(t,o){t.params.page!==o.params.page&&this.loadPage(t.params.page)}}};var ak={class:"container"},sk={class:"row"},lk={ref:"content",class:"col relAnchor"},dk=kt("i",{class:"fas fa-edit"},null,-1);function Ob(t,o,n,s,d,u){let c=Un("router-link"),m=Un("md-render");return mr(),Br("div",ak,[kt("div",sk,[kt("div",lk,[t.$route.params.page?(mr(),Eu(c,{key:0,class:"btn btn-secondary btn-sm editBtn",to:{name:"edit",params:{page:t.$route.params.page}}},{default:$n(()=>[dk]),_:1},8,["to"])):Rs("v-if",!0),wt(m,{content:d.content,prerender:u.prerender,onRendered:u.rendered},null,8,["content","prerender","onRendered"])],512)])])}xl.render=Ob;xl.__file="src/view.vue";var Lb=xl;var uk=[{component:Lb,name:"view",path:"/:page"},{component:Db,name:"edit",path:"/:page/edit"},{name:"home",path:"/",redirect:"/Home"}],Fb=pg({history:Xh(),mode:"history",routes:uk}),Mb=Eh({name:"WikiMain",render(){return sn(hg)},router:Fb});Mb.use(Fb);Mb.mount("#app");})(); diff --git a/src/markdown.vue b/src/markdown.vue index e0c17d5..9263639 100644 --- a/src/markdown.vue +++ b/src/markdown.vue @@ -36,7 +36,10 @@ export default { content = this.prerender(content) } - const converter = new showdown.Converter() + const converter = new showdown.Converter({ + tables: true, + }) + converter.setFlavor('github') this.render = converter.makeHtml(content) this.$emit('rendered') },