Skip to content

Commit

Permalink
add webmention form to submit page
Browse files Browse the repository at this point in the history
for #22
  • Loading branch information
aaronpk committed Jan 30, 2017
1 parent e199c57 commit 4272930
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 40 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
@@ -1,7 +1,7 @@
BSD License
-----------

Copyright (c) 2013 by Aaron Parecki. All rights reserved.
Copyright (c) 2013-2017 by Aaron Parecki. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
4 changes: 2 additions & 2 deletions Locale/de/default.po
Expand Up @@ -107,8 +107,8 @@ msgid "Send a Webmention"
msgstr "Sende einen Webmention"

#: /views/submit.php:22
msgid "Send a {0} notification to let IndieNews know about your post. When the mention is received, IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "Sende einen {0}, damit die IndieNews-Site von deinem Artikel erfährt. Sobald IndieNews den Mention empfängt, wird IndieNews den Artikel von deiner Seite laden und nach dem {1}-Markup suchen, um den Titel und Autoren-Namen zu finden."
msgid "IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "IndieNews wird den Artikel von deiner Seite laden und nach dem {1}-Markup suchen, um den Titel und Autoren-Namen zu finden."

#: /views/submit.php:25
msgid "Detailed instructions on how to submit a post"
Expand Down
4 changes: 2 additions & 2 deletions Locale/fr/default.po
Expand Up @@ -104,8 +104,8 @@ msgid "Send a Webmention"
msgstr "Envoyer une WebMention"

#: /views/submit.php:22
msgid "Send a {0} notification to let IndieNews know about your post. When the mention is received, IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "Envoyer une {0} notification pour faire connaître votre article à IndieNews. Quand la mention est reçue, IndieNews récupérera la page à partir de votre site et regardera le {1} marquage pour trouver le titre de l’article et l’auteur."
msgid "IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "IndieNews récupérera la page à partir de votre site et regardera le {1} marquage pour trouver le titre de l’article et l’auteur."

#: /views/submit.php:25
msgid "Detailed instructions on how to submit a post"
Expand Down
4 changes: 2 additions & 2 deletions Locale/nl/default.po
Expand Up @@ -104,8 +104,8 @@ msgid "Send a Webmention"
msgstr "Stuur een Webmention"

#: /views/submit.php:22
msgid "Send a {0} notification to let IndieNews know about your post. When the mention is received, IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "Stuur een {0} notificatie om IndieNews op de hoogte te stellen van je post. Als de Webmention ontvangen is zal IndieNews de ingestuurde pagina opvragen en naar de {1} mark-up kijken om de titel en auteur van het artikel te vinden."
msgid "IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "Als de Webmention ontvangen is zal IndieNews de ingestuurde pagina opvragen en naar de {1} mark-up kijken om de titel en auteur van het artikel te vinden."

#: /views/submit.php:25
msgid "Detailed instructions on how to submit a post"
Expand Down
4 changes: 2 additions & 2 deletions Locale/sv/default.po
Expand Up @@ -104,8 +104,8 @@ msgid "Send a Webmention"
msgstr "Skicka en WebMention"

#: /views/submit.php:22
msgid "Send a {0} notification to let IndieNews know about your post. When the mention is received, IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "Skicka en {0} notifikation för att informera IndieNews om ditt inlägg. När omnämnandet är mottaget hämtar IndieNews sidan från din sajt och letar efter {1} formatering för att hitta inläggstitel och författare."
msgid "IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author."
msgstr "När omnämnandet är mottaget hämtar IndieNews sidan från din sajt och letar efter {1} formatering för att hitta inläggstitel och författare."

#: /views/submit.php:25
msgid "Detailed instructions on how to submit a post"
Expand Down
10 changes: 10 additions & 0 deletions lib/helpers.php
Expand Up @@ -2,6 +2,16 @@
define('APP', dirname(__FILE__).'/../'); // cakephp i18n needs this
define('LANG_REGEX', '(en|sv|de|fr|nl)');

function supportedLanguages() {
return [
'en' => 'English',
'sv' => 'Svenska',
'de' => 'Deutsch',
'fr' => 'Français',
'nl' => 'Nederlands',
];
}

function getPostsForParentID($parentID) {
return ORM::for_table('posts')->raw_query('
SELECT *, GREATEST(1, TIMESTAMPDIFF(HOUR, date_submitted, NOW())) AS age
Expand Down
20 changes: 5 additions & 15 deletions views/index.php
Expand Up @@ -4,21 +4,11 @@
</div>

<div class="languages">
<div>
<a href="/en">English</a>
</div>
<div>
<a href="/sv">Svenska</a>
</div>
<div>
<a href="/de">Deutsch</a>
</div>
<div>
<a href="/fr">Français</a>
</div>
<div>
<a href="/nl">Nederlands</a>
</div>
<?php foreach(supportedLanguages() as $l=>$lang): ?>
<div>
<a href="/<?= $l ?>"><?= $lang ?></a>
</div>
<?php endforeach; ?>
</div>

<div class="row" style="margin-top: 20px;">
Expand Down
4 changes: 3 additions & 1 deletion views/submit-full.php
Expand Up @@ -42,9 +42,11 @@
<h3>3. Send a <a href="https://indieweb.org/webmention">Webmention</a></h3>
<p>If your website sends <a href="https://www.w3.org/TR/webmention/">Webmentions</a> automatically, then you don't need to worry about this step. Otherwise, follow the instructions below to send a Webmention, or just use the Webmention form available at <a href="/en/webmention">the IndieNews Webmention endpoint</a>.</p>
<h4>Example Request</h4>
<p>Make a POST request to <code>https://news.indieweb.org/webmention</code> with two parameters,
<p>Make a POST request to <code>https://news.indieweb.org/en/webmention</code> with two parameters,
<code>source</code> and <code>target</code>, where target is
<code>https://news.indieweb.org/en</code> and source is
<code>http://example.com/100</code> assuming you are submitting a page on your site with
Expand Down
29 changes: 19 additions & 10 deletions views/submit.php
@@ -1,25 +1,34 @@
<div class="hero-unit" style="padding: 40px;">
<h2>IndieNews</h2>
<p><?= __('IndieNews is a community-curated list of articles relevant to the {0}Indie Web{1}.', ['<a href="https://indieweb.org/why">', '</a>']) ?></p>
</div>

<div class="row">
<div class="span12">
<h2><?= __('Submit') ?></h2>

<p><?= __('You won\'t find a "submit" form on this site. You don\'t even need to be logged in to this site to submit a post!') ?></p>
<h2><?= __('Submit a Post') ?></h2>

<h4><?= __('Write a Post') ?></h4>

<p><?= __('Write a post on your own site, and mark it up with the Microformats markup for an {0}.', '<a href="http://microformats.org/wiki/microformats2#h-entry">h-entry</a>') ?></p>
<p><?= __('Write a post on your own site, and mark it up with the Microformats markup for an {0}.', '<a href="http://microformats.org/wiki/h-entry">h-entry</a>') ?></p>

<p><?= __('To submit someone else\'s post, create a {0} post on your site linking to it.', '<a href="https://indieweb.org/bookmark">bookmark</a>') ?></p>

<h4><?= __('Link to IndieNews') ?></h4>

<p><?= __('Somewhere on the page you are submitting, add a {0} or {1} link to {2}the IndieNews home page{3} for your language.', ['<a href="https://indieweb.org/rel-syndication">u-syndication</a>', '<a href="https://indieweb.org/u-category">u-category</a>', '<a href="/'.$this->lang.'">', '</a>']) ?></p>

<h4><?= __('Send a Webmention') ?></h4>

<p><?= __('Send a {0} notification to let IndieNews know about your post. When the mention is received, IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author.', ['<a href="https://indieweb.org/webmention">Webmention</a>', '<a href="http://microformats.org/wiki/microformats2#h-entry">h-entry</a>']) ?></p>
<p><?= __('If your website sends {0} automatically, then your post will be submitted as soon as you post it to your website! Otherwise, you can enter your post\'s URL below.', ['<a href="https://www.w3.org/TR/webmention/">Webmentions</a>']) ?>

<p><?= __('IndieNews will fetch the page from your site and look for the {1} markup to find the post title and author.', ['<a href="https://indieweb.org/webmention">Webmention</a>', '<a href="http://microformats.org/wiki/h-entry">h-entry</a>']) ?></p>

<div style="background-color: #efefef; border: 1px #ccc solid; border-radius: 4px; padding: 12px; margin-bottom: 1em;">
<form action="/<?= $this->lang ?>/webmention" method="POST" style="margin: 0;">
<div>
<label for="source"><?= __('Your Post URL') ?></label>
<input type="url" name="source">
</div>
<input type="hidden" name="target" value="<?= Config::$baseURL ?>/<?= $this->lang ?>">
<input type="hidden" name="html" value="1">
<button type="submit" class="btn"><?= __('Submit') ?></button>
</form>
</div>

<p style="border-top: 1px #ddd solid; margin-top: 20px; font-style: italic;">
<a href="/how-to-submit-a-post"><?= __('Detailed instructions on how to submit a post') ?></a>
Expand Down
14 changes: 9 additions & 5 deletions views/webmention.php
Expand Up @@ -4,25 +4,29 @@
<h2><?= __('Webmention Endpoint') ?></h2>

<div style="max-width: 600px;">
<p><?= __('Once you\'ve <a href="/how-to-submit-a-post">written a post</a> with the proper markup, you will need to send a Webmention to submit it to IndieNews. Your software should do that automatically, but you can also use the form below.') ?></p>
<p><?= __('Once you\'ve <a href="/how-to-submit-a-post">written a post</a> with the proper markup, you will need to send a Webmention to submit it to IndieNews. Your software should do that automatically if it supports {0}, but you can also use the form below.', ['<a href="https://www.w3.org/TR/webmention/">Webmention</a>']) ?></p>
</div>

<form class="form-horizontal" action="/<?= $this->lang ?>/webmention" method="POST">
<div class="control-group">
<label class="control-label" for="source">Your URL</label>
<label class="control-label" for="source"><?= __('Your Post URL') ?></label>
<div class="controls">
<input type="url" name="source" placeholder="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="source">IndieNews URL</label>
<label class="control-label" for="source"><?= __('IndieNews Page') ?></label>
<div class="controls">
<input type="url" name="target">
<select name="target">
<?php foreach(supportedLanguages() as $l=>$lang): ?>
<option value="<?= $l ?>" <?= $this->lang == $l ? ' selected="selected"' : '' ?>><?= $lang ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn">Send Webmention</button>
<button type="submit" class="btn"><?= __('Send Webmention') ?></button>
</div>
</div>
</form>
Expand Down

0 comments on commit 4272930

Please sign in to comment.