diff options
| -rw-r--r-- | app.js | 2 | ||||
| -rw-r--r-- | css/style.css | 2 | ||||
| -rw-r--r-- | index.html | 1 | ||||
| -rw-r--r-- | lib.js | 60 | ||||
| -rw-r--r-- | lib/misc.js | 42 | ||||
| -rw-r--r-- | render.js | 20 | ||||
| -rw-r--r-- | welcome.js | 4 | 
7 files changed, 65 insertions, 66 deletions
| @@ -15,7 +15,7 @@ function keyPage (keys) {    message.appendChild(h('button', {      onclick: function () {       localforage.removeItem('id', function () { - +       location.hash = ''         location.reload()       })      } diff --git a/css/style.css b/css/style.css index 1850551..a59af50 100644 --- a/css/style.css +++ b/css/style.css @@ -41,7 +41,7 @@ hr {  }  #scroller { -  max-width: 780px; +  max-width: 50em;    margin-right: auto;    margin-left: auto;  } @@ -10,6 +10,7 @@    <script src="./lib/nacl-util.min.js"></script>    <script src="./lib/localforage.min.js"></script>    <script src="./lib/marked.min.js"></script> +  <script src="./lib/misc.js"></script>    <script src="lib.js"></script>    <script src="welcome.js"></script>    <script src="render.js"></script> @@ -1,6 +1,4 @@ - - -function requestFeed (src, server, requester) { +/*function requestFeed (src, server, requester) {    console.log(src)    console.log(server) @@ -57,7 +55,7 @@ function requestFeed (src, server, requester) {        }       }    }) -} +}*/  // publish new messages to your log  function publish (toPublish, keys) { @@ -210,45 +208,23 @@ function getName (id) {    return name  } -// human-time by Dave Eddy https://github.com/bahamas10/human - -function human(seconds) { -  if (seconds instanceof Date) -    seconds = Math.round((Date.now() - seconds) / 1000); -  var suffix = seconds < 0 ? 'from now' : 'ago'; -  seconds = Math.abs(seconds); - -  var times = [ -    seconds / 60 / 60 / 24 / 365, // years -    seconds / 60 / 60 / 24 / 30,  // months -    seconds / 60 / 60 / 24 / 7,   // weeks -    seconds / 60 / 60 / 24,       // days -    seconds / 60 / 60,            // hours -    seconds / 60,                 // minutes -    seconds                       // seconds -  ]; -  var names = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second']; - -  for (var i = 0; i < names.length; i++) { -    var time = Math.floor(times[i]); -    var name = names[i]; -    if (time > 1) -      name += 's'; - -    if (time >= 1) -      return time + ' ' + name + ' ' + suffix; +function getHeader (post, mini) { +  var inner +  if (mini) { +    var inner = mini    } -  return '0 seconds ' + suffix; -} -// hscrpt by Dominic Tarr https://github.com/dominictarr/hscrpt/blob/master/LICENSE -function h (tag, attrs, content) { -  if(Array.isArray(attrs)) content = attrs, attrs = {} -  var el = document.createElement(tag) -  for(var k in attrs) el[k] = attrs[k] -  if(content) content.forEach(function (e) { -    if(e) el.appendChild('string' == typeof e ? document.createTextNode(e) : e) -  }) -  return el +  var head = h('span', [ +    h('a', {href: '#' + post.key}, [ +      h('p', {classList: 'right'}, [human(new Date(post.content.timestamp))]), +    ]), +    h('p', [ +      h('a', {href: '#' + post.content.author}, [ +        getName(post.content.author) +      ]), +      inner +    ]) +  ]) +  return head  } diff --git a/lib/misc.js b/lib/misc.js new file mode 100644 index 0000000..afc3a33 --- /dev/null +++ b/lib/misc.js @@ -0,0 +1,42 @@ +// human-time by Dave Eddy https://github.com/bahamas10/human + +function human(seconds) { +  if (seconds instanceof Date) +    seconds = Math.round((Date.now() - seconds) / 1000); +  var suffix = seconds < 0 ? 'from now' : 'ago'; +  seconds = Math.abs(seconds); + +  var times = [ +    seconds / 60 / 60 / 24 / 365, // years +    seconds / 60 / 60 / 24 / 30,  // months +    seconds / 60 / 60 / 24 / 7,   // weeks +    seconds / 60 / 60 / 24,       // days +    seconds / 60 / 60,            // hours +    seconds / 60,                 // minutes +    seconds                       // seconds +  ]; +  var names = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second']; + +  for (var i = 0; i < names.length; i++) { +    var time = Math.floor(times[i]); +    var name = names[i]; +    if (time > 1) +      name += 's'; + +    if (time >= 1) +      return time + ' ' + name + ' ' + suffix; +  } +  return '0 seconds ' + suffix; +} + +// hscrpt by Dominic Tarr https://github.com/dominictarr/hscrpt/blob/master/LICENSE +function h (tag, attrs, content) { +  if(Array.isArray(attrs)) content = attrs, attrs = {} +  var el = document.createElement(tag) +  for(var k in attrs) el[k] = attrs[k] +  if(content) content.forEach(function (e) { +    if(e) el.appendChild('string' == typeof e ? document.createTextNode(e) : e) +  }) +  return el +} + @@ -116,23 +116,3 @@ function renderMessage (post) {    return messageDiv  } -function getHeader (post, mini) { -  var inner  -  if (mini) { -    var inner = mini -  } - -  var head = h('span', [ -    h('a', {href: '#' + post.key}, [ -      h('p', {classList: 'right'}, [human(new Date(post.content.timestamp))]), -    ]), -    h('p', [ -      h('a', {href: '#' + post.content.author}, [ -        getName(post.content.author) -      ]), -      inner -    ]) -  ]) -  return head -} - @@ -9,7 +9,7 @@ function welcomeScreen (keys) {    scroller.appendChild(message)    message.appendChild(h('h1', ['Welcome to Bogbook'])) -  message.appendChild(h('p', ['Bogbook is a distributed blogging network of signed append-only feeds. To avoid confusion, we call them "bogs".'])) +  message.appendChild(h('p', ['Bogbook is a distributed blogging network of signed append-only feeds. We call them "bogs".']))    message.appendChild(h('p', ['Please note: Bogbook is experimental software, not for use in producton environments. Expect bugs and breaking changes. Pull-requests are needed.']))    message.appendChild(h('p', {innerHTML: marked('View the code: [http://github.com/bogbook/bog](http://github.com/bogbook/bog). Questions? [ev@evbogue.com](mailto:ev@evbogue.com).')}))    message.appendChild(h('hr')) @@ -17,7 +17,7 @@ function welcomeScreen (keys) {    message.appendChild(h('p', {innerHTML: marked('This is an ed25519 public/private signing keypair. It was generated using [TweetNaCl.js](https://tweetnacl.js.org/#/)')}))    message.appendChild(h('pre', [JSON.stringify(keys)]))    message.appendChild(h('p', ['Right now, this keypair exists only in memory. When you leave this page, the keypair will vanish forever. If you refresh this page you\'ll receive a new keypair.'])) -  message.appendChild(h('p', {innerHTML: marked('To save this keypair, identify with handle below. Once you identify, your public/private keypair will be stored in your browser using [localForage.js](https://localforage.github.io/localForage). Save your keypair somewhere safe to preserve your identity.')})) +  message.appendChild(h('p', {innerHTML: marked('To save this keypair, identify with a handle below. Once you identify, your public/private keypair will be stored in your browser using [localForage.js](https://localforage.github.io/localForage). Save your keypair somewhere safe to preserve your identity.')}))    message.appendChild(h('hr'))    message.appendChild(h('h3', ['Identify'])) | 
