From: Andrew Otto Date: Thu, 12 Apr 2012 21:54:24 +0000 (-0400) Subject: Adding permalink to graph-display view X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=8bf6212c57d63d0a12f486ee298a580a78b0068c;p=limn-bak.git Adding permalink to graph-display view --- diff --git a/lib/graph/graph-model.co b/lib/graph/graph-model.co index 11e106d..0a8dc31 100644 --- a/lib/graph/graph-model.co +++ b/lib/graph/graph-model.co @@ -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})" # }}} diff --git a/lib/template/graph-display.jade b/lib/template/graph-display.jade index 8fb078e..efecac2 100644 --- a/lib/template/graph-display.jade +++ b/lib/template/graph-display.jade @@ -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) +