Add external URL Post method
authorChip Black <bytex64@bytex64.net>
Thu, 26 Apr 2012 08:12:37 +0000 (01:12 -0700)
committerChip Black <bytex64@bytex64.net>
Thu, 26 Apr 2012 08:12:37 +0000 (01:12 -0700)
www/jssrc/blerg/Blerg.js
www/jssrc/blerg/ExternalURLPost.js [new file with mode: 0644]
www/jssrc/blerg/package.js

index 3228d67..af0f688 100644 (file)
@@ -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 (file)
index 0000000..6a36b87
--- /dev/null
@@ -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 + ')'
+        });
+    },
+});
index 9640acd..3192d42 100644 (file)
@@ -15,5 +15,6 @@ enyo.depends(
     'User.js',
     'Tag.js',
     'Feed.js',
+    'ExternalURLPost.js',
     'Blerg.js'
 );