autoregister by visiting tt-rss preferences
[tt-rss-subtome.git] / init.php
index 4f624ff18d894c7246e946504d9bf0ff263b0e57..2ccb4e4c64a7def863a21425dc269750228d1627 100644 (file)
--- a/init.php
+++ b/init.php
@@ -15,10 +15,10 @@ class SubToMe extends Plugin
     public function about()
     {
         return array(
-            0.1,
-            'Add TT-RSS to SubToMe.com',
+            0.2,
+            'Add Tiny Tiny RSS to SubToMe.com',
             'cweiske',
-            false//not a system plugin
+            false
         );
     }
     
@@ -32,55 +32,25 @@ class SubToMe extends Plugin
         if ($args != "prefPrefs") {
             return;
         }
+        $name = 'Tiny Tiny RSS @ '
+            . parse_url(get_self_url_prefix(), PHP_URL_HOST);
 
         $ttSubscribeUrl = get_self_url_prefix()
             . '/public.php?op=subscribe&feed_url={url}';
-
         $regUrl = 'https://www.subtome.com/register-no-ui.html'
-            . '?name=##NAME##'
+            . '?name=' . urlencode($name)
             . '&url=' . urlencode($ttSubscribeUrl);
+        $hRegUrl = htmlspecialchars($regUrl);
+
         $jRegUrl = json_encode($regUrl);
 
         echo <<<HTM
 <div dojoType="dijit.layout.AccordionPane" title="SubToMe">
- <form dojoType="dijit.form.Form" id="subtome_reg_form">
-  <script type="dojo/method" event="onSubmit" args="evt">
-    evt.preventDefault();
-    if (this.validate()) {
-        var regUrl = $jRegUrl.replace(
-            '##NAME##', document.getElementById("subtome_name").value
-        );
-        var me = document.getElementById('subtome_reg_form');
-        me.insertAdjacentHTML(
-            'afterend',
-            '<iframe style="display:none;" src="' + regUrl + '" />'
-        );
-        document.getElementById("subtome_done").style = "";
-    }
-  </script>
-
-  <table width="100%" class="prefPrefsList">
-   <tr><td colspan="2"><h3>Configure SubToMe</h3></td></tr>
-   <tr>
-    <td width="40%" class="prefName">
-     <label for="subtome_name">Name</label>
-    </td>
-    <td class="prefValue">
-     <input name="subtome_name" id="subtome_name" type="text" size="20" value="Tiny Tiny RSS" dojoType="dijit.form.TextBox"/>
-    </td>
-   </tr>
-  </table>
-  <p>
-   <input type="submit" value="Add TT-RSS to SubToMe.com"/>
-   <span id="subtome_done" style="display: none">
-    <input type="checkbox" checked="checked" value="1"
-           dojoType="dijit.form.CheckBox" />
-    Registration finished!
-   </span>
-  </p>
- </form>
-
- <h3>Testing</h3>
+ <iframe style="display:none;" src="$hRegUrl"></iframe>
+ <p>
+  Tiny Tiny RSS has been added to subtome.com automatically
+  by visiting the Tiny Tiny RSS preferences.
+ </p>
  <p>
   Try the "Subscribe" button on
   <a href="http://blog.superfeedr.com/">blog.superfeedr.com</a>.