Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasott committed Jan 6, 2017
1 parent 43c2bd8 commit 0d85d6b
Show file tree
Hide file tree
Showing 12 changed files with 864 additions and 351 deletions.
62 changes: 45 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Webmention Plugin for Craft CMS

This plugin provides a [Webmention](https://www.w3.org/TR/webmention/) endpoint for [Craft CMS](https://craftcms.com).
This plugin provides a [Webmention](https://www.w3.org/TR/webmention/) endpoint for [Craft CMS](https://craftcms.com) and allows for sending Webmentions to other sites.

## Installation

Expand All @@ -11,8 +11,9 @@ This plugin provides a [Webmention](https://www.w3.org/TR/webmention/) endpoint

## Configuration

### Webmention endpoint
In order to receive Webmentions, the Webmention endpoint for your site needs to be discoverable by the server sending the Webmention. So you will need to add the following line in the <head>` section of your main layout template:

## Receiving Webmentions: The Webmention endpoint
In order to receive Webmentions, the Webmention endpoint of your site needs to be discoverable by the server sending the Webmention. So you will need to add the following line in the `<head>` section of your main layout template:

```
<link rel="webmention" href="{{ craft.webmention.endpointUrl }}" />
Expand Down Expand Up @@ -40,6 +41,23 @@ Simply use this helper:
{{ craft.webmention.webmentionForm(craft.request.url) }}
```

## Sending Webmentions
Once installed, your Craft site will send Webmentions to other sites. On every save of a published entry, the plugin scans the complete entry for any occurrences of URLs and then sends Webmentions to the corresponding Webmention endpoints.

### Sending Webmentions for certain entry types only
By default, Webmentions are sent for all entry types but you can also restrict this to certain entry types. Please make sure to go to the settings page of the plugin and select for which entry types Webmentions should be sent.

### Switching Webmentions on/off for individual entries
There may be times you want to disable the Webmentions sending functionality on a per-entry basis. This can be accomlished by adding a new “Webmention Switch” field to the field layout of an Entry Type.

![Screenshot showing the creation of a new field](/webmention/resources/screenshot-craft-webmention-create-new-field.jpg?raw=true)

You are now able to switch Webmention sending on or off for individual entries!

![Screenshot of the new field in the control panel](/webmention/resources/screenshot-craft-webmention-field.jpg?raw=true)

**This setting overrides the Entry Type-specific settings from the settings page.** So if you, for example, disable Webmentions for an Entry Type, you can still send them for individual entries by installing the magic switch. ;)

## Craft Plugin Settings

The Webmention plugin comes with a settings page for the Craft backend. You can change the following options:
Expand All @@ -61,6 +79,9 @@ The plugin saves user photos (avatars) for incoming Webmentions for better perfo
*Note: For now, this will create a new subfolder in your default assets folder. So there has to be at least one asset source defined! ;)*
Also, if you change this value, avatars that have been stored before won't be moved to the new path.

* **Sections and Entry Types**
Lets you select all Sections and Entry Types for which you want to send Webmentions. When new sections or Entry Types are added, they are set to “send Webmentions” by default.

## Features

### Receiving Webmentions
Expand Down Expand Up @@ -95,15 +116,22 @@ If you don't use Brid.gy you can easily deactivate the parsing in the plugin set
### HTTP Responses

The Webmention plugin validates and processes the request and then returns HTTP status codes for certain errors or the successful processing of the Webmention:
* If the URLs provided for `source` and `target` do not match an http(s) scheme, a **400 Bad Request** status code is returned.
* If the specified target URL is not found, a **400 Bad Request** status code is returned.
* Also, if the provided `source` is not linking back to `target`, the answer will be a resounding **400 Bad Request**!
* On success, the plugin responds with a status of **200 OK**.

- If the URLs provided for `source` and `target` do not match an http(s) scheme, a **400 Bad Request** status code is returned.
- If the specified target URL is not found, a **400 Bad Request** status code is returned.
- Also, if the provided `source` is not linking back to `target`, the answer will be a resounding **400 Bad Request**!
- On success, the plugin responds with a status of **200 OK**.

**Note: Currently, the plugin does not process the Webmention verification asynchronously.**

## Changelog

### 0.3.0

- Webmention sending functionality implemented
- Setting added: Entry Types (for Webmention sending)
- New “Webmention Switch” field type

### 0.2.0

- Webmentions are now stored as Craft elements (ElementType: `Webmention_webmention`)
Expand All @@ -112,21 +140,21 @@ The Webmention plugin validates and processes the request and then returns HTTP

### 0.1.0

* First version
- First version

## Roadmap
* Add Webmention sending functionality
* Process Webmentions asynchronously
* Provide an easy way to change how Webmentions are displayed (e. g. grouping y/n)
*
- Process Webmentions asynchronously
- Provide an easy way to change how Webmentions are displayed (e. g. grouping y/n)
-

## Thank You!
Thanks to everyone who helped me setting this up:
* [Aaron Parecki](https://aaronparecki.com/) (@aaronpk) for support and feedback – and also for the great work he does related to Webmention.
* [Bastian Allgeier](http://bastianallgeier.com) (@bastianallgeier) for allowing me to get highly inspired by his [Kirby Webmentions Plugin](https://github.com/bastianallgeier/kirby-webmentions)
* [Tom Arnold](https://www.webrocker.de/) (@webrocker) for relentlessly sending test Webmentions. ;)
* [Jeremy Keith](https://adactio.com) (@adactio) for the feedback and also for giving the initial spark.
* Everyone at the IndieWebCamp Düsseldorf 2016 and in the IndieWeb Community
[Jason Garber](https://sixtwothree.org/) (@jgarber) for his [webmention client plugin](https://github.com/jgarber623/craft-webmention-client) and the kind permission to reuse parts of the code when implementing the sending functionality.
- [Aaron Parecki](https://aaronparecki.com/) (@aaronpk) for support and feedback – and also for the great work he does related to Webmention.
- [Bastian Allgeier](http://bastianallgeier.com) (@bastianallgeier) for allowing me to get highly inspired by his [Kirby Webmentions Plugin](https://github.com/bastianallgeier/kirby-webmentions)
- [Tom Arnold](https://www.webrocker.de/) (@webrocker) for relentlessly sending test Webmentions. ;) Also for feedback on Webmention sending settings.
- [Jeremy Keith](https://adactio.com) (@adactio) for the feedback and also for giving the initial spark.
- Everyone at the IndieWebCamps Düsseldorf and Berlin 2016 and in the IndieWeb Community!

## License

Expand Down
29 changes: 28 additions & 1 deletion webmention/WebmentionPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ function init()
{
// Require dependencies (composer)
require CRAFT_PLUGINS_PATH.'/webmention/vendor/autoload.php';

craft()->on('entries.saveEntry', function(Event $event) {
craft()->webmention->onSaveEntry($event);
});

# sections.onDeleteSection
craft()->on('sections.onDeleteSection', function(Event $event) {
craft()->webmention->syncEntryTypes();
});
# sections.onSaveSection
craft()->on('sections.onSaveSection', function(Event $event) {
craft()->webmention->syncEntryTypes();
});
# sections.onSaveEntryType
craft()->on('sections.onSaveEntryType', function(Event $event) {
craft()->webmention->syncEntryTypes();
});
}

public function getName()
Expand Down Expand Up @@ -54,18 +71,28 @@ public function registerSiteRoutes()
}
protected function defineSettings()
{
$entryTypes = [];

foreach(craft()->sections->getAllSections() as $section) {

foreach($section->getEntryTypes() as $entryType) {
$entryTypes[$entryType->handle] = ['checked' => true, 'label' => $entryType->name, 'handle' => $entryType->handle];
}
}

// Define Plugin Settings for the CP
return array(
'layout' => array(AttributeType::String, 'required' => false, 'default' => '_layout'),
'endpointSlug' => array( AttributeType::String, 'label' => 'Webmention Endpoint Route (Slug)', 'default' => 'webmention' ),
'maxTextLength' => array( AttributeType::String, 'label' => 'Maximum length for Webmention text', 'default' => '420' ),
'useBridgy' => array( AttributeType::Bool, 'default' => true ),
'avatarPath' => array( AttributeType::String, 'label' => 'Avatar storage path', 'default' => 'avatars/' ),
'entryTypes' => array( AttributeType::Mixed, 'default' => $entryTypes )
);
}
public function getSettingsUrl()
{
return 'webmention';
return 'webmention/settings';
}
public function onBeforeInstall()
{
Expand Down
Loading

0 comments on commit 0d85d6b

Please sign in to comment.