Skip to content

Instantly share code, notes, and snippets.

@makevoid
Created August 1, 2015 18:03
Show Gist options
  • Select an option

  • Save makevoid/dcb030cab63a53e0f04b to your computer and use it in GitHub Desktop.

Select an option

Save makevoid/dcb030cab63a53e0f04b to your computer and use it in GitHub Desktop.
Transport plugin modified - fedwiki
expand = (text)->
text
.replace /&/g, '&'
.replace /</g, '&lt;'
.replace />/g, '&gt;'
.replace /\*(.+?)\*/g, '<i>$1</i>'
beam = (url) ->
$.getJSON url, (page) ->
resultPage = wiki.newPage(page)
wiki.showResult resultPage
emit = ($item, item) ->
$item.append """
<p style="background-color:#eee;padding:15px;">
#{expand item.text}<br>
</p>
"""
bind = ($item, item) ->
$item.dblclick -> wiki.textEditor $item, item
$item.find('button').click ->
beam item.text
$item.on 'drop', (e) ->
e.preventDefault()
e.stopPropagation()
htmlDtoppedElem = e.originalEvent.dataTransfer.getData('text/html')
link = $(htmlDtoppedElem).attr "href"
$.getJSON item.text, { drop: link }, (page) ->
resultPage = wiki.newPage(page)
wiki.showResult resultPage
window.plugins.transport = {emit, bind} if window?
module.exports = {expand} if module?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment