Skip to content

Commit

Permalink
Move plugins.json to Github
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Nov 11, 2021
1 parent bff1e6d commit 29a1cc2
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 40 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ There is a cache of your friends post in form of a Custom Post Type friend_post

## Changelog

### 1.8.2
- Move plugin updater data to Github

### 1.8.1
- Fix whitespace missing in feed additions

Expand Down
5 changes: 5 additions & 0 deletions bin/generate-emojis-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* @package Friends
*/

if ( 'cli' !== php_sapi_name() ) {
fwrite( STDERR, "Must run from CLI.\n" );
exit( 1 );
}

$pre_selected = array( '👍', '❤️', '😂', '😍', '😭', '😊', '😩', '😁', '👎' );
$out = array();
$cache = __DIR__ . '/../emoji-rankings.json';
Expand Down
43 changes: 39 additions & 4 deletions bin/generate-plugins-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
* @package Friends
*/

// Use HEAD requests below.
stream_context_set_default(
array(
'http' => array(
'method' => 'HEAD',
),
)
);

if ( 'cli' !== php_sapi_name() ) {
fwrite( STDERR, "Must run from CLI.\n" );
exit( 1 );
}

$json = array();
foreach ( glob( __DIR__ . '/../../friends-*', GLOB_ONLYDIR ) as $dir ) {
$slug = basename( $dir );
Expand Down Expand Up @@ -35,8 +49,27 @@

$data['name'] = trim( strtok( $readme_md, PHP_EOL ), ' #' );

$data['trunk'] = "https://github.com/akirk/$slug/$slug.$version.zip";
$data['trunk'] = "https://github.com/akirk/$slug/archive/refs/tags/$version.zip";
$data['download_link'] = $data['trunk'];

$headers = get_headers( $data['download_link'] );
$exists = false;
foreach ( $headers as $header ) {
if ( preg_match( '#HTTP/[0-9.]+\s404#', $header ) ) {
$exists = false;
break;
}
if ( preg_match( '#HTTP/[0-9.]+\s200#', $header ) ) {
$exists = true;
break;
}
}
if ( ! $exists ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $slug, ' version ', $version, ' does not exist at ', $data['download_link'];
exit( 1 );
}

$data['last_updated'] = gmdate( 'Y-m-d', exec( 'git --git-dir=' . $dir . '/.git/ log -1 --format=%ct ' ) );
$data['sections'] = array();

Expand All @@ -45,11 +78,11 @@
continue;
}
$title = strtok( $section, PHP_EOL );
$data['sections'][ $title ] = trim( substr( $section, strlen( $title ) ) );
$data['sections'][ $title ] = simple_convert_markdown( substr( $section, strlen( $title ) ) );
}
$json[ $slug ] = $data;
}
file_put_contents( __DIR__ . '/../plugins.json', json_encode( $json, JSON_PRETTY_PRINT ) );
file_put_contents( __DIR__ . '/../plugins.json', json_encode( $json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) );
echo 'plugins.json was created.', PHP_EOL;

/**
Expand All @@ -62,6 +95,8 @@
function simple_convert_markdown( $md ) {
$html = $md;
$html = preg_replace( '/^# (.*)$/m', '<h2>$1</h2>', $html );
$html = preg_replace( '/^## (.*)$/m', '<h3>$1</h3>', $html );
$html = preg_replace( '/^### (.*)$/m', '<h4>$1</h4>', $html );
$html = preg_replace( '/\[([^\]]*)\]\(([^)]*)\)/', '<a href="$2">$1</a>', $html );
return preg_replace( '/\n+/', '<br/>\n', $html );
return trim( preg_replace( '/\n+/', '<br/>\n', trim( $html ) ) );
}
2 changes: 1 addition & 1 deletion friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin name: Friends
* Plugin author: Alex Kirk
* Plugin URI: https://github.com/akirk/friends
* Version: 1.8.1
* Version: 1.8.2
*
* Description: Decentralized Social Networking with WordPress. Connect WordPresses through friend requests and read each other’s (private) posts in a feed reader.
*
Expand Down
2 changes: 1 addition & 1 deletion includes/class-friends-plugin-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function get_plugins() {
$data = get_transient( $cache_key );
if ( false === $data || apply_filters( 'friends_deactivate_plugin_cache', false ) ) {
$remote = wp_remote_get(
'https://wpfriends.at/plugins.json',
'https://raw.githubusercontent.com/akirk/friends/main/plugins.json',
array(
'timeout' => 10,
'headers' => array(
Expand Down
2 changes: 1 addition & 1 deletion includes/class-friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Alex Kirk
*/
class Friends {
const VERSION = '1.8.1';
const VERSION = '1.8.2';
const CPT = 'friend_post_cache';
const FEED_URL = 'friends-feed-url';
const PLUGIN_URL = 'https://wordpress.org/plugins/friends/';
Expand Down
67 changes: 34 additions & 33 deletions plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,80 @@
"friends-autoresolve-links": {
"name": "Friends Autoresolve Links",
"short_description": "Transform plaintext links of incoming content (especially t.co shortlinks) into rich(er) links.",
"more_info": "https:\/\/github.com\/akirk\/friends-autoresolve-links",
"more_info": "https://github.com/akirk/friends-autoresolve-links",
"slug": "friends-autoresolve-links",
"version": "1.0.1",
"trunk": "https:\/\/github.com\/akirk\/friends-autoresolve-links\/friends-autoresolve-links.1.0.1.zip",
"download_link": "https:\/\/github.com\/akirk\/friends-autoresolve-links\/friends-autoresolve-links.1.0.1.zip",
"last_updated": "2021-07-07",
"version": "1.0.2",
"trunk": "https://github.com/akirk/friends-autoresolve-links/archive/refs/tags/1.0.2.zip",
"download_link": "https://github.com/akirk/friends-autoresolve-links/archive/refs/tags/1.0.2.zip",
"last_updated": "2021-11-11",
"sections": {
"Description": "This plugin is meant to be used with the [Friends plugin](https:\/\/github.com\/akirk\/friends\/)."
"Description": "This plugin is meant to be used with the <a href=\"https://github.com/akirk/friends/\">Friends plugin</a>."
}
},
"friends-debugger": {
"name": "Friends Debugger",
"short_description": "Tooling for debugging the Friends Plugin more easily.",
"more_info": "https:\/\/github.com\/akirk\/friends-debugger",
"more_info": "https://github.com/akirk/friends-debugger",
"slug": "friends-debugger",
"version": "0.1",
"trunk": "https:\/\/github.com\/akirk\/friends-debugger\/friends-debugger.0.1.zip",
"download_link": "https:\/\/github.com\/akirk\/friends-debugger\/friends-debugger.0.1.zip",
"last_updated": "2021-05-19",
"trunk": "https://github.com/akirk/friends-debugger/archive/refs/tags/0.1.zip",
"download_link": "https://github.com/akirk/friends-debugger/archive/refs/tags/0.1.zip",
"last_updated": "2021-11-11",
"sections": {
"Description": "This plugin outputs some more data and provides tools like a Feed Log."
}
},
"friends-parser-fraidyscrape": {
"name": "Friends Parser Fraidyscrape",
"short_description": "Use the Fraidyscrape extractor to view feeds for web sites that don't provide machine readable feeds.",
"more_info": "https:\/\/github.com\/akirk\/friends-parser-fraidyscrape",
"more_info": "https://github.com/akirk/friends-parser-fraidyscrape",
"slug": "friends-parser-fraidyscrape",
"version": "1.0.1",
"trunk": "https:\/\/github.com\/akirk\/friends-parser-fraidyscrape\/friends-parser-fraidyscrape.1.0.1.zip",
"download_link": "https:\/\/github.com\/akirk\/friends-parser-fraidyscrape\/friends-parser-fraidyscrape.1.0.1.zip",
"last_updated": "2021-05-05",
"version": "1.0.2",
"trunk": "https://github.com/akirk/friends-parser-fraidyscrape/archive/refs/tags/1.0.2.zip",
"download_link": "https://github.com/akirk/friends-parser-fraidyscrape/archive/refs/tags/1.0.2.zip",
"last_updated": "2021-11-11",
"sections": {
"Description": "This is a PHP port of the JavaScript extractor Fraidyscrape to be used as a plugin for the [Friends Plugin](https:\/\/wordpress.org\/plugins\/friends) which can then be used to follow your friends on platforms that don't provide RSS feeds, or some news sites.\n\n### Fraidyscrape\n\nFraidyscrape is the rule-based HTML, JSON and TXT scraper - used in the\nmicro-famous, macro-fearful Web research tool [Fraidycat](https:\/\/fraidyc.at\/).\n\n> It is presently quite a dark art to figure out. No one really knows what it does!\n\nThis plugin is meant to be used with the [Friends plugin](https:\/\/github.com\/akirk\/friends\/)."
"Description": "This is a PHP port of the JavaScript extractor Fraidyscrape to be used as a plugin for the <a href=\"https://wordpress.org/plugins/friends\">Friends Plugin</a> which can then be used to follow your friends on platforms that don't provide RSS feeds, or some news sites.<br/>\\n<h4>Fraidyscrape</h4><br/>\\nFraidyscrape is the rule-based HTML, JSON and TXT scraper - used in the<br/>\\nmicro-famous, macro-fearful Web research tool <a href=\"https://fraidyc.at/\">Fraidycat</a>.<br/>\\n> It is presently quite a dark art to figure out. No one really knows what it does!<br/>\\nThis plugin is meant to be used with the <a href=\"https://github.com/akirk/friends/\">Friends plugin</a>."
}
},
"friends-parser-rss-bridge": {
"name": "Friends Parser RSS Bridge",
"short_description": "Use a local version of RSS-Bridge to view feeds for web sites that don't provide machine readable feeds.",
"more_info": "https:\/\/github.com\/akirk\/friends-parser-rss-bridge",
"more_info": "https://github.com/akirk/friends-parser-rss-bridge",
"slug": "friends-parser-rss-bridge",
"version": "1.0.3",
"trunk": "https:\/\/github.com\/akirk\/friends-parser-rss-bridge\/friends-parser-rss-bridge.1.0.3.zip",
"download_link": "https:\/\/github.com\/akirk\/friends-parser-rss-bridge\/friends-parser-rss-bridge.1.0.3.zip",
"last_updated": "2021-03-16",
"version": "1.0.4",
"trunk": "https://github.com/akirk/friends-parser-rss-bridge/archive/refs/tags/1.0.4.zip",
"download_link": "https://github.com/akirk/friends-parser-rss-bridge/archive/refs/tags/1.0.4.zip",
"last_updated": "2021-11-11",
"sections": {
"Description": "This parser is powered by the open source project [RSS Bridge](https:\/\/github.com\/RSS-Bridge\/rss-bridge) (resp. a very similar fork at [akirk\/rss-bridge](https:\/\/github.com\/akirk\/rss-bridge)) and allows to parse many external services that don't provide RSS feeds, such as Skimfeed, Twitter, Bandcamp, Wikipedia and more.\n\nThe RSS Bridge project provides a set of \"bridges\" that overcome the gap between web sites' content and a machine readable format, such as RSS. This plugin extends the bridge into the WordPress world, especially to the [Friends Plugin](https:\/\/wordpress.org\/plugins\/friends) which can then be used to follow your friends on platforms that don't provide RSS feeds, or some news sites.\n\nThis plugin is meant to be used with the [Friends plugin](https:\/\/github.com\/akirk\/friends\/)."
"Description": "This parser is powered by the open source project <a href=\"https://github.com/RSS-Bridge/rss-bridge\">RSS Bridge</a> (resp. a very similar fork at <a href=\"https://github.com/akirk/rss-bridge\">akirk/rss-bridge</a>) and allows to parse many external services that don't provide RSS feeds, such as Skimfeed, Twitter, Bandcamp, Wikipedia and more.<br/>\\nThe RSS Bridge project provides a set of \"bridges\" that overcome the gap between web sites' content and a machine readable format, such as RSS. This plugin extends the bridge into the WordPress world, especially to the <a href=\"https://wordpress.org/plugins/friends\">Friends Plugin</a> which can then be used to follow your friends on platforms that don't provide RSS feeds, or some news sites.<br/>\\nThis plugin is meant to be used with the <a href=\"https://github.com/akirk/friends/\">Friends plugin</a>."
}
},
"friends-post-collection": {
"name": "Friends Post Collection",
"short_description": "Collect posts from around the web and create feeds.",
"more_info": "https:\/\/github.com\/akirk\/friends-post-collection",
"more_info": "https://github.com/akirk/friends-post-collection",
"slug": "friends-post-collection",
"version": "0.6.1",
"trunk": "https:\/\/github.com\/akirk\/friends-post-collection\/friends-post-collection.0.6.1.zip",
"download_link": "https:\/\/github.com\/akirk\/friends-post-collection\/friends-post-collection.0.6.1.zip",
"last_updated": "2021-08-17",
"version": "0.6.2",
"trunk": "https://github.com/akirk/friends-post-collection/archive/refs/tags/0.6.2.zip",
"download_link": "https://github.com/akirk/friends-post-collection/archive/refs/tags/0.6.2.zip",
"last_updated": "2021-11-11",
"sections": {
"Description": "This plugin provides the facilities to store feed items in a separate post type. These can be used to create your own compliation of posts and re-publish them for friends."
}
},
"friends-send-to-e-reader": {
"name": "Friends Post Collection",
"short_description": "Send new articles directly to your e-reader via e-mail or download the ePub.",
"more_info": "https:\/\/github.com\/akirk\/friends-send-to-e-reader",
"more_info": "https://github.com/akirk/friends-send-to-e-reader",
"slug": "friends-send-to-e-reader",
"version": "0.2.4",
"trunk": "https:\/\/github.com\/akirk\/friends-send-to-e-reader\/friends-send-to-e-reader.0.2.4.zip",
"download_link": "https:\/\/github.com\/akirk\/friends-send-to-e-reader\/friends-send-to-e-reader.0.2.4.zip",
"last_updated": "2021-11-05",
"version": "0.3",
"trunk": "https://github.com/akirk/friends-send-to-e-reader/archive/refs/tags/0.3.zip",
"download_link": "https://github.com/akirk/friends-send-to-e-reader/archive/refs/tags/0.3.zip",
"last_updated": "2021-11-11",
"sections": {
"Description": "See the post [Subscribing to RSS Feeds on your E-Reader using your own WordPress blog](https:\/\/wpfriends.at\/2021\/09\/20\/subscribing-to-rss-feeds-on-your-e-reader\/) for more details on how it works.\n\nThis plugin is meant to be used with the [Friends plugin](https:\/\/github.com\/akirk\/friends\/)."
"Description": "See the post <a href=\"https://wpfriends.at/2021/09/20/subscribing-to-rss-feeds-on-your-e-reader/\">Subscribing to RSS Feeds on your E-Reader using your own WordPress blog</a> for more details on how it works.<br/>\\nThis plugin is meant to be used with the <a href=\"https://github.com/akirk/friends/\">Friends plugin</a>.",
"Changelog": "<h4>0.3</h4><br/>\\n- Allow downloading the ePub.<br/>\\n- Theoretically add support for Tolino. Not functional because Thalia doesn't want to provide OAuth2 credentials."
}
}
}

0 comments on commit 29a1cc2

Please sign in to comment.