You're viewing old version number 61. - Current version

15 min

Add webmention client code to Junco

https://github.com/indieweb/php-mf2
generic microformats-2 parser. It doesn’t have a hard-coded list of all the different microformats, just a set of procedures to handle different property types (e.g. p- for plaintext, u- for URL, etc). This allows for a very small and maintainable parser.
https://github.com/indieweb/mention-client-php
Client library for sending webmention and pingback notifications.

https://github.com/converspace/webmention/issues/9
http://waterpigs.co.uk/notes?tagged=webmention
http://waterpigs.co.uk/notes?tagged=reply
http://microformats.org/wiki/h-entry
http://indiewebcamp.com/comments-presentation#How_to_markup

I publish microformats2 with classic mf fallback. Also consume lots of microformats data and built some tools to help others do the same:
http://github.com/indieweb/php-mf2
http://github.com/barnabywalters/php-mf-cleaner

Dvlp to-dos (3oct2013)

  • if webmention posted manually with the form, then return to user as happens now by displaying the page of replies.
  • if webmention posted programmatically, then return status codes.
  • "If the WebMention request was successful, the server MUST reply with an HTTP 202 Accepted" - http://webmention.org
    • return JSON responses:
      • "result": "WebMention was successful"
      • "error": "no_link_found",
      • "error_description": "The source URI does not contain a link to the target URI"
  • [X] "WebMention receivers SHOULD moderate WebMentions, and if a link is displayed back to the source, SHOULD link to source with rel="nofollow" to prevent spam." - http://webmention.org
  • investigate indieweb comments
    • why comments and webmentions?
  • [X] same source post URL can be posted only once to the target.
  • [X] create new get_blog_post subroutine check for target.
  • [X] webmentions can only be posted when the blog post contains the blog_username tag.
  • [X] add the webmention=no command to disable the option for a blog post.
  • [X] currently, webmentions will remain unavailable for microblog posts.
  • [X] look for the e-content microformat property on html5 section tag.

Microformats

using:
http://search.cpan.org/~gaas/HTML-Parser-3.71/lib/HTML/TokeParser.pm

https://eschnou.com/entry/testing-indieweb-federation-with-waterpigscouk-aaronpareckicom-and--62-24908.html

To get a webmention (source) reply post to appear at the target website, wrap the source post with an h-entry microformat
<div class="h-entry">
article post
</div>
another way:
<article role="article" class="h-as-note h-entry hentry note-single">
<section class="e-content">
article text
</section>
</article>
or this way:
<article class="entry h-entry entry-single flow wf">
<section class="e-content">
article text
</section>
</article>
from the microformats website:
<article class="h-entry">
  <h1 class="p-name">Microformats are amazing</h1>
  <p>Published by <a class="p-author h-card">W. Developer</a>
     on <time class="dt-published" datetime="2013-06-13 12:00:00">13<sup>th</sup> June 2013</time>
 
  <p class="p-summary">In which I extoll the virtues of using microformats.</p>
 
  <div class="e-content">
    <p>Blah blah blah</p>
  </div>
</article>

http://adactio.com/journal/6495/
I’m using that to check the cURLed source for any responses that have been marked up using h-entry. That’s one of the microformats 2 vocabularies—a much simpler way of writing structured content with microformats. Aaron, Amber, and Barnaby all sent responses that were marked up with h-entry so now their responses appear in full.

http://microformats.org/wiki/microformats2
http://microformats.org/wiki/h-entry


Access these tags and links:

update: 21Sep2013 - focus on these links initially:

Add to header.tmpl:

<meta name="author" content="Jeremy Keith" />
<link rel="webmention" href="http://adactio.com/webmention.php" />


old link list:

"The ability for one webpage to let another know the first has linked to the second is a vital indieweb building block.
The key mention technology for the indieweb is: webmention"

http://gist.github.com/adactio/6575229 - "The form I put at the end of every blog post I make so that you can ping my webmention endpoint with your response."

<form method="post" action="/webmention.php">
<p>Have you published a response to this?
<label for="webmention-source">Let me know the <abbr title="Uniform Resource Locator">URL</abbr></label>:
</p>
<input type="url" name="source" id="webmention-source">
<input type="hidden" name="target" value="http://adactio.com/journal/6495/">
<input type="submit" value="Ping!">
</form>

Sep 15, 2013 - Parsing webmentions

Understanding

I'm still trying to understand webmentions and pingbacks.

I guess that I viewed this more as a remote-commenting function.

  • Blogger A creates a post
  • Blogger B would like to "comment" on Blogger A's post, but A does not allow comments.
  • Blogger B can create a post that is responding to A, but unless B contacts A through e-mail or some other means, A will be unaware of B's blog response.
  • But if Blogger A supported some kind of remote commenting system, and maybe that could be webmention, then Blogger B could create a blog post and include the URL to Blogger A's post.
  • at the bottom of Blogger A's post would be Blogger B's blog post response title, which would be a link to Blogger B's reply post.
  • Blogger B can only create one blog post response for each blog post by A.

The above would work and display similar to my reply as a blog post function in my Kestrel code that was removed when I started over with the Junco codebase.

Maybe a remote comment procedure would send to the original blog post app:

  • reply blog post URL
  • reply blog post title
  • reply blog post author name/username that links to Blogger B's home page
  • reply blog post creation/published date (date sent to Blogger A)
  • an optional brief description or intro to the blog post, limited to x-number words or characters (Blogger A's software could set the char or word limit or not display the description at all)

Make it a POST request from Blogger B to Blogger A, and encapsulate the above info in JSON.

Could still be abused by spammers and trolls, unless Blogger A establishes a white list of users permitted to create blog replies. Blogger B would have to seek permission from Blogger A to be on the whitelist.

Webmention Protocol Summary

From http://indiewebcamp.com/webmention

Assuming Aaron's blog supports receiving webmentions, and Barnaby's blog supports sending webmentions:

  1. User Aaron posts a blog post on his blog
  2. User Barnaby writes post on his blog that links to Aaron's post.
  3. After publishing the post (i.e. it has a URL), Barnaby's server notices this link as part of the publishing process
  4. Barnaby's server does webmention discovery on Aaron's post to find its webmention endpoint (if not found, process stops)
  5. Barnaby's server sends a webmention to Aaron's post's webmention endpoint with
    source set to Barnaby's post's permalink
    target set to Aaron's post's permalink.
  6. Aaron's server receives the webmention
  7. Aaron's server verifies that target (after following redirects) in the webmention is a valid permalink on Aaron's blog (if not, processing stops)
  8. Aaron's server verifies that the source (when retrieved, after following redirects) in the webmention contains a hyperlink to the target (if not, processing stops)

Unmentioned but implied (and vaguely mentioned in the pingback spec):

  • Aaron's server displays the information about Barnaby's post somewhere on Aaron's post.

Own Your Comments
Proposed by Aaron Parecki

This session is about IndieWeb Commenting and feedback systems.
What does it mean to post a comment in an indie web? As the author of a comment, you should own and control it, most likely you should post it on your own site. But we still want to have the benefits of centralized commenting systems like seeing a list of all comments left on a post, filtering spam comments, etc.

One way to handle comments is through the pingback or trackback protocols, both of which are widely implemented in many major blogging platforms. We can discuss the merits and drawbacks of each, and other possible solutions. A workshop session could involve implementing trackbacks/pingbacks on your own site, or implementing a new mechanism for using them.

Also see: backfeed

Junco support 21Sep2013

Should the remote webmention information be posted in the content table as a microblog post?

If so, what about author id info? Create a generic "Webmention" account at JotHut?

Would I need to add one or more columns to the content database table to support webmentions?

If the info was stored as a microblog post, then in theory, I could still click the "replies" link at the top of the site.

Since at the moment, I do not plan to allow others to create accounts at JotHut, the "replies" link at the top of the site is meaningless. I have been using the reply feature on my microblog posts to add additional information or notes. I did not expect to use the reply mechanism for my own microblog posts, but it's a handy tool for quick-hitting notes that should are associated in a common thread.

If I don't store webmentions in the content table, then I would need to add an additional link to the top of the site that would display the list of recent remote replies.

The webmention table may need to store:

  • id
  • target = URL for my post at Jot Hut
  • source = remote URL for the response to my post
  • date = when the response was submitted to Jot Hut (not the date that the remote response or webmention was created by another person)
  • status = 'o' open for display

I should provide the ability to hide webmentions from displaying under my posts.

And I should add a blacklist of sites prohibited from creating a webmention.

The webmentions would not display by default under my posts at Jot Hut. I would treat this the same way that I do now with the built-in reply mechanism, which is to display a link, such as: webmentions: 8 that when clicked will show all the replies. Example:

http://jothut.com/cgi-bin/junco.pl/microblogpost/3904 - notes taken while watching the Browns-Dolphins game.

The above post displays something like this:


Miami, 2nd half, opening poss, 3rd and 11 own 16, pass inc. 3 and out. Punt. Ball downed at Clev 22. Good punter for Miami. #browns.

From JR's : micro blog
created on Sep 08, 2013 at 02:48:35 PM - # - replies: 95
reply


The "replies: 95" link must be clicked to display the replies for the post. That's different from a normal commenting system on a blog or message board, but webmentions is a different response mechanism.

With Jot Hut, I prefer to keep the display page for a blog or microblog focused on the content that I create. One additional click is not a hardship, in my opinion.

regex

http://www.perlmonks.org/?node_id=507660

Here is the regex to match the tag with attributes value.
m#<([^">]+(?:"[^"]+")*[^>]+)>#

another comment

m#
<             ## start with <
(             ## group start 
[^">]+        ## text but Not match " and >
(?:"[^"]+")*  ## if " found, match till end quote found. Its optional
[^>]+         ## text but Not match and >
)             ## group end 
>             ## End with >
#

http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html

Reply To - Comments

https://eschnou.com/entry/testing-indieweb-federation-with-waterpigscouk-aaronpareckicom-and--62-24908.html

http://indiewebcamp.com/comment

http://microformats.org/wiki/comment-brainstorming

 <div class="entry-content e-content" property="schema:text sioc:content">
<p>Testing, testing, <a href="http://eschnou.com/entry/testing-indieweb-federation-with-waterpigscouk-aaronpareckicom-and--62-24908.html" rel="in-reply-to" class="u-in-reply-to">is this thing on?</a></p>
</div>

View this example reply post that appears in the same above thread at eschnou.com.
http://www.sandeep.io/32

Automate Webmentions

For webmention: If I want to automate my Junco code so that my source post (reply) is sent to the target, then I should include this class="u-in-reply-to" on the target URL when it's included in my source (reply) post.

When a microblog (note) or blog post (article) is created in Junco, the app would search for class="u-in-reply-to" within anchor tags, which would be targets. If found, then Junco would do a "get" on that target URL, read through the HTML, and search meta or link tags for a webmention URL program.

If the target has a webmention program, then Junco would send a POST request to that target's webmention program. The POST params would include URLs for target (the post that I'm replying to) and source (my reply post).

Once the POST request has been made, the target webmention app would return a status code, so that Junco can determine if success or failure or something else. Doesn't matter too much, since the source post still gets posted within the Junco app.

The target code would process the Junco post request, and add my source (reply) post to the thread or comment section of the target post. And if my source post contained h-entry and e-content info, then it's possible that some or all of my post would appear in the target's comment section.

A lot depends upon how the target app processes a webmention. Maybe after the Junco post request, and the target app has verified my source post, then my source post would go into a moderation queue and would not appear immediately in the comments section of the target page.

The target app may only display the source URL in the target's comment section and ignore the source's h-entry info.

The target may only display a snippet of the source's h-entry info, which is what I'm doing within the Junco app when the Junco app is receiving a webmention POST request (the Junco app is the target.)

If the target system does not supported automated webmentions (the target does not contain the webmentioni app in the meta or link tags), then maybe the target page contains the HTML form to allow a user to submit manually the source URL, which is what I'm doing now within Junco as of Oct 3, 2013.

Plus maybe the source software does not support auotmated webmentions. The source system may not scan its own source posts for links with the u-in-reply-to in order to send a POST request to the target. This is the current status for Junco as of Oct 3, 2013.

I'd like to automate Junco to send and receive webmention POST requests.

And I want to continue to supply the HTML form for manually submitting a webmention to a post within Junco.

If Junco was automated to make webmentions to the target, then the source post would include the target's URL, of course. For blog source posts, it would be easy to add the "in-reply-to" to the target's URL. For microblog source posts, I would need to add a new feature:

in-reply-to:http://jothut.com/cgi-bin/d16augjunco.pl/blogpost/19

The Junco code would convert the URL to a link with the in-reply-to for the formatted markup. The link would be clickable when the displayed in Junco. And then Junco would automate the webmention POST to the target per above.

To keep it simple, I could also use the above proposed feature in blog posts too, but if I did not want to display the entire URL but only some link text, then the anchor tag or the Textile or Markdown anchor markup would contain the class="u-in-reply-to" that I would add manually.

Indieweb Comments How-To

From: http://indiewebcamp.com/comment

How To

Make a comment

How to publish an indieweb comment replying to an original post

Write a post (note/article/comment) on your own site

Link to the original with rel="in-reply-to"

If you are using the h-entry microformat to mark up your comment (you should), add class="u-in-reply-to" to the link as well

Send a pingback/webmention from your server to the original's server

Ideally your server/software should automatically do the (3)
pingback/webmention for all links in your post.

Twitter

Some explanation of how this might all work:
https://github.com/barnabywalters/IndieWeb-Reply-Browser-Extension
https://github.com/barnabywalters/own-your-comments

http://indiewebcamp.com/Twitter

In short, you have to use Twitter's snowflake API to POSSE posts to Twitter.

http://indiewebcamp.com/POSSE

http://waterpigs.co.uk/notes/4SFEn4/
Have you come across indiewebcamp.com at all, especially the work we’re doing on cross-site replying, webmentions and reply-contexts? E.G. this post is a reply on my own site to one of your tweets :)
http://indiewebcamp.com/reply same as http://indiewebcamp.com/comment - whew, that's good.
http://indiewebcamp.com/webmention
http://indiewebcamp.com/reply-context

http://trailed.io/about

Curl testing

From the command prompt

http://indiewebcamp.com/webmention#How_to_Test_Webmentions

send the webmention:

curl -i -d "source=$your_url&amp;target=$target_url" $targets_webmention_endpoint

Junco example:
curl -i -d "source=http://jothut.com/cgi-bin/app.pl/microblogpost/122&target=http://jothut.com/cgi-bin/app.pl/blogpost/19" http://jothut.com/cgi-bin/app.pl/webmention

Since the webmention was already posted, running the curl again returns:

HTTP/1.1 404 Bad Request
Date: Fri, 04 Oct 2013 17:51:28 GMT
Server: Apache
Transfer-Encoding: chunked
Content-Type: application/json

{
  "error": "already_registered",
  "error_description": "The specified WebMention has already been registered."
}

Junco code automating webmention post

When creating/updating a post in Junco, the app searches for:

rel="in-reply-to" class="u-in-reply-to"

within the anchor tag, and then grabs the target URL within that anchor tag, searched for the webmention endpoint within the page located at the target URL, and then automates a post.

The Junco app would already know the source URL after a create/update of a post.

Command prompt script.

#!/usr/bin/perl -wT

use strict;
use warnings;
$|++;
use lib '/home/Junco/lib';
use MIME::Base64;
use REST::Client;

# set set up some defaults:
my $domain   = 'jothut.com';
my $function = 'webmention';
my $prog = 'app.pl';

my $headers = {
    'Content-type' => 'application/x-www-form-urlencoded'
};

# set up a REST session
my $rest = REST::Client->new( {
           host => "http://$domain/cgi-bin/$prog",
} );

# then we have to url encode the params that we want in the body
my $pdata = {
    'source'        => 'http://jothut.com/cgi-bin/app.pl/microblogpost/143',
    'target'          => 'http://jothut.com/cgi-bin/app.pl/blogpost/19/03Oct2013/Webmention-Test-post---TARGET---1oct2013'
};
my $params = $rest->buildQuery( $pdata );

# but buildQuery() prepends a '?' so we strip that out
$params =~ s/\?//;

# then send the request:
# POST requests have 3 args: URL, BODY, HEADERS
$rest->POST( "/$function" , $params , $headers );
print $rest->responseContent() . "\n";

#junco - #juncotodo - #indieweb - #comments

From JR's : articles
2724 words - 19211 chars - 15 min read
created on
updated on - #
source - versions

Related articles
In Progress - Add webmention client code to Junco - Oct 21, 2013
Syndicate JotHut.com posts to Twitter using the share button - Nov 01, 2013
Creating a Webmention blog reply post at JotHut - Oct 23, 2013
Webmention info to read again - Apr 02, 2014
Webmention.io and IndiAuth - Dec 18, 2014
more >>



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: Nov 15, 2024 - 5:58 a.m. EST