From 1941a2c33bc27ae6871b0f78d85994d231a65b45 Mon Sep 17 00:00:00 2001 From: arbreton Date: Thu, 30 May 2019 20:33:10 +0200 Subject: [PATCH 1/9] Updated metadata implementation with helmet --- package-lock.json | 13 +++++++++---- package.json | 2 +- src/components/views/ViewCampaign.jsx | 24 ++++++++++++++++++++++++ src/configuration.js | 3 +++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index d996d45ef..56b3deea7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18718,19 +18718,24 @@ "integrity": "sha512-FlsPxavEyMuR6TjVbSSywovXSEyOg6ZDj5+Z8nbsRl9EkOzAhEIcS+GLoQDC5fz/t9suhUXWmUrOBrgeUvrMxw==", "dev": true }, + "react-fast-compare": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-2.0.4.tgz", + "integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==" + }, "react-ga": { "version": "2.5.7", "resolved": "https://registry.npmjs.org/react-ga/-/react-ga-2.5.7.tgz", "integrity": "sha512-UmATFaZpEQDO96KFjB5FRLcT6hFcwaxOmAJZnjrSiFN/msTqylq9G+z5Z8TYzN/dbamDTiWf92m6MnXXJkAivQ==" }, "react-helmet": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-5.2.0.tgz", - "integrity": "sha1-qBgR3yExOm1VxfBYxK66XW89l6c=", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-5.2.1.tgz", + "integrity": "sha512-CnwD822LU8NDBnjCpZ4ySh8L6HYyngViTZLfBBb3NjtrpN8m49clH8hidHouq20I51Y6TpCTISCBbqiY5GamwA==", "requires": { - "deep-equal": "^1.0.1", "object-assign": "^4.1.1", "prop-types": "^15.5.4", + "react-fast-compare": "^2.0.2", "react-side-effect": "^1.1.0" } }, diff --git a/package.json b/package.json index 109cf06e2..91a0f5f7f 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "react-datepicker": "1.4.1", "react-dom": ">=16.4.2", "react-ga": "^2.5.7", - "react-helmet": "^5.2.0", + "react-helmet": "^5.2.1", "react-html-parser": "^2.0.2", "react-input-token": "^1.1.2", "react-js-pagination": "^3.0.1", diff --git a/src/components/views/ViewCampaign.jsx b/src/components/views/ViewCampaign.jsx index 95ed5d736..079cf6f91 100644 --- a/src/components/views/ViewCampaign.jsx +++ b/src/components/views/ViewCampaign.jsx @@ -5,6 +5,7 @@ import Avatar from 'react-avatar'; import Masonry, { ResponsiveMasonry } from 'react-responsive-masonry'; import ReactHtmlParser from 'react-html-parser'; import BigNumber from 'bignumber.js'; +import { Helmet } from 'react-helmet'; import Balances from 'components/Balances'; import { feathersClient } from '../../lib/feathersClient'; @@ -35,6 +36,7 @@ import config from '../../configuration'; * @param history Browser history object * @param balance User's current balance */ + class ViewCampaign extends Component { constructor(props) { super(props); @@ -142,6 +144,7 @@ class ViewCampaign extends Component { render() { const { history, currentUser, balance } = this.props; + const { campaignUrl } = config; const { isLoading, campaign, @@ -162,6 +165,27 @@ class ViewCampaign extends Component { {!isLoading && (
+ + {campaign.title} + + {/* Google / Search Engine Tags */} + + + + + {/* Facebook Meta Tags */} + + + + + + + {/* Twitter Meta Tags */} + + + + +
Campaign

{campaign.title}

diff --git a/src/configuration.js b/src/configuration.js index 66888c0aa..6ffb37f91 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -36,6 +36,7 @@ const configurations = { homeNetworkName: 'Home Ganache', homeNetworkId: 66, ipfsGateway: 'http://localhost:8080/ipfs/', + campaignUrl: 'http://localhost:3010/campaigns/', sendErrors: false, analytics: { ga_UA: 'UA-103956937-3', @@ -62,6 +63,7 @@ const configurations = { homeNetworkName: 'Ropsten', homeNetworkId: 3, ipfsGateway: 'https://ipfs.giveth.io/ipfs/', + campaignUrl: 'https://develop.giveth.io/campaigns/', analytics: { ga_UA: 'UA-103956937-5', useGoogleAnalytics: true, @@ -87,6 +89,7 @@ const configurations = { homeNetworkName: 'Ropsten', homeNetworkId: 3, ipfsGateway: 'https://ipfs.giveth.io/ipfs/', + campaignUrl: 'https://beta.giveth.io/campaigns/', analytics: { ga_UA: 'UA-103956937-4', useGoogleAnalytics: true, From c5e19e3a108e11b50933a775df4af04a6529971a Mon Sep 17 00:00:00 2001 From: arbreton Date: Thu, 30 May 2019 21:37:11 +0200 Subject: [PATCH 2/9] Added React Snap for preloading react app --- package-lock.json | 387 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 4 +- src/index.js | 21 ++- 3 files changed, 386 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 56b3deea7..d24ef6258 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2228,8 +2228,7 @@ "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", - "dev": true + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, "boom": { "version": "2.10.1", @@ -2651,7 +2650,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-3.0.0.tgz", "integrity": "sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M=", - "dev": true, "requires": { "no-case": "^2.2.0", "upper-case": "^1.1.1" @@ -2794,6 +2792,29 @@ "functional-red-black-tree": "^1.0.1" } }, + "cheerio": { + "version": "1.0.0-rc.2", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", + "integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=", + "requires": { + "css-select": "~1.2.0", + "dom-serializer": "~0.1.0", + "entities": "~1.1.1", + "htmlparser2": "^3.9.1", + "lodash": "^4.15.0", + "parse5": "^3.0.1" + }, + "dependencies": { + "parse5": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", + "requires": { + "@types/node": "*" + } + } + } + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -4028,7 +4049,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", - "dev": true, "requires": { "boolbase": "~1.0.0", "css-what": "2.1", @@ -4040,7 +4060,6 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dev": true, "requires": { "dom-serializer": "0", "domelementtype": "1" @@ -4072,11 +4091,19 @@ } } }, + "css-tree": { + "version": "1.0.0-alpha.28", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.28.tgz", + "integrity": "sha512-joNNW1gCp3qFFzj4St6zk+Wh/NBv0vM5YbEreZk0SD4S23S+1xBKb6cLDg2uj4P4k/GUMlIm6cKIDqIG+vdt0w==", + "requires": { + "mdn-data": "~1.1.0", + "source-map": "^0.5.3" + } + }, "css-what": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", - "integrity": "sha1-lGfQMsOM+u+58teVASUwYvh/ob0=", - "dev": true + "integrity": "sha1-lGfQMsOM+u+58teVASUwYvh/ob0=" }, "cssesc": { "version": "0.1.0", @@ -6432,6 +6459,11 @@ } } }, + "express-history-api-fallback": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/express-history-api-fallback/-/express-history-api-fallback-2.2.1.tgz", + "integrity": "sha1-OirSf3vryQ/FM9EQ18bYMJe80Fc=" + }, "extend": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", @@ -6491,6 +6523,43 @@ "webpack-sources": "^1.0.1" } }, + "extract-zip": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", + "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "requires": { + "concat-stream": "1.6.2", + "debug": "2.6.9", + "mkdirp": "0.5.1", + "yauzl": "2.4.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "requires": { + "pend": "~1.2.0" + } + }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "requires": { + "fd-slicer": "~1.0.1" + } + } + } + }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -7216,8 +7285,7 @@ "filesize": { "version": "3.5.11", "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.5.11.tgz", - "integrity": "sha512-ZH7loueKBoDb7yG9esn1U+fgq7BzlzW6NRi5/rMdxIZ05dj7GFD/Xc5rq2CDt5Yq86CyfSYVyx4242QQNZbx1g==", - "dev": true + "integrity": "sha512-ZH7loueKBoDb7yG9esn1U+fgq7BzlzW6NRi5/rMdxIZ05dj7GFD/Xc5rq2CDt5Yq86CyfSYVyx4242QQNZbx1g==" }, "fill-range": { "version": "2.2.4", @@ -9636,6 +9704,14 @@ "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" }, + "highland": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/highland/-/highland-2.13.0.tgz", + "integrity": "sha512-zGZBcgAHPY2Zf9VG9S5IrlcC7CH9ELioXVtp9T5bU2a4fP2zIsA+Y8pV/n/h2lMwbWMHTX0I0xN0ODJ3Pd3aBQ==", + "requires": { + "util-deprecate": "^1.0.2" + } + }, "history": { "version": "4.9.0", "resolved": "https://registry.npmjs.org/history/-/history-4.9.0.tgz", @@ -13524,8 +13600,7 @@ "lower-case": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", - "integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=", - "dev": true + "integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=" }, "lowercase-keys": { "version": "1.0.1", @@ -13985,6 +14060,11 @@ "inherits": "^2.0.1" } }, + "mdn-data": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz", + "integrity": "sha512-FSYbp3lyKjyj3E7fMl6rYvUdX0FBXaluGqlFoYESWQlyUTq8R+wp0rkFxoYFqZlHCvsUXGjyJmLQSnXToYhOSA==" + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -14316,6 +14396,40 @@ "dom-walk": "^0.1.0" } }, + "minimalcss": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/minimalcss/-/minimalcss-0.8.1.tgz", + "integrity": "sha512-a+kbRVvxz+oQf43pweflM38KvcvVuTvv3v6a8UgVbfS7E2rktSJSf8kfbGToSXgbiBDP83WTh8MWL6PdT9ljag==", + "requires": { + "cheerio": "1.0.0-rc.2", + "css-tree": "1.0.0-alpha.28", + "csso": "~3.5.0", + "filesize": "^3.5.11", + "minimist": "^1.2.0", + "puppeteer": "^1.8.0" + }, + "dependencies": { + "csso": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/csso/-/csso-3.5.1.tgz", + "integrity": "sha512-vrqULLffYU1Q2tLdJvaCYbONStnfkfimRxXNaGjxMldI0C7JPBC4rB1RyjhfdZ4m1frm8pM9uRPKH3d2knZ8gg==", + "requires": { + "css-tree": "1.0.0-alpha.29" + }, + "dependencies": { + "css-tree": { + "version": "1.0.0-alpha.29", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.29.tgz", + "integrity": "sha512-sRNb1XydwkW9IOci6iB2xmy8IGCj6r/fr+JWitvJ2JxQRPzN3T4AGGVWCMlVmVwM1gtgALJRmGIlWv5ppnGGkg==", + "requires": { + "mdn-data": "~1.1.0", + "source-map": "^0.5.3" + } + } + } + } + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -14695,7 +14809,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", "integrity": "sha1-YLgTOWvjmz8SiKTB7V0efSi0ZKw=", - "dev": true, "requires": { "lower-case": "^1.1.1" } @@ -15356,7 +15469,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", "integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=", - "dev": true, "requires": { "boolbase": "~1.0.0" } @@ -15900,7 +16012,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz", "integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=", - "dev": true, "requires": { "no-case": "^2.2.0" } @@ -18269,6 +18380,54 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, + "puppeteer": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.17.0.tgz", + "integrity": "sha512-3EXZSximCzxuVKpIHtyec8Wm2dWZn1fc5tQi34qWfiUgubEVYHjUvr0GOJojqf3mifI6oyKnCdrGxaOI+lWReA==", + "requires": { + "debug": "^4.1.0", + "extract-zip": "^1.6.6", + "https-proxy-agent": "^2.2.1", + "mime": "^2.0.3", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^2.6.1", + "ws": "^6.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "mime": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.3.tgz", + "integrity": "sha512-QgrPRJfE+riq5TPZMcHZOtm8c6K/yYrMbKIoRfapfiGLxS8OTeIfRhUGW5LU7MlRa52KOAGCfUNruqLrIBvWZw==" + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + }, + "ws": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", @@ -18927,6 +19086,183 @@ "shallowequal": "^1.0.1" } }, + "react-snap": { + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/react-snap/-/react-snap-1.23.0.tgz", + "integrity": "sha512-spmg2maHSedLrn6QBAfLJkyMqeeffLTIs7h40pS1copW2xBrajx4HEAcanm+7IVGO6SYCPoGwvbU3U30UFN25g==", + "requires": { + "clean-css": "4.2.1", + "express": "4.16.4", + "express-history-api-fallback": "2.2.1", + "highland": "2.13.0", + "html-minifier": "3.5.21", + "minimalcss": "0.8.1", + "mkdirp": "0.5.1", + "puppeteer": "^1.8.0", + "serve-static": "1.13.2", + "sourcemapped-stacktrace-node": "2.1.8" + }, + "dependencies": { + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + } + }, + "clean-css": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz", + "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==", + "requires": { + "source-map": "~0.6.0" + } + }, + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "express": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.3", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.2", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" + }, + "html-minifier": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.21.tgz", + "integrity": "sha512-LKUKwuJDhxNa3uf/LPR/KVjm/l3rBqtYeCOAekvG8F1vItxMUpueGd94i/asDDr8/1u7InxzFA5EeGjhhG5mMA==", + "requires": { + "camel-case": "3.0.x", + "clean-css": "4.2.x", + "commander": "2.17.x", + "he": "1.2.x", + "param-case": "2.1.x", + "relateurl": "0.2.x", + "uglify-js": "3.4.x" + } + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "uglify-js": { + "version": "3.4.10", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", + "integrity": "sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==", + "requires": { + "commander": "~2.19.0", + "source-map": "~0.6.1" + }, + "dependencies": { + "commander": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + } + } + } + } + }, "react-spinner": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/react-spinner/-/react-spinner-0.2.7.tgz", @@ -19234,8 +19570,7 @@ "relateurl": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", - "integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=", - "dev": true + "integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=" }, "remove-trailing-separator": { "version": "1.1.0", @@ -20759,6 +21094,23 @@ "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" }, + "sourcemapped-stacktrace-node": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/sourcemapped-stacktrace-node/-/sourcemapped-stacktrace-node-2.1.8.tgz", + "integrity": "sha512-xQOqfT5mquKLBp+H06WTeGYEQh7OF5wa44IPHbh+qNdTP15xSzxwISPml1xCweJ6DExDpDDxXe/P34wP+GdDrg==", + "requires": { + "es6-promise": "^4.1.1", + "isomorphic-fetch": "^2.2.1", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + } + } + }, "sparkles": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.1.tgz", @@ -22852,8 +23204,7 @@ "upper-case": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", - "integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg=", - "dev": true + "integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg=" }, "uri-js": { "version": "4.2.2", diff --git a/package.json b/package.json index 91a0f5f7f..4121dc3b2 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "react-router": "^4.1.2", "react-router-dom": "^4.1.2", "react-share": "^2.4.0", + "react-snap": "^1.23.0", "react-toastify": "2.1.7", "react-toggle": "^4.0.2", "request": "^2.88.0", @@ -86,7 +87,8 @@ "eslint:fix": "eslint --fix src/**/*.js*", "eject": "react-scripts eject", "prettify": "prettier --write 'src/**/*.js*'", - "doc": "jsdoc src -r -d docs" + "doc": "jsdoc src -r -d docs", + "postbuild": "react-snap" }, "lint-staged": { "src/**/*.{js,jsx,json}": [ diff --git a/src/index.js b/src/index.js index b3651c171..40c40eebe 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,12 @@ import React from 'react'; -import ReactDOM from 'react-dom'; import localForage from 'localforage'; - +import { hydrate, render } from 'react-dom'; import registerServiceWorker from './lib/registerServiceWorker'; import Application from './containers/Application'; import './styles/application.css'; +const rootElement = document.getElementById('root'); + try { localForage .config({ @@ -19,10 +20,16 @@ try { // console.log(e); } -/* global document */ -ReactDOM.render( - , // eslint-disable-line react/jsx-filename-extension - document.getElementById('root'), -); +if (rootElement.hasChildNodes()) { + hydrate( + , // eslint-disable-line react/jsx-filename-extension + document.getElementById('root'), + ); +} else { + render( + , // eslint-disable-line react/jsx-filename-extension + document.getElementById('root'), + ); +} registerServiceWorker(); From 3ba78edf103d4a5aefd3f9b3993dc7e1cccbf936 Mon Sep 17 00:00:00 2001 From: dapplion Date: Thu, 30 May 2019 23:19:41 +0200 Subject: [PATCH 3/9] Fix tests by correcting lint error --- src/contextProviders/Web3Provider.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/contextProviders/Web3Provider.jsx b/src/contextProviders/Web3Provider.jsx index d2561f932..a36484477 100644 --- a/src/contextProviders/Web3Provider.jsx +++ b/src/contextProviders/Web3Provider.jsx @@ -141,9 +141,9 @@ class Web3Provider extends Component { title: 'Web3 Connection Error', content: React.swal.msg(

- Unable to connect to the web3 provider. Please check if your MetaMask (or other web3 provider) is - connected to a valid network. If so try restarting your browser or open the DApp in - private window. + Unable to connect to the web3 provider. Please check if your MetaMask (or other web3 + provider) is connected to a valid network. If so try restarting your browser or open the + DApp in private window.

, ), }); From 58752101d91514a32bafcfa9fe447a6b3a4a4c9b Mon Sep 17 00:00:00 2001 From: arbreton Date: Thu, 30 May 2019 23:20:46 +0200 Subject: [PATCH 4/9] Added edit campaign button on ViewCampaign.jsx --- src/components/views/ViewCampaign.jsx | 30 ++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/views/ViewCampaign.jsx b/src/components/views/ViewCampaign.jsx index 079cf6f91..ca6871434 100644 --- a/src/components/views/ViewCampaign.jsx +++ b/src/components/views/ViewCampaign.jsx @@ -6,13 +6,13 @@ import Masonry, { ResponsiveMasonry } from 'react-responsive-masonry'; import ReactHtmlParser from 'react-html-parser'; import BigNumber from 'bignumber.js'; import { Helmet } from 'react-helmet'; - import Balances from 'components/Balances'; + import { feathersClient } from '../../lib/feathersClient'; import Loader from '../Loader'; import MilestoneCard from '../MilestoneCard'; import GoBackButton from '../GoBackButton'; -import { isOwner, getUserName, getUserAvatar } from '../../lib/helpers'; +import { isOwner, getUserName, getUserAvatar, history } from '../../lib/helpers'; import { checkBalance } from '../../lib/middleware'; import BackgroundImageHeader from '../BackgroundImageHeader'; import DonateButton from '../DonateButton'; @@ -142,8 +142,20 @@ class ViewCampaign extends Component { }); } + editCampaign(id) { + checkBalance(this.props.balance) + .then(() => { + history.push(`/campaigns/${id}/edit`); + }) + .catch(err => { + if (err === 'noBalance') { + // handle no balance error + } + }); + } + render() { - const { history, currentUser, balance } = this.props; + const { currentUser, balance } = this.props; const { campaignUrl } = config; const { isLoading, @@ -157,6 +169,7 @@ class ViewCampaign extends Component { donationsTotal, newDonations, } = this.state; + if (!isLoading && !campaign) return

Unable to find a campaign

; return ( @@ -189,6 +202,17 @@ class ViewCampaign extends Component {
Campaign

{campaign.title}

+ {campaign.owner.address === currentUser.address && campaign.isActive && ( + + )} Date: Thu, 30 May 2019 23:47:10 +0200 Subject: [PATCH 5/9] Added HTTPS CDN --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index ac94d5a3b..1f433a485 100644 --- a/public/index.html +++ b/public/index.html @@ -36,7 +36,7 @@ crossorigin="anonymous"> - + From 41d43b255942d3e23a82925ea3d7a19a256e9500 Mon Sep 17 00:00:00 2001 From: arbreton Date: Fri, 31 May 2019 18:26:13 +0200 Subject: [PATCH 6/9] Minor changes to slied modals for state handling --- .env | 1 + src/components/DelegateButton.jsx | 26 +++++++++++++++++------ src/components/DelegateMultipleButton.jsx | 15 ++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 19aaeaacd..1104667cb 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ PORT=3010 NODE_PATH=src/ +REACT_APP_ENVIRONMENT=localhost \ No newline at end of file diff --git a/src/components/DelegateButton.jsx b/src/components/DelegateButton.jsx index ba18e95f4..2501568ed 100644 --- a/src/components/DelegateButton.jsx +++ b/src/components/DelegateButton.jsx @@ -73,6 +73,7 @@ class DelegateButton extends Component { objectsToDelegateToMilestone: [], modalVisible: false, amount: '0', + amountSelected: '0', maxAmount: new BigNumber('0'), curProjectId: null, }; @@ -97,7 +98,7 @@ class DelegateButton extends Component { }); } - selectedObject(type, { target }) { + selectedObject(type, { target }, amountSelected) { const admin = this.props.types.find(t => t._id === target.value[0]); let maxAmount = this.props.donation.amountRemaining; @@ -109,10 +110,16 @@ class DelegateButton extends Component { maxAmount = maxDelegationAmount; } } + let tempAmount = 0; + if (amountSelected !== 0) { + tempAmount = amountSelected; + } else { + tempAmount = maxAmount.toFixed(); + } this.setState({ maxAmount, - amount: maxAmount.toFixed(), + amount: tempAmount, objectsToDelegateToCampaign: target.value, }); if (type === Milestone.type) { @@ -297,7 +304,7 @@ class DelegateButton extends Component { placeholder="Select a Campaign" value={campaignValue} options={milestoneOnly ? milestoneOnlyCampaignTypes : campaignTypes} - onSelect={v => this.selectedObject(Campaign.type, v)} + onSelect={v => this.selectedObject(Campaign.type, v, this.state.amountSelected)} maxLength={1} /> this.selectedObject(Milestone.type, v)} + onSelect={v => this.selectedObject(Milestone.type, v, this.state.amountSelected)} />
@@ -326,7 +333,12 @@ class DelegateButton extends Component { [maxAmount.toNumber()]: maxAmount.toFixed(), }} tooltip={false} - onChange={amount => this.setState({ amount: Number(amount).toFixed(2) })} + onChange={amount => + this.setState({ + amount: Number(amount).toFixed(2), + amountSelected: Number(amount).toFixed(2), + }) + } /> @@ -341,7 +353,9 @@ class DelegateButton extends Component { }} name="amount" value={this.state.amount} - onChange={amount => this.setState({ amount })} + onChange={amount => + this.setState({ amount }, this.setState({ amountSelected: amount })) + } /> diff --git a/src/components/DelegateMultipleButton.jsx b/src/components/DelegateMultipleButton.jsx index 6bc42f530..ae1ee6fee 100644 --- a/src/components/DelegateMultipleButton.jsx +++ b/src/components/DelegateMultipleButton.jsx @@ -60,6 +60,7 @@ class DelegateMultipleButton extends Component { modalVisible: false, delegations: [], maxAmount: new BigNumber('0'), + selectedAmount: '0', delegationOptions: [], objectToDelegateFrom: [], tokenWhitelistOptions: props.tokenWhitelist.map(t => ({ @@ -135,13 +136,13 @@ class DelegateMultipleButton extends Component { ); } - selectedObject({ target }) { + selectedObject({ target }, selectedAmount) { this.setState({ objectToDelegateFrom: target.value, isLoadingDonations: true }); - this.loadDonations(target.value); + this.loadDonations(target.value, selectedAmount); } - loadDonations(ids) { + loadDonations(ids, selectedAmount) { if (ids.length !== 1) return; const entity = this.state.delegationOptions.find(c => c.id === ids[0]); @@ -188,6 +189,7 @@ class DelegateMultipleButton extends Component { (sum, d) => sum.plus(d.amountRemaining), new BigNumber('0'), ); + if (selectedAmount !== 0) amount = selectedAmount; if (this.props.milestone && this.props.milestone.isCapped) { const maxDonationAmount = this.props.milestone.maxAmount.minus( @@ -333,7 +335,7 @@ class DelegateMultipleButton extends Component { placeholder={milestone ? 'Select a DAC or Campaign' : 'Select a DAC'} value={this.state.objectToDelegateFrom} options={delegationOptions} - onSelect={this.selectedObject} + onSelect={this.selectedObject(this.state.selectedAmount)} maxLength={1} /> @@ -388,6 +390,7 @@ class DelegateMultipleButton extends Component { amount: prevState.maxAmount.gte(newAmount) ? newAmount.toFixed(2) : prevState.maxAmount.toFixed(2), + selectedAmount: amount, })) } /> @@ -404,7 +407,9 @@ class DelegateMultipleButton extends Component { }} name="amount" value={amount} - onChange={(name, newAmount) => this.setState({ amount: newAmount })} + onChange={(name, newAmount) => + this.setState({ amount: newAmount, selectedAmount: newAmount }) + } /> From 983b178d35837549bc4ce691f3a308f1282d66dc Mon Sep 17 00:00:00 2001 From: arbreton Date: Fri, 31 May 2019 18:26:48 +0200 Subject: [PATCH 7/9] #729 amount changes on campaign change --- src/components/DelegateButton.jsx | 1 - src/components/DelegateMultipleButton.jsx | 27 ++++++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/DelegateButton.jsx b/src/components/DelegateButton.jsx index 2501568ed..31f692760 100644 --- a/src/components/DelegateButton.jsx +++ b/src/components/DelegateButton.jsx @@ -128,7 +128,6 @@ class DelegateButton extends Component { this.setState({ curProjectId: admin ? admin.projectId : null, objectsToDelegateToCampaign: target.value, - objectsToDelegateToMilestone: [], }); } } diff --git a/src/components/DelegateMultipleButton.jsx b/src/components/DelegateMultipleButton.jsx index ae1ee6fee..2aaa22e61 100644 --- a/src/components/DelegateMultipleButton.jsx +++ b/src/components/DelegateMultipleButton.jsx @@ -60,7 +60,7 @@ class DelegateMultipleButton extends Component { modalVisible: false, delegations: [], maxAmount: new BigNumber('0'), - selectedAmount: '0', + selectedAmount: new BigNumber('0'), delegationOptions: [], objectToDelegateFrom: [], tokenWhitelistOptions: props.tokenWhitelist.map(t => ({ @@ -118,7 +118,10 @@ class DelegateMultipleButton extends Component { this.setState({ delegationOptions }, () => { if (delegationOptions.length === 1) { - this.selectedObject({ target: { value: [delegationOptions[0].id] } }); + this.selectedObject( + { target: { value: [delegationOptions[0].id] } }, + new BigNumber(0), + ); } }); }, @@ -189,7 +192,12 @@ class DelegateMultipleButton extends Component { (sum, d) => sum.plus(d.amountRemaining), new BigNumber('0'), ); - if (selectedAmount !== 0) amount = selectedAmount; + + const localMax = amount; + + if (selectedAmount.toNumber() !== 0) { + amount = selectedAmount; + } if (this.props.milestone && this.props.milestone.isCapped) { const maxDonationAmount = this.props.milestone.maxAmount.minus( @@ -201,9 +209,9 @@ class DelegateMultipleButton extends Component { this.setState({ delegations, - maxAmount: amount, - amount: amount.toFixed(), + maxAmount: localMax, isLoadingDonations: false, + amount, }); }, () => this.setState({ isLoadingDonations: false }), @@ -335,7 +343,7 @@ class DelegateMultipleButton extends Component { placeholder={milestone ? 'Select a DAC or Campaign' : 'Select a DAC'} value={this.state.objectToDelegateFrom} options={delegationOptions} - onSelect={this.selectedObject(this.state.selectedAmount)} + onSelect={v => this.selectedObject(v, this.state.selectedAmount)} maxLength={1} /> @@ -390,7 +398,7 @@ class DelegateMultipleButton extends Component { amount: prevState.maxAmount.gte(newAmount) ? newAmount.toFixed(2) : prevState.maxAmount.toFixed(2), - selectedAmount: amount, + selectedAmount: new BigNumber(newAmount), })) } /> @@ -408,7 +416,10 @@ class DelegateMultipleButton extends Component { name="amount" value={amount} onChange={(name, newAmount) => - this.setState({ amount: newAmount, selectedAmount: newAmount }) + this.setState({ + amount: newAmount, + selectedAmount: new BigNumber(newAmount), + }) } /> From 1d4da653bf3ec93109fb147c09e4cdd7649256af Mon Sep 17 00:00:00 2001 From: arbreton Date: Fri, 31 May 2019 18:29:11 +0200 Subject: [PATCH 8/9] #778 restored ipfs default gateway --- src/configuration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configuration.js b/src/configuration.js index 6ffb37f91..dc8d38311 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -114,7 +114,7 @@ const configurations = { foreignNetworkId: 4, homeNetworkName: 'Mainnet', homeNetworkId: 1, - ipfsGateway: 'https://giveth.ipfs.alibre.io/ipfs/', + ipfsGateway: 'https://ipfs.giveth.io/ipfs/', analytics: { ga_UA: 'UA-103956937-2', useGoogleAnalytics: true, From 250556c8288dd9e86db1baf484c352d77df51a06 Mon Sep 17 00:00:00 2001 From: arbreton Date: Fri, 31 May 2019 19:16:53 +0200 Subject: [PATCH 9/9] Removed react-snap postscript for prerendering --- .env | 1 - package.json | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.env b/.env index 1104667cb..19aaeaacd 100644 --- a/.env +++ b/.env @@ -1,3 +1,2 @@ PORT=3010 NODE_PATH=src/ -REACT_APP_ENVIRONMENT=localhost \ No newline at end of file diff --git a/package.json b/package.json index 4121dc3b2..ef2f19b5d 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,7 @@ "eslint:fix": "eslint --fix src/**/*.js*", "eject": "react-scripts eject", "prettify": "prettier --write 'src/**/*.js*'", - "doc": "jsdoc src -r -d docs", - "postbuild": "react-snap" + "doc": "jsdoc src -r -d docs" }, "lint-staged": { "src/**/*.{js,jsx,json}": [