From f5eba55960cba26d820f88144776f7177db92c0b Mon Sep 17 00:00:00 2001 From: Chip Black Date: Thu, 26 Apr 2012 01:12:37 -0700 Subject: [PATCH] Add external URL Post method --- www/jssrc/blerg/Blerg.js | 8 +------- www/jssrc/blerg/ExternalURLPost.js | 30 ++++++++++++++++++++++++++++++ www/jssrc/blerg/package.js | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 www/jssrc/blerg/ExternalURLPost.js diff --git a/www/jssrc/blerg/Blerg.js b/www/jssrc/blerg/Blerg.js index 3228d67..af0f688 100644 --- a/www/jssrc/blerg/Blerg.js +++ b/www/jssrc/blerg/Blerg.js @@ -2,6 +2,7 @@ enyo.kind({ name: "blerg.Blerg", kind: "Control", lastHash: null, + pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.ExternalURLPost, blerg.Welcome ], handlers: { onStartSignup: "showSignupDialog", onTryLogin: "tryLogin", @@ -25,13 +26,6 @@ enyo.kind({ onLoginFailed: "loginFailed", onLogoutSuccessful: "logout"} ], - urlmap: [ - ['search', /^\?post\/([^/]+)\/(.+)/, "blerg.ExternalURLPost"], - ['hash', /^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/, "blerg.Tag"], - ['hash', /^#\/feed(?:\/p(\d+))?$/, "blerg.Feed"], - ['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, "blerg.User"] - ], - pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.Welcome ], rendered: function() { this.inherited(arguments); diff --git a/www/jssrc/blerg/ExternalURLPost.js b/www/jssrc/blerg/ExternalURLPost.js new file mode 100644 index 0000000..6a36b87 --- /dev/null +++ b/www/jssrc/blerg/ExternalURLPost.js @@ -0,0 +1,30 @@ +enyo.kind({ + name: "blerg.ExternalURLPost", + published: { + title: "", + url: "" + }, + statics: { + locationDetect: function(l) { + var m = l.search.match(/^\?post\/([^/]+)\/(.+)/); + if (m) { + return { + kind: "blerg.ExternalURLPost", + title: decodeURIComponent(m[1]).replace(']','').replace('[',''), + url: decodeURIComponent(m[2]) + }; + } else { + return false; + } + } + }, + create: function() { + this.inherited(arguments); + + this.bubble("onSetTitle", {section: "Blerg It!"}); + this.bubble("onPostVisibility", { + showing: true, + data: '[' + this.title + '](' + this.url + ')' + }); + }, +}); diff --git a/www/jssrc/blerg/package.js b/www/jssrc/blerg/package.js index 9640acd..3192d42 100644 --- a/www/jssrc/blerg/package.js +++ b/www/jssrc/blerg/package.js @@ -15,5 +15,6 @@ enyo.depends( 'User.js', 'Tag.js', 'Feed.js', + 'ExternalURLPost.js', 'Blerg.js' ); -- 2.34.1