Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
Release 2.0.0
Browse files Browse the repository at this point in the history
Removed Twitter Syndication
  • Loading branch information
dg01d committed Aug 9, 2018
1 parent 51b4850 commit b72c4b7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 91 deletions.
15 changes: 7 additions & 8 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Then edit the included `configs.php` file to enable various features. The full f
'storageFolder' => '../content', // the folder to store the posts in
'trashFolder' => '../trash', // the folder to move removed posts into
// Config Block for Twitter
'twitterName' => 'poopyCakes', // your twitter account name, don't use the @
// Config Block for Twitter -- Used only for XRay for rich context replies
'twAPIkey' => 'WomtvR2YoT', // Create an app on dev.twitter.com for your account.
'twAPIsecret' => 'NILIDJXg1e', // APIkey & APIsecret are the APP's key & Secret
'twUserKey' => 'ILs4jUS7a6', // UserKey & User Secret are under 'Your access token'
Expand Down Expand Up @@ -67,11 +66,11 @@ Then edit the included `configs.php` file to enable various features. The full f

### Notes

- Twitter Keys can be obtained using the [Create New App](https://apps.twitter.com/app/new) on twitter.
- Mastodon Keys are more command-line driven, but relatively straightforward. See [the Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md)
- As Mastodon is a federated network, you do need to _explicitly_ specify your Mastodon Instance.
- If using the micro.blog function, you need to specify your site's rss/atom feed.
- To use the weather data, you'll need to add access data for a location-tracking endpoint (like a self-hosted version of [Compass](https://github.com/aaronpk/Compass)) and a DarkSky [API Key](https://darksky.net/dev/docs)
- Twitter Keys can be obtained using the [Create New App](https://apps.twitter.com/app/new) on twitter.
- Since 1.5, you can configure the frontmatter format for your posts. Currently the options are json, used in [Hugo](https://gohugo.io/content-management/front-matter/), or yaml, optionally used in Hugo, but required by other static engines such as [Jekyll](https://jekyllrb.com/docs/frontmatter/) or [Metalsmith](http://www.metalsmith.io). This could be used with other generators, such as [Pelican](docs.getpelican.com/en/stable/content.html), but the script would need to be changed to meet their specific format requirements.


Expand All @@ -88,7 +87,6 @@ On my site, these headers are provided as follows:
<link rel="authorization_endpoint" href="https://indieauth.com/auth" />
<link rel="token_endpoint" href="https://tokens.indieauth.com/token" />
<link rel="micropub" href="https://ascraeus.org/nanopub.php" />

```

### Data Structure
Expand All @@ -99,8 +97,9 @@ The location of the data store - where the script places your posts - is set wit
/srv
|-- output
|-- content
|-- micro
|-- article
|-- like
|-- link
| |-- micro
| |-- article
| |-- like
| |-- link
|-- trash
```
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MicroPub support for Static Blog Engine
=======================================

**Note** This release removes support for syndicating to twitter.com.

This php script provides micropub support for Static Site Generators. Incoming posts are rewritten to a suitable front-matter format and saved to the user's content store.

Currently, the script will handle the following indieweb functions:-
Expand Down Expand Up @@ -30,7 +32,7 @@ Optional

[Full implementation report](https://micropub.rocks/implementation-reports/servers/132/dohoQpnIdZYxrwcpMgzj) is available on [micropub.rocks](https://micropub.rocks/)

**nanopub** additionally supports syndication of content to external silos. Currently it provides syndication to [Twitter](https://twitter.com) and [Mastodon](https://mastodon.social), although it also provides a framework implementation for any modern API-based endpoint. An example is provided of the script pinging the [micro.blog](https://micro.blog) service to update the user's feed.
**nanopub** additionally supports syndication of content to external silos. Currently it provides syndication to [Mastodon](https://mastodon.social), although it also provides a framework implementation for any modern API-based endpoint. An example is provided of the script pinging the [micro.blog](https://micro.blog) service to update the user's feed.

The code is self-explanatory and documented, and can be adjusted easily to meet different needs.

Expand All @@ -50,12 +52,6 @@ Any errors resulting from use of the deprecated formats are a matter for the cli

TODO
----
* [X] Save all content in the correct Hugo JSON format
* [X] Read all content from disk in correct microformats2 syntax
* [X] Make it work with a more complete set of micropub features
* [X] Reply-to
* [X] Like-Of
* [X] Repost-Of
* [ ] Make a `setup.php` script to complete the required configuration settings.
* [ ] Implement rsvp's, itineraries &c
* [ ] Trigger sitegen on succesful operation.
Expand All @@ -78,6 +74,7 @@ Changes
-------
Version | Date | Notes
-------:|:----:|:-----
2.0.0| 2018-08-09 | Removed support for syndication to twitter
1.5.1| 2018-04-12 | Clarified Installation & packaged vendor files
1.5 | 2018-02-01 | Added configurable frontmatter, currently json or yaml
1.4 | 2018-01-26 | Extended for weather reporting, and rich-context likes/reposts
Expand Down
5 changes: 2 additions & 3 deletions configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
'storageFolder' => '../content', // the folder to store the posts in
'trashFolder' => '../trash', // the folder to move removed posts into

// Config Block for Twitter
'twitterName' => 'poopyCakes', // your twitter account name, don't use the @
// Config Block for Twitter -- Used only for XRay for rich context replies
'twAPIkey' => 'WomtvR2YoT', // Create an app on dev.twitter.com for your account.
'twAPIsecret' => 'NILIDJXg1e', // APIkey & APIsecret are the APP's key & Secret
'twUserKey' => 'ILs4jUS7a6', // UserKey & User Secret are under 'Your access token'
Expand All @@ -37,4 +36,4 @@
'frontFormat' => 'json'
);

?>
?>
75 changes: 2 additions & 73 deletions nanopub.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license https://opensource.org/licenses/FPL-1.0.0 0BSD
* @link https://github.com/dg01d/nanopub
* @category Micropub
* @version 1.5
* @version 2.0.0
*/

require 'vendor/autoload.php';
Expand All @@ -22,10 +22,6 @@
*/

$configs = include 'configs.php';
$twAPIkey = $configs->twAPIkey;
$twAPIsecret = $configs->twAPIsecret;
$twUserKey = $configs->twUserKey;
$twUserSecret = $configs->twUserSecret;
$siteUrl = $configs->siteUrl;
$siteFeed = $configs->siteFeed;
$weatherToggle = $configs->weatherToggle;
Expand Down Expand Up @@ -283,10 +279,6 @@ function write_file($frontmatter, $content, $fn)
$array = array(
"syndicate-to" => array(
0 => array(
"uid" => "https://twitter.com",
"name" => "Twitter"
),
1 => array(
"uid" => "https://".$configs->mastodonInstance,
"name" => "Mastodon"
)
Expand All @@ -304,10 +296,6 @@ function write_file($frontmatter, $content, $fn)
"media-endpoint" => $configs->mediaPoint,
"syndicate-to" => array(
0 => array(
"uid" => "https://twitter.com",
"name" => "Twitter"
),
1 => array(
"uid" => "https://".$configs->mastodonInstance,
"name" => "Mastodon"
)
Expand Down Expand Up @@ -587,9 +575,6 @@ function ($a) {
if (isset($frontmatter['repost_of'])) {
$frontmatter['repost_site'] = hostname_of_uri($frontmatter['repost_of']);
$url_parse = xray_machine($frontmatter['repost_of'], $frontmatter['repost_site']);
if ($frontmatter['repost_site'] == 'twitter.com') {
$synds['0'] = "https://twitter.com";
}
}
unset($props['repost-of']);

Expand All @@ -601,9 +586,6 @@ function ($a) {
if (isset($frontmatter['replytourl'])) {
$frontmatter['replysite'] = hostname_of_uri($frontmatter['replytourl']);
$url_parse = xray_machine($frontmatter['replytourl'], $frontmatter['replysite']);
if ($frontmatter['replysite'] == 'twitter.com') {
$synds['0'] = "https://twitter.com";
}
}
unset($props['in-reply-to']);

Expand Down Expand Up @@ -712,59 +694,6 @@ function ($a) {
// Sets up a variable linking to the toot
$frontmatter['mastodonlink'] = $array_mastodon['url'];
}

// then twitter, with its useless 140 chars
if (in_array("https://twitter.com", $synds)) {

$TwText = substr($synText, 0, 260) . ''. $canonical;

// Calls the external Twitter Library

$settings = array(
'consumer_key' => $twAPIkey,
'consumer_secret' => $twAPIsecret,
'oauth_access_token' => $twUserKey,
'oauth_access_token_secret' => $twUserSecret
);

$url = 'https://api.twitter.com/1.1/statuses/update.json';
$requestMethod = 'POST';
$postfields = array(
'status' => $TwText
);

if ((isset($frontmatter['replytourl']) && $frontmatter['replysite'] == "twitter.com")) {
$postfields['in_reply_to_status_id'] = tw_url_to_status_id($frontmatter['replytourl']);
$postfields['auto_populate_reply_metadata'] = true;
}
if ((isset($frontmatter['like_of'])) && ($frontmatter['like_site'] == "twitter.com")) {
$url = 'https://api.twitter.com/1.1/favorites/create.json';
$postfields['id'] = tw_url_to_status_id($frontmatter['like_of']);
unset($postfields['status']);
}
if ((isset($frontmatter['repost_of'])) && ($frontmatter['repost_site'] == "twitter.com")) {
$id = tw_url_to_status_id($frontmatter['repost_of']);
$url = 'https://api.twitter.com/1.1/statuses/retweet/' . $id . '.json';
$postfields['id'] = $id;
unset($postfields['status']);
}

//Perform a POST request and echo the response

$twitter = new TwitterAPIExchange($settings);
$twarray = json_decode(
$twitter->buildOauth($url, $requestMethod)
->setPostfields($postfields)
->performRequest()
);
if ((isset($frontmatter['repost_of'])) || (isset($frontmatter['like_of']))) {
$frontmatter['twitlink'] = isset($frontmatter['repost_of']) ? $frontmatter['repost_of'] : $frontmatter['like_of'];
} else {
$str = $twarray->id_str;
$nym = $twarray->user->screen_name;
$frontmatter['twitlink'] = "https://twitter.com/" . $nym . "/status/" . $str;
}
}
}

// All values obtained, we tidy up the array and convert to json
Expand All @@ -788,4 +717,4 @@ function ($a) {
header("Location: ". $canonical);
}
}
}
}

0 comments on commit b72c4b7

Please sign in to comment.