Skip to content

Commit

Permalink
twitter popup called on click b/c of browser pop up issues, added lan…
Browse files Browse the repository at this point in the history
…g to filename
  • Loading branch information
alexandersimoes committed Mar 31, 2014
1 parent b12034d commit 6cc867e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
5 changes: 4 additions & 1 deletion oec/explore/views.py
Expand Up @@ -241,11 +241,14 @@ def download():
data = request.form.get("content", request.json.get("content", None))
format = request.form.get("format", request.json.get("format", None))
title = request.form.get("title", request.json.get("title", None))
title = "{0}_{1}".format(g.locale, title)
save = request.form.get("save", request.json.get("save", False))

temp = tempfile.NamedTemporaryFile()
if save:
file_path = os.path.abspath(os.path.join(oec_dir, 'static/generated', "{0}.png".format(title)))
if os.path.isfile(file_path):
return jsonify({"file_name":"{0}.png".format(title), "new":False})
new_file = open(file_path, 'w')
temp.write(data.encode("utf-8"))
temp.seek(0)
Expand Down Expand Up @@ -273,7 +276,7 @@ def download():
response_data = data.encode("utf-8")

if save:
return jsonify({"file_name":os.path.basename(new_file.name)})
return jsonify({"file_name":os.path.basename(new_file.name), "new":True})

content_disposition = "attachment;filename=%s.%s" % (title, format)
content_disposition = content_disposition.replace(",", "_")
Expand Down
8 changes: 3 additions & 5 deletions oec/html/explore/embed.html
Expand Up @@ -125,7 +125,7 @@ <h3>{{ _('Share') }}</h3>
<a href="http://www.facebook.com/dialog/feed?caption=The Observatory of Economic Complexity&display=popup&app_id={{facebook_id}}&name={{ current_build.get_name() }}({{ current_build.get_year() }})&link=http://atlas.media.mit.edu/explore/{{ current_build.url() }}&redirect_uri=http://atlas.media.mit.edu/close/&picture=http://atlas.media.mit.edu/static/img/touchicon.png" class="share_button" target="_blank" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" id="Facebook" title="Facebook">
<i class="fa fa-facebook"></i>
</a>
<a href="https://twitter.com/share?url=http://atlas.media.mit.edu/explore/{{ current_build.url() }}&text={{ current_build.get_name()|striptags|safe }} ({{ current_build.get_year() }})&hashtags=oec" class="share_button" target="_blank" id="Twitter" title="Tweet">
<a href="https://twitter.com/share?url=http://atlas.media.mit.edu/explore/{{ current_build.url() }}&text={{ current_build.get_name()|striptags|safe }} ({{ current_build.get_year() }})&hashtags=oec" class="share_button" target="_blank" onclick="return !window.open(this.href, 'Twitter', 'width=640,height=300')" id="Twitter" title="Tweet">
<i class="fa fa-twitter"></i>
</a>
<a href="https://plus.google.com/share?url=http://atlas.media.mit.edu/explore/{{ current_build.url() }}&hl={{ g.locale }}" class="share_button" target="_blank" onclick="return !window.open(this.href, 'Google+', 'width=640,height=300')" id="Google" title="Google+">
Expand Down Expand Up @@ -966,9 +966,7 @@ <h3>{{ _('Short URL') }}</h3>
d3.json("/explore/download/")
.header("Content-Type", "application/json")
.post(JSON.stringify({"title":title, "format":format, "save":save, "content": svg_xml}), function(error, data) {

callback()

if(callback) { callback() }
});

}
Expand Down Expand Up @@ -1022,7 +1020,7 @@ <h3>{{ _('Short URL') }}</h3>
var my_callback = function(){
return !window.open(share_url, 'Twitter', 'width=640,height=300')
}
d3.selectAll("#download a.png").on("click")("png", true, my_callback)
d3.selectAll("#download a.png").on("click")("png", true)
d3.event.preventDefault();
})

Expand Down
13 changes: 1 addition & 12 deletions oec/html/explore/index.html
Expand Up @@ -11,21 +11,10 @@
{% endif %}

<meta name="twitter:card" content="photo">
<meta name="twitter:site" content="">
<meta name="twitter:creator" content="">
<meta name="twitter:title" content="{{ current_build.get_name()|striptags|safe }}">
<meta name="twitter:image:src" content="http://atlas.media.mit.edu/static/generated/{{ request.path.split('/')[1:-1]|join('_') }}.png">
<meta name="twitter:image:src" content="http://atlas.media.mit.edu/static/generated/{{ g.locale }}_{{ request.path.split('/')[1:-1]|join('_') }}.png">
<meta name="twitter:domain" content="atlas.media.mit.edu">
<meta name="twitter:url" content="http://atlas.media.mit.edu{{ request.path }}">
<meta name="twitter:app:name:iphone" content="">
<meta name="twitter:app:name:ipad" content="">
<meta name="twitter:app:name:googleplay" content="">
<meta name="twitter:app:url:iphone" content="">
<meta name="twitter:app:url:ipad" content="">
<meta name="twitter:app:url:googleplay" content="">
<meta name="twitter:app:id:iphone" content="">
<meta name="twitter:app:id:ipad" content="">
<meta name="twitter:app:id:googleplay" content="">

{% endblock %}

Expand Down

0 comments on commit 6cc867e

Please sign in to comment.