This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
indieweb.module
115 lines (105 loc) · 11.2 KB
/
indieweb.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* @file
* IndieWeb functionality.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function indieweb_help($route_name, RouteMatchInterface $route_match) {
$help = [
'indieweb.admin.webmention_settings' => [
'title' => 'Receiving webmentions',
'text' => '<p>' . t('The easiest way to start receiving webmentions and pingbacks for any page is by using <a href="https://webmention.io/" target="_blank">https://webmention.io</a>. <br />You have to create an account by signing in with your domain. For more information how to sign in with your domain, see the IndieAuth configuration.<br />Webmention.io is open source so you can also host the service yourself.<br />You can also use the built-in webmention endpoint to receive webmentions.<br />All collected webmentions and pingbacks can be viewed on the webmention overview page at /admin/content/webmention</a>.<br /><br /><strong>Blocks</strong><br />- Webmentions: show the likes and reposts of that url.<br />- Webmention notify form: let people submit a URL if the current page is mentioned there<br />- RSVP: shows people attending, interested etc. for an event<br />- Pingbacks: render all urls to site pinging back per page') . '</p>',
],
'indieweb.admin.webmention_send_settings' => [
'title' => 'Sending webmentions and syndicating content',
'text' => '<p>' . t('The easiest way to syndicate content on social networks is by using <a href="https://brid.gy/" target="_blank">https://brid.gy</a>. <br />You have to create an account by signing in with your preferred social network. Bridgy is open source so you can also host the service yourself.<br /><br />Syndicating and sending webmentions can be done per node in the "Publish to" fieldset, which is protected with the "send webmentions" permission.<br />If no targets are configured, there is nothing to do. There is a syndication field on every node and comment type available to render your syndications for <a href="https://indieweb.org/posse-post-discovery" target="_blank">POSSE-Post-Discovery</a>.<br />If comments are enabled, put those fields only on the microformat view mode. The comment itself is available on comment/indieweb/cid and it is this URL that will be used for sending webmentions.') . '</p>',
],
'indieweb.admin.comment_settings' => [
'title' => 'Comments',
'text' => t("When a webmention is saved and is of property 'in-reply-to', it is possible to create a comment if the target of the webmention has comments enabled.<br />You have to create an entity reference field on your comment type which points to a webmention. This module ships with a comment webmention storage field, so it's easy to add.<br />On the 'Manage display' page of the comment you can set the formatter of that entity reference field to 'Webmention'.<br />The webmention preprocess formats the text content using the 'restricted_html' content format which comes default in Drupal 8<br />Every comment is available also at comment/indieweb/cid so this URL can also be a target for a webmention. If a webmention is send to this target, a comment will be created on the node, with the target cid as the parent.<br />Also, last but not least, don't forget to set permissions to view webmentions."),
],
'indieweb.microformat.admin.settings' => [
'title' => 'Microformats',
'text' => '<p>' . t('Microformats are extensions to HTML for marking up people, organizations, events, locations, blog posts, products, reviews, resumes, recipes etc. Sites use microformats to publish a standard API that is consumed and used by search engines, aggregators, and other tools. See <a href="https://indieweb.org/microformats" target="_blank">https://indieweb.org/microformats</a> for more info. You will want to enable this if you want to publish or want other sites and readers to parse your content. The module will add classes on content, images etc. You can also add it to the markup yourself. Also read <a href="https://brid.gy/about#microformats">https://brid.gy/about#microformats</a> for details how Bridgy decides what to publish if you are using that service.<br /><br />Your homepage (at least, other pages are fine too) should also contain a h-card entry. An author block can be configured in the blocks section. Example markup:<br /><div class="indieweb-highlight-code"><div class="h-card">My name is <a class="u-url p-name" rel="me" href="/">Your name</a></div></div>') . '</p>',
],
'entity.indieweb_feed.collection' => [
'title' => 'Feeds',
'text' => t('<p>Generate feeds in Microformats2 or JF2<br />Because content can be nodes, comments etc, it isn\'t possible to use views. However, you can create multiple feeds which aggregate the content in a page and/or feed.<br />The feeds are controlled by the \'access content\' permission and all items in the HTML feed will be rendered with the \'Microformat\' view mode. You can create this view mode yourself or use the one that comes with the Microformats module</p><p>You will need feeds when:</p><ul><li>you use Bridgy: the service will look for html link headers with rel="feed" and use those pages to crawl so it knows to which content it needs to send webmentions to.</li><li>you want to allow IndieWeb readers (Monocle, Together, Indigenous) to subscribe to your content. These are alternate types which can either link to a page with microformat entries. It\'s advised to have an h-card on that page too as some parsers don\'t go to the homepage to fetch that content.</li></ul>'),
],
'indieweb.admin.micropub_settings' => [
'title' => 'Micropublishing',
'text' => '<p>' . t("Allow posting to your site. Before you can post, you need to authenticate and enable the IndieAuth Authentication API.<br />See IndieAuth to configure. More information about micropub: see <a href='https://indieweb.org/Micropub' target='_blank'>https://indieweb.org/Micropub</a>.") . '</p><p>' . t("A very good client to test is <a href='https://quill.p3k.io' target='_blank'>https://quill.p3k.io</a>. A full list is available at <a href='https://indieweb.org/Micropub/Clients'>https://indieweb.org/Micropub/Clients</a>.<br />Indigenous (iOS and Android) are also microsub readers.") . '</p><p>Even if you do not decide to use the micropub endpoint, this screen gives you a good overview what kind of content types and fields you can create which can be used for sending webmentions or read by microformat parsers.</p>',
],
'indieweb.admin.microsub_settings' => [
'title' => 'Readers',
'text' => '<p>' . t('Microsub is an early draft of a spec that provides a standardized way for clients to consume and interact with feeds collected by a server. <a href="https://indieweb.org/Microsub#Clients" target="_blank">Readers</a> are Indigenous (iOS and Android), Monocle and Together (both web) and many others to come. Servers are Aperture, Ekster etc. See <a href="https://indieweb.org/Microsub#Servers" target="_blank">https://indieweb.org/Microsub#Servers</a>. This module allows you to expose a microsub header link which can either be the built-in microsub server or set to an external service.<br /><br />Want to follow Twitter in your reader? Checkout <a href="https://granary.io" target="_blank">https://granary.io</a>!') . '</p>',
],
'indieweb.admin.microsub_channels' => [
'title' => 'Channels and sources',
'text' => '<p>Configure your channels and sources for the built-in Microsub server. In case the server is not enabled, no items will be fetched.',
],
'indieweb.admin.indieauth_settings' => [
'title' => 'IndieAuth',
'text' => '<p>' . t('IndieAuth is a way to use your own domain name to sign in to websites. Indieauth.com is a hosted service that does this for you and also adds Authentication API. It works by linking your website to one or more authentication providers such as Twitter or Google (RelMeAuth), then entering your domain name in the login form on websites that support IndieAuth. Indielogin.com and Indieauth.com is open source so you can also host the service yourself.<br /><br />The easy way is to add rel="me" links on your homepage which point to your social media accounts and on each of those services adding a link back to your home page. An author block is available which allows you to add rel="me" links in the note textarea. They can even be hidden. e.g.<div class="indieweb-highlight-code"><a href="https://twitter.com/swentel" target="_blank" title="Twitter" rel="me"></a></div><br />You can also use a PGP key if you don\'t want to use a third party service. See <a href="https://indieauth.com/setup" target="_blank">https://indieauth.com/setup</a> for full details.') . '</p><p>You can also use the built-in auth and token endpoints and authorize with a Drupal user.</p>',
],
'indieweb.admin.context_settings' => [
'title' => 'Post context',
'text' => '<p>' . t('When you create a post with a link which is a reply, like, repost or bookmark of an external post, you can fetch content from that URL so you can render more context.<br />You can also enable fetching of contexts on microsub items when you use the built-in microsub server.<br /><br />To enable this feature for node types, go to the node type settings screen and select a link field. Then on the manage display pages, add the post context field to the display. For microsub items, you can configure this per source.<br />Note: post contexts only work right now if the site for which you want to get the context supports microformats.') . '</p>'
],
'indieweb.admin.cache_settings' => [
'title' => 'Media cache',
'text' => '<p>' . t('When using the built-in webmention or microsub endpoint, a lot of file urls are stored to external images. If you enable the Imagecache external module, the files are downloaded so they are cached locally. Use even more caching power by installing the CDN module.') . '</p>'
],
'indieweb.admin.contact_settings' => [
'title' => 'Contacts',
'text' => '<p>' . t('Stores contacts optionally on incoming webmentions. Contacts can be managed at admin/content/contacts.') . '</p>'
],
'indieweb.admin.websub_settings' => [
'title' => 'WebSub',
'text' => '<p>' . t('Allows to notify hubs when you publish content. You can subscribe to WebSub enabled feeds in all Microsub sources.') . '</p>'
],
'indieweb.fediverse' => [
'title' => 'Fediverse',
'text' => 'Check the README file that comes with this module to know how to setup your site with the Fediverse via Bridgy fed.',
],
];
if ($route_name == 'help.page.indieweb') {
$output = '';
foreach ($help as $item) {
$output .= '<h3>' . $item['title'] . '</h3>';
$output .= $item['text'];
}
return $output;
}
elseif (isset($help[$route_name])) {
return $help[$route_name]['text'];
}
}
/**
* Generates a machine name from a url.
*
* @param $url
*
* @return string
*/
function indieweb_generate_machine_name_from_url($url) {
return 'indieweb_' . str_replace(['https://', 'http://', '/', '-', '.'], '', $url);
}
/**
* Returns the path without the hostname from a URL.
*
* @param $url
*
* @return string $path
* The path.
*/
function indieweb_get_path($url) {
$path = trim(parse_url($url, PHP_URL_PATH));
if (empty($path)) {
$path = "/";
}
return $path;
}