Git Product home page Git Product logo

shareit's Introduction

Share it

I've built social sharing buttons a few times and decided it was time to extract it to a package! The goal of this package is to do a few things:

  • Render appropriate meta tags for Facebook/OG and Twitter (via spiderable)
  • Support social sharing buttons with bootstrap-3 (default) and font-awesome
  • Expand to support other social platforms besides just twitter & facebook, in a configurable way

See also our project home (WIP).

Quick Start

meteor add joshowens:shareit

Usage

Simply put {{>shareit}} in your template. We use the following keys in your current data context (more on this below):

  • title
  • author - expects a string or a function (see below). The function is used only for twitter. If an object is returned, and author.profile.twitter exists, this value will be used instead.
  • excerpt or description or summary in FB and Twitter

and optionally:

  • url - defaults to current page URL
  • sitenap - defaults to current page hostname
  • thumbnail - image in FB and Twitter. Expects a function (see below).

Notes:

  1. Facebook:

  2. The og:type is article.

  3. Images should at least 1200x630; if above 600x315 you'll get a big photo share, and below, a small photo, see this.

  4. Sharing Best Practices for Websites & Mobile Apps

  5. Twitter

  6. The twitter:card type is summary.

  7. Image, min of 120x120 & < 1MB, see this. For "large image summaries" (in our roadmap, below), at least 280x150 & < 1 MB, see this.

  8. Google+ tags are not added yet, but when you share on Google+, it's smart enough to get everything it needs from the other tags.

  9. Social media image dimensions 2014: the complete guide for Facebook, Twitter and Google +

Regarding the Data Context

{{> shareit}} will work anywhere in a template where {{title}}, {{excerpt}}, etc would work. The source of the data context would be the data() function for a route in iron:router, or from a surrounding {{#with}} tag. (You can use {{#each}} too, but only the last rendered block will be used to set the page meta tags:

<template name="article">
  <h1>{{title}}</h1>
  {{> shareit}}
</template>

Just like any Meteor template/component, you can override the data context for a single component by specifying a single non-key argument. e.g. {{> shareit shareData}} will get title from {{shareData.title}}, etc. shareData can itself be a key in the current data context, or a helper function of the current template, e.g.:

<template name="article">
  {{shareit shareData}}
</template>
Template.article.helpers({
  shareData: function() {
    return { title: ..., etc } || MyCol.findOne() || etc
  }
});

Functions

For keys that take functions (author, image), the value of this function will be used. We use these functions to do lookups. If the function is setup anonymously inside a helper, this is the current data context. e.g.

Template.article.helpers({
  shareData: function() {
    return {
      title: this.data,
      author: Meteor.users.findOne(this.authorId)
  }
});

Configuration

Somewhere in your client (not server) code you can configure ShareIt. This is completely optional and the defaults are listed below:

  ShareIt.configure({
    sites: {                // nested object for extra configurations
        'facebook': {
            'appId': null	// use sharer.php when it's null, otherwise use share dialog
        },
        'twitter': {},
        'googleplus': {},
        'pinterest': {}
    },
    classes: "large btn", // string (default: 'large btn')
                          // The classes that will be placed on the sharing buttons, bootstrap by default.
    iconOnly: false,      // boolean (default: false)
                          // Don't put text on the sharing buttons
    applyColors: true,     // boolean (default: true)
                          // apply classes to inherit each social networks background color
    faSize: '',            // font awesome size
    faClass: ''		  // font awesome classes like square
  });

If you have valid facebook app id, we recommend you configure it to use Facebook Share Dialog. If no app id is provided, it would use deprecated sharer.php. Example facebook configuration:

    ShareIt.configure({
        sites: {
            'facebook': {
                'appId': YOUR_APP_ID
            }
        }
    });

Roadmap

  • Support text OR functions for thumbnail
  • Rename thumbnail to image with backwards compatilility (FB suggestion of 1200x630 is not a thumbnail :))
  • Twitter: use summary for thumbnail, and summary_large_image for image
  • Google+ tags (snippets)

shareit's People

Contributors

brucehubbard avatar gadicc avatar hellogerard avatar piyushcoader avatar queso avatar rgoomar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shareit's Issues

Disable a social network

Hi,

In the description there is no way to disable one or several socials, for example just use Facebook & Twitter ?

Is there a way to achieve that ?

Thank's

Doesn't share on mobile?

ShareIt seems to work fine on a desktop browser and a tablet, but not HTC phone. Anybody else experience this?

Add rel="nofollow"

Can you please add rel="nofollow" to the share tags ?

It's much better for the SEO.

More Sharing Options

Currently there is just Twitter and Facebook.
I would like to see Google+ and maybe even reddit.

Any others you guys would like to see?

Can't get faSize to Work

Hello:

I'm trying to use Font Awesome for my share icons. I've got everything looking right, applying the correct classes, except the faSize: "3x" key: value pair doesn't seem to work. I've also tried faSize: "fa-3x" to no avail. Any ideas?

Also for Twitter summary cards, only the title override works for me as a shareData helper. I can't get either description or summary to populate in Twitter.

Great package!

N

The social buttons not are not working right

I have used only {{> shareit}} on a static page. No configuration.

When I click the facebook share button, it opens a new tab with a hash after the url. (nothing gets shared)
When I click the google share button, two twitter tweet popups appear. (nothing gets shared on google)

Twitter share seems to work right.

Getting a couple errors

If I'm using your blog package and use the shareit outside the blog I'm getting the following errors

Exception from Tracker afterFlush function: string is not a function
TypeError: string is not a function
at Template.shareit.rendered (http://localhost:3000/packages/joshowens_shareit.js?e9d2ef9de98d0405521de354bb5338fe6ae6cfbb:159:24)

But if I add the shareit package (meteor add fantasyhub:shareit) I then get the following errors
Uncaught Error: There are multiple templates named 'shareit'. Each template needs a unique name.

Add ARIA labels for the blind

I have been informed by blind users of my app that the buttons of this package are not read by screen readers (e.g. ChromeVox).
Please fix this simply by adding aria-label="Share to Facebook" (and Twitter, etc.) on each of the a elements.

Thank you.

Responsive Buttons

I think there should be something added where the buttons would minimize to just be the social icon on mobile devices and full buttons on desktops / widescreen tablets.

Currently, it just stays as a button and having this implementation would make it look a lot nicer on mobile devices and fit better on the screen.

fb not reading all info

This is my url
http://www.meteorsnippets.com/blog/upload-files-to-cloud-services

I'm using meteor blog with existig shareit package in my url I've image and all the desc.

I can see meta tags in the code
fbog

but when I share them in fb, images are not showing in the sharing page.

I tried to debug using fb debug tool , I fetched new scraping info,it is throwing some errors like

fbscrap

This is what fb is reading from that url
fbreading

I deployed my site in meteor servers, Is that the issue?

Sharer.php despite appId

I configure a valid appId for the Facebook button but still getting the sharer.php funcionality, and the lovetostrike fork isn't working at all on the FB button.

PLEASE correct this, this is a useful package with lots of downloads.
Thanks in advance

Getting errors when I pass shareData object

I have defined shareData object in my template helper as specified:

shareData: function() {
return {
title: this.myobj.title,
author: this.myobj.author,
summary: this.myobj.message,
image: this.myobj.imageUrl,
thumbnail: this.myobj.imageUrl,
}
}

but when I am passing this to the shareit template it is giving me the following errors {{>shareit shareData}}

Exception from Tracker afterFlush function: string is not a function
TypeError: string is not a function

Image attached.
screen shot 2014-12-24 at 10 30 27 pm

Share button does not capture shareData attributes in the share activity

Information passed form shareData object does not seem to reach the redirected page on share platform. Twitter share captures the title attribute, while google and facebook share pages dont show up anything (on mobile google-plus app capture the url to be shared, web version does not).

Here is my shareData object:

shareData: function() {
var resp = { title: "Really appreciate genuine work happening at "+this.details.name,
excerpt:this.details.mission,
description:this.details.description,
summary:this.details.about,
author:"via SociallyHumble.com"
};
return resp;
},

Here is my shareit config:

ShareIt.configure({
sites: { // nested object for extra configurations
'facebook': {
'appId': "960820120603379" // use sharer.php when it's null, otherwise use share dialog
},
'twitter': {},
'googleplus': {},
'pinterest': {}
},
classes: "btn-sm share-btn", // string (default: 'large btn')
// The classes that will be placed on the sharing buttons, bootstrap by default.
iconOnly: true, // boolean (default: false)
// Don't put text on the sharing buttons
applyColors: true, // boolean (default: true)
// apply classes to inherit each social networks background color
faSize: '', // font awesome size
faClass: '' // font awesome classes like square
});

Feature request - DB Key mapping

Good morning,

I'm interested in using this package for social sharing on my web app, though my hesitation is that this requires specific mongodb keys to pull the correct data when sharing. Would it be possible to have a configuration for mongodb key mapping so that I can keep my current db key names and still use this package? Example is below. Let me know when you can. Thanks! -Chris

e.g.:
ShareIt.configure({
dbMap: {
title: projectTitle,
author: creator,
description: projectDescription
}
});

fb error with shareit

I am getting the strangest thing, it is not a redirect_uri, but rather a "Something went wrong, whoops" page.

The link shareit creates is:

https://www.facebook.com/dialog/feed?app_id=248093175573193&link=http%3A%2F%2Flocalhost%3A3000%2F3&name=This%20intelligent%20car%20is%20dumb!!!!&description=This%20intelligent%20car%20is%20dumb!!!!&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F3

I am obviously developing with meteor on 3000.

Can anyone share sample settings in fb for local development since it seems to be a problem on that side and not with shareit (i think).

Thank you.

sharer.php despite appId

Thanks for this great package!
I have a small issue though. I configure my appId like so:

ShareIt.configure({
  sites: {
    'facebook': {
      'appId': 12345
    }
  },
  useFB: true,
  classes: "btn btn-xs",
  iconOnly: true,
});

Still, I don't get the dialog but the sharer.php. Any idea, what i might be doing wrong here?

Pull library for twitter widget into package?

Trying to meet some security requirements right now and saw this package is pulling a script from twitter. Could this library be pulled into the package?

<script id="twitter-wjs" src="https://platform.twitter.com/widgets.js"></script>

Straight from google's security requirements:
Bad idea 3:
Let's load this tiny script from Twitter or Facebook...

Don't. Any scripts loaded from third-party sites gain full access to google.com. We don't know how good their security practices are, and we don't want to increase our attack surface in such a way. Keep in mind that even some of the largest and most reputable sites on the Internet have a fair number of serious flaws discovered every year; popularity itself is really not an argument.

Spiderable.js exception on docker

As this extension has dependency on spiderable package, which is causing the following error when I am deploying the application to Docker.
How can I remove the dependency because I want to you ongoworks:spiderable package instead of default one as ongoworks works fine in docker.

spiderable: phantomjs failed: null
stderr:
spiderable: phantomjs failed at http://www.myaddresspin.com/robots.txt: { [Error: Command failed: /usr/bin/env bash -c exec phantomjs --load-images=no --ssl-protocol=TLSv1 /dev/stdin <<'END'
var url = "http://www.myaddresspin.com/robots.txt";// 'url' is assigned to in a statement before this.
var page = require('webpage').create();

var isReady = function () {
return page.evaluate(function () {
if (typeof Meteor === 'undefined'
|| Meteor.status === undefined
|| !Meteor.status().connected) {
return false;
}
if (typeof Package === 'undefined'
|| Package.spiderable === undefined
|| Package.spiderable.Spiderable === undefined) {
return false;
}
return Package.spiderable.Spiderable.isReady();
});
};

var dumpPageContent = function () {
var out = page.content;
out = out.replace(/<script[^>]+>(.|\n|\r)?</script\s>/ig, '');
out = out.replace('', '');
console.log(out);
};

page.open(url, function(status) {
if (status === 'fail')
phantom.exit();
});

setInterval(function() {
if (isReady()) {
dumpPageContent();
phantom.exit();
}
}, 100);
END

Can't open '/dev/stdin'
]
killed: false,
code: 255,
signal: null,
cmd: '/usr/bin/env bash -c exec phantomjs --load-images=no --ssl-protocol=TLSv1 /dev/stdin <<'END'\nvar url = "http://www.myaddresspin.com/robots.txt";// 'url' is assigned to in a statement before this.\nvar page = require('webpage').create();\n\nvar isReady = function () {\n return page.evaluate(function () {\n if (typeof Meteor === 'undefined'\n || Meteor.status === undefined\n || !Meteor.status().connected) {\n return false;\n }\n if (typeof Package === 'undefined'\n || Package.spiderable === undefined\n || Package.spiderable.Spiderable === undefined) {\n return false;\n }\n return Package.spiderable.Spiderable.isReady();\n });\n};\n\nvar dumpPageContent = function () {\n var out = page.content;\n out = out.replace(/<script[^>]+>(.|\n|\r)?<\/script\s>/ig, '');\n out = out.replace('', '');\n console.log(out);\n};\n\npage.open(url, function(status) {\n if (status === 'fail')\n phantom.exit();\n});\n\nsetInterval(function() {\n if (isReady()) {\n dumpPageContent();\n phantom.exit();\n }\n}, 100);\nEND\n' }
stderr: Can't open '/dev/stdin'

stdout:
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
at Object.Meteor.nodeCodeMustBeInFiber (packages/meteor.js:1075:11)
at [object Object].
.extend.get (packages/meteor.js:1087:12)
at [object Object].RouteController.lookupOption (packages/iron_router.js:143:29)
at new Controller.extend.constructor (packages/iron_router.js:103:21)
at [object Object].ctor (packages/iron_core.js:144:17)
at Function.Router.createController (packages/iron_router.js:810:18)
at Function.Router.dispatch (packages/iron_router.js:1335:25)
at Object.router (packages/iron_router.js:624:12)
at next (/bundle/bundle/programs/server/npm/node_modules/meteor/webapp/node_modules/connect/lib/proto.js:174:15)
at packages/spiderable.js:171:11

Shareit not exported? Is the repo up-to-date?

Hey. I see that the Shareit (should be ShareIt ?) export is commented out in package.js#L26, and also that the version in this file is 0.1.0 while published version to Atmosphere is 0.2.0.

Any insight? :)

If I get a chance, are PRs welcome for documentation in the README? Doesn't look like much is happening on the doc site :)

Ability to tweet/post from database

Would it be possible to add the ability to tweet/post data from the database? I have a table on my webpage and I would like to add another column that would have the shareit buttons so I could tweet/post the data that is contained within that row to twitter/facebook/etc.

Thanks!
Kevin

Uncaught ReferenceError: ShareIt is not defined

I have added the shareIt package and in /client/lib/shareItConfiguration.js the default configuration:
ShareIt.configure({
useFB: true, // boolean (default: true)
// Whether to show the Facebook button
useTwitter: true, // boolean (default: true)
// Whether to show the Twitter button
useGoogle: true, // boolean (default: true)
// Whether to show the Google+ button
buttons: 'large' // string ('large' (default), 'small', 'responsive')
// Whether to use large or small buttons or both in a responsive manner.
});

The above error are shown in chrome when loading the page.

The {{>shareIt}} template are showing twitter and facebook but not G+. When clicking on the any of the two buttons I'm just redirected to #.

When looking in my sources (source map enabled) i only see
joshowens:shareit/client/views/social.[html,coffee]
joshowens:shareit/shareit.coffee
joshowens_shareit/social.less.css

Not the coffee files for facebook, twitter etc which are in the online package.js file.

I tried on 0.9.3 and 0.9.4 same thing.

.meteor/version
joshowens:[email protected]

Any clues to what i have done wrong.

Publish current version to Atmosphere

The version on Atmosphere seems to be severyl outdated and I only found out by manually comparing the sources.
Could you please publish the current version? As of now lovetostrikes package is actually more current on Atmosphere.

Debugger in ShareIt Build JS

On a deployed app, a "debugger" gets inserted into line 322 within the following js file:

.meteor/local/build/programs/web.browser/packages/joshowens_shareit.js

I'm not sure why it keeps getting inserted when deploying but I manually overwrite this file and remove it for the time being.

Uncaught ReferenceError: process is not defined

Getting the following error after updating to the latest meteor version
Uncaught ReferenceError: process is not defined joshowens_shareit.js:32 Uncaught ReferenceError: process is not defined

Updating to Meteor v1.2 doesn't support less version used

Maybe I'm doing something wrong, but Meteor update isn't letting me update to the latest version of this package. It actually looks like it downgraded the package in an update, and now meteor update yields:

The following top-level dependencies were not updated to the very latest version
available:
 * joshowens:shareit 0.0.3 (0.3.1 is available)

I tried to force to the latest version with:

meteor remove joshownes:shareit
meteor add joshowens:shareit@=0.3.1

But it resulted in the following error:

While selecting package versions:
error: Conflict: Constraint [email protected] is not satisfied by less 2.5.0_2.
Constraints on package "less":
* less@=2.5.0_2 <- top level
* [email protected] <- joshowens:shareit 0.3.1

Any advice?

Button icons moved

the buttons icons are now different not aligned correctly looks pretty bad and their really big
screen shot 2014-10-16 at 9 52 29 am

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.