From 2dc5b0faf63516f8cc0d9d3dc4a4670cb1fb39d2 Mon Sep 17 00:00:00 2001 From: Gjergj Kadriu Date: Sun, 2 Jan 2022 23:03:40 +0100 Subject: [PATCH] push --- build/942db92a36e5ac025548.png | Bin 4727 -> 0 bytes build/css/index.css | 11 -- build/css/index.css.map | 1 - build/index.js | 8 +- build/index.js.map | 2 +- package.json | 14 +- src/lib/bloggrs-client/index.js | 227 ++++++++++++++++++++++++++++++++ src/lib/bloggrs-sdk/index.js | 39 ++++++ src/lib/index.js | 15 +-- webpack.config.js | 67 +++++----- 10 files changed, 316 insertions(+), 68 deletions(-) delete mode 100644 build/942db92a36e5ac025548.png delete mode 100644 build/css/index.css delete mode 100644 build/css/index.css.map create mode 100644 src/lib/bloggrs-client/index.js create mode 100644 src/lib/bloggrs-sdk/index.js diff --git a/build/942db92a36e5ac025548.png b/build/942db92a36e5ac025548.png deleted file mode 100644 index 27dd6bfd016c09098f1c1fe309ebb14303b7999c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4727 zcmai2XH-*7w+>MdLhlGjRS?n8tJD~Z2#6pc1Oie-nsnqvY6u{`ib(I$5d^8B8lxgL zbc9f(1f(f3RJn(Dt^4bK>wZ7ZIWv3h+3h@g&z^}fGSs1ma6>>K5dB?UxG@MsApneH zsi}ZB#OHMf@S*Y4weSIfXj#r5iqW}{6A*|+>@HmMVZh8*uC<#9G51qGr%;x%;Ew|4 z_y+C|0Z=2I+!4b8q`n1Bcn*)Y9hX_+$JEwXhlnWJt2f*R3{4F#3G&<;wF>Lb@NUx7 zz1uIDvhaz+u|yj4w1JpmDh`#rRh0m#`I%fd;Ba9F>6y5xs7BydlOMXToF(W#nEhLQ zO=a!yjF2Q;k}iNwHXCmGh3h&4cdJXX@hHxnV$@GF9t(Wbp)kfeso$v&4~Yt63Z4GQ z#00ypfo6g*38Ia{s0G;sVAO>m=6`803ZZ{#XfXU=8a3rhrgPfA%mD3QW`OotHXr!m0;xc;m17-R>|w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JQ9n!3jNA<6KwxN*f;n-?!h zj?#cg8`;|?1=~u+Z5mwJjWFXZ+{A(WEOUj*r(BL*eKSefBKuo>_6V(Ym!?>Kk>%`h zgHmHIZtj_dTD?-1sHmtJ!yx2%qkg;EC{gw{1MgUfEZN>S-#PypOH3kfMsKqn6U_28 zO6ubOIljS8imIBMo6V_vbeUi%&H{z`faL+*tG(y5`#nM_pF^eT(8(FpOm{T?7EO)@PN|Bpoi9P&0W`RzoAw8N zj`|#3agoSDhiRW^yk6%4k@pXLQodz8Ja@L4dcOVz~t5yHfKIBnw*Y_cF?6aFU zW3q-1i71h{xt3%?Wp)-XpH&a1dai3#dVuQ=EwaQ{V=E3RktrYIXuIa~GuUYyFRRbm zG%cF#ip9Gs2p`ybQUW@c0cQwS!+^3h1FN~bb;}xa;_iYTeg_>1u%7!w<*$YV;^e4s z`-;(;*VdDgKP5HIC&-c@%eol=0SDtlXU4OQZJ*|!o4GQG=?YH3|Lo9FiA7NkNHK&y zRVhyeLX^6!lL2^P_xNtWMo9G^U&=XQGl}>!JQYS~@|pH-!S~1-RhDATN=2mkBmSvF z-u(PGxPui4Hb(4Giu^|;qVK#v&?zo96xJLtFC@Rb!99+V`?Ao!^Trt zv)t0WU~kno>k`mvN*!aqF7zg{$^{=B0Htd2Htm{x>FvI*DqSa}=PpI|vgQMfK{"use strict";var e={d:(o,t)=>{for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};function t(e,o){for(var t=0;tn});const n=r((function e(){var o,t,r;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e),r=function(){console.log("Library method fired")},(t="myMethod")in(o=this)?Object.defineProperty(o,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[t]=r,console.log("Library constructor loaded")}));return o})()})); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bloggrs=t():e.bloggrs=t()}(self,(function(){return(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t,n,r,a,s,o){try{var i=e[s](o),c=i.value}catch(e){return void n(e)}i.done?t(c):Promise.resolve(c).then(r,a)}function r(e){return function(){var t=this,r=arguments;return new Promise((function(a,s){var o=e.apply(t,r);function i(e){n(o,a,s,i,c,"next",e)}function c(e){n(o,a,s,i,c,"throw",e)}i(void 0)}))}}function a(e,t){for(var n=0;np});const s=function(){function e(t){var n=t.blog_id,r=t.secret;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.blog_id=n,this.secret=r,this.base_url="http://localhost:4000/api/v1"}var t,n,s,o,i,c,l;return t=e,(n=[{key:"getCategories",value:(l=r(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(this.base_url,"/blogs/").concat(this.blog_id,"/categories"));case 2:return t=e.sent,e.next=5,t.json();case 5:return n=e.sent,r=n.data.categories,e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getPosts",value:(c=r(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(this.base_url,"/blogs/").concat(this.blog_id,"/posts"));case 2:return t=e.sent,e.next=5,t.json();case 5:return n=e.sent,r=n.data.posts,e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getPages",value:(i=r(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(this.base_url,"/blogs/").concat(this.blog_id,"/pages"));case 2:return t=e.sent,e.next=5,t.json();case 5:return n=e.sent,r=n.data.pages,e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getBlog",value:(o=r(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(this.base_url,"/blogs/").concat(this.blog_id));case 2:return t=e.sent,e.next=5,t.json();case 5:return n=e.sent,r=n.data.blog,e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})}])&&a(t.prototype,n),s&&a(t,s),Object.defineProperty(t,"prototype",{writable:!1}),e}();function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){c=!0,s=e},f:function(){try{o||null==n.return||n.return()}finally{if(c)throw s}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n\n
\n \x3c!-- Current: "bg-slate-900 text-white", Default: "text-slate-300 hover:bg-slate-700 hover:text-white" --\x3e\n\n '.concat(r.map((function(e){return'').concat(e.name,"")})).join(" "),"\n
\n \n "),t.innerHTML=a,e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),d(this,"handleCreateHeaderWidget",function(){var e=l(regeneratorRuntime.mark((function e(t){var r,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.bloggrsApi.getBlog();case 2:return r=e.sent,a='\n \n '),t.innerHTML=a,s=t.querySelector("#pages_list"),n.createWidget(s,{type:"pages_list"}),e.abrupt("return",a);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),d(this,"handleCreateCategoriesWidget",function(){var e=l(regeneratorRuntime.mark((function e(t){var r,a,s,i,c,l,u,d,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log(n.bloggrsApi,n.bloggrsApi,n.secret),e.next=3,n.bloggrsApi.getCategories();case 3:r=e.sent,(a=document.createElement("div")).className="my-50 mb-14 bg-white shadow-md max-h-1/2 w-3/4 rounded-md justify-center",(s=document.createElement("div")).className="mx-6",(i=document.createElement("h1")).className="py-3 mb-4 text-slate-700 font-medium text-xl",i.innerHTML="Categories",(c=document.createElement("ul")).className="py-4 mx-5 list-disc space-y-3",l=o(r);try{for(l.s();!(u=l.n()).done;)d=u.value,(p=document.createElement("li")).innerHTML="".concat(d.name," (").concat(d.meta.posts_count,")"),c.appendChild(p)}catch(e){l.e(e)}finally{l.f()}return s.appendChild(i),s.appendChild(c),a.appendChild(s),t.appendChild(a),e.abrupt("return",a);case 20:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),d(this,"handleCreatePostsListWidget",function(){var e=l(regeneratorRuntime.mark((function e(t){var r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.bloggrsApi.getPosts();case 2:return r=e.sent,a='\n
\n '.concat(r.map((function(e){return'\n
\n
\n
\n

\n '.concat(e.title,'\n

\n

\n ').concat(e.html_content,'\n

\n
\n

\n Wednesday, December 22, 2021     |\n

\n

\n John Cena\n

\n
\n
\n

\n \n ').concat(e.meta.likes_count,' likes\n

\n

\n \n ').concat(e.meta.comments_count," comments\n

\n
\n
\n
\n ")})).join(" "),"\n
\n "),t.innerHTML=a,e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this.blog_id=r,this.secret=a,this.bloggrsApi=new s({blog_id:r,secret:a})}var t,n,r;return t=e,(n=[{key:"createWidget",value:function(e,t){var n=t.type;return{categories:this.handleCreateCategoriesWidget,pages_list:this.handleCreatePagesListWidget,header:this.handleCreateHeaderWidget,posts_list:this.handleCreatePostsListWidget}[n](e)}}])&&u(t.prototype,n),r&&u(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();return t})()})); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map index 94be0f58..3380fd51 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAmB,UAAID,IAEvBD,EAAgB,UAAIC,IARtB,CASGK,MAAM,WACT,Y,aCTA,IAAIC,EAAsB,CCA1B,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3E,EAAwB,CAACM,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClF,EAAyBd,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,M,qTCOvD,QAVMC,GACJ,a,uGAAc,S,EAIH,WACTC,QAAQC,IAAI,0B,EALA,c,EAAA,M,sFACZD,QAAQC,IAAI,iC,ULMhB","sources":["webpack://MyLibrary/webpack/universalModuleDefinition","webpack://MyLibrary/webpack/bootstrap","webpack://MyLibrary/webpack/runtime/define property getters","webpack://MyLibrary/webpack/runtime/hasOwnProperty shorthand","webpack://MyLibrary/webpack/runtime/make namespace object","webpack://MyLibrary/./src/lib/index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLibrary\"] = factory();\n\telse\n\t\troot[\"MyLibrary\"] = factory();\n})(self, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import \"./index.css\";\n\nclass MyLibrary {\n constructor() {\n console.log(\"Library constructor loaded\");\n }\n\n myMethod = () => {\n console.log(\"Library method fired\");\n };\n}\n\nexport default MyLibrary;\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","MyLibrary","console","log"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAiB,QAAID,IAErBD,EAAc,QAAIC,IARpB,CASGK,MAAM,WACT,Y,aCTA,IAAIC,EAAsB,CCA1B,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3E,EAAwB,CAACM,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClF,EAAyBd,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,M,qgBCiCvD,QAtCMC,WACJ,cAAiC,IAAnBC,EAAmB,EAAnBA,QAASC,EAAU,EAAVA,Q,4FAAU,SAC/BC,KAAKF,QAAUA,EACfE,KAAKD,OAASA,EACdC,KAAKC,SAAW,+B,0FAElB,uHACoBC,MAAM,GAAD,OAClBF,KAAKC,SADa,kBACKD,KAAKF,QADV,gBADzB,cACQK,EADR,gBAMYA,EAAIC,OANhB,uBAKYC,EALZ,EAKIC,KAAQD,WALZ,kBAOSA,GAPT,gD,iGASA,uHACoBH,MAAM,GAAD,OAAIF,KAAKC,SAAT,kB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SAASC,cAAc,OAC/BC,UAAY,+CACrBE,EAASb,UAAY,cACfc,EAAWL,SAASC,cAAc,OAC/BC,UAAY,gCAZQ,IAaR1B,GAbQ,IAa7B,2BAAS8B,EAAwB,SACzBC,EAASP,SAASC,cAAc,OAC/BV,UAAP,UAAsBe,EAASjB,KAA/B,aAAwCiB,EAASE,KAAKC,YAAtD,KACAJ,EAASK,YAAYH,GAhBM,qCAmB7BJ,EAAUO,YAAYN,GACtBD,EAAUO,YAAYL,GACtBpB,EAAIyB,YAAYP,GAChBrB,EAAG4B,YAAYzB,GAtBc,kBAuBtBA,GAvBsB,4CA/IE,wIAwKH,WAAOH,GAAP,wGACR,EAAKC,WAAW4B,WADR,cACtBjC,EADsB,OAEtBO,EAFsB,8FAItBP,EACCQ,KAAI,SAAC0B,GACJ,sSAKMA,EAAKC,MALX,qHAQMD,EAAKE,aARX,imBAqB4CF,EAAKJ,KAAKO,YArBtD,sQAyB2BH,EAAKJ,KAAKQ,eAzBrC,qHAgCD1B,KAAK,KAtCgB,wBAyC5BR,EAAGS,UAAYN,EAzCa,kBA0CrBA,GA1CqB,2CAxKG,uDAC/Bd,KAAKF,QAAUA,EACfE,KAAKD,OAASA,EACdC,KAAKY,WAAa,IAAIf,EAAW,CAAEC,QAAAA,EAASC,OAAAA,I,mDAiN9C,SAAaY,EAAb,GAA2B,IAARc,EAAQ,EAARA,KAOjB,MANgB,CACdpB,WAAYL,KAAK8C,6BACjBC,WAAY/C,KAAKgD,4BACjBC,OAAQjD,KAAKkD,yBACbC,WAAYnD,KAAKoD,6BAEJ3B,GAAMd,Q,gFA5NnBD,G,UNQN","sources":["webpack://bloggrs/webpack/universalModuleDefinition","webpack://bloggrs/webpack/bootstrap","webpack://bloggrs/webpack/runtime/define property getters","webpack://bloggrs/webpack/runtime/hasOwnProperty shorthand","webpack://bloggrs/webpack/runtime/make namespace object","webpack://bloggrs/./src/lib/bloggrs-sdk/index.js","webpack://bloggrs/./src/lib/bloggrs-client/index.js","webpack://bloggrs/./src/lib/index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"bloggrs\"] = factory();\n\telse\n\t\troot[\"bloggrs\"] = factory();\n})(self, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","class BloggrsAPI {\n constructor({ blog_id, secret }) {\n this.blog_id = blog_id;\n this.secret = secret;\n this.base_url = \"http://localhost:4000/api/v1\";\n }\n async getCategories() {\n const res = await fetch(\n `${this.base_url}/blogs/${this.blog_id}/categories`\n );\n const {\n data: { categories },\n } = await res.json();\n return categories;\n }\n async getPosts() {\n const res = await fetch(`${this.base_url}/blogs/${this.blog_id}/posts`);\n const {\n data: { posts },\n } = await res.json();\n return posts;\n }\n async getPages() {\n const res = await fetch(`${this.base_url}/blogs/${this.blog_id}/pages`);\n const {\n data: { pages },\n } = await res.json();\n return pages;\n }\n async getBlog() {\n const res = await fetch(`${this.base_url}/blogs/${this.blog_id}`);\n const {\n data: { blog },\n } = await res.json();\n return blog;\n }\n}\n\nexport default BloggrsAPI;\n","import BloggrsAPI from \"../bloggrs-sdk\";\n\nclass BloggrsClient {\n constructor({ blog_id, secret }) {\n this.blog_id = blog_id;\n this.secret = secret;\n this.bloggrsApi = new BloggrsAPI({ blog_id, secret });\n }\n handleCreatePagesListWidget = async (el) => {\n const pages = await this.bloggrsApi.getPages();\n const div = `\n \n `;\n el.innerHTML = div;\n return div;\n };\n handleCreateHeaderWidget = async (el) => {\n const blog = await this.bloggrsApi.getBlog();\n const div = `\n \n `;\n el.innerHTML = div;\n const pages_list_el = el.querySelector(\"#pages_list\");\n this.createWidget(pages_list_el, { type: \"pages_list\" });\n return div;\n };\n handleCreateCategoriesWidget = async (el) => {\n console.log(this.bloggrsApi, this.bloggrsApi, this.secret);\n const categories = await this.bloggrsApi.getCategories();\n const div = document.createElement(\"div\");\n div.className =\n \"my-50 mb-14 bg-white shadow-md max-h-1/2 w-3/4 rounded-md justify-center\";\n const div__div2 = document.createElement(\"div\");\n div__div2.className = \"mx-6\";\n const div2__h1 = document.createElement(\"h1\");\n div2__h1.className = \"py-3 mb-4 text-slate-700 font-medium text-xl\";\n div2__h1.innerHTML = \"Categories\";\n const div2__ul = document.createElement(\"ul\");\n div2__ul.className = \"py-4 mx-5 list-disc space-y-3\";\n for (let category of categories) {\n const ul__li = document.createElement(\"li\");\n ul__li.innerHTML = `${category.name} (${category.meta.posts_count})`;\n div2__ul.appendChild(ul__li);\n }\n //\n div__div2.appendChild(div2__h1);\n div__div2.appendChild(div2__ul);\n div.appendChild(div__div2);\n el.appendChild(div);\n return div;\n };\n handleCreatePostsListWidget = async (el) => {\n const posts = await this.bloggrsApi.getPosts();\n const div = `\n
\n ${posts\n .map((post) => {\n return `\n
\n
\n
\n

\n ${post.title}\n

\n

\n ${post.html_content}\n

\n
\n

\n Wednesday, December 22, 2021     |\n

\n

\n John Cena\n

\n
\n
\n

\n \n ${post.meta.likes_count} likes\n

\n

\n \n ${post.meta.comments_count} comments\n

\n
\n
\n
\n `;\n })\n .join(\" \")}\n
\n `;\n el.innerHTML = div;\n return div;\n };\n createWidget(el, { type }) {\n const widgets = {\n categories: this.handleCreateCategoriesWidget,\n pages_list: this.handleCreatePagesListWidget,\n header: this.handleCreateHeaderWidget,\n posts_list: this.handleCreatePostsListWidget,\n };\n return widgets[type](el);\n }\n}\n\nexport default BloggrsClient;\n","import bloggrs from \"./bloggrs-client\";\n// import \"./index.css\";\n\nexport default bloggrs;\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","BloggrsAPI","blog_id","secret","this","base_url","fetch","res","json","categories","data","posts","pages","blog","BloggrsClient","el","bloggrsApi","getPages","div","map","page","slug","name","join","innerHTML","getBlog","pages_list_el","querySelector","createWidget","type","console","log","getCategories","document","createElement","className","div__div2","div2__h1","div2__ul","category","ul__li","meta","posts_count","appendChild","getPosts","post","title","html_content","likes_count","comments_count","handleCreateCategoriesWidget","pages_list","handleCreatePagesListWidget","header","handleCreateHeaderWidget","posts_list","handleCreatePostsListWidget"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index a83545e0..c771bb63 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "@hodgef/js-library-boilerplate-basic", - "version": "1.6.35", - "description": "Javascript Minimal Starter Kit for building libraries", + "name": "@bloggrs/bloggrsjs", + "version": "0.0.1", + "description": "bloggrs.js is a JavaScript library for building performant and custom blog platforms with Bloggrs.", "main": "build/index.js", "scripts": { "start": "webpack serve --config webpack.config.demo.js", @@ -13,14 +13,14 @@ }, "repository": { "type": "git", - "url": "https://github.com/hodgef/js-library-boilerplate-basic" + "url": "https://github.com/bloggrs/bloggrs.js" }, - "author": "Francisco Hodge (https://github.com/hodgef)", + "author": "Gjergj Kadriu (https://github.com/gjergjk71)", "license": "MIT", "bugs": { - "url": "https://github.com/hodgef/js-library-boilerplate-basic/issues" + "url": "https://github.com/bloggrs/bloggrs.js/issues" }, - "homepage": "https://github.com/hodgef/js-library-boilerplate-basic", + "homepage": "https://github.com/bloggrs/bloggrs.js", "keywords": [ "library", "starter", diff --git a/src/lib/bloggrs-client/index.js b/src/lib/bloggrs-client/index.js new file mode 100644 index 00000000..7a3f0284 --- /dev/null +++ b/src/lib/bloggrs-client/index.js @@ -0,0 +1,227 @@ +import BloggrsAPI from "../bloggrs-sdk"; + +class BloggrsClient { + constructor({ blog_id, secret }) { + this.blog_id = blog_id; + this.secret = secret; + this.bloggrsApi = new BloggrsAPI({ blog_id, secret }); + } + handleCreatePagesListWidget = async (el) => { + const pages = await this.bloggrsApi.getPages(); + const div = ` + + `; + el.innerHTML = div; + return div; + }; + handleCreateHeaderWidget = async (el) => { + const blog = await this.bloggrsApi.getBlog(); + const div = ` + + `; + el.innerHTML = div; + const pages_list_el = el.querySelector("#pages_list"); + this.createWidget(pages_list_el, { type: "pages_list" }); + return div; + }; + handleCreateCategoriesWidget = async (el) => { + console.log(this.bloggrsApi, this.bloggrsApi, this.secret); + const categories = await this.bloggrsApi.getCategories(); + const div = document.createElement("div"); + div.className = + "my-50 mb-14 bg-white shadow-md max-h-1/2 w-3/4 rounded-md justify-center"; + const div__div2 = document.createElement("div"); + div__div2.className = "mx-6"; + const div2__h1 = document.createElement("h1"); + div2__h1.className = "py-3 mb-4 text-slate-700 font-medium text-xl"; + div2__h1.innerHTML = "Categories"; + const div2__ul = document.createElement("ul"); + div2__ul.className = "py-4 mx-5 list-disc space-y-3"; + for (let category of categories) { + const ul__li = document.createElement("li"); + ul__li.innerHTML = `${category.name} (${category.meta.posts_count})`; + div2__ul.appendChild(ul__li); + } + // + div__div2.appendChild(div2__h1); + div__div2.appendChild(div2__ul); + div.appendChild(div__div2); + el.appendChild(div); + return div; + }; + handleCreatePostsListWidget = async (el) => { + const posts = await this.bloggrsApi.getPosts(); + const div = ` +
+ ${posts + .map((post) => { + return ` +
+
+
+

+ ${post.title} +

+

+ ${post.html_content} +

+
+

+ Wednesday, December 22, 2021     | +

+

+ John Cena +

+
+
+

+ + ${post.meta.likes_count} likes +

+

+ + ${post.meta.comments_count} comments +

+
+
+
+ `; + }) + .join(" ")} +
+ `; + el.innerHTML = div; + return div; + }; + createWidget(el, { type }) { + const widgets = { + categories: this.handleCreateCategoriesWidget, + pages_list: this.handleCreatePagesListWidget, + header: this.handleCreateHeaderWidget, + posts_list: this.handleCreatePostsListWidget, + }; + return widgets[type](el); + } +} + +export default BloggrsClient; diff --git a/src/lib/bloggrs-sdk/index.js b/src/lib/bloggrs-sdk/index.js new file mode 100644 index 00000000..7fe6b251 --- /dev/null +++ b/src/lib/bloggrs-sdk/index.js @@ -0,0 +1,39 @@ +class BloggrsAPI { + constructor({ blog_id, secret }) { + this.blog_id = blog_id; + this.secret = secret; + this.base_url = "http://localhost:4000/api/v1"; + } + async getCategories() { + const res = await fetch( + `${this.base_url}/blogs/${this.blog_id}/categories` + ); + const { + data: { categories }, + } = await res.json(); + return categories; + } + async getPosts() { + const res = await fetch(`${this.base_url}/blogs/${this.blog_id}/posts`); + const { + data: { posts }, + } = await res.json(); + return posts; + } + async getPages() { + const res = await fetch(`${this.base_url}/blogs/${this.blog_id}/pages`); + const { + data: { pages }, + } = await res.json(); + return pages; + } + async getBlog() { + const res = await fetch(`${this.base_url}/blogs/${this.blog_id}`); + const { + data: { blog }, + } = await res.json(); + return blog; + } +} + +export default BloggrsAPI; diff --git a/src/lib/index.js b/src/lib/index.js index ae92ffa0..1b7aec28 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -1,13 +1,4 @@ -import "./index.css"; +import bloggrs from "./bloggrs-client"; +// import "./index.css"; -class MyLibrary { - constructor() { - console.log("Library constructor loaded"); - } - - myMethod = () => { - console.log("Library method fired"); - }; -} - -export default MyLibrary; +export default bloggrs; diff --git a/webpack.config.js b/webpack.config.js index c2f4edf4..4c6ed8e6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,24 +1,27 @@ -const path = require('path'); -const webpack = require('webpack'); +const path = require("path"); +const webpack = require("webpack"); const PrettierPlugin = require("prettier-webpack-plugin"); -const TerserPlugin = require('terser-webpack-plugin'); -const getPackageJson = require('./scripts/getPackageJson'); +const TerserPlugin = require("terser-webpack-plugin"); +const getPackageJson = require("./scripts/getPackageJson"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); -const { - version, - name, - license, - repository, - author, -} = getPackageJson('version', 'name', 'license', 'repository', 'author'); +const { version, name, license, repository, author } = getPackageJson( + "version", + "name", + "license", + "repository", + "author" +); const banner = ` ${name} v${version} ${repository.url} - Copyright (c) ${author.replace(/ *\<[^)]*\> */g, " ")} and project contributors. + Copyright (c) ${author.replace( + / *\<[^)]*\> */g, + " " + )} and project contributors. This source code is licensed under the ${license} license found in the LICENSE file in the root directory of this source tree. @@ -26,27 +29,27 @@ const banner = ` module.exports = { mode: "production", - devtool: 'source-map', - entry: './src/lib/index.js', + devtool: "source-map", + entry: "./src/lib/index.js", output: { - filename: 'index.js', - path: path.resolve(__dirname, 'build'), - library: 'MyLibrary', - libraryTarget: 'umd', - clean: true + filename: "index.js", + path: path.resolve(__dirname, "build"), + library: "bloggrs", + libraryTarget: "umd", + clean: true, }, optimization: { minimize: true, minimizer: [ - new TerserPlugin({ extractComments: false}), + new TerserPlugin({ extractComments: false }), new OptimizeCSSAssetsPlugin({ cssProcessorOptions: { map: { - inline: false - } - } + inline: false, + }, + }, }), - ] + ], }, module: { rules: [ @@ -54,8 +57,8 @@ module.exports = { test: /\.m?js$/, exclude: /(node_modules|bower_components)/, use: { - loader: 'babel-loader' - } + loader: "babel-loader", + }, }, { test: /\.(sa|sc|c)ss$/, @@ -63,14 +66,14 @@ module.exports = { MiniCssExtractPlugin.loader, { loader: "css-loader", options: { sourceMap: true } }, ], - } - ] + }, + ], }, plugins: [ new PrettierPlugin(), new MiniCssExtractPlugin({ - filename: 'css/index.css' + filename: "css/index.css", }), - new webpack.BannerPlugin(banner) - ] -}; \ No newline at end of file + new webpack.BannerPlugin(banner), + ], +};