Mirror of github.com/nicolabs/mastodon-timeline-widget
Go to file
2017-05-18 19:19:28 +09:00
.gitignore ignore zip file in repository 2017-05-16 20:01:12 +09:00
LICENSE.txt license add info + update files 2017-05-08 16:07:03 +09:00
mastodon.widget-jp.js separate texts for other languages support + code cleanup 2017-05-18 16:07:11 +09:00
mastodon.widget.css separate texts for other languages support + code cleanup 2017-05-18 16:07:11 +09:00
mastodon.widget.js handling of multiple pictures 2017-05-18 18:09:24 +09:00
README.md update readme files 2017-05-18 19:19:28 +09:00
README_en.md update readme files 2017-05-18 19:19:28 +09:00

Mastodon.widget

The idea of this little script is to allow users to display their Mastodon timeline on their blog/website.

You can use our wizard to generate an access token very easily. Simply follow the link below:
Azet.jp's Mastodon Widget Wizard

Requirements

  • jQuery
  • access token from the mastodon instance you want to display the timeline from

To help you create a token, we'll soon provide a page on our website that will guide you through the requiered steps.

Installation

  1. Download the required files (only one JS and one CSS).

  2. Simply paste the code bellow in you website:

<link rel="stylesheet" href="mastodon.widget.css">
<script type="text/javascript" src="mastodon.widget.js"></script>
<script>
	$(document).ready(function() {
		// jQUERY is required!
		var mapi = new MastodonApi({
			target_selector  : '#myTimeline'
			,instance_uri    : '[MASTODON INSTANCE]'
			,access_token    : '[ACCESS TOKEN]'
			,account_id      : '[ACCOUNT ID]'
			// optional parameters
			//,toots_limit     : 5
			//,pic_icon        : '<i class="fa fa-picture-o"></i>' // requires http://fontawesome.io
		});
	});
</script>

In the sample above, you have to replace the folowing:

  • [MASTODON INSTANCE] => i.e : https://mastodon.technology
  • [ACCESS TOKEN] => token you created for your app and linked with your Mastodon instance account
  • [ACCOUNT ID] => your user ID on Mastodon instance
  1. Add a container for your timeline where you want in the body of your website:
    <div id="myTimeline" class="mastodon-timeline mastodon-timeline-dark"></div>

Available parameters

The parameters below are optional.

Parameter name Default Explanation
toots_limit 20 maximum number of visible toots
pic_icon [picture] icon to be displayed when medias are attached

Regarding pic_icon, you can use an image you have on your server like so: <img src="mypicicon.gif" />.
Or you can also use font-awesome and set <i class="fa fa-picture-o"></i>.

Customization

You have the choice between 2 basic themes:

  • mastodon-timeline-light
  • mastodon-timeline-dark

Or you can create your own. Please have a look in the CSS file for more details.

Languages supported

In a separate file, you can setup the text to support a different language.
For example, in the Japanese file mastodon.widget-jp.js we can find the folowing settings:

MastodonApi.text = {
	spoilerBtnClosed  : "もっと見る"
	,spoilerBtnOpened : "隠す"
	,nsfwLabel        : "閲覧注意"
	,nsfwViewMsg      : "クリックして表示"
};

Please be sure to insert the translation javascript file <script> tag after mastodon.widget.js.