From 3a42f0ce28742f8654605307e23a04aae21125d0 Mon Sep 17 00:00:00 2001 From: Andrew Otto Date: Thu, 12 Apr 2012 17:54:24 -0400 Subject: [PATCH] Adding permalink to graph-display view --- lib/graph/graph-model.co | 13 +++++++++++++ lib/template/graph-display.jade | 12 +++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) 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) + -- 1.7.0.4