Changeset - 77eaccba654e
[Not reviewed]
default
0 6 0
Drew Perttula - 8 years ago 2017-06-10 07:17:20
drewp@bigasterisk.com
try to fix timeline sending empty ctx to rdfdb
Ignore-this: f778183e90f073b9914d9b6736560d99
6 files changed with 33 insertions and 14 deletions:
0 comments (0 inline, 0 general)
light9/rdfdb/rdflibpatch.py
Show inline comments
 
@@ -70,6 +70,7 @@ def graphFromQuads(q):
 

	
 
def graphFromNQuad(text):
 
    g1 = ConjunctiveGraph()
 
    # text might omit ctx on some lines. rdflib just puts in a bnode, which shows up later.
 
    g1.parse(data=text, format='nquads')
 
    return g1
 

	
light9/web/effects/effects.coffee
Show inline comments
 
@@ -4,7 +4,7 @@ Polymer
 
    graph: {type: Object}
 
    effectClasses: { type: Array }
 
  ready: ->
 
    @graph.runHandler(@getClasses.bind(@))
 
    @graph.runHandler(@getClasses.bind(@), 'getClasses')
 

	
 
  getClasses: ->
 
    U = (x) => @graph.Uri(x)
light9/web/graph.coffee
Show inline comments
 
@@ -71,6 +71,9 @@ class AutoDependencies
 
  runHandler: (func, label) ->
 
    # what if we have this func already? duplicate is safe?
 

	
 
    if not label?
 
      throw new Error("missing label")
 

	
 
    h = new Handler(func, label)
 
    @handlerStack[@handlerStack.length - 1].innerHandlers.push(h)
 
    console.time("handler #{label}")
 
@@ -127,10 +130,10 @@ class window.SyncedGraph
 
    @clearGraph()
 

	
 
    if @patchSenderUrl
 
      @_client = new RdfDbClient(@patchSenderUrl, @clearGraph.bind(@),
 
      @_client = new RdfDbClient(@patchSenderUrl, @_clearGraphOnNewConnection.bind(@),
 
                                 @_applyPatch.bind(@), @setStatus)
 
    
 
  clearGraph: -> # for debugging
 
  clearGraph: ->
 
    # just deletes the statements; watchers are unaffected.
 
    if @graph?
 
      @_applyPatch({addQuads: [], delQuads: @graph.find()})
 
@@ -139,7 +142,11 @@ class window.SyncedGraph
 
    @graph = N3.Store()
 
    @_addPrefixes(@prefixes)
 
    @cachedFloatValues = new Map();
 
    
 

	
 
  _clearGraphOnNewConnection: -> # must not send a patch to the server!
 
    log('graph: clearGraphOnNewConnection')
 
    @clearGraph()
 
    log('graph: clearGraphOnNewConnection done')
 
      
 
  _addPrefixes: (prefixes) ->
 
    @graph.addPrefixes(prefixes)
 
@@ -175,6 +182,13 @@ class window.SyncedGraph
 
  applyAndSendPatch: (patch) ->
 
    if !Array.isArray(patch.addQuads) || !Array.isArray(patch.delQuads)
 
      throw new Error("corrupt patch: #{patch}")
 

	
 
    for qs in [patch.addQuads, patch.delQuads]
 
      for q in qs
 
        if not q.graph?
 
          throw new Error("corrupt patch: #{q}")
 

	
 
    log('graph: patch', patch)
 
    @_applyPatch(patch)
 
    @_client.sendPatch(patch) if @_client
 

	
light9/web/live/live.coffee
Show inline comments
 
@@ -157,7 +157,7 @@ Polymer
 
    @newEffectName = ''
 

	
 
  onGraph: ->
 
    @graph.runHandler(@update.bind(@))
 
    @graph.runHandler(@update.bind(@), 'controls')
 
  resendAll: ->
 
    for llc in @getElementsByTagName("light9-live-control")
 
      llc.resend()
light9/web/rdfdbclient.coffee
Show inline comments
 
@@ -52,7 +52,7 @@ parseJsonPatch = (jsonPatch, cb) ->
 

	
 
class window.RdfDbClient
 
  # Send and receive patches from rdfdb
 
  constructor: (@patchSenderUrl, @clearGraph, @applyPatch, @setStatus) ->
 
  constructor: (@patchSenderUrl, @clearGraphOnNewConnection, @applyPatch, @setStatus) ->
 
    @_patchesToSend = []
 
    @_lastPingMs = -1
 
    @_patchesReceived = 0
 
@@ -77,7 +77,7 @@ class window.RdfDbClient
 
      #{ping}ms")
 
 
 
  sendPatch: (patch) ->
 
    console.log('queue patch to server ', patchSizeSummary(patch))
 
    console.log('rdfdbclient: queue patch to server ', patchSizeSummary(patch))
 
    @_patchesToSend.push(patch)
 
    @_updateStatus()
 
    @_continueSending()           
 
@@ -89,17 +89,17 @@ class window.RdfDbClient
 
    @ws = new WebSocket(fullUrl)
 

	
 
    @ws.onopen = =>
 
      log('connected to', fullUrl)
 
      log('rdfdbclient: connected to', fullUrl)
 
      @_updateStatus()
 
      @clearGraph()
 
      @clearGraphOnNewConnection()
 
      @_pingLoop()
 

	
 
    @ws.onerror = (e) =>
 
      log('ws error ' + e)
 
      log('rdfdbclient: ws error ' + e)
 
      @ws.onclose()
 

	
 
    @ws.onclose = =>
 
      log('ws close')
 
      log('rdfdbclient: ws close')
 
      @_updateStatus()
 
      clearTimeout(@_reconnectionTimeout) if @_reconnectionTimeout?
 
      @_reconnectionTimeout = setTimeout(@_newConnection.bind(@), 1000)
 
@@ -134,7 +134,7 @@ class window.RdfDbClient
 

	
 
    sendOne = (patch, cb) =>
 
        toJsonPatch(patch, (json) =>
 
          log('send patch to server, ' + json.length + ' bytes')
 
          log('rdfdbclient: send patch to server, ' + json.length + ' bytes')
 
          @ws.send(json)
 
          @_patchesSent++
 
          @_updateStatus()
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -285,7 +285,7 @@ Polymer
 
    song: { type: String, notify: true }
 
    zoomInX: { type: Object, notify: true }
 
    rows: { value: [0...ROW_COUNT] }
 
    zoom: { type: Object, notify: true, observer: 'onZoom' }
 
    zoom: { type: Object, notify: true, observer: 'onZoom' } # viewState.zoomSpec
 
    zoomFlattened: { type: Object, notify: true }
 
  onZoom: ->
 
    updateZoomFlattened = ->
 
@@ -364,6 +364,7 @@ Polymer
 

	
 
    desiredWidthX = @offsetWidth * .3
 
    desiredWidthT = @zoomInX.invert(desiredWidthX) - @zoomInX.invert(0)
 
    desiredWidthT = Math.min(desiredWidthT, @zoom.duration() - dropTime)
 
    
 
    for i in [0...4]
 
      pt = points[i]
 
@@ -630,6 +631,9 @@ Polymer
 

	
 
  editAttr: (song, note, attr, value) ->
 
    U = (x) => @graph.Uri(x)
 
    if not song?
 
      log("can't edit inline attr yet, no song")
 
      return
 
    quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: song}
 

	
 
    existingColorScaleSetting = null
 
@@ -650,7 +654,7 @@ Polymer
 
      @graph.applyAndSendPatch(patch)
 
    
 
  addHandler: ->
 
    @graph.runHandler(@update.bind(@))
 
    @graph.runHandler(@update.bind(@), "update inline attrs #{@uri}")
 
    
 
  update: ->
 
    #console.time('attrs update')
0 comments (0 inline, 0 general)