diff --git a/src/base/jstemplates/place-detail-promotion-bar.html b/src/base/jstemplates/place-detail-promotion-bar.html index cc5d3fc70b..ba25552d26 100644 --- a/src/base/jstemplates/place-detail-promotion-bar.html +++ b/src/base/jstemplates/place-detail-promotion-bar.html @@ -2,8 +2,8 @@
diff --git a/src/base/static/js/models/attachment-collection.js b/src/base/static/js/models/attachment-collection.js index f787e91d0b..268ea24aac 100644 --- a/src/base/static/js/models/attachment-collection.js +++ b/src/base/static/js/models/attachment-collection.js @@ -12,5 +12,9 @@ module.exports = Backbone.Collection.extend({ thingUrl = thingModel.url(); return thingUrl + '/attachments'; + }, + + parse: function(response) { + return response.results; } }); diff --git a/src/base/static/js/utils.js b/src/base/static/js/utils.js index 420ca67ccd..bf5047872e 100644 --- a/src/base/static/js/utils.js +++ b/src/base/static/js/utils.js @@ -54,6 +54,78 @@ var self = module.exports = { return isAdmin; }, + getPathname: function(model) { + if (model.get("url-title")) { + return model.get("url-title"); + } else if (model.get("datasetSlug")) { + return model.get("datasetSlug") + "/" + model.get("id"); + } else { + return model.get("id"); + } + }, + + buildSharingQuerystring: function(components) { + return [ + "?url=", encodeURIComponent(components.redirectUrl), + "&title=", encodeURIComponent(components.title), + "&img=", encodeURIComponent(components.img), + "&desc=", encodeURIComponent(components.desc), + "&height=", encodeURIComponent(components.height), + "&width=", encodeURIComponent(components.width) + ].join(""); + }, + + initiateShare: function(service, shareUrl, queryString) { + if (service === "twitter") { + shareUrl = ["https://twitter.com/intent/tweet?url=", + encodeURIComponent(shareUrl + queryString)].join(""); + window.open(shareUrl, "Twitter", "height=300, width=600"); + } else if (service === "facebook") { + FB.ui({ + method: 'share', + href: shareUrl + queryString + }, function(response){}); + } + }, + + onSocialShare: function(model, service) { + var self = this, + appConfig = Shareabouts.Config.app, + shareUrl = "http://social.mapseed.org", + components = { + title: model.get("title") || + model.get("name") || + appConfig.title, + desc: model.get("description") || + appConfig.meta_description, + img: (model.attachmentCollection.models.length > 0) ? + model.attachmentCollection.models[0].get("file") : + [window.location.protocol, "//", window.location.host, appConfig.thumbnail].join(""), + redirectUrl: [window.location.protocol, "//", window.location.host, "/", this.getPathname(model)].join("") + }, + $img = $("img[src='" + components.img + "']"); + + components["height"] = $img.height() || 630; + components["width"] = $img.width() || 1200; + + if (components.img.startsWith("data:")) { + + // If the image was just created and has a data url, fetch the attachment + // collection to obtain the S3 url before contacting the sharing microservice. + model.attachmentCollection.fetch({ + reset: true, + success: function(collection) { + components.img = collection.first().get("file"); + var queryString = self.buildSharingQuerystring(components); + self.initiateShare(service, shareUrl, queryString); + } + }); + } else { + var queryString = this.buildSharingQuerystring(components); + this.initiateShare(service, shareUrl, queryString); + } + }, + // Given the information provided in a url (that is, an id and possibly a slug), // attempt to find the corresponding model within all collections on the page. // Three conditions are possible: diff --git a/src/base/static/js/views/place-detail-view.js b/src/base/static/js/views/place-detail-view.js index 0a40f63ddb..86bee82ca8 100644 --- a/src/base/static/js/views/place-detail-view.js +++ b/src/base/static/js/views/place-detail-view.js @@ -18,7 +18,9 @@ 'click input[data-input-type="binary_toggle"]': 'onBinaryToggle', 'change .publish-control-container input': 'onPublishedStateChange', 'change input, textarea': 'saveDraftChanges', - 'keyup input[name="url-title"]': 'onUpdateUrlTitle' + 'keyup input[name="url-title"]': 'onUpdateUrlTitle', + 'click .share-twitter': 'onShareTwitter', + 'click .share-facebook': 'onShareFacebook' }, initialize: function() { var self = this; @@ -134,6 +136,14 @@ Util.localstorage.destroy(this.LOCALSTORAGE_KEY); }, + onShareTwitter: function() { + Util.onSocialShare(this.model, "twitter"); + }, + + onShareFacebook: function() { + Util.onSocialShare(this.model, "facebook"); + }, + onClickStoryPrevious: function() { this.options.router.navigate(this.model.attributes.story.previous, {trigger: true}); }, diff --git a/src/base/static/js/views/place-list-view.js b/src/base/static/js/views/place-list-view.js index 0ca0b6f134..e21479c838 100644 --- a/src/base/static/js/views/place-list-view.js +++ b/src/base/static/js/views/place-list-view.js @@ -45,6 +45,12 @@ return data; }, + + events: { + 'click .share-twitter': 'onShareTwitter', + 'click .share-facebook': 'onShareFacebook' + }, + initialize: function() { var supportType = Shareabouts.Config.support.submission_type; @@ -60,6 +66,12 @@ userToken: Shareabouts.Config.userToken }); }, + onShareTwitter: function() { + Util.onSocialShare(this.model, "twitter"); + }, + onShareFacebook: function() { + Util.onSocialShare(this.model, "facebook"); + }, onBeforeRender: function() { // if an attachmentCollection has models in it, make sure the place // model's attachment attribute is set for the attachments to be diff --git a/src/base/static/scss/_content.scss b/src/base/static/scss/_content.scss index 0015c5e886..6bfd106daa 100644 --- a/src/base/static/scss/_content.scss +++ b/src/base/static/scss/_content.scss @@ -165,21 +165,19 @@ a.minimize-btn { float: right; padding: 0 !important; margin-left: 10px; - - a { - display: block; - width: 32px; - height: 32px; - overflow: hidden; - text-indent: -9999px; - } + display: block; + width: 32px; + height: 32px; + overflow: hidden; + text-indent: -9999px; + cursor: pointer; } -.share-twitter a { +.share-twitter { background: url(images/twitter-32.png) 0 0 no-repeat scroll; } -.share-facebook a { +.share-facebook { background: url(images/facebook-32.png) 0 0 no-repeat scroll; } diff --git a/src/base/templates/base.html b/src/base/templates/base.html index 44f433dc64..e41e12b551 100644 --- a/src/base/templates/base.html +++ b/src/base/templates/base.html @@ -296,6 +296,7 @@

S.bootstrapped.currentUser ? 'user:' + S.bootstrapped.currentUser.id : {{ user_token_json|safe }}), + app: {{ config.app|as_json }}, flavor: {{ config.data|as_json }}, place: {{ config.place|as_json }}, placeTypes: {{ config.place_types|as_json }}, diff --git a/src/flavors/bogtobay/templates/index.html b/src/flavors/bogtobay/templates/index.html index 17c7642a54..72e1f3fc8e 100644 --- a/src/flavors/bogtobay/templates/index.html +++ b/src/flavors/bogtobay/templates/index.html @@ -7,43 +7,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/central-puget-sound/config.yml b/src/flavors/central-puget-sound/config.yml index 02cfb849e7..54bc65fe33 100644 --- a/src/flavors/central-puget-sound/config.yml +++ b/src/flavors/central-puget-sound/config.yml @@ -9,6 +9,8 @@ app: # Meta author that will show up in Google search results meta_author: SmarterCleanup.org + facebook_app_id: 1865303377128313 + # When the map loads, existing places will be loaded in chunks. By default, # the size of the chunks will be a reasonable default dictated by the API # server. If you would like to override the chunk size, use this setting: diff --git a/src/flavors/central-puget-sound/templates/index.html b/src/flavors/central-puget-sound/templates/index.html index 39573e4a27..a05ae4f9d8 100644 --- a/src/flavors/central-puget-sound/templates/index.html +++ b/src/flavors/central-puget-sound/templates/index.html @@ -5,43 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - - - {% endif%} -{% endblock %} - @@ -70,4 +33,24 @@ }) }(Shareabouts)); + + + {% endblock %} diff --git a/src/flavors/defaultflavor/templates/index.html b/src/flavors/defaultflavor/templates/index.html index a0214a78c7..2e3199c96e 100644 --- a/src/flavors/defaultflavor/templates/index.html +++ b/src/flavors/defaultflavor/templates/index.html @@ -5,39 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/duwamish-watershed/templates/index.html b/src/flavors/duwamish-watershed/templates/index.html index 89d89d8d95..40e490afec 100644 --- a/src/flavors/duwamish-watershed/templates/index.html +++ b/src/flavors/duwamish-watershed/templates/index.html @@ -7,43 +7,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/duwamish_flavor/config.yml b/src/flavors/duwamish_flavor/config.yml index 274b032ba5..4e1e7e8b0e 100644 --- a/src/flavors/duwamish_flavor/config.yml +++ b/src/flavors/duwamish_flavor/config.yml @@ -9,6 +9,11 @@ app: # Meta author that will show up in Google search results meta_author: SmarterCleanup.org + # Fallback image to use for sharing on social services if no model image is present + thumbnail: /static/css/images/fb-thumbnail.png + + facebook_app_id: 433349350355712 + # When the map loads, existing places will be loaded in chunks. By default, # the size of the chunks will be a reasonable default dictated by the API # server. If you would like to override the chunk size, use this setting: diff --git a/src/flavors/duwamish_flavor/templates/index.html b/src/flavors/duwamish_flavor/templates/index.html index ae2b6a1bb0..fc10b1196e 100644 --- a/src/flavors/duwamish_flavor/templates/index.html +++ b/src/flavors/duwamish_flavor/templates/index.html @@ -7,43 +7,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - - - {% endif%} -{% endblock %} - @@ -72,4 +35,24 @@ }) }(Shareabouts)); -{% endblock %} + + + +{% endblock %} \ No newline at end of file diff --git a/src/flavors/greensboropb/config.yml b/src/flavors/greensboropb/config.yml index 89abcba9f4..3f9c083965 100755 --- a/src/flavors/greensboropb/config.yml +++ b/src/flavors/greensboropb/config.yml @@ -9,6 +9,8 @@ app: district: tagline: _(How would YOU spend $100K?) + facebook_app_id: 1865303377128313 + # languages: # - code: en diff --git a/src/flavors/greensboropb/templates/index.html b/src/flavors/greensboropb/templates/index.html index c6372a397d..5d857da567 100755 --- a/src/flavors/greensboropb/templates/index.html +++ b/src/flavors/greensboropb/templates/index.html @@ -9,41 +9,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} - - -{% endblock %} - {% block app_icons %} @@ -156,4 +121,24 @@ // }(Shareabouts, jQuery)); + + + {% endblock %} \ No newline at end of file diff --git a/src/flavors/greenways/templates/index.html b/src/flavors/greenways/templates/index.html index 399b1af347..21412c5d36 100644 --- a/src/flavors/greenways/templates/index.html +++ b/src/flavors/greenways/templates/index.html @@ -8,39 +8,6 @@

Seattle Neighborhood Greenways

{% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/gtopenspace/templates/index.html b/src/flavors/gtopenspace/templates/index.html index 2cbd647ade..7612648360 100644 --- a/src/flavors/gtopenspace/templates/index.html +++ b/src/flavors/gtopenspace/templates/index.html @@ -7,43 +7,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/lakewashington/config.yml b/src/flavors/lakewashington/config.yml index ce95c1ab59..612457ae0a 100644 --- a/src/flavors/lakewashington/config.yml +++ b/src/flavors/lakewashington/config.yml @@ -9,6 +9,8 @@ app: # Meta author that will show up in Google search results meta_author: smartercleanup.org + facebook_app_id: 1476977695699521 + # When the map loads, existing places will be loaded in chunks. By default, # the size of the chunks will be a reasonable default dictated by the API diff --git a/src/flavors/lakewashington/templates/index.html b/src/flavors/lakewashington/templates/index.html index a0214a78c7..2788677ce9 100644 --- a/src/flavors/lakewashington/templates/index.html +++ b/src/flavors/lakewashington/templates/index.html @@ -5,39 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - @@ -55,4 +22,26 @@ Analytics, custom JS, and such go here --> {% block includes %} + + + + {% endblock %} + diff --git a/src/flavors/pboakland/config.yml b/src/flavors/pboakland/config.yml index d0746ba536..490526900e 100644 --- a/src/flavors/pboakland/config.yml +++ b/src/flavors/pboakland/config.yml @@ -9,6 +9,8 @@ app: # Meta author that will show up in Google search results meta_author: HaxGeo.com + facebook_app_id: 211870442664924 + # When the map loads, existing places will be loaded in chunks. By default, # the size of the chunks will be a reasonable default dictated by the API # server. If you would like to override the chunk size, use this setting: diff --git a/src/flavors/pboakland/templates/index.html b/src/flavors/pboakland/templates/index.html index 68cc29d320..533109cd2c 100644 --- a/src/flavors/pboakland/templates/index.html +++ b/src/flavors/pboakland/templates/index.html @@ -7,39 +7,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - @@ -57,4 +24,25 @@ Analytics, custom JS, and such go here --> {% block includes %} + + + + {% endblock %} diff --git a/src/flavors/pugetsound/templates/index.html b/src/flavors/pugetsound/templates/index.html index a0214a78c7..2e3199c96e 100644 --- a/src/flavors/pugetsound/templates/index.html +++ b/src/flavors/pugetsound/templates/index.html @@ -5,39 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/rail/templates/index.html b/src/flavors/rail/templates/index.html index a0214a78c7..2e3199c96e 100644 --- a/src/flavors/rail/templates/index.html +++ b/src/flavors/rail/templates/index.html @@ -5,39 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/raingardens/config.yml b/src/flavors/raingardens/config.yml index a4ffb6bfe4..eec4854101 100644 --- a/src/flavors/raingardens/config.yml +++ b/src/flavors/raingardens/config.yml @@ -11,6 +11,8 @@ app: # Meta author that will show up in Google search results meta_author: SmarterCleanup.org + facebook_app_id: 1877110258972873 + # When the map loads, existing places will be loaded in chunks. By default, # the size of the chunks will be a reasonable default dictated by the API diff --git a/src/flavors/raingardens/templates/index.html b/src/flavors/raingardens/templates/index.html index 1fdc0f3805..9ccaaf3029 100644 --- a/src/flavors/raingardens/templates/index.html +++ b/src/flavors/raingardens/templates/index.html @@ -5,42 +5,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - {% endif%} -{% endblock %} - - @@ -69,4 +33,24 @@ }) }(Shareabouts)); + + + {% endblock %} diff --git a/src/flavors/snoqualmie/templates/index.html b/src/flavors/snoqualmie/templates/index.html index 24d812e2fd..1a45b4bfc1 100644 --- a/src/flavors/snoqualmie/templates/index.html +++ b/src/flavors/snoqualmie/templates/index.html @@ -5,43 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/trees/templates/index.html b/src/flavors/trees/templates/index.html index a03b619a50..ef2697e0be 100644 --- a/src/flavors/trees/templates/index.html +++ b/src/flavors/trees/templates/index.html @@ -5,42 +5,6 @@ {{ config.app.title }} {% endblock %} -{% block meta %} - {% if place %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - - {% endif%} -{% endblock %} - - diff --git a/src/flavors/waterfront/templates/index.html b/src/flavors/waterfront/templates/index.html index a0214a78c7..2e3199c96e 100644 --- a/src/flavors/waterfront/templates/index.html +++ b/src/flavors/waterfront/templates/index.html @@ -5,39 +5,6 @@ {{ config.app.name }} {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - diff --git a/src/flavors/willamette/config.yml b/src/flavors/willamette/config.yml index abe6c08789..269790c54e 100644 --- a/src/flavors/willamette/config.yml +++ b/src/flavors/willamette/config.yml @@ -9,6 +9,8 @@ app: # Meta author that will show up in Google search results meta_author: smartercleanup.org + facebook_app_id: 1925392277683737 + # When the map loads, existing places will be loaded in chunks. By default, # the size of the chunks will be a reasonable default dictated by the API diff --git a/src/flavors/willamette/templates/index.html b/src/flavors/willamette/templates/index.html index 2e8128400d..b0d1f652be 100644 --- a/src/flavors/willamette/templates/index.html +++ b/src/flavors/willamette/templates/index.html @@ -7,39 +7,6 @@ {% endblock %} -{% block meta %} - {% if place %} - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% comment %} TODO: Fill this in when we know if the username is from twitter - - {% endcomment %} - - - - - - {% with attachment=place.properties.attachments|first %} - - {% endwith %} - {% else %} - - - - - - - - - - {% endif%} -{% endblock %} - @@ -57,4 +24,25 @@ Analytics, custom JS, and such go here --> {% block includes %} + + + + {% endblock %}