Skip to content

Commit 4987cf2

Browse files
committed
First formal version. README and CHANGELOG.
- Version updated to 1.0.0, as we're at a good and stable base. - Completed README and CHANGELOG with useful informations and docs.
1 parent d587c95 commit 4987cf2

File tree

6 files changed

+110
-10
lines changed

6 files changed

+110
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
*.css.map
55

66

7-
# vendors directory commited because Grav don't install composer dependencies
7+
# vendors directory committed because Grav don't install composer dependencies

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# v0.1.0
2-
## 06/30/2018
1+
# v1.0.0
2+
## 07/07/2018
33

44
1. [](#new)
5-
* ChangeLog started...
5+
* First version
6+
* Support for Twitter, Mastodon and Instagram, with light or dark embeds, using simple shortcodes.
7+
* Support for texts, images, videos, GIF, multiple medias, Mastodon's CW.
8+
* Images and videos can be downloaded locally for enhanced independence.

README.md

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ You should now have all the plugin files under
2222

2323
/your/site/grav/user/plugins/static-social-embeds
2424

25-
> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav) and the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) to operate.
25+
> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error), [Problems](https://github.com/getgrav/grav-plugin-problems) and [Shortcode Core](https://github.com/getgrav/grav-plugin-shortcode-core) plugins to operate. Also, the [CURL PHP extension](https://secure.php.net/curl) must be enabled for this plugin to work.
2626
2727
### Admin Plugin
2828

@@ -32,18 +32,101 @@ If you use the admin plugin, you can install directly through the admin plugin b
3232

3333
Before configuring this plugin, you should copy the `user/plugins/static-social-embeds/static-social-embeds.yaml` to `user/config/plugins/static-social-embeds.yaml` and only edit that copy.
3434

35-
Here is the default configuration and an explanation of available options:
35+
Here is the default configuration and a short explanation of available options. Extensive explanations are available in the admin page of the plugin.
3636

3737
```yaml
3838
enabled: true
39+
40+
# The plugin ships its own JS and CSS to run the static embeds.
41+
# If you want to provide your own, feel free to disable them.
42+
built_in_css: true
43+
built_in_js: true
44+
45+
# The plugin can download images, videos, and GIFs, to ensure a
46+
# complete independence from the social networks, at the cost of
47+
# some disk space.
48+
downloaded_content:
49+
images: true
50+
videos: true
51+
52+
# Options for Twitter: embed theme (with the default CSS, matches the
53+
# light & dark Twitter themes) and API credentials required to load
54+
# tweets (an explanation on how to create an application is available
55+
# below).
56+
twitter:
57+
theme: light
58+
consumer_key: null
59+
consumer_secret: null
60+
access_token: null
61+
access_token_secret: null
62+
63+
# Options for Mastodon: embed theme (with the default CSS, matches the
64+
# light & dark Mastodon themes).
65+
mastodon:
66+
theme: light
67+
68+
# Options for Instagram: embed theme (with the default CSS, the light theme
69+
# matches Instagram, and the dark one was created from the light one and
70+
# some inspiration from Twitter own dark theme).
71+
instagram:
72+
theme: light
3973
```
4074
75+
Themes can be `light` or `dark` as for now and for the built-in CSS. If you want to add your own, themes only add a CSS class to the embeds containers: `sse-theme-[thetheme]` (e.g. `sse-theme-light` or `sse-theme-dark`); you can put anything there and reference it on your CSS file.
76+
77+
### Twitter setup
78+
79+
To use Twitter embeds, you'll need to register an application. This is done in a few simple steps.
80+
81+
1. Go to [the Twitter Apps page](https://apps.twitter.com/app/new) to create an application. You don't need to provide a callback URL (we never use that).
82+
2. Then, click the **Keys and access tokens** tab and at the bottom of the page, click **Create my Access Token**.
83+
3. Finally, copy the credentials in the configuration file (or in the admin).
84+
4185
Note that if you use the admin plugin, a file with your configuration, and named static-social-embeds.yaml will be saved in the `user/config/plugins/` folder once the configuration is saved in the admin.
4286

87+
### Customization
88+
89+
If you want to customize the embeds' HTML code, you can override the `partials/static-social-embeds` templates. The template name is the same as the shortcode name (see below), e.g. `toot.html.twig` for Mastodon embeds template. Templates context vary for different social networks; checkout built-in templates or shortcode classes to know which variables you can use.
90+
4391
## Usage
4492

45-
**Describe how to use the plugin.**
93+
The plugin supports static embeds for Twitter, Mastodon and Instagram posts. It tries to match original embeds styles, so it's close to the real embeds, wut without any request to the social networks: independence!
94+
95+
Three shortcodes are declared to embed status: `tweet`, `toot` and `instagram`, for respectively Twitter, Mastodon and Instagram. They accept one parameter: the status URL to embed. Use them in your articles like this:
96+
97+
```markdown
98+
[tweet="https://twitter.com/INSVideos/status/1013375197984980992"]
99+
100+
[toot="https://mamot.fr/@ploum/100244825435451499"]
101+
102+
[instagram="https://www.instagram.com/p/BkiaGXxgmOH/"]
103+
```
104+
105+
The following shortcodes will be rendered as below (for light and dark themes, with built-in CSS & JS).
106+
107+
![](assets/docs/embeds-preview.png)
108+
109+
Texts, images (single or multiples), videos (single or multiples), GIFs, are supported for all networks above. Mastodon toots supports CW and sensitive images.
110+
111+
Extensive caching is used to retrieve data and medias only once per embed. The first page load may be slow (especially if there are a lot of embeds in the page), but subsequent calls will be lightning-fast, as all data will be read from the cache, without any request to the social networks (no tracking, yay!). This also means that if an embed status is deleted, it will be kept on your site if the cache is not deleted. Custom locations are used for the cache files.
112+
113+
- Raw data is stored in `<root>/cache/static-social-embeds`. You can delete this folder at any time: embeds data will be retrieved from the social networks if not found in the cache.
114+
- Images and videos are stored in `<root>/images/static-social-embeds`. You _should not_ delete this folder without deleting the above cache folder: if images are downloaded, links to images and videos references this medias cache folder. If you delete it, all images from existing embeds will be broken, except if you remove the data cache folder, as it will trigger a re-download of the medias (or references of CDN URLs if you disable the medias download).
115+
116+
The plugin is translated in English and French.
117+
118+
## Technical considerations regarding Instagram
119+
120+
While Twitter and Mastodon data are retrieved using their respective API, there is no way to do that with Instagram (or there is, but deprecated and soon-to-be-removed in december 2018). We scrap an internal JSON embed in the post pages to retrieve data (thanks to [RSSBridge](https://github.com/RSS-Bridge/rss-bridge/blob/master/bridges/InstagramBridge.php) for the tip). As it isn't official, it may break anytime.
121+
122+
Data is cached without expiration, so as long as you don't delete the cache, existing embeds will never break. New ones will. Feel free to open an issue if such problem occurs (but this is pretty stable for a few years now and I hope it will remains as such).
123+
124+
## Thanks
125+
126+
- Thanks to [`jedkirby/tweet-entity-linker`](https://github.com/jedkirby/tweet-entity-linker) used to parse tweets and add entities links (hashtags, mentions…) referenced in Twitter's JSON statuses.
46127

47128
## To Do
48129

49-
- [ ] Future plans, if any
130+
- [ ] Support for Twitter pools.
131+
- [ ] Support for Pleroma (should be simple as it's compatible with the Mastodon API) and maybe other networks (by request).
132+
- [ ] Maybe option to proxy medias, allowing not to store them but still serve them from the website's domain.

assets/docs/embeds-preview.png

1.23 MB
Loading

blueprints.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Static Social Embeds
2-
version: 0.1.0
2+
version: 1.0.0
33
description: |
44
Embeds social status (like tweets, instagram posts, toots, etc.) in articles without using their embed iframe,
55
but rather statically without any dependency to the service.
@@ -10,7 +10,7 @@ author:
1010
homepage: https://github.com/Nebulius/grav-plugin-static-social-embeds
1111
keywords: grav, plugin, embed, static, twitter, instagram, mastodon, tweet, toot, integration, post
1212
bugs: https://github.com/Nebulius/grav-plugin-static-social-embeds/issues
13-
docs: https://github.com/Nebulius/grav-plugin-static-social-embeds/blob/develop/README.md
13+
docs: https://github.com/Nebulius/grav-plugin-static-social-embeds/blob/master/README.md
1414
license: MIT
1515

1616
dependencies:

static-social-embeds.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
enabled: true
22

3+
# The plugin ships its own JS and CSS to run the static embeds.
4+
# If you want to provide your own, feel free to disable them.
35
built_in_css: true
46
built_in_js: true
57

8+
# The plugin can download images, videos, and GIFs, to ensure a
9+
# complete independence from the social networks, at the cost of
10+
# some disk space.
611
downloaded_content:
712
images: true
813
videos: true
914

15+
# Options for Twitter: embed theme (with the default CSS, matches the
16+
# light & dark Twitter themes) and API credentials required to load
17+
# tweets (an explanation on how to create an application is available
18+
# below).
1019
twitter:
1120
theme: light
1221
consumer_key: null
1322
consumer_secret: null
1423
access_token: null
1524
access_token_secret: null
1625

26+
# Options for Mastodon: embed theme (with the default CSS, matches the
27+
# light & dark Mastodon themes).
1728
mastodon:
1829
theme: light
1930

31+
# Options for Instagram: embed theme (with the default CSS, the light theme
32+
# matches Instagram, and the dark one was created from the light one and
33+
# some inspiration from Twitter own dark theme).
2034
instagram:
2135
theme: light

0 commit comments

Comments
 (0)