       favicon_src: "/favicon.png"
       title: page.title
 
-  $pageElement.append( pageHeader )
+  $page.append( pageHeader )
   
   unless isRemotePage
-    $('img.favicon',$pageElement).error (e)->
+    $('img.favicon',$page).error (e)->
       plugin.get 'favicon', (favicon) ->
         favicon.create()
 
-  if (rev = $pageElement.attr('id').split('_rev')[1])?
+  if (rev = $page.attr('id').split('_rev')[1])?
     date = page.journal[page.journal.length-1].date
-    $pageElement.addClass('ghost').data('rev',rev).append $ """
+    $page.addClass('ghost').data('rev',rev).append $ """
       <h2 class="revision">
         <span>
           #{if date? then util.formatDate(date) else "Revision #{rev}"}
         </span>
       </h2>
     """
-renderPageIntoPageElement = (pageData,$pageElement, siteFound) ->
+renderPageIntoPageElement = (pageData,$page, siteFound) ->
   page = $.extend(util.emptyPage(), pageData)
-  $pageElement.data("data", page)
-  slug = $pageElement.attr('id')
-  site = $pageElement.data('site')
+  $page.data("data", page)
+  slug = $page.attr('id')
+  site = $page.data('site')
 
   context = ['view']
   context.push site if site?

      neighborhood.registerNeighbor action.site if action.site?

  whenGotten = (data,siteFound) ->
    wiki.buildPage( data, siteFound, $pageElement )
    registerNeighbors( data, siteFound )

  pageHandler.get

  action.id = item.id
  pageHandler.put thisPageElement, action

initDragging = ($page) ->
  $story = $page.find('.story')
  $story.sortable(connectWith: '.page .story').on("sortupdate", handleDragging)


initAddButton = ($page) ->
  $page.find(".add-factory").live "click", (evt) ->
    return if $page.hasClass 'ghost'
    evt.preventDefault()
    createFactory($page)

createFactory = ($page) ->
  item =
    type: "factory"
    id: util.randomBytes(8)
  itemElement = $("<div />", class: "item factory").data('item',item).attr('data-id', item.id)
  itemElement.data 'pageElement', $page
  $page.find(".story").append(itemElement)
  plugin.do itemElement, item
  beforeElement = itemElement.prev('.item')
  before = wiki.getItem(beforeElement)
  pageHandler.put $page, {item: item, id: item.id, type: "add", after: before?.id}

buildPageHeader = ({title,tooltip,header_href,favicon_src})->
  """<h1 title="#{tooltip}"><a href="#{header_href}"><img src="#{favicon_src}" height="32px" class="favicon"></a> #{title}</h1>"""

emitHeader = ($page, page) ->
  site = $page.data('site')
  isRemotePage = site? and site != 'local' and site != 'origin' and site != 'view'
  header = ''

