Changeset 2463574
- Timestamp:
- 01/27/2021 01:25:35 PM (5 years ago)
- Location:
- roam-block
- Files:
-
- 10 edited
- 1 copied
-
tags/0.1.3 (copied) (copied from roam-block/trunk)
-
tags/0.1.3/build/index.asset.php (modified) (1 diff)
-
tags/0.1.3/build/index.js (modified) (1 diff)
-
tags/0.1.3/endpoints.php (modified) (3 diffs)
-
tags/0.1.3/readme.txt (modified) (3 diffs)
-
tags/0.1.3/roam-block.php (modified) (1 diff)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/endpoints.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/roam-block.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
roam-block/tags/0.1.3/build/index.asset.php
r2450567 r2463574 1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => ' 7d73cd931fb97c108c36a1f92195fdbd');1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '68750ce44029f8776ddd4e28c8db00bd'); -
roam-block/tags/0.1.3/build/index.js
r2450567 r2463574 1 (window.roam_blockWebpack=window.roam_blockWebpack||[]).push([[1],{8:function(e,t,r){}}]),function(e){function t(t){for(var n,c,i=t[0],l=t[1],s=t[2],p=0,b=[];p<i.length;p++)c=i[p],Object.prototype.hasOwnProperty.call(o,c)&&o[c]&&b.push(o[c][0]),o[c]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(u&&u(t);b.length;)b.shift()();return a.push.apply(a,s||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],n=!0,i=1;i<r.length;i++){var l=r[i];0!==o[l]&&(n=!1)}n&&(a.splice(t--,1),e=c(c.s=r[0]))}return e}var n={},o={0:0},a=[];function c(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.m=e,c.c=n,c.d=function(e,t,r){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(c.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)c.d(r,n,function(t){return e[t]}.bind(null,n));return r},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="";var i=window.roam_blockWebpack=window.roam_blockWebpack||[],l=i.push.bind(i);i.push=t,i=i.slice();for(var s=0;s<i.length;s++)t(i[s]);var u=l;a.push([15,1]),r()}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.primitives},function(e,t,r){var n=r(9),o=r(10),a=r(11),c=r(13);e.exports=function(e,t){return n(e)||o(e,t)||a(e,t)||c()}},function(e,t){e.exports=window.wp.apiFetch},function(e,t){e.exports=window.wp.blocks},,function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var c,i=e[Symbol.iterator]();!(n=(c=i.next()).done)&&(r.push(c.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}}},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t,r){},function(e,t,r){"use strict";r.r(t);var n=r(7),o=r(2),a=(r(8),r(5)),c=r.n(a),i=r(0),l=r(3),s=r(1),u=r(6),p=r.n(u),b=r(4),m=Object(i.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)(b.Path,{d:"M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})),f=Object(i.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)(b.Path,{d:"M6.2 5.2v13.4l5.8-4.8 5.8 4.8V5.2z"}));function d(e,t){var r=new FileReader;r.readAsText(e),r.onload=function(r){var n=r.target.result;p()({path:"/roam-research/upload-graph",method:"POST",data:{graphContent:n,graphName:e.name.replace(".json","")}}).then((function(){t("OK")}))}}r(14),Object(n.registerBlockType)("artpi/roam-block",{apiVersion:2,attributes:{uid:{type:"string"},childrenListView:{type:"string",default:"list"},showHeader:{type:"boolean",default:!0},content:{type:"string",source:"html",selector:".wp-block-artpi-roam-block",default:""}},title:Object(o.__)("Roam Research Block","roam-block"),description:Object(o.__)("Embed Roam Blocks or pages in WordPress, just as you would in Roam","roam-block"),category:"embed",icon:"sos",supports:{html:!0},edit:function(e){var t=e.attributes,r=e.setAttributes,n=Object(i.useState)(""),a=c()(n,2),u=a[0],b=a[1],h=Object(i.useState)([]),w=c()(h,2),O=w[0],j=w[1],v=Object(i.useState)("OK"),y=c()(v,2),g=y[0],k=y[1];return Object(i.useEffect)((function(){var e=setTimeout((function(){u.length>5&&p()({path:"/roam-research/search_block?q=".concat(u)}).then(j).catch((function(e){"graph_missing"===e.code&&k("MISSING")}))}),500);return function(){clearTimeout(e)}}),[u]),Object(i.createElement)("div",Object(l.useBlockProps)({className:"artpi-roam-block-children-"+t.childrenListView+" artpi-roam-block-header-"+(t.showHeader?"visible":"hidden")}),Object(i.createElement)(l.InspectorControls,{initialOpen:!0},Object(i.createElement)(s.PanelBody,{title:Object(o.__)("Your Roam Graph export","roam-block"),initialOpen:"true"},Object(i.createElement)(s.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return d(e.target.files.item(0),k)}},Object(o.__)("Upload .json file from Roam Research export","roam-block")))),t.content&&Object(i.createElement)(l.BlockControls,null,Object(i.createElement)(s.Toolbar,{label:"Options"},Object(i.createElement)(s.ToolbarButton,{isActive:"list"===t.childrenListView,icon:m,label:"Display as a list",onClick:function(){return r({childrenListView:"list"===t.childrenListView?"document":"list"})}}),Object(i.createElement)(s.ToolbarButton,{isActive:!!t.showHeader,icon:f,label:"Include Parent",onClick:function(){return r({showHeader:!t.showHeader})}}))),!t.uid&&Object(i.createElement)(s.Placeholder,{label:"Roam Block Embed"},"MISSING"===g&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(s.Notice,{isDismissible:!1,status:"warning"},"Your Roam graph is missing. Please export it from Roam and upload here:"),Object(i.createElement)(s.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return d(e.target.files.item(0),k)}},Object(o.__)("Upload .json file from Roam Research export","roam-block"))),"OK"===g&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(s.TextControl,{label:"Search Roam Block",placeholder:"Search Roam block just as you would with ((",value:u,onChange:b}),Object(i.createElement)("div",{className:"wp-block-artpi-roam-block-results"},O.map((function(e){var t=e.content,n=e.uid,o=e.title,a=e.snippet;return Object(i.createElement)("div",{key:n,onClick:function(){return r({uid:n,content:t})}},Object(i.createElement)("div",{className:"wp-block-artpi-roam-block-results-title"},o),Object(i.createElement)("div",null,a))}))))),t.content&&Object(i.createElement)(i.RawHTML,null,t.content))},save:function(e){var t=e.attributes;return Object(i.createElement)("div",l.useBlockProps.save(),Object(i.createElement)(i.RawHTML,null,t.content))}})}]);1 (window.roam_blockWebpack=window.roam_blockWebpack||[]).push([[1],{8:function(e,t,r){}}]),function(e){function t(t){for(var o,c,l=t[0],i=t[1],u=t[2],p=0,b=[];p<l.length;p++)c=l[p],Object.prototype.hasOwnProperty.call(n,c)&&n[c]&&b.push(n[c][0]),n[c]=0;for(o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o]);for(s&&s(t);b.length;)b.shift()();return a.push.apply(a,u||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],o=!0,l=1;l<r.length;l++){var i=r[l];0!==n[i]&&(o=!1)}o&&(a.splice(t--,1),e=c(c.s=r[0]))}return e}var o={},n={0:0},a=[];function c(t){if(o[t])return o[t].exports;var r=o[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.m=e,c.c=o,c.d=function(e,t,r){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(c.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)c.d(r,o,function(t){return e[t]}.bind(null,o));return r},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="";var l=window.roam_blockWebpack=window.roam_blockWebpack||[],i=l.push.bind(l);l.push=t,l=l.slice();for(var u=0;u<l.length;u++)t(l[u]);var s=i;a.push([15,1]),r()}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.primitives},function(e,t,r){var o=r(9),n=r(10),a=r(11),c=r(13);e.exports=function(e,t){return o(e)||n(e,t)||a(e,t)||c()}},function(e,t){e.exports=window.wp.apiFetch},function(e,t){e.exports=window.wp.blocks},,function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],o=!0,n=!1,a=void 0;try{for(var c,l=e[Symbol.iterator]();!(o=(c=l.next()).done)&&(r.push(c.value),!t||r.length!==t);o=!0);}catch(e){n=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(n)throw a}}return r}}},function(e,t,r){var o=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t,r){},function(e,t,r){"use strict";r.r(t);var o=r(7),n=r(2),a=(r(8),r(5)),c=r.n(a),l=r(0),i=r(3),u=r(1),s=r(6),p=r.n(s),b=r(4),m=Object(l.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(l.createElement)(b.Path,{d:"M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})),d=Object(l.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(l.createElement)(b.Path,{d:"M6.2 5.2v13.4l5.8-4.8 5.8 4.8V5.2z"}));function f(e,t){var r=new FileReader;r.readAsText(e),r.onload=function(r){var o=r.target.result;p()({path:"/roam-research/upload-graph",method:"POST",data:{graphContent:o,graphName:e.name.replace(".json","")}}).then((function(){t("OK")}))}}r(14),Object(o.registerBlockType)("artpi/roam-block",{apiVersion:2,attributes:{uid:{type:"string"},childrenListView:{type:"string",default:"list"},showHeader:{type:"boolean",default:!0},content:{type:"string",source:"html",selector:".wp-block-artpi-roam-block",default:""}},title:Object(n.__)("Roam Research Block","roam-block"),description:Object(n.__)("Embed Roam Blocks or pages in WordPress, just as you would in Roam","roam-block"),category:"embed",icon:"sos",supports:{html:!0},edit:function(e){var t=e.attributes,r=e.setAttributes,o=Object(l.useState)(""),a=c()(o,2),s=a[0],b=a[1],h=Object(l.useState)(""),w=c()(h,2),O=w[0],j=w[1],v=Object(l.useState)([]),y=c()(v,2),g=y[0],k=y[1],E=Object(l.useState)("OK"),x=c()(E,2),_=x[0],S=x[1];return Object(l.useEffect)((function(){var e=setTimeout((function(){s.length>5&&p()({path:"/roam-research/search_block?q=".concat(s)}).then(k).catch((function(e){"graph_missing"===e.code&&S("MISSING")}))}),500);return function(){clearTimeout(e)}}),[s]),Object(l.createElement)("div",Object(i.useBlockProps)({className:"artpi-roam-block-children-"+t.childrenListView+" artpi-roam-block-header-"+(t.showHeader?"visible":"hidden")}),Object(l.createElement)(i.InspectorControls,{initialOpen:!0},Object(l.createElement)(u.PanelBody,{title:Object(n.__)("Your Roam Graph export","roam-block"),initialOpen:"true"},Object(l.createElement)(u.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return f(e.target.files.item(0),S)}},Object(n.__)("Upload .json file from Roam Research export","roam-block"))),Object(l.createElement)(u.PanelBody,{title:Object(n.__)("Secret Upload URL","roam-block"),initialOpen:!1,onToggle:function(e){e&&p()({path:"/roam-research/get_upload_token"}).then((function(e){return j(e.url)}))}},Object(l.createElement)("p",null,Object(n.__)("You can use automated script to keep your graph updated. Keep this URL private - it will allow everyone to update Roam Graph on your blog.","roam-block")),Object(l.createElement)("a",{href:"https://deliber.at/roam/roam-api"},Object(l.createElement)("p",null,Object(n.__)("Instructions how to set up Roam-Research-Private-API to do so for you.","roam-block"))),Object(l.createElement)(u.TextControl,{label:"Secret Upload URL",value:O}))),t.content&&Object(l.createElement)(i.BlockControls,null,Object(l.createElement)(u.Toolbar,{label:"Options"},Object(l.createElement)(u.ToolbarButton,{isActive:"list"===t.childrenListView,icon:m,label:"Display as a list",onClick:function(){return r({childrenListView:"list"===t.childrenListView?"document":"list"})}}),Object(l.createElement)(u.ToolbarButton,{isActive:!!t.showHeader,icon:d,label:"Include Parent",onClick:function(){return r({showHeader:!t.showHeader})}}))),!t.uid&&Object(l.createElement)(u.Placeholder,{label:"Roam Block Embed"},"MISSING"===_&&Object(l.createElement)(l.Fragment,null,Object(l.createElement)(u.Notice,{isDismissible:!1,status:"warning"},"Your Roam graph is missing. Please export it from Roam and upload here:"),Object(l.createElement)(u.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return f(e.target.files.item(0),S)}},Object(n.__)("Upload .json file from Roam Research export","roam-block"))),"OK"===_&&Object(l.createElement)(l.Fragment,null,Object(l.createElement)(u.TextControl,{label:"Search Roam Block",placeholder:"Search Roam block just as you would with ((",value:s,onChange:b}),Object(l.createElement)("div",{className:"wp-block-artpi-roam-block-results"},g.map((function(e){var t=e.content,o=e.uid,n=e.title,a=e.snippet;return Object(l.createElement)("div",{key:o,onClick:function(){return r({uid:o,content:t})}},Object(l.createElement)("div",{className:"wp-block-artpi-roam-block-results-title"},n),Object(l.createElement)("div",null,a))}))))),t.content&&Object(l.createElement)(l.RawHTML,null,t.content))},save:function(e){var t=e.attributes;return Object(l.createElement)("div",i.useBlockProps.save(),Object(l.createElement)(l.RawHTML,null,t.content))}})}]); -
roam-block/tags/0.1.3/endpoints.php
r2450567 r2463574 11 11 'methods' => 'POST', 12 12 'callback' => __NAMESPACE__ . '\roam_update_graph', 13 'permission_callback' => __NAMESPACE__ . '\check_permissions ',13 'permission_callback' => __NAMESPACE__ . '\check_permissions_upload', 14 14 ) 15 15 ); … … 23 23 ) 24 24 ); 25 register_rest_route( 26 'roam-research', 27 '/get_upload_token', 28 array( 29 'methods' => 'GET', 30 'callback' => __NAMESPACE__ . '\roam_get_upload_token', 31 'permission_callback' => __NAMESPACE__ . '\check_permissions', 32 ) 33 ); 25 34 } 26 35 ); 36 37 function check_permissions_upload( \WP_REST_Request $request ) { 38 if ( check_permissions() ) { 39 return true; 40 } 41 $params = $request->get_params(); 42 $token = get_option( 'roam_update_token' ); 43 if ( $token && $params['token'] === $token ) { 44 return true; 45 } 46 return false; 47 } 27 48 28 49 function check_permissions() { … … 31 52 } 32 53 54 function roam_get_upload_token( \WP_REST_Request $request ) { 55 $token = get_option( 'roam_update_token' ); 56 if ( ! $token ) { 57 $token = wp_generate_password( 20, false ); 58 update_option( 'roam_update_token', $token ); 59 } 60 $url = get_rest_url( null, 'roam-research/upload-graph' ); 61 $query = parse_url( $url, PHP_URL_QUERY ); 62 63 $url = $url . ( $query ? '&' : '?' ) . 'token=' . $token; 64 return array( 65 'token' => $token, 66 'url' => $url, 67 ); 68 } 69 33 70 function roam_update_graph( \WP_REST_Request $request ) { 34 71 $params = $request->get_params(); 72 if ( ! is_string( $params['graphContent'] ) ) { 73 $params['graphContent'] = json_encode( $params['graphContent'] ); 74 } 75 35 76 update_option( 'roam_graph_content', $params['graphContent'] ); 36 77 update_option( 'roam_graph_name', $params['graphName'] ); -
roam-block/tags/0.1.3/readme.txt
r2450601 r2463574 4 4 Requires at least: 5.3.1 5 5 Tested up to: 5.3.1 6 Stable tag: 0.1. 26 Stable tag: 0.1.3 7 7 Requires PHP: 7.0.0 8 8 License: GPL-2.0-or-later … … 53 53 Since blocks are a conceptual unit of both Gutenberg and Roam - I created this plugin. 54 54 55 = Why do I have to manually upload the roam graph? =55 = Do I have to manually upload the roam graph? = 56 56 57 Roam is still working in providing a proper API. Please harass @Conaw 57 Roam does not have an API that could run through WordPress. I have built a project that can keep your Roam graph in WP automatically updated, but it has to run on another machine. 58 [Details how to set it up are here.](https://deliber.at/roam/wp-roam-block/) 58 59 59 60 = How do I upload the graph? = … … 85 86 = 0.1.2 = 86 87 * Fix WordPress version tag 88 = 0.1.3 = 89 * Expose update URL to automatically update Roam Graph via https://deliber.at/roam/roam-api/ -
roam-block/tags/0.1.3/roam-block.php
r2450601 r2463574 4 4 * Plugin URI: https://deliber.at/wp-roam-block/ 5 5 * Description: Embed Roam Blocks or pages in WordPress, just as you would in Roam 6 * Version: 0.1. 26 * Version: 0.1.3 7 7 * Author: Artur Piszek (artpi) 8 8 * Author URI: https://piszek.com -
roam-block/trunk/build/index.asset.php
r2450567 r2463574 1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => ' 7d73cd931fb97c108c36a1f92195fdbd');1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '68750ce44029f8776ddd4e28c8db00bd'); -
roam-block/trunk/build/index.js
r2450567 r2463574 1 (window.roam_blockWebpack=window.roam_blockWebpack||[]).push([[1],{8:function(e,t,r){}}]),function(e){function t(t){for(var n,c,i=t[0],l=t[1],s=t[2],p=0,b=[];p<i.length;p++)c=i[p],Object.prototype.hasOwnProperty.call(o,c)&&o[c]&&b.push(o[c][0]),o[c]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(u&&u(t);b.length;)b.shift()();return a.push.apply(a,s||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],n=!0,i=1;i<r.length;i++){var l=r[i];0!==o[l]&&(n=!1)}n&&(a.splice(t--,1),e=c(c.s=r[0]))}return e}var n={},o={0:0},a=[];function c(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.m=e,c.c=n,c.d=function(e,t,r){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(c.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)c.d(r,n,function(t){return e[t]}.bind(null,n));return r},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="";var i=window.roam_blockWebpack=window.roam_blockWebpack||[],l=i.push.bind(i);i.push=t,i=i.slice();for(var s=0;s<i.length;s++)t(i[s]);var u=l;a.push([15,1]),r()}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.primitives},function(e,t,r){var n=r(9),o=r(10),a=r(11),c=r(13);e.exports=function(e,t){return n(e)||o(e,t)||a(e,t)||c()}},function(e,t){e.exports=window.wp.apiFetch},function(e,t){e.exports=window.wp.blocks},,function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var c,i=e[Symbol.iterator]();!(n=(c=i.next()).done)&&(r.push(c.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}}},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t,r){},function(e,t,r){"use strict";r.r(t);var n=r(7),o=r(2),a=(r(8),r(5)),c=r.n(a),i=r(0),l=r(3),s=r(1),u=r(6),p=r.n(u),b=r(4),m=Object(i.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)(b.Path,{d:"M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})),f=Object(i.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(i.createElement)(b.Path,{d:"M6.2 5.2v13.4l5.8-4.8 5.8 4.8V5.2z"}));function d(e,t){var r=new FileReader;r.readAsText(e),r.onload=function(r){var n=r.target.result;p()({path:"/roam-research/upload-graph",method:"POST",data:{graphContent:n,graphName:e.name.replace(".json","")}}).then((function(){t("OK")}))}}r(14),Object(n.registerBlockType)("artpi/roam-block",{apiVersion:2,attributes:{uid:{type:"string"},childrenListView:{type:"string",default:"list"},showHeader:{type:"boolean",default:!0},content:{type:"string",source:"html",selector:".wp-block-artpi-roam-block",default:""}},title:Object(o.__)("Roam Research Block","roam-block"),description:Object(o.__)("Embed Roam Blocks or pages in WordPress, just as you would in Roam","roam-block"),category:"embed",icon:"sos",supports:{html:!0},edit:function(e){var t=e.attributes,r=e.setAttributes,n=Object(i.useState)(""),a=c()(n,2),u=a[0],b=a[1],h=Object(i.useState)([]),w=c()(h,2),O=w[0],j=w[1],v=Object(i.useState)("OK"),y=c()(v,2),g=y[0],k=y[1];return Object(i.useEffect)((function(){var e=setTimeout((function(){u.length>5&&p()({path:"/roam-research/search_block?q=".concat(u)}).then(j).catch((function(e){"graph_missing"===e.code&&k("MISSING")}))}),500);return function(){clearTimeout(e)}}),[u]),Object(i.createElement)("div",Object(l.useBlockProps)({className:"artpi-roam-block-children-"+t.childrenListView+" artpi-roam-block-header-"+(t.showHeader?"visible":"hidden")}),Object(i.createElement)(l.InspectorControls,{initialOpen:!0},Object(i.createElement)(s.PanelBody,{title:Object(o.__)("Your Roam Graph export","roam-block"),initialOpen:"true"},Object(i.createElement)(s.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return d(e.target.files.item(0),k)}},Object(o.__)("Upload .json file from Roam Research export","roam-block")))),t.content&&Object(i.createElement)(l.BlockControls,null,Object(i.createElement)(s.Toolbar,{label:"Options"},Object(i.createElement)(s.ToolbarButton,{isActive:"list"===t.childrenListView,icon:m,label:"Display as a list",onClick:function(){return r({childrenListView:"list"===t.childrenListView?"document":"list"})}}),Object(i.createElement)(s.ToolbarButton,{isActive:!!t.showHeader,icon:f,label:"Include Parent",onClick:function(){return r({showHeader:!t.showHeader})}}))),!t.uid&&Object(i.createElement)(s.Placeholder,{label:"Roam Block Embed"},"MISSING"===g&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(s.Notice,{isDismissible:!1,status:"warning"},"Your Roam graph is missing. Please export it from Roam and upload here:"),Object(i.createElement)(s.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return d(e.target.files.item(0),k)}},Object(o.__)("Upload .json file from Roam Research export","roam-block"))),"OK"===g&&Object(i.createElement)(i.Fragment,null,Object(i.createElement)(s.TextControl,{label:"Search Roam Block",placeholder:"Search Roam block just as you would with ((",value:u,onChange:b}),Object(i.createElement)("div",{className:"wp-block-artpi-roam-block-results"},O.map((function(e){var t=e.content,n=e.uid,o=e.title,a=e.snippet;return Object(i.createElement)("div",{key:n,onClick:function(){return r({uid:n,content:t})}},Object(i.createElement)("div",{className:"wp-block-artpi-roam-block-results-title"},o),Object(i.createElement)("div",null,a))}))))),t.content&&Object(i.createElement)(i.RawHTML,null,t.content))},save:function(e){var t=e.attributes;return Object(i.createElement)("div",l.useBlockProps.save(),Object(i.createElement)(i.RawHTML,null,t.content))}})}]);1 (window.roam_blockWebpack=window.roam_blockWebpack||[]).push([[1],{8:function(e,t,r){}}]),function(e){function t(t){for(var o,c,l=t[0],i=t[1],u=t[2],p=0,b=[];p<l.length;p++)c=l[p],Object.prototype.hasOwnProperty.call(n,c)&&n[c]&&b.push(n[c][0]),n[c]=0;for(o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o]);for(s&&s(t);b.length;)b.shift()();return a.push.apply(a,u||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],o=!0,l=1;l<r.length;l++){var i=r[l];0!==n[i]&&(o=!1)}o&&(a.splice(t--,1),e=c(c.s=r[0]))}return e}var o={},n={0:0},a=[];function c(t){if(o[t])return o[t].exports;var r=o[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.m=e,c.c=o,c.d=function(e,t,r){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(c.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)c.d(r,o,function(t){return e[t]}.bind(null,o));return r},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="";var l=window.roam_blockWebpack=window.roam_blockWebpack||[],i=l.push.bind(l);l.push=t,l=l.slice();for(var u=0;u<l.length;u++)t(l[u]);var s=i;a.push([15,1]),r()}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.primitives},function(e,t,r){var o=r(9),n=r(10),a=r(11),c=r(13);e.exports=function(e,t){return o(e)||n(e,t)||a(e,t)||c()}},function(e,t){e.exports=window.wp.apiFetch},function(e,t){e.exports=window.wp.blocks},,function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],o=!0,n=!1,a=void 0;try{for(var c,l=e[Symbol.iterator]();!(o=(c=l.next()).done)&&(r.push(c.value),!t||r.length!==t);o=!0);}catch(e){n=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(n)throw a}}return r}}},function(e,t,r){var o=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t,r){},function(e,t,r){"use strict";r.r(t);var o=r(7),n=r(2),a=(r(8),r(5)),c=r.n(a),l=r(0),i=r(3),u=r(1),s=r(6),p=r.n(s),b=r(4),m=Object(l.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(l.createElement)(b.Path,{d:"M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})),d=Object(l.createElement)(b.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(l.createElement)(b.Path,{d:"M6.2 5.2v13.4l5.8-4.8 5.8 4.8V5.2z"}));function f(e,t){var r=new FileReader;r.readAsText(e),r.onload=function(r){var o=r.target.result;p()({path:"/roam-research/upload-graph",method:"POST",data:{graphContent:o,graphName:e.name.replace(".json","")}}).then((function(){t("OK")}))}}r(14),Object(o.registerBlockType)("artpi/roam-block",{apiVersion:2,attributes:{uid:{type:"string"},childrenListView:{type:"string",default:"list"},showHeader:{type:"boolean",default:!0},content:{type:"string",source:"html",selector:".wp-block-artpi-roam-block",default:""}},title:Object(n.__)("Roam Research Block","roam-block"),description:Object(n.__)("Embed Roam Blocks or pages in WordPress, just as you would in Roam","roam-block"),category:"embed",icon:"sos",supports:{html:!0},edit:function(e){var t=e.attributes,r=e.setAttributes,o=Object(l.useState)(""),a=c()(o,2),s=a[0],b=a[1],h=Object(l.useState)(""),w=c()(h,2),O=w[0],j=w[1],v=Object(l.useState)([]),y=c()(v,2),g=y[0],k=y[1],E=Object(l.useState)("OK"),x=c()(E,2),_=x[0],S=x[1];return Object(l.useEffect)((function(){var e=setTimeout((function(){s.length>5&&p()({path:"/roam-research/search_block?q=".concat(s)}).then(k).catch((function(e){"graph_missing"===e.code&&S("MISSING")}))}),500);return function(){clearTimeout(e)}}),[s]),Object(l.createElement)("div",Object(i.useBlockProps)({className:"artpi-roam-block-children-"+t.childrenListView+" artpi-roam-block-header-"+(t.showHeader?"visible":"hidden")}),Object(l.createElement)(i.InspectorControls,{initialOpen:!0},Object(l.createElement)(u.PanelBody,{title:Object(n.__)("Your Roam Graph export","roam-block"),initialOpen:"true"},Object(l.createElement)(u.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return f(e.target.files.item(0),S)}},Object(n.__)("Upload .json file from Roam Research export","roam-block"))),Object(l.createElement)(u.PanelBody,{title:Object(n.__)("Secret Upload URL","roam-block"),initialOpen:!1,onToggle:function(e){e&&p()({path:"/roam-research/get_upload_token"}).then((function(e){return j(e.url)}))}},Object(l.createElement)("p",null,Object(n.__)("You can use automated script to keep your graph updated. Keep this URL private - it will allow everyone to update Roam Graph on your blog.","roam-block")),Object(l.createElement)("a",{href:"https://deliber.at/roam/roam-api"},Object(l.createElement)("p",null,Object(n.__)("Instructions how to set up Roam-Research-Private-API to do so for you.","roam-block"))),Object(l.createElement)(u.TextControl,{label:"Secret Upload URL",value:O}))),t.content&&Object(l.createElement)(i.BlockControls,null,Object(l.createElement)(u.Toolbar,{label:"Options"},Object(l.createElement)(u.ToolbarButton,{isActive:"list"===t.childrenListView,icon:m,label:"Display as a list",onClick:function(){return r({childrenListView:"list"===t.childrenListView?"document":"list"})}}),Object(l.createElement)(u.ToolbarButton,{isActive:!!t.showHeader,icon:d,label:"Include Parent",onClick:function(){return r({showHeader:!t.showHeader})}}))),!t.uid&&Object(l.createElement)(u.Placeholder,{label:"Roam Block Embed"},"MISSING"===_&&Object(l.createElement)(l.Fragment,null,Object(l.createElement)(u.Notice,{isDismissible:!1,status:"warning"},"Your Roam graph is missing. Please export it from Roam and upload here:"),Object(l.createElement)(u.FormFileUpload,{isPrimary:!0,accept:"application/json",onChange:function(e){return f(e.target.files.item(0),S)}},Object(n.__)("Upload .json file from Roam Research export","roam-block"))),"OK"===_&&Object(l.createElement)(l.Fragment,null,Object(l.createElement)(u.TextControl,{label:"Search Roam Block",placeholder:"Search Roam block just as you would with ((",value:s,onChange:b}),Object(l.createElement)("div",{className:"wp-block-artpi-roam-block-results"},g.map((function(e){var t=e.content,o=e.uid,n=e.title,a=e.snippet;return Object(l.createElement)("div",{key:o,onClick:function(){return r({uid:o,content:t})}},Object(l.createElement)("div",{className:"wp-block-artpi-roam-block-results-title"},n),Object(l.createElement)("div",null,a))}))))),t.content&&Object(l.createElement)(l.RawHTML,null,t.content))},save:function(e){var t=e.attributes;return Object(l.createElement)("div",i.useBlockProps.save(),Object(l.createElement)(l.RawHTML,null,t.content))}})}]); -
roam-block/trunk/endpoints.php
r2450567 r2463574 11 11 'methods' => 'POST', 12 12 'callback' => __NAMESPACE__ . '\roam_update_graph', 13 'permission_callback' => __NAMESPACE__ . '\check_permissions ',13 'permission_callback' => __NAMESPACE__ . '\check_permissions_upload', 14 14 ) 15 15 ); … … 23 23 ) 24 24 ); 25 register_rest_route( 26 'roam-research', 27 '/get_upload_token', 28 array( 29 'methods' => 'GET', 30 'callback' => __NAMESPACE__ . '\roam_get_upload_token', 31 'permission_callback' => __NAMESPACE__ . '\check_permissions', 32 ) 33 ); 25 34 } 26 35 ); 36 37 function check_permissions_upload( \WP_REST_Request $request ) { 38 if ( check_permissions() ) { 39 return true; 40 } 41 $params = $request->get_params(); 42 $token = get_option( 'roam_update_token' ); 43 if ( $token && $params['token'] === $token ) { 44 return true; 45 } 46 return false; 47 } 27 48 28 49 function check_permissions() { … … 31 52 } 32 53 54 function roam_get_upload_token( \WP_REST_Request $request ) { 55 $token = get_option( 'roam_update_token' ); 56 if ( ! $token ) { 57 $token = wp_generate_password( 20, false ); 58 update_option( 'roam_update_token', $token ); 59 } 60 $url = get_rest_url( null, 'roam-research/upload-graph' ); 61 $query = parse_url( $url, PHP_URL_QUERY ); 62 63 $url = $url . ( $query ? '&' : '?' ) . 'token=' . $token; 64 return array( 65 'token' => $token, 66 'url' => $url, 67 ); 68 } 69 33 70 function roam_update_graph( \WP_REST_Request $request ) { 34 71 $params = $request->get_params(); 72 if ( ! is_string( $params['graphContent'] ) ) { 73 $params['graphContent'] = json_encode( $params['graphContent'] ); 74 } 75 35 76 update_option( 'roam_graph_content', $params['graphContent'] ); 36 77 update_option( 'roam_graph_name', $params['graphName'] ); -
roam-block/trunk/readme.txt
r2450601 r2463574 4 4 Requires at least: 5.3.1 5 5 Tested up to: 5.3.1 6 Stable tag: 0.1. 26 Stable tag: 0.1.3 7 7 Requires PHP: 7.0.0 8 8 License: GPL-2.0-or-later … … 53 53 Since blocks are a conceptual unit of both Gutenberg and Roam - I created this plugin. 54 54 55 = Why do I have to manually upload the roam graph? =55 = Do I have to manually upload the roam graph? = 56 56 57 Roam is still working in providing a proper API. Please harass @Conaw 57 Roam does not have an API that could run through WordPress. I have built a project that can keep your Roam graph in WP automatically updated, but it has to run on another machine. 58 [Details how to set it up are here.](https://deliber.at/roam/wp-roam-block/) 58 59 59 60 = How do I upload the graph? = … … 85 86 = 0.1.2 = 86 87 * Fix WordPress version tag 88 = 0.1.3 = 89 * Expose update URL to automatically update Roam Graph via https://deliber.at/roam/roam-api/ -
roam-block/trunk/roam-block.php
r2450601 r2463574 4 4 * Plugin URI: https://deliber.at/wp-roam-block/ 5 5 * Description: Embed Roam Blocks or pages in WordPress, just as you would in Roam 6 * Version: 0.1. 26 * Version: 0.1.3 7 7 * Author: Artur Piszek (artpi) 8 8 * Author URI: https://piszek.com
Note: See TracChangeset
for help on using the changeset viewer.