Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
node_modules
arena-schema.json.js
.json.js
7 changes: 5 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
const withYaml = require('next-plugin-yaml');

module.exports = withYaml({
env: {
APPLICATION_ID: process.env.APPLICATION_ID,
APPLICATION_SECRET: process.env.APPLICATION_SECRET,
Expand All @@ -9,4 +11,5 @@ module.exports = {
GRAPHQL_TOKEN: process.env.GRAPHQL_TOKEN,
AUTHENTICATION_ENABLED: process.env.NODE_ENV === 'production' ? false : true
}
};

});
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@use-it/event-listener": "^0.1.4",
"agent-base": "^6.0.2",
"axios": "^0.19.2",
"cambria": "^0.1.2",
"dotenv": "^8.2.0",
"downshift": "^5.0.3",
"es6-promise": "^4.2.8",
Expand All @@ -28,6 +29,8 @@
"graphql": "^15.0.0",
"html-react-parser": "^0.10.3",
"isomorphic-unfetch": "^3.0.0",
"js-yaml": "^3.14.1",
"js-yaml-loader": "^1.2.2",
"localforage": "^1.8.1",
"next": "^9.2.1",
"next-with-apollo": "^5.0.1",
Expand Down Expand Up @@ -59,6 +62,7 @@
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"husky": "^4.3.6",
"next-plugin-yaml": "^1.0.1",
"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0"
},
Expand Down
24 changes: 24 additions & 0 deletions src/arena-groves.lens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Convert an Are.na Block into the Groves format
schemaName: Block

lens:
- hoist:
host: data
name: blokk
- remove:
name: data
- rename:
source: blokk
destination: block
- in:
name: block
lens:
- rename:
source: id
destination: arena
- add:
name: id
type: object
- plunge:
name: arena
host: id
10 changes: 10 additions & 0 deletions src/arena-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"blokk": {
"__typename": "Text",
"title": null,
"id": 1754146,
"content": "torture is similar to graphic design"
}
}
}
25 changes: 25 additions & 0 deletions src/components/convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as Cambria from 'cambria';
import arenaBlock from '~/src/arena-schema.json';
import roamBlock from '~/src/roam-schema.json';
import arenaSchema from '~/src/arena-groves.lens.yml';
import roamSchema from '~/src/roam-groves.lens.yml';

export const arenaToRoam = () => {
const lens = Cambria.loadYamlLens(JSON.stringify(arenaSchema));

const grovesDoc = Cambria.applyLensToDoc(lens, arenaBlock);

console.log(JSON.stringify(grovesDoc));

return grovesDoc;
};

export const roamToArena = () => {
const lens = Cambria.loadYamlLens(JSON.stringify(roamSchema));

const grovesDoc = Cambria.applyLensToDoc(lens, roamBlock);

console.log(JSON.stringify(grovesDoc));

return grovesDoc;
};
11 changes: 11 additions & 0 deletions src/groves-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"block": {
"id": {
"roam": "q7CjodisF",
"arena": "1754146"
},
"__typename": "Text",
"title": null,
"content": "torture is similar to graphic design"
}
}
25 changes: 19 additions & 6 deletions src/pages/g/[grove].js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useDropzone } from 'react-dropzone';
import { ADD_BLOCK } from '~/src/mutations';
import { useMutation } from '@apollo/client';
import { ToastContainer } from 'react-toastify';
import { roamToArena } from '~/src/components/convert';

const Grove = (props) => {
const router = useRouter();
Expand Down Expand Up @@ -47,6 +48,16 @@ const Grove = (props) => {
}
});

const addToArenaFromRoam = () => {
const val = roamToArena().data.blokk.content;
addBlock({
variables: {
channelId: router.query.grove,
value: val
}
});
};

// const onDrop = useCallback((acceptedFiles) => {
// acceptedFiles.map(async (file) => {
// setFiles(
Expand Down Expand Up @@ -89,12 +100,12 @@ const Grove = (props) => {
// }).then((res) => {
// console.log(res);

// addBlock({
// variables: {
// channelId: router.query.grove,
// value: url,
// },
// });
// addBlock({
// variables: {
// channelId: router.query.grove,
// value: url,
// },
// });
// });
// });
// });
Expand All @@ -118,6 +129,7 @@ const Grove = (props) => {

return (
<WorkspaceProvider>
<button onClick={addToArenaFromRoam}>Roam to Arena</button>
<ToastContainer
position="bottom-center"
autoClose={2000}
Expand All @@ -134,6 +146,7 @@ const Grove = (props) => {
<GrovesCanvas {...props}>
{selectedChannel && selectedChannel.channel ? (
<>
{/* <button onClick={arenaToRoam}>Arena to Roam</button> */}
{/* <input {...getInputProps()} hidden /> */}
{selectedChannel.channel.initial_contents.map((blokk, i) => {
return (
Expand Down
26 changes: 26 additions & 0 deletions src/roam-groves.lens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Convert an Roam Block into the Groves format
schemaName: Block

lens:
- rename:
source: success
destination: data
- in:
name: data
lens:
- remove: { name: uid }
- rename:
source: string
destination: content
- add:
name: blokk
type: object
- plunge:
name: content
host: blokk
- in:
name: blokk
lens:
- add:
name: title
type: string
6 changes: 6 additions & 0 deletions src/roam-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"success": {
"string": "hello here is a new block imported from roam research!",
"uid": "q7CjodisF"
}
}
99 changes: 98 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,18 @@ callsites@^3.0.0:
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==

cambria@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/cambria/-/cambria-0.1.2.tgz#03c818164ff23069876bbd80d8b5163b4cf11d7d"
integrity sha512-UYDMyP6O+I/I6uRpT/Du6yBh1haZMF7sNPyZdu7vMeFN3Oi48oKs1r1MZTIciPXZP4I+2NHhwuohTz/CETCGuw==
dependencies:
commander "^5.1.0"
fast-json-patch "^3.0.0-1"
graphlib "^2.1.8"
js-yaml "^3.14.0"
json-schema "^0.2.5"
to-json-schema "^0.2.5"

camelcase@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42"
Expand Down Expand Up @@ -2339,6 +2351,11 @@ commander@^2.20.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==

commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
Expand Down Expand Up @@ -3337,6 +3354,11 @@ fast-glob@^3.1.1:
micromatch "^4.0.2"
picomatch "^2.2.1"

fast-json-patch@^3.0.0-1:
version "3.0.0-1"
resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.0.0-1.tgz#4c68f2e7acfbab6d29d1719c44be51899c93dabb"
integrity sha512-6pdFb07cknxvPzCeLsFHStEy+MysPJPgZQ9LbQ/2O67unQF93SNqfdSqnPPl71YMHX+AD8gbl7iuoGFzHEdDuw==

fast-json-stable-stringify@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
Expand Down Expand Up @@ -3639,6 +3661,13 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==

graphlib@^2.1.8:
version "2.1.8"
resolved "https://registry.yarnpkg.com/graphlib/-/graphlib-2.1.8.tgz#5761d414737870084c92ec7b5dbcb0592c9d35da"
integrity sha512-jcLLfkpoVGmH7/InMC/1hIvOPSUh38oJtGhvrOFGzioE1DZ+0YW16RgmOJhHiuWTvGiJQ9Z1Ik43JvkRPRvE+A==
dependencies:
lodash "^4.17.15"

graphql-tag@^2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.11.0.tgz#1deb53a01c46a7eb401d6cb59dec86fa1cccbffd"
Expand Down Expand Up @@ -4150,7 +4179,16 @@ jest-worker@24.9.0:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

js-yaml@^3.13.1:
js-yaml-loader@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/js-yaml-loader/-/js-yaml-loader-1.2.2.tgz#2c15f93915617acd19676d648945fa3003f8629b"
integrity sha512-H+NeuNrG6uOs/WMjna2SjkaCw13rMWiT/D7l9+9x5n8aq88BDsh2sRmdfxckWPIHtViYHWRG6XiCKYvS1dfyLg==
dependencies:
js-yaml "^3.13.1"
loader-utils "^1.2.3"
un-eval "^1.2.0"

js-yaml@^3.13.1, js-yaml@^3.14.0, js-yaml@^3.14.1:
version "3.14.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
Expand Down Expand Up @@ -4183,6 +4221,11 @@ json-schema-traverse@^0.4.1:
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==

json-schema@^0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.5.tgz#97997f50972dd0500214e208c407efa4b5d7063b"
integrity sha512-gWJOWYFrhQ8j7pVm0EM8Slr+EPVq1Phf6lvzvD/WCeqkrx/f2xBI0xOsRRS9xCn3I4vKtP519dvs3TP09r24wQ==

json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
Expand Down Expand Up @@ -4351,11 +4394,41 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=

lodash.keys@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-4.2.0.tgz#a08602ac12e4fb83f91fc1fb7a360a4d9ba35205"
integrity sha1-oIYCrBLk+4P5H8H7ejYKTZujUgU=

lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash.omit@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60"
integrity sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=

lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=

lodash.without@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac"
integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw=

lodash.xor@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.xor/-/lodash.xor-4.5.0.tgz#4d48ed7e98095b0632582ba714d3ff8ae8fb1db6"
integrity sha1-TUjtfpgJWwYyWCunFNP/iuj7HbY=

lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
Expand Down Expand Up @@ -4646,6 +4719,13 @@ neo-async@^2.5.0, neo-async@^2.6.1, neo-async@^2.6.2:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==

next-plugin-yaml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/next-plugin-yaml/-/next-plugin-yaml-1.0.1.tgz#90e96637dfa445806fc44d1df3506c0f1446246a"
integrity sha512-k13wbpN33wTgrgWUBiXPtObXO94JOEiwvYKJ3X0JrBz2yaW24EfNaVqHwA0dwhsn9PyPIKhPhgsu3bhJsNs+cQ==
dependencies:
js-yaml-loader "^1.2.2"

next-tick@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
Expand Down Expand Up @@ -6369,6 +6449,18 @@ to-fast-properties@^2.0.0:
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=

to-json-schema@^0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/to-json-schema/-/to-json-schema-0.2.5.tgz#ef3c3f11ad64460dcfbdbafd0fd525d69d62a98f"
integrity sha512-jP1ievOee8pec3tV9ncxLSS48Bnw7DIybgy112rhMCEhf3K4uyVNZZHr03iQQBzbV5v5Hos+dlZRRyk6YSMNDw==
dependencies:
lodash.isequal "^4.5.0"
lodash.keys "^4.2.0"
lodash.merge "^4.6.2"
lodash.omit "^4.5.0"
lodash.without "^4.4.0"
lodash.xor "^4.5.0"

to-object-path@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
Expand Down Expand Up @@ -6499,6 +6591,11 @@ typescript@^4.1.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==

un-eval@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/un-eval/-/un-eval-1.2.0.tgz#22a95c650334d59d21697efae32612218ecad65f"
integrity sha512-Wlj/pum6dQtGTPD/lclDtoVPkSfpjPfy1dwnnKw/sZP5DpBH9fLhBgQfsqNhe5/gS1D+vkZUuB771NRMUPA5CA==

unfetch@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be"
Expand Down