Skip to content

Commit

Permalink
transport logic (hardwired)
Browse files Browse the repository at this point in the history
  • Loading branch information
WardCunningham committed Mar 16, 2016
1 parent 4eab5bd commit 83df435
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/future.coffee
Expand Up @@ -5,13 +5,48 @@
resolve = require './resolve'
neighborhood = require './neighborhood'

lineup = require './lineup'
refresh = require './refresh'
transport = 'http://localhost:4020/proxy'

emit = ($item, item) ->
$item.append """#{item.text}<br><br><button class="create">create</button> new blank page"""
if true
$item.append """<br><button class="transport" data-slug=#{item.slug}>create</button> transport from #{transport}"""
$item.append "<p class=caption> unavailable</p>"
$.get 'http://localhost:4020', ->
$item.find('.caption').text 'ready'
if (info = neighborhood.sites[location.host])? and info.sitemap?
for item in info.sitemap
if item.slug.match /-template$/
$item.append """<br><button class="create" data-slug=#{item.slug}>create</button> from #{resolve.resolveLinks "[[#{item.title}]]"}"""

bind = ($item, item) ->
$item.find('button.transport').click (e) ->
$item.find('.caption').text 'waiting'

# duplicatingTransport and Templage logic

params =
title: $item.parents('.page').data('data').title

req =
type: "POST",
url: transport
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(params)

$.ajax(req).done (page) ->
$item.find('.caption').text 'ready'
console.log 'page', page
resultPage = wiki.newPage(page)
# wiki.showResult resultPage
$page = $item.parents('.page')
pageObject = lineup.atKey $page.data('key')
pageObject.become(resultPage)
page = pageObject.getRawPage()
refresh.rebuildPage pageObject, $page.empty()


module.exports = {emit, bind}

0 comments on commit 83df435

Please sign in to comment.