Show micropub error descriptions
[tt-rss-micropub.git] / commentform.phtml
index f6282c913aef0f5a86c19f970186839bdd9cc41d..d1ffd8275ed3229c9cd7d1404cc79c09e9452134 100644 (file)
@@ -1,26 +1,77 @@
-<div class="form">
- <h2>Reply to this post</h2>
- <form method="post" action="backend.php">
-  <input type="hidden" name="op" value="pluginhandler"/>
-  <input type="hidden" name="plugin" value="micropub"/>
-  <input type="hidden" name="method" value="action"/>
-  <input type="hidden" name="mode"   value="post"/>
-
-  <input type="hidden" name="replyTo" value="<?= htmlspecialchars($article['link']) ?>"/>
-  <label for="micropub-me">Identity:</label>
-  <select id="micropub-me" name="me" size="1">
-   <?php foreach ($accounts as $url) { ?>
-    <option value="<?= htmlspecialchars($url) ?>"><?= htmlspecialchars($url) ?></option>
-   <?php } ?>
-  </select><br/>
-  <textarea name="content" rows="4" cols="60"></textarea><br/>
-  <button type="submit">Post comment</button>
+<h2>Reply to this post</h2>
+<div class="postReply" id="postReply">
+ <form method="post" action="backend.php" id="postReplyForm"
+       dojoType="dijit.form.Form">
+  <script type="dojo/method" event="onSubmit" args="evt">
+  evt.preventDefault();
+  if (this.validate()) {
+      notify_progress('Sending reply...', true);
+
+      new Ajax.Request('backend.php', {
+          parameters: dojo.objectToQuery(this.getValues()),
+          onSuccess: function(transport) {
+              notify_info(transport.responseJSON.message);
+              $('postReplyUrl').writeAttribute(
+                  'href', transport.responseJSON.location
+              );
+              $('postReplyUrl').innerHTML = transport.responseJSON.location;
+              //Effect.Shrink('postReply');
+              //Effect.Grow('postReplySuccess');
+              $('postReply').hide();
+              $('postReplySuccess').show();
+          },
+          onFailure: function(transport) {
+              notify_error(transport.responseText);
+          }
+      });
+  }
+  </script>
+
+  <?php print_hidden('op', 'pluginhandler'); ?>
+  <?php print_hidden('plugin', 'micropub'); ?>
+  <?php print_hidden('method', 'action'); ?>
+  <?php print_hidden('mode', 'post'); ?>
+  <input name="action" value="" id="mpaction"
+         dojoType="dijit.form.TextBox" style="display: none"/>
+
+  <?php print_hidden('postUrl', htmlspecialchars($article['link'])); ?>
+
+  <div style="text-align: right">
+   <button type="submit" name="action"
+     onclick="dijit.byId('mpaction').set('value',this.value);"
+     value="bookmark">🔖 Bookmark</button>
+   <button type="submit" name="action"
+     onclick="dijit.byId('mpaction').set('value',this.value);"
+     value="like">♥ Like</button>
+  </div>
+
+  <textarea name="content" rows="4" cols="60"
+            style="box-sizing: border-box; width:100%; height: auto"
+            dojoType="dijit.form.SimpleTextarea"
+   ></textarea><br/>
+
+  <?php if (count($accounts) == 1) { ?>
+   <?php print_hidden('me', htmlspecialchars(reset($accounts))); ?>
+  <?php } else { ?>
+   <label for="micropub-me">Identity:</label>
+   <?php print_select('micropub-me', $defaultAccount, $accountUrls,
+     'dojoType="dijit.form.Select" size="1"', 'me'); ?>
+   <br/>
+  <?php } ?>
+
+  <button type="submit" name="action"
+    onclick="dijit.byId('mpaction').set('value',this.value);"
+    value="comment">Post comment</button>
  </form>
  </form>
+
+ <div class="reply" style="text-align: right">
+  or
+  <a href="<?= htmlspecialchars($quillUrl) ?>" class="mpbutton dijitButton" target="_blank">
+   Reply with Quill
+  </a>
+ </div>
 </div>
 
 </div>
 
-<div class="reply" style="text-align: right">
- or 
- <a href="<?= htmlspecialchars($quillUrl) ?>" class="mpbutton dijitButton" target="_blank">
-  Reply with Quill
- </a>
+<div id="postReplySuccess" class="alert alert-success" style="display:none">
+ Post created at <a id="postReplyUrl" href="#"></a>.
 </div>
 </div>