diff --git a/lib/drop.coffee b/lib/drop.coffee index 1975030b..0988144f 100644 --- a/lib/drop.coffee +++ b/lib/drop.coffee @@ -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]}"} @@ -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 diff --git a/lib/legacy.coffee b/lib/legacy.coffee index 64562b61..82fc388c 100644 --- a/lib/legacy.coffee +++ b/lib/legacy.coffee @@ -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>/g, '[$1 $2]' + pageObject.addParagraph markup + link.showResult pageObject + getTemplate = (slug, done) -> return done(null) unless slug console.log 'getTemplate', slug @@ -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 ->