Skip to content

Commit

Permalink
handle simplest blog to wiki transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
WardCunningham committed Jun 18, 2015
1 parent bf97820 commit 7ce99ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/drop.coffee
Expand Up @@ -22,6 +22,12 @@ isPage = (url) ->
return item
null

isLiveblog = (url) ->
if found = url.match /^((https?:\/\/liveblog\.co\/users\/[a-z]+)\/\d+\/\d+\/\d+\/([a-zA-Z]+)).html$/
[ignore, resource, user, key] = found
return {resource, user, key}
null

isVideo = (url) ->
if found = url.match /^https?:\/\/www.youtube.com\/watch\?v=([\w\-]+).*$/
return {text: "YOUTUBE #{found[1]}"}
Expand Down Expand Up @@ -50,6 +56,9 @@ dispatch = (handlers) ->
if page = isPage url
if (handle = handlers.page)?
return stop handle page
if blog = isLiveblog url
if (handle = handlers.blog)?
return stop handle blog
if video = isVideo url
if (handle = handlers.video)?
return stop handle video
Expand Down
14 changes: 14 additions & 0 deletions lib/legacy.coffee
Expand Up @@ -71,6 +71,19 @@ $ ->
link.showResult resultPage
reader.readAsText(file)

readBlog = ({resource, user, key}) ->
$.getJSON "#{resource}.json", (outline) ->
pageObject = newPage
title: outline.text
journal: [
type: "create"
date: new Date(outline.created).getTime()
item: {title: outline.text, story: []} ]
for node in outline.subs || []
markup = node.text.replace /<a href="(.+?)">(.+?)<\/a>/g, '[$1 $2]'
pageObject.addParagraph markup
link.showResult pageObject

getTemplate = (slug, done) ->
return done(null) unless slug
console.log 'getTemplate', slug
Expand Down Expand Up @@ -166,6 +179,7 @@ $ ->
.bind 'dragover', (evt) -> evt.preventDefault()
.bind "drop", drop.dispatch
page: (item) -> link.doInternalLink item.slug, null, item.site
blog: (blog) -> readBlog blog
file: (file) -> readFile file

$(".provider input").click ->
Expand Down

0 comments on commit 7ce99ea

Please sign in to comment.