bitnation customizations

bitnation customizations

--- @client/homepage.coffee
+++ @client/homepage.coffee
@@ -333,23 +333,24 @@
               color: 'white'
               opacity: if hovering || current then 1 else .8

-            if subdomain.name == 'dao'
+            if subdomain.name in ['dao', 'BITNATION']
               _.extend tab_style,
                 padding: '10px 30px 4px 30px'
                 color: if current then 'black' else if hovering then '#F8E71C' else 'white'
                 backgroundColor: if current then 'white'
                 borderRadius: '16px 16px 0 0'
-                borderLeft: if current then "2px solid #F8E71C"
-                borderTop: if current then "2px solid #F8E71C"
-                borderRight: if current then "2px solid #F8E71C"
+                border: '2px solid'
+                borderBottom: 'none'
+                borderColor: if current then '#F8E71C' else 'transparent'
+
             else if subdomain.name == 'HALA'
               _.extend tab_style,
                 padding: '10px 30px 0px 30px'
                 color: if current then 'black' else if hovering then '#000' else 'white'
                 backgroundColor: if current then 'white'
-                borderLeft: if current then "1px solid #000"
-                borderTop: if current then "1px solid #000"
-                borderRight: if current then "1px solid #000"
+                border: '1px solid'
+                borderBottom: 'none'
+                borderColor: if current then '#000' else 'transparent'

             else if subdomain.name == 'bradywalkinshaw'
               _.extend tab_style,


register-cert

register-cert

--- rquery/rquery.cson
+++ rquery/rquery.cson
@@ -21,6 +21,10 @@
       type: 'url'
    aboutUrl:
       type: 'url'
+   enrollExpire:
+      type: 'duration'
+      unit: 'seconds'
+      max: 999
    keyExpire:
       type: 'duration'
       unit: 'seconds'


Convert a number of functions into methods of Expectation.

--- src/TinyMockJS.coffee
+++ src/TinyMockJS.coffee
@@ -138,7 +138,7 @@
     @_returns = undefined
     @_throws = undefined
     @called = false
-    _install_mock_method(@, object, method_name)
+    @_install_mock_method()
     all_expectations.push(@)

   #
@@ -147,8 +147,8 @@
   #   ...
   #
   args: (args...) ->
-    _check_args_usage(@, args...)
-    _save_args(@, args)
+    @_check_args_usage(args...)
+    @_save_args(args)
     @

   #
@@ -157,8 +157,8 @@
   #   ...
   #
   returns: (value) ->
-    _check_returns_usage(@, value)
-    _save_returns(@, value)
+    @_check_returns_usage(value)
+    @_save_returns(value)
     @

   #
@@ -167,8 +167,8 @@
   #   ...
   #
   throws: (error) ->
-    _check_throws_usage(@, error)
-    _save_throws(@, error)
+    @_check_throws_usage(error)
+    @_save_throws(error)
     @

   #
@@ -188,58 +188,57 @@
       ( @_args.length == args.length ) and
       ( @_args.every ( element, i ) -> element == args[ i ] )

-
-# private
-
-_check_args_usage = (expectation, args...) ->
-  _throw_args_usage() if args.length == 0
-  _throw_args_used_more_than_once() unless expectation._args.length == 0
-
-_check_returns_usage = (expectation, value) ->
-  _throw_returns_usage() unless value?
-  _throw_returns_used_more_than_once() if expectation._returns?
-  _throw_returns_and_throws_both_used() if expectation._throws?
-
-_check_throws_usage = (expectation, error) ->
-  _throw_throws_usage(error) unless error?
-  _throw_throws_used_more_than_once() if expectation._throws?
-  _throw_returns_and_throws_both_used() if expectation._returns?
-
-_save_args = (expectation, args) ->
-  expectation._args = args
-
-_save_returns = (expectation, value) ->
-  expectation._returns = value
-
-_save_throws = (expectation, error) ->
-  expectation._throws = error
-
-_install_mock_method = (expectation, object, method_name) ->
-  object = object.prototype if is_class(object)
-  original_method = object[ method_name ]
-  object[ method_name ] = build_mocked_method(method_name)
-  if original_method?
-    expectation.uninstall_mocked_method = -> object[ method_name ] = original_method
-  else
-    expectation.uninstall_mocked_method = -> delete object[ method_name ]
-
-_throw_args_usage = ->
-  throw new Error( "you need to supply at least one argument to args(), e.g. my_mock.expects('my_method').args(42)" )
-
-_throw_args_used_more_than_once = ->
-  throw new Error( "you specified args() more than once, e.g. my_mock.expects('my_method').args(1).args(2); use it once per expectation" )
-
-_throw_returns_usage = ->
-  throw new Error( "you need to supply an argument to returns(), e.g. my_mock.expects('my_method').returns(123)" )
-
-_throw_returns_used_more_than_once = ->
-  throw new Error( "you specified returns() more than once, e.g. my_mock.expects('my_method').returns(1).returns(2); use it once per expectation" )
-
-_throw_throws_usage = ->
-  throw new Error( "you need to supply an argument to throws(), e.g. my_mock.expects('my_method').throws('an error')" )
-
-_throw_throws_used_more_than_once = ->
-  throw new Error( "you specified throws() more than once, e.g. my_mock.expects('my_method').throws('something').throws('something else'); use it once per expectation" )
-
-_throw_returns_and_throws_both_used = ->
-  throw new Error( "you specified both returns() and throws() on the same expectation; use one or the other on an expectation" )
+  # private
+
+  _check_args_usage: (args...) ->
+    @_throw_args_usage() if args.length == 0
+    @_throw_args_used_more_than_once() unless @_args.length == 0
+
+  _check_returns_usage: (value) ->
+    @_throw_returns_usage() unless value?
+    @_throw_returns_used_more_than_once() if @_returns?
+    @_throw_returns_and_throws_both_used() if @_throws?
+
+  _check_throws_usage: (error) ->
+    @_throw_throws_usage(error) unless error?
+    @_throw_throws_used_more_than_once() if @_throws?
+    @_throw_returns_and_throws_both_used() if @_returns?
+
+  _save_args: (args) ->
+    @_args = args
+
+  _save_returns: (value) ->
+    @_returns = value
+
+  _save_throws: (error) ->
+    @_throws = error
+
+  _install_mock_method: ->
+    object = if is_class(@_object) then @_object.prototype else @_object
+    original_method = object[ @method_name ]
+    object[ @method_name ] = build_mocked_method(@method_name)
+    if original_method?
+      @uninstall_mocked_method = -> object[ @method_name ] = original_method
+    else
+      @uninstall_mocked_method = -> delete object[ @method_name ]
+
+  _throw_args_usage: ->
+    throw new Error( "you need to supply at least one argument to args(), e.g. my_mock.expects('my_method').args(42)" )
+
+  _throw_args_used_more_than_once: ->
+    throw new Error( "you specified args() more than once, e.g. my_mock.expects('my_method').args(1).args(2); use it once per expectation" )
+
+  _throw_returns_usage: ->
+    throw new Error( "you need to supply an argument to returns(), e.g. my_mock.expects('my_method').returns(123)" )
+
+  _throw_returns_used_more_than_once: ->
+    throw new Error( "you specified returns() more than once, e.g. my_mock.expects('my_method').returns(1).returns(2); use it once per expectation" )
+
+  _throw_throws_usage: ->
+    throw new Error( "you need to supply an argument to throws(), e.g. my_mock.expects('my_method').throws('an error')" )
+
+  _throw_throws_used_more_than_once: ->
+    throw new Error( "you specified throws() more than once, e.g. my_mock.expects('my_method').throws('something').throws('something else'); use it once per expectation" )
+
+  _throw_returns_and_throws_both_used: ->
+    throw new Error( "you specified both returns() and throws() on the same expectation; use one or the other on an expectation" )


added next()

added next()

--- src/api/statsd.coffee
+++ src/api/statsd.coffee
@@ -79,8 +79,9 @@

   if (type == 'status') {
     for (i = 0; i < status_array.length; i++) {
-      path = render_url + ".statuses." + status_array[i] + ".count,'1week'))&from=-1weeks&format=json";
+      path = render_url + ".statuses." + status_array[i] + ".count,'1week'))&format=json";
       results[status_array[i]] = yield exports.fetchData(path);
+      results[status_array[i]].next()
       statuses[status_array[i]] =  'data' in results[status_array[i]] ? results[status_array[i]].data[0][0] : 0
     }


Fix selector

Fix selector

--- helper.coffee
+++ helper.coffee
@@ -5,7 +5,7 @@
   el.innerHTML = Typist.renderVariants el.textContent, INSTALL_OPTIONS.variants,
     className: 'eager-typist-element'

-  new Typist el.querySelector('eager-typist-element'),
+  new Typist el.querySelector('.eager-typist-element'),
     letterInterval: 60
     textInterval:   3000
     selectClassName: 'eager-typist-selected'


codepen: else if instead of else and then if

--- app/_src/components/codepen-embed.coffee
+++ app/_src/components/codepen-embed.coffee
@@ -49,8 +49,7 @@
 			# Note: CodePenEmbed will auto-execute
 			# after it's loaded (ei.js)
 			@injectCodePenJS()
-		else
-			if typeof CodePenEmbed is 'object'
+		else if typeof CodePenEmbed is 'object'
 				CodePenEmbed.init()

 	getTemplate: (params) ->


fix js

fix js

--- app/assets/javascripts/leather.js.coffee
+++ app/assets/javascripts/leather.js.coffee
@@ -22,12 +22,8 @@
       false

   $(document).on 'click touchstart', 'body', (e) ->
-    e.stopPropagation()
-    e.preventDefault()
     if e.handled != true
       unless ($(e.target).hasClass("off-canvas") || $(e.target).data('toggle') == "off-canvas")
         $(this).removeClass("off-canvas-show-right")
         $(this).removeClass("off-canvas-show-left")
-      e.handled = true
-    else
-      false+      e.handled = true


try qwery and bonzo

try qwery and bonzo

--- mechanics/001-binary-star/csmain.coffee
+++ mechanics/001-binary-star/csmain.coffee
@@ -6,12 +6,10 @@
   'bean',
   'cs!/wahlque/util/url'
 ], (_, domReady, qwery, bonzo, bean, url) ->
+  $ = (selector) <- bonzo(qwery(selector))
+
   domReady( ->
       ps = url.params()
-      ps['qwery'] = !!qwery
-      ps['bonzo'] = !!bonzo
-      ps['bean'] = !!bean
-
       ctx =
           keys: _.keys(ps) or []
           vals: ps
@@ -19,5 +17,5 @@
         "
<% _.each(keys, function(key) { %>
<%= key %>: <%= vals[key] %>
 <% }); %>
",
         ctx
       )
-      document.getElementById("params").innerHTML = list
+      $("#params").html(list)
   )


Remove custom scroll to top behavior from paginator in favor of generalized react router solution

--- app/talk/lib/paginator.cjsx
+++ app/talk/lib/paginator.cjsx
@@ -10,7 +10,6 @@
     page: React.PropTypes.number                  # page number
     onPageChange: React.PropTypes.func.isRequired # passed (page) on change
     firstAndLast: React.PropTypes.bool            # optional, add 'first' & 'last' buttons
-    scrollOnChange: React.PropTypes.bool          # optional, scroll to top of page on change
     pageSelector: React.PropTypes.bool            # show page selector?
     pageKey: React.PropTypes.string               # optional name for key param (defaults to 'page')

@@ -23,7 +22,6 @@
       updateQueryParams @history, queryChange
     firstAndLast: true
     pageSelector: true
-    scrollOnChange: true
     previousLabel:  Previous
     nextLabel: Next

@@ -40,7 +38,6 @@

   setPage: (activePage) ->
     @props.onPageChange.call(this, activePage)
-    window.scrollTo(0,0) if @props.scrollOnChange

   onClickNext: ->
     @logClick 'next-page'


Added rootNode and resize method

Added rootNode and resize method

--- src/Scene.coffee
+++ src/Scene.coffee
@@ -8,8 +8,11 @@
     @style[DivSugar._transformOrigin] = '0% 0%'
     @style[DivSugar._perspectiveOrigin] = '50% 50%'

+    @rootNode = DivSugar.createNode 'rootNode'
+    @appendChild @rootNode
+
     @setPerspective 1000
-    @setSize 100, 100
+    @setSize 400, 300
     @setPosition 0, 0
     @setVisible true
     @setClip true
@@ -34,18 +37,9 @@
     @_height = height
     @_viewWidth = viewWidth
     @_viewHeight = viewHeight
-
-    x = (width - viewWidth) / 2
-    y = (height - viewHeight) / 2
-    sx = width / viewWidth
-    sy = height / viewHeight
-    nod = DivSugar.NUM_OF_DIGITS
-
-    @style.width = "#{viewWidth.toFixed(nod)}px"
-    @style.height = "#{viewHeight.toFixed(nod)}px"
-    @style[DivSugar._transform] = "translate(#{x.toFixed(nod)}px, #{y.toFixed(nod)}px) scale(#{sx.toFixed(nod)}, #{sy.toFixed(nod)})"
-
-    @setImageClip @_imageClipU1, @_imageClipV1, @_imageClipU2, @_imageClipV2
+    @style.width = "#{width.toFixed(DivSugar.NUM_OF_DIGITS)}px"
+    @style.height = "#{height.toFixed(DivSugar.NUM_OF_DIGITS)}px"
+    @rootNode.setTransform(DivSugar.Matrix.UNIT).scale(width / viewWidth, height / viewHeight)
     return @

   getPositionX: -> @_positionX
@@ -117,3 +111,25 @@
     @style.backgroundSize = "#{w.toFixed(nod)}% #{h.toFixed(nod)}%"

     return @
+
+  resize: (width, height, mode) ->
+    if @parentNode?
+      switch mode
+        when 'center'
+          break
+
+        when 'contain'
+          if width < height * @_viewWidth / @_viewHeight
+            @setSize width, width * @_viewHeight / @_viewWidth, @_viewWidth, @_viewHeight
+          else
+            @setSize height * @_viewWidth / @_viewHeight, height, @_viewWidth, @_viewHeight
+
+        when 'cover'
+          if width > height * @_viewWidth / @_viewHeight
+            @setSize width, width * @_viewHeight / @_viewWidth, @_viewWidth, @_viewHeight
+          else
+            @setSize height * @_viewWidth / @_viewHeight, height, @_viewWidth, @_viewHeight
+
+      @setPosition (width - @_width) / 2, (height - @_height) / 2
+
+    return @


Remove browser autocomplete when composing message

--- client/app/components/mails_input.coffee
+++ client/app/components/mails_input.coffee
@@ -10,7 +10,6 @@

 # Public: input to enter multiple mails
 # @TODO : use something tag-it like
-# @TODO : autocomplete contacts

 module.exports = MailsInput = React.createClass
     displayName: 'MailsInput'
@@ -70,6 +69,7 @@
                     valueLink: @proxyValueLink(),
                     type: 'text',
                     placeholder: @props.placeholder
+                    'autoComplete': 'off'
                 div
                     className: 'input-group-addon btn btn-cozy contact',
                     onClick: @onQuery,


Neatened volume level meter calculation.

--- client/components/vumeter/vumeter.coffee
+++ client/components/vumeter/vumeter.coffee
@@ -1,8 +1,6 @@
+clamp = (value, min, max) -> Math.min Math.max(min, value), max
+
 Template.vumeter.meter = (vumeter) ->
-  green = if vumeter % 50 < vumeter then 50 else vumeter
-  yellow = if vumeter % 85 < vumeter then 35 else vumeter - 50
-  red = if vumeter % 100 < vumeter then 15 else vumeter - 85
-
-  'green': green
-  'yellow': yellow
-  'red': red
+  'green': clamp vumeter, 0, 50
+  'yellow': clamp vumeter - 50, 0, 35
+  'red': clamp vumeter - 85, 0, 15


Removing event listeners on close

Removing event listeners on close


Show preview button in description editor


Fixed a bug with empty-string values used by url template params

--- app/lib/sdk/resource.coffee
+++ app/lib/sdk/resource.coffee
@@ -86,8 +86,8 @@
           alt = $1.replace /\-([a-z])/g, ($0, c) -> c.toUpperCase()
           if value[$1]? then value[$1]
           else if value[alt]? then value[alt]
-          else if meta["#{type}_template"]?[$1] then meta["#{type}_template"][$1]
-          else if meta["#{type}_template"]?[alt] then meta["#{type}_template"][alt]
+          else if meta["#{type}_template"]?[$1]? then meta["#{type}_template"][$1]
+          else if meta["#{type}_template"]?[alt]? then meta["#{type}_template"][alt]
           else $0

   express = (T, members, stat) ->


Fixed tweening floors. (#4969)

Fixed tweening floors. (#4969)

--- app/lib/surface/Lank.coffee
+++ app/lib/surface/Lank.coffee
@@ -352,7 +352,7 @@

     newScaleFactorX = @thang?.scaleFactorX ? @thang?.scaleFactor ? 1
     newScaleFactorY = @thang?.scaleFactorY ? @thang?.scaleFactor ? 1
-    if @layer?.name is 'Land' or @thang?.spriteName is 'Beam'
+    if @layer?.name is 'Land' or @thang?.isLand or @thang?.spriteName is 'Beam'
       @scaleFactorX = newScaleFactorX
       @scaleFactorY = newScaleFactorY
     else if @thang and (newScaleFactorX isnt @targetScaleFactorX or newScaleFactorY isnt @targetScaleFactorY)


add more components for extended search

add more components for extended search

--- app/scripts/extended.coffee
+++ app/scripts/extended.coffee
@@ -46,6 +46,11 @@
                 c.log "struct_values error"
             )

+    singleValue:
+        template: '<input type="hidden">'
+        controller: ($scope) ->
+            $scope.model = _.values($scope.dataset)[0]
+
     defaultTemplate: _.template """
                 <input ng-model='input' class='arg_value' escaper ng-model-options='{debounce : {default : 300, blur : 0}, updateOn: "default blur"}'
                 <%= maybe_placeholder %>>


Uncomment header in nl-NL.coffee

Uncomment header in nl-NL.coffee

--- app/locale/nl-NL.coffee
+++ app/locale/nl-NL.coffee
@@ -700,7 +700,7 @@
     more_info_2: "lerarenforum"
     more_info_3: "Het is een goede plek om contact te leggen met andere leerkrachten, die CodeCombat gebruiken."

-#  teachers_quote:
+  teachers_quote:
 #    name: "Quote Form"
 #    title: "Request a Quote"
 #    subtitle: "Get CodeCombat in your classroom, club, school or district!"


fix some stuff for minification

fix some stuff for minification

--- assets/js/directives.coffee
+++ assets/js/directives.coffee
@@ -10,8 +10,9 @@
 			"height" : "@"
 		},
 		"replace" : true,
-		"controller" : ($scope, $http) ->
+		"controller" : ["$scope", "$http", ($scope, $http) ->

+		]
 		"link": (scope, iElem, iAttr) ->
 			lightColor = iAttr['colorLight'] || '#dddddd'
 			darkColor = iAttr['colorDark'] || '#222222'


Store lightcurve wrapper selector in a variable.

--- assets/js/lightcurve.coffee
+++ assets/js/lightcurve.coffee
@@ -1,15 +1,16 @@
 $ = jQuery
 $ ->
+    selector = '.lightcurve'
     margin =
         top: 20
         right: 20
         bottom: 20
         left: 40
-    width = $('.lightcurve').width()
+    width = $(selector).width()
     height = 0.3 * width
     width = width - margin.left - margin.right
     height = height - margin.top - margin.bottom
-    svg = d3.select('.lightcurve').append('svg')
+    svg = d3.select(selector).append('svg')
         .attr
             width: width + margin.left + margin.right
             height: height + margin.top + margin.bottom
@@ -18,7 +19,7 @@
             transform: "translate(#{margin.left},#{margin.top})"
     xScale = d3.scale.linear().range([0, width]).nice()
     yScale = d3.scale.linear().range([0, height]).nice()
-    csvUrl = $('.lightcurve').data 'csvSource'
+    csvUrl = $(selector).data 'csvSource'
     d3.csv(
         csvUrl,
         ((d) ->


Work with component definition instead

Work with component definition instead

--- components/UpdateComponentLibrary.coffee
+++ components/UpdateComponentLibrary.coffee
@@ -7,7 +7,7 @@
   output.send
     runtime:
       action: 'storage:save:runtime'
-      payload: runtime.runtime
+      payload: runtime.runtime.definition
   # Deactivate all running contexts
   while runtime.contexts.length
     ctx = runtime.contexts.shift()
@@ -46,7 +46,7 @@
         output.send
           out:
             clearLibrary: true
-        c.runtimes[def.runtime].runtime.components = {}
+        c.runtimes[def.runtime].runtime.definition.components = {}
         c.runtimes[def.runtime].updated = true

       # Send updated component definition out
@@ -62,7 +62,7 @@
         return

       # Add this component to the listing
-      c.runtimes[def.runtime].runtime.components[def.name] = def
+      c.runtimes[def.runtime].runtime.definition.components[def.name] = def

       # Add this activation context so it can be deactivated
       c.runtimes[def.runtime].contexts.push context
@@ -89,13 +89,13 @@
         updated: false
         contexts: []

-      unless typeof payload.components is 'object'
+      unless typeof payload.definition.components is 'object'
         # No cached component information available
         output.done()
         return

       # Send previously cached components to have a starting point
-      for name, def of payload.components
+      for name, def of payload.definition.components
         output.send
           out:
             componentDefinition: def


TextMate bundles end in .tmbundle or _tmbundle

--- src/app/config.coffee
+++ src/app/config.coffee
@@ -114,6 +114,6 @@
       console.error "Failed to load `#{userInitScriptPath}`", error.stack, error

   isTextMateBundle: (packageName) ->
-    /\.tmbundle$/.test(packageName)
+    /(\.|_)tmbundle$/.test(packageName)

 _.extend Config.prototype, EventEmitter


Don't set widthChanged handler on gutter

The gutter now uses flex box so the width is no longer explicitly
set based on the number of lines.

--- src/app/editor.coffee
+++ src/app/editor.coffee
@@ -404,10 +404,6 @@
     @verticalScrollbar.on 'scroll', =>
       @scrollTop(@verticalScrollbar.scrollTop(), adjustVerticalScrollbar: false)

-    unless @mini
-      @gutter.widthChanged = (newWidth) =>
-        @scrollView.css('left', newWidth + 'px')
-
     @scrollView.on 'scroll', =>
       if @scrollView.scrollLeft() == 0
         @gutter.removeClass('drop-shadow')


APLArray.each(f) passes indices to f as a 2nd arg

--- src/array.coffee
+++ src/array.coffee
@@ -31,7 +31,7 @@
     p = @offset
     indices = for axis in @shape then 0
     loop
-      f @data[p]
+      f @data[p], indices
       axis = @shape.length - 1
       while axis >= 0 and indices[axis] + 1 is @shape[axis]
         p -= indices[axis] * @stride[axis]
@@ -52,7 +52,7 @@
     q = a.offset
     indices = for axis in @shape then 0
     loop
-      f @data[p], a.data[q]
+      f @data[p], a.data[q], indices
       axis = @shape.length - 1
       while axis >= 0 and indices[axis] + 1 is @shape[axis]
         p -= indices[axis] * @stride[axis]
@@ -67,14 +67,14 @@
   map: (f) ->
     assert typeof f is 'function'
     data = []
-    @each (x) -> data.push f x
+    @each (x, indices) -> data.push f x, indices
     new APLArray data, @shape

   map2: (a, f) ->
     assert a instanceof APLArray
     assert typeof f is 'function'
     data = []
-    @each2 a, (x, y) -> data.push f x, y
+    @each2 a, (x, y, indices) -> data.push f x, y, indices
     new APLArray data, @shape

   toArray: (limit = Infinity) ->


Made middleware compatible with connect, rather than express

--- src/beans.coffee
+++ src/beans.coffee
@@ -205,6 +205,16 @@
   else
     console.log "Don't know how to \"#{args[0]}\"."

+# Make custom sender to stream.
+makeSender = (end) ->
+  end = true unless end?
+  if end
+    (res, s) ->
+      res.writeHead 200, 'Content-Type': 'text/javascript'
+      res.end s
+  else
+    (res, s) -> res.write s
+
 # Route middleware to serve user source.
 userSource = (options) ->
   # General rebuild mechanism.
@@ -225,24 +235,29 @@
       fn fixedSource

   # The actual custom middleware function.
+  send = makeSender options?.end
   (req, res) ->
     getSource (source) ->
-      res.send source
+      send res, source

 # Route middleware to serve include source.
 includeSource = (options) ->
   info = loadinfo()
+  send = makeSender options?.end
   include() if options?.refresh
   (req, res) ->
     includes = []
     for includedFile of info.browser.include
       includes.push fs.readFileSync(includedFile, 'utf8')
-    res.send includes.join('\n')
+    send res, includes.join('\n')

 # Route middleware to serve everything.
 middleware = (options) ->
+  end = options?.end
+  options.end = false
+  includeMiddleware = includeSource options
+  options.end = end
   userMiddleware = userSource options
-  includeMiddleware = includeSource options
   (req, res, next) ->
     includeMiddleware req, res, next
     userMiddleware req, res, next


patch fix for new uploading issue

patch fix for new uploading issue

--- generators/app/templates/gulpfile.coffee
+++ generators/app/templates/gulpfile.coffee
@@ -399,6 +399,7 @@
                         # Pass cookie jar into callback
                         cb(jar)
                     else
+                        gutil.log('Request fail 1')
                         handleRequestError(err, httpResponse)
             else
                 gutil.log('Incorrect username/password'.red)
@@ -412,6 +413,7 @@
         if !err and httpResponse.statusCode is 200
             gutil.log('Successfully logged out'.green)
         else
+            gutil.log('Request fail 2')
             handleRequestError(err, httpResponse)

 checkIfImageExists = (link, updateImageStores, tryLogout, cb) ->
@@ -543,8 +545,9 @@
                 multiform['wpUploadFile'] = fs.createReadStream(file)
                 multiform['wpDestFile'] = "#{teamName}_#{year}_#{page}"

-            cb(url, file, page, type, multiform, jar, tryLogout, updateImageStores)
+            cb(url, file, page, type, multiform, jar, tryLogout, updateImageStores, link)
         else
+            gutil.log('Request fail 3')
             handleRequestError(err, httpResponse)

 colourify = (file, url, multiform, type) ->
@@ -563,12 +566,14 @@
         return "Uploaded #{file} → #{url}"

 # **postEdit**
-postEdit = (url, file, page, type, multiform, jar, tryLogout, updateImageStores) ->
+postEdit = (url, file, page, type, multiform, jar, tryLogout, updateImageStores, link) ->

     if type isnt 'image'
         postUrl = url + '?action=submit'
     else
         postUrl = url
+
+    # gutil.log(multiform)

     request {
         url      : postUrl
@@ -615,8 +620,23 @@
                         gutil.log(colourify(file, url, multiform, type))
                         tryLogout()
                 else
+                    gutil.log('Request fail 4')
                     handleRequestError(err, httpResponse)
+        else if httpResponse.statusCode is 200
+            gutil.log('Upload failed for '.yellow + file + ', trying again.'.yellow)
+            # if type is 'page'
+            #     upload(link, 'page', jar, tryLogout)
+            # else if type is 'template'
+            #     upload(link, 'template', jar, tryLogout)
+            # else if type is 'stylesheet'
+            #     upload(link, 'stylesheet', jar, tryLogout)
+            # else if type is 'script'
+            #     upload(link, 'script', jar, tryLogout)
+            # else if type is 'image'
+            #     upload(link, 'image', jar, tryLogout, updateImageStores)
+            upload(link, type, jar, tryLogout, updateImageStores)
         else
+            gutil.log('Request fail 5')
             handleRequestError(err, httpResponse)

 upload = (link, type, jar, tryLogout, updateImageStores) ->
@@ -712,6 +732,7 @@

             cb(pages)
         else
+            gutil.log('Request fail 6')
             handleRequestError(err, httpResponse)

@@ -749,6 +770,7 @@

             tryLogout()
         else
+            gutil.log('Request fail 7')
             handleRequestError(err, httpResponse)

 gulp.task 'pull', ->