Skip to content

Commit

Permalink
ShareThis-based social sharing buttons, fixes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedlund committed Oct 1, 2013
1 parent ea57031 commit d9712a9
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/assets/stylesheets/events.scss
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,19 @@
.event-topics-types {
margin-top: -10px;
}

.event-share-buttons {
max-width: $main-width;
min-height: 25px;
margin-top: 10px;

.st-widget {
float: left;
}

// g+1 share widget has too much spacing on right-side of widget, workaround
.st_plusone_hcount {
margin-right: -10px;
}
}
}
2 changes: 2 additions & 0 deletions app/views/events/_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
.event-organization-label= t('.organization_label')
= link_to organization.name, organization_path(organization)

= render 'share_buttons'

- if event.venue
%h2.event-venue-title= t('.venue')
.event-venue{:class => (event.venue.location ? 'has-location' : '')}
Expand Down
16 changes: 16 additions & 0 deletions app/views/events/_share_buttons.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- if sharethis_key = @current_site.sharethis_key.presence
- content_for :javascript_insert do
= javascript_include_tag 'http://w.sharethis.com/button/buttons.js'
:javascript
stLight.options({
publisher: #{sharethis_key.to_json.html_safe},
doNotHash: true,
doNotCopy: true,
hashAddressBar: false
});

.event-share-buttons
.st-widget.st_plusone_hcount{:displayText => 'Google +1'}
.st-widget.st_twitter_hcount{:displayText => 'Tweet'}
.st-widget.st_facebook_hcount{:displayText => 'Facebook'}
.st-widget.st_reddit_hcount{:displayText => 'Reddit'}
5 changes: 5 additions & 0 deletions db/migrate/20131001031403_add_sharethis_key_to_sites.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSharethisKeyToSites < ActiveRecord::Migration
def change
add_column :sites, :sharethis_key, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130930234907) do
ActiveRecord::Schema.define(:version => 20131001031403) do

create_table "events", :force => true do |t|
t.string "title"
Expand Down Expand Up @@ -81,6 +81,7 @@
t.integer "map_zoom"
t.string "locale"
t.string "ga_account_id"
t.string "sharethis_key"
end

create_table "sources", :force => true do |t|
Expand Down

0 comments on commit d9712a9

Please sign in to comment.