diff --git a/gen/moon.hoon b/gen/moon.hoon index 333a1eeef..278018931 100644 --- a/gen/moon.hoon +++ b/gen/moon.hoon @@ -10,8 +10,10 @@ $~ $~ == -:- %noun -?> =(1 (met 5 p.bec)) +:- %tang :_ ~ :- %leaf +=+ ran=(clan p.bec) +?: ?=({?($earl $pawn)} ran) + "can't create a moon from a {?:(?=($earl ran) "moon" "comet")}" =+ mon=(mix (lsh 5 1 (end 5 1 eny)) p.bec) =+ tic=.^(@ /a/(scot %p p.bec)/tick/(scot %da now)/(scot %p mon)) "moon: {<`@p`mon>}; ticket: {<`@p`tic>}" diff --git a/ren/tree/head.hoon b/ren/tree/head.hoon index a305ec46a..a5e242a03 100644 --- a/ren/tree/head.hoon +++ b/ren/tree/head.hoon @@ -50,14 +50,14 @@ :: "codemirror/4.3.0/mode/markdown/markdown.min.js"); ;* ?. nopack.dbg :_ ~ - ;script(type "text/javascript", src "{?.(aut "" "/~~")}". - "/~/at/===/web/pack/js/tree-urb.js"); -:: "/~/at/===/web/pack/js/tree-hoon-urb.js"); + ;script(type "text/javascript", src "{?.(aut "" "/~~/~/at")}". + "/===/web/pack/js/tree-urb.js"); +:: "/===/web/pack/js/tree-hoon-urb.js"); ;= :: ;script(type "text/javascript", src "/===/web/lib/js/hoon.js"); ;script(type "text/javascript", src "/===/web/tree/main.js"); - ;script(type "text/javascript", src "{?.(aut "" "/~~")}". - "/~/at/===/web/lib/js/urb.js"); + ;script(type "text/javascript", src "{?.(aut "" "/~~/~/at")}". + "/===/web/lib/js/urb.js"); == ;link(type "application/rss+xml", rel "alternate", href "{(spud tub)}.rss-xml"); == diff --git a/web/talk/main.css b/web/talk/main.css index 6e31782c4..b3bfa3366 100644 --- a/web/talk/main.css +++ b/web/talk/main.css @@ -68,14 +68,12 @@ div.gram.same:hover div.meta { white-space: nowrap; } .speech { - margin-left: 1.875rem; - white-space: nowrap; } + margin-left: 1.875rem; } .exp { font-family: 'scp'; font-size: .9rem; } .exp .speech { - white-space: nowrap; max-width: 100%; overflow-x: scroll; } .exp .speech > span { diff --git a/web/talk/main.js b/web/talk/main.js index 9d021469a..68c84c887 100644 --- a/web/talk/main.js +++ b/web/talk/main.js @@ -511,7 +511,7 @@ module.exports = recl({ },{"../util.coffee":15,"./MemberComponent.coffee":4,"classnames":16}],6:[function(require,module,exports){ -var INFINITE, Infinite, MESSAGE_HEIGHT_FIRST, MESSAGE_HEIGHT_FIRST_MARGIN_TOP, MESSAGE_HEIGHT_SAME, Message, MessageActions, MessageStore, StationActions, StationStore, div, recl, util; +var FONT_SIZE, INFINITE, Infinite, MESSAGE_HEIGHT_FIRST, MESSAGE_HEIGHT_FIRST_MARGIN_TOP, MESSAGE_HEIGHT_SAME, Message, MessageActions, MessageStore, StationActions, StationStore, div, recl, util; util = require('../util.coffee'); @@ -533,12 +533,14 @@ Message = require('./MessageComponent.coffee'); INFINITE = true; -MESSAGE_HEIGHT_FIRST = 54; - -MESSAGE_HEIGHT_FIRST_MARGIN_TOP = 36; - MESSAGE_HEIGHT_SAME = 27; +MESSAGE_HEIGHT_FIRST = 56 - MESSAGE_HEIGHT_SAME; + +MESSAGE_HEIGHT_FIRST_MARGIN_TOP = 16; + +FONT_SIZE = parseInt($('body').css('font-size').match(/(\d*)px/)[1]); + module.exports = recl({ displayName: "Messages", pageSize: 200, @@ -630,7 +632,12 @@ module.exports = recl({ } this.focused = true; $(window).on('blur', this._blur); - return $(window).on('focus', this._focus); + $(window).on('focus', this._focus); + return $(window).on('resize', _.debounce((function(_this) { + return function() { + return _this.forceUpdate(); + }; + })(this), 250)); }, componentWillUpdate: function(props, state) { return this.scrollBottom = $(document).height() - ($(window).scrollTop() + window.innerHeight); @@ -678,7 +685,7 @@ module.exports = recl({ return StationActions.setAudience(audi); }, render: function() { - var _messages, body, lastIndex, lastSaid, messageHeights, messages, ref, station; + var _messages, body, canvas, context, lastIndex, lastSaid, messageHeights, messages, ref, speechLength, station; station = this.state.station; messages = this.sortedMessages(this.state.messages); this.last = messages[messages.length - 1]; @@ -696,18 +703,46 @@ module.exports = recl({ lastIndex = this.lastSeen ? messages.indexOf(this.lastSeen) + 1 : null; lastSaid = null; messageHeights = []; + canvas = document.createElement('canvas'); + context = canvas.getContext('2d'); + speechLength = $('.grams').width() - (FONT_SIZE * 1.875); _messages = messages.map((function(_this) { return function(message, index) { - var height, marginTop, nowSaid, sameAs, speech; + var height, lineNums, marginTop, nowSaid, sameAs, speech, speechArr; nowSaid = [message.ship, _.keys(message.thought.audience)]; sameAs = _.isEqual(lastSaid, nowSaid); lastSaid = nowSaid; + lineNums = 1; + speechArr = []; + context.font = FONT_SIZE + 'px bau'; + if (message.thought.statement.speech.lin != null) { + speechArr = message.thought.statement.speech.lin.txt.split(/(\s|-)/); + } else if (message.thought.statement.speech.url != null) { + speechArr = message.thought.statement.speech.url.txt.split(/(\s|-)/); + } else if (message.thought.statement.speech.fat != null) { + context.font = (FONT_SIZE * 0.9) + 'px scp'; + speechArr = message.thought.statement.speech.fat.taf.exp.txt.split(/(\s|-)/); + } + _.reduce(_.tail(speechArr), function(base, word) { + if (context.measureText(base + word).width > speechLength) { + lineNums += 1; + if (word === ' ') { + return ''; + } else if (word === '-') { + return _.head(base.split(/\s|-/).reverse()) + word; + } else { + return word; + } + } else { + return base + word; + } + }, _.head(speechArr)); if (INFINITE) { if (sameAs) { - height = MESSAGE_HEIGHT_SAME; + height = MESSAGE_HEIGHT_SAME * lineNums; marginTop = 0; } else { - height = MESSAGE_HEIGHT_FIRST; + height = MESSAGE_HEIGHT_FIRST + (MESSAGE_HEIGHT_SAME * lineNums); marginTop = MESSAGE_HEIGHT_FIRST_MARGIN_TOP; } } else { diff --git a/web/tree/main.css b/web/tree/main.css index 0848a6502..65980622d 100644 --- a/web/tree/main.css +++ b/web/tree/main.css @@ -98,31 +98,49 @@ div.logo.inverse:before { content: "\25D0"; } @media (min-width: 768px) { + .menu, .ctrl { - width: 180px; } + width: 180px; + max-width: 180px; } .ctrl.open, .ctrl:hover { max-width: 360px; min-width: 180px; - width: auto; } } + width: auto; } + .menu.depth-1 { + margin-left: 180px; } + .menu.depth-2 { + margin-left: 360px; } } @media (min-width: 992px) { + .menu, .ctrl { - width: 235px; } + width: 235px; + max-width: 235px; } .ctrl.open, .ctrl:hover { max-width: 470px; min-width: 235px; - width: auto; } } + width: auto; } + .menu.depth-1 { + margin-left: 235px; } + .menu.depth-2 { + margin-left: 470px; } } @media (min-width: 1200px) { + .menu, .ctrl { - width: 285px; } + width: 285px; + max-width: 285px; } .ctrl.open, .ctrl:hover { max-width: 570px; min-width: 285px; - width: auto; } } + width: auto; } + .menu.depth-1 { + margin-left: 285px; } + .menu.depth-2 { + margin-left: 570px; } } #head .loading { display: none; } @@ -203,9 +221,11 @@ div.logo.inverse:before { border: 0; text-transform: none; } +.ctrl.navbar { + max-width: none; } + .ctrl.navbar.open, .ctrl.navbar:hover { - max-width: none; min-width: none; } @media (max-width: 991px) { @@ -632,6 +652,11 @@ ol > li:before { color: #000; padding: 0; } +.body[data-path*='/docs'] .head, +.body[data-path^='/work'] .head { + margin-bottom: 4rem; + padding-left: 0; } + .body[data-path*='/docs'] .book h2, .body[data-path^='/work'] .book h2 { color: #B1B7BD; } @@ -1312,7 +1337,7 @@ ol > li:before { color: #0500F0; } .sections h1:first-of-type { - padding-bottom: 0; } + padding-bottom: 1rem; } .sections li h1 { font-size: 1.2rem; } @@ -1335,9 +1360,6 @@ ol > li:before { margin-bottom: 3rem; float: none; } -.sections .kids > div p { - font-weight: 500; } - .sections hr { display: none; } diff --git a/web/tree/main.js b/web/tree/main.js index 3915e7221..69281b7a6 100644 --- a/web/tree/main.js +++ b/web/tree/main.js @@ -1,10 +1,12 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { - index = keys.indexOf(this.props.curr); - next = index + 1; - if (next === keys.length) { - next = 0; - } - next = keys[next]; - next = this.props.kids[next]; - if (next) { - return div({ - className: "link-next" - }, a({ - href: this.props.path + "/" + next.name - }, "Next: " + next.meta.title)); - } + }, name("Next", function(arg) { + var curr, index, keys, kids, next, path, ref1, ref2; + curr = arg.curr, path = arg.path, kids = arg.kids; + if ((ref1 = kids[curr]) != null ? (ref2 = ref1.meta) != null ? ref2.next : void 0 : void 0) { + keys = util.getKeys(kids); + if (keys.length > 1) { + index = keys.indexOf(curr); + next = index + 1; + if (next === keys.length) { + next = 0; + } + next = keys[next]; + next = kids[next]; + if (next) { + return div({ + className: "link-next" + }, a({ + href: path + "/" + next.name + }, "Next: " + next.meta.title)); } } - return div({}, ""); } + return div({}, ""); })), comments: Comments, - footer: recl({ - displayName: "Footer", - render: function() { - var containerClas, footerClas; - containerClas = clas({ - footer: true, - container: this.props.container === 'false' - }); - footerClas = clas({ - 'col-md-12': this.props.container === 'false' - }); - return div({ - className: containerClas, - key: 'footer-container' + footer: name("Footer", function(arg) { + var container, containerClas, footerClas; + container = arg.container; + containerClas = clas({ + footer: true, + container: container === 'false' + }); + footerClas = clas({ + 'col-md-12': container === 'false' + }); + return div({ + className: containerClas, + key: 'footer-container' + }, [ + div({ + className: footerClas, + key: 'footer-inner' }, [ - div({ - className: footerClas, - key: 'footer-inner' - }, [ - "This page was made by Urbit. Feedback: ", a({ - href: "mailto:urbit@urbit.org" - }, "urbit@urbit.org"), " ", a({ - href: "https://twitter.com/urbit_" - }, "@urbit_") - ]) - ]); - } + "This page was made by Urbit. Feedback: ", a({ + href: "mailto:urbit@urbit.org" + }, "urbit@urbit.org"), " ", a({ + href: "https://twitter.com/urbit_" + }, "@urbit_") + ]) + ]); }) }; @@ -563,7 +569,7 @@ module.exports = recl({ },{}],5:[function(require,module,exports){ -var Comment, Ship, TreeActions, a, clas, code, div, form, h2, img, input, load, p, query, reactify, recl, ref, rele, textarea, util; +var Comment, DEFER_USER, Ship, TreeActions, a, clas, code, div, form, h2, img, input, load, p, query, reactify, recl, ref, rele, textarea, util; clas = require('classnames'); @@ -585,6 +591,8 @@ rele = React.createElement; ref = React.DOM, div = ref.div, p = ref.p, h2 = ref.h2, img = ref.img, a = ref.a, form = ref.form, textarea = ref.textarea, input = ref.input, code = ref.code; +DEFER_USER = true; + Comment = function(arg) { var body, loading, ref1, time, user; time = arg.time, user = arg.user, body = arg.body, loading = (ref1 = arg.loading) != null ? ref1 : false; @@ -614,15 +622,23 @@ module.exports = query({ }; }, componentDidMount: function() { - return urb.init((function(_this) { - return function() { - return _this.setState({ - user: urb.user - }); - }; - })(this)); + if (!DEFER_USER) { + return urb.init((function(_this) { + return function() { + return _this.setState({ + user: urb.user + }); + }; + })(this)); + } }, componentDidUpdate: function(_props) { + var ref1; + if (urb.user && !this.state.user) { + this.setState({ + user: (ref1 = urb.user) != null ? ref1 : "" + }); + } if (this.props.comt.length > _props.comt.length) { return this.setState({ loading: null @@ -860,22 +876,27 @@ module.exports = recl({ },{}],9:[function(require,module,exports){ -var div, recl; +var div, name, recl; recl = React.createClass; +name = function(displayName, component) { + return _.extend(component, { + displayName: displayName + }); +}; + div = React.DOM.div; -module.exports = recl({ - displayName: "ImagePanel", - render: function() { - return div({ - className: "image-container", - style: { - backgroundImage: "url('" + this.props.src + "')" - } - }); - } +module.exports = name("ImagePanel", function(arg) { + var src; + src = arg.src; + return div({ + className: "image-container", + style: { + backgroundImage: "url('" + src + "')" + } + }); }); @@ -1261,7 +1282,9 @@ module.exports = recl({ })(this)); }, componentWillUnmount: function() { - return TreeActions.clearNav(); + return setTimeout((function() { + return TreeActions.clearNav(); + }), 0); }, render: function() { return div({ @@ -1502,6 +1525,9 @@ module.exports = query({ if (href && !/^https?:\/\//i.test(href)) { e.preventDefault(); url = new URL(this.href); + if (!/http/.test(url.protocol)) { + return; + } if (urb.util.basepath("", url.pathname) !== urb.util.basepath("", document.location.pathname)) { document.location = this.href; return; @@ -1972,12 +1998,14 @@ module.exports = _.extend(reactify, { },{"../stores/TreeStore.coffee":27,"./LoadComponent.coffee":12}],18:[function(require,module,exports){ -var appendNext, recl, rele, waitingScripts; +var TreeActions, appendNext, recl, rele, waitingScripts; recl = React.createClass; rele = React.createElement; +TreeActions = require('../actions/TreeActions.coffee'); + waitingScripts = null; appendNext = function() { @@ -1997,7 +2025,7 @@ module.exports = recl({ var s; s = document.createElement('script'); _.assign(s, this.props); - urb.waspElem(s); + TreeActions.registerScriptElement(s); s.onload = appendNext; this.js = s; if (waitingScripts != null) { @@ -2018,7 +2046,7 @@ module.exports = recl({ }); -},{}],19:[function(require,module,exports){ +},{"../actions/TreeActions.coffee":1}],19:[function(require,module,exports){ var a, div, input, query, reactify, recl, ref, slice = [].slice; @@ -2518,19 +2546,21 @@ module.exports = { return $.get(url, {}, function(data, status, xhr) { var dep; delete pending[url]; - dep = urb.getXHRWasp(xhr); - urb.sources[dep] = url; - waspWait.push(dep); - if (_.isEmpty(pending)) { - waspWait.map(urb.waspData); - waspWait = []; + if (urb.wasp != null) { + dep = urb.getXHRWasp(xhr); + urb.sources[dep] = url; + waspWait.push(dep); + if (_.isEmpty(pending)) { + waspWait.map(urb.waspData); + waspWait = []; + } } if (cb) { return cb(null, data); } }); }, - put: function(data, mark, appl) { + put: function(data, mark, appl, cb) { if (appl == null) { appl = /[a-z]*/.exec(mark)[0]; } @@ -2538,9 +2568,14 @@ module.exports = { return urb.send(data, { mark: mark, appl: appl - }); + }, cb); }); }, + waspElem: function(a) { + if (urb.wasp != null) { + return urb.waspElem(a); + } + }, encode: function(obj) { var _encode, delim; delim = function(n) { @@ -2896,6 +2931,9 @@ scroll = { }, scroll: function() { var ct, dy, top; + if (!((this.$n != null) && (this.$d != null))) { + return; + } this.cs = $(window).scrollTop(); if (this.w > 767) { this.clearNav();