Adding permalink to graph-display view
authorAndrew Otto <acotto@gmail.com>
Thu, 12 Apr 2012 21:54:24 +0000 (17:54 -0400)
committerAndrew Otto <acotto@gmail.com>
Thu, 12 Apr 2012 21:54:24 +0000 (17:54 -0400)
lib/graph/graph-model.co
lib/template/graph-display.jade

index 11e106d..0a8dc31 100644 (file)
@@ -275,6 +275,19 @@ Graph = exports.Graph = BaseModel.extend do # {{{
         path = _.compact [ @urlRoot, slug, action ] .join '/'
         "#path?#{@toKV { keepSlug: !!slug }}"
     
+    /**
+     * @returns {String} Path portion of slug URL, e.g.  /graphs/:slug
+     */
+    toLink: ->
+        "#{@urlRoot}/#{@get('slug')}"
+    
+    /**
+     * @returns {String} Permalinked URI, e.g. http://reportcard.wmflabs.org/:slug
+     */
+    toPermalink: ->
+        "#{window.location.protocol}//#{window.location.host}#{@toLink()}"
+    
+
     toString: -> "#{@ctorName}(id=#{@id}, cid=#{@cid})"
 # }}}
 
index 8fb078e..efecac2 100644 (file)
@@ -10,9 +10,15 @@ section.graph.graph-display(id=view.id)
         .graph-legend
     
     .graph-details-row.row-fluid
-        .graph-desc
+        .graph-desc.span6
             != jade.filters.markdown(desc)
         
-        //- 
-            .graph-notes.span6
+        .span8
+            .graph-permalink 
+                a(href='#{model.toLink()}') Permalink: 
+                input.span6(value='#{model.toPermalink()}')
+
+            //- 
+            .graph-notes
                 != jade.filters.markdown(notes)
+