git ssb

2+

mixmix / ticktack



Commit b87644d4179bd0b35e02a999a6ddb4208fe4615b

add link click handler

mix irving committed on 8/10/2017, 10:07:15 AM
Parent: 119e5a731640d722b01b4aa15a4ec30a09b17285

Files changed

app/html/app.jschanged
app/html/nav.jschanged
app/index.jschanged
app/async/catch-link-click.jsadded
package-lock.jsonchanged
package.jsonchanged
styles/global.mcsschanged
app/html/app.jsView
@@ -1,11 +1,13 @@
11 const nest = require('depnest')
22 const values = require('lodash/values')
33 const insertCss = require('insert-css')
4+const openExternal = require('open-external')
45
56 exports.gives = nest('app.html.app')
67
78 exports.needs = nest({
9+ 'app.async.catchLinkClick': 'first',
810 'history.sync.push': 'first',
911 'history.obs.location': 'first',
1012 'history.obs.store': 'first',
1113 'router.sync.router': 'first',
@@ -18,8 +20,14 @@
1820 function app () {
1921 const css = values(api.styles.css()).join('\n')
2022 insertCss(css)
2123
24+ api.app.async.catchLinkClick(document.body, (link, { isExternal }) => {
25+ if (isExternal) return openExternal(link)
26+
27+ api.history.sync.push(link)
28+ })
29+
2230 api.history.obs.location()(render)
2331 api.history.sync.push({ page: 'home' })
2432 }
2533
app/html/nav.jsView
@@ -17,8 +17,9 @@
1717 h('div.back', { 'ev-click': back }, '←'),
1818 h('div', { 'ev-click': () => push({page: 'home'}) }, 'Home'),
1919 // h('div', { 'ev-click': () => push({type: 'group', key: '%sadlkjas;lkdjas'}) }, 'Group'),
2020 h('div', { 'ev-click': () => push({key: '%fXXZgQrwnj7F+Y19H0IXxNriuvPFoahvusih3UzpkfA=.sha256'}) }, 'Thread A'),
21- h('div', { 'ev-click': () => push({key: '%3cWZHeN6k03XpvDBxrxP5bGLsNByFLTvr/rKYFV4f+c=.sha256'}) }, 'Thread B')
21+ h('div', { 'ev-click': () => push({key: '%3cWZHeN6k03XpvDBxrxP5bGLsNByFLTvr/rKYFV4f+c=.sha256'}) }, 'Thread B'),
22+ h('a', { href: '%YRhFXmsAwipgyiwuHSP+EBr9fGjSqrMpWXUxgWcHxkM=.sha256' }, 'href link')
2223 ])
2324 }
2425 }
app/index.jsView
@@ -1,5 +1,8 @@
11 module.exports = {
2+ async: {
3+ catchLinkClick: require('./async/catch-link-click'),
4+ },
25 html: {
36 app: require('./html/app'),
47 thread: require('./html/thread'),
58 nav: require('./html/nav')
app/async/catch-link-click.jsView
@@ -1,0 +1,38 @@
package-lock.jsonView
@@ -1001,8 +1001,13 @@
10011001 "version": "1.1.0",
10021002 "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
10031003 "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k="
10041004 },
1005+ "open-external": {
1006+ "version": "0.1.1",
1007+ "resolved": "https://registry.npmjs.org/open-external/-/open-external-0.1.1.tgz",
1008+ "integrity": "sha1-GfrTVRhBp3TwY8Nxs5+ycXXKjS4="
1009+ },
10051010 "optimist": {
10061011 "version": "0.6.1",
10071012 "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
10081013 "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=",
@@ -1051,11 +1056,11 @@
10511056 "mutant": "3.21.2"
10521057 }
10531058 },
10541059 "patchcore": {
1055- "version": "1.9.0",
1056- "resolved": "https://registry.npmjs.org/patchcore/-/patchcore-1.9.0.tgz",
1057- "integrity": "sha512-d9bJ7oivSS9uLknOZxnpJMDWTGVSyLmUt38mOTrL0LD1YEAAmThhi+6i/+mPXhm6605DFbYzWtxBVmXQ2t2SjQ==",
1060+ "version": "1.9.1",
1061+ "resolved": "https://registry.npmjs.org/patchcore/-/patchcore-1.9.1.tgz",
1062+ "integrity": "sha512-TLm96QXRvutu0nvYkpkpCqmlpAxHlVex6rbz6pXdTnne5AYkM1k/VaKX+30vYRQimWtqIpl1zuKb8Q34g2B3iw==",
10581063 "requires": {
10591064 "bulk-require": "1.0.1",
10601065 "bulkify": "1.4.2",
10611066 "color-hash": "1.0.3",
@@ -1073,9 +1078,9 @@
10731078 "pull-stream": "3.6.0",
10741079 "simple-mime": "0.1.0",
10751080 "sorted-array-functions": "1.0.0",
10761081 "split-buffer": "1.0.0",
1077- "ssb-client": "4.5.0",
1082+ "ssb-client": "4.5.1",
10781083 "ssb-config": "2.2.0",
10791084 "ssb-feed": "2.3.0",
10801085 "ssb-keys": "7.0.10",
10811086 "ssb-markdown": "3.3.0",
@@ -1216,8 +1221,18 @@
12161221 "relative-url": "1.0.2",
12171222 "ws": "1.1.4"
12181223 }
12191224 },
1225+ "punycode": {
1226+ "version": "1.3.2",
1227+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
1228+ "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
1229+ },
1230+ "querystring": {
1231+ "version": "0.2.0",
1232+ "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
1233+ "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
1234+ },
12201235 "quote-stream": {
12211236 "version": "0.0.0",
12221237 "resolved": "https://registry.npmjs.org/quote-stream/-/quote-stream-0.0.0.tgz",
12231238 "integrity": "sha1-zeKelMQJsW4Z3HCYuJtmWPlyHTs=",
@@ -1449,11 +1464,11 @@
14491464 "resolved": "https://registry.npmjs.org/split-buffer/-/split-buffer-1.0.0.tgz",
14501465 "integrity": "sha1-t+jgq1E0UVi3LB9tvvJAbVHx0Cc="
14511466 },
14521467 "ssb-client": {
1453- "version": "4.5.0",
1454- "resolved": "https://registry.npmjs.org/ssb-client/-/ssb-client-4.5.0.tgz",
1455- "integrity": "sha1-oiXi20o6q0NmGyemRLODfPNsuRA=",
1468+ "version": "4.5.1",
1469+ "resolved": "https://registry.npmjs.org/ssb-client/-/ssb-client-4.5.1.tgz",
1470+ "integrity": "sha512-Kn4eoSl3ZuS4BteQAtRIFM52jsGJPar4NJHLjis5OFxV22pNub/JfZHC2FdJBTtkPWJIJZi0ullCsm/EQ1Xs7Q==",
14561471 "requires": {
14571472 "explain-error": "1.0.4",
14581473 "multicb": "1.2.2",
14591474 "multiserver": "1.10.0",
@@ -1721,8 +1736,17 @@
17211736 "version": "1.0.2",
17221737 "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz",
17231738 "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po="
17241739 },
1740+ "url": {
1741+ "version": "0.11.0",
1742+ "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz",
1743+ "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=",
1744+ "requires": {
1745+ "punycode": "1.3.2",
1746+ "querystring": "0.2.0"
1747+ }
1748+ },
17251749 "util-deprecate": {
17261750 "version": "1.0.2",
17271751 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
17281752 "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
package.jsonView
@@ -22,11 +22,13 @@
2222 "libnested": "^1.2.1",
2323 "lodash": "^4.17.4",
2424 "micro-css": "^2.0.1",
2525 "mutant": "^3.21.2",
26+ "open-external": "^0.1.1",
2627 "patch-history": "^1.0.0",
27- "patchcore": "^1.9.0",
28+ "patchcore": "^1.9.1",
2829 "pull-stream": "^3.6.0",
2930 "read-directory": "^2.1.0",
30- "setimmediate": "^1.0.5"
31+ "setimmediate": "^1.0.5",
32+ "url": "^0.11.0"
3133 }
3234 }
styles/global.mcssView
@@ -2,6 +2,15 @@
22 font-family: arial
33 background-color: #fff
44
55 margin: 0
6+
7+ (a) {
8+ color: #1a95a9
9+ text-decoration: none
10+
11+ :hover {
12+ text-decoration: underline
13+ }
14+ }
615 }
716

Built with git-ssb-web