Skip to content

Commit

Permalink
Implemented fix for #41 - refactored to work with latest TT-RSS chang…
Browse files Browse the repository at this point in the history
…es (#42)

Co-authored-by: Vishal Grover <[email protected]>
  • Loading branch information
vishalg and Vishal Grover authored Mar 10, 2021
1 parent 2a533f1 commit d8e4767
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 60 deletions.
87 changes: 42 additions & 45 deletions wallabag_v2/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,52 @@ function init($host) {
function hook_prefs_tab($args) {
if ($args != "prefPrefs") return;

$w_user = $this->host->get($this, "wallabag_username");
$w_pass = $this->host->get($this, "wallabag_password");
$w_url = $this->host->get($this, "wallabag_url");
$w_cid = $this->host->get($this, "wallabag_client_id");
$w_csec = $this->host->get($this, "wallabag_client_secret");
$w_access = $this->host->get($this, "wallabag_access_token");
$w_user = $this->host->get($this, "wallabag_username");
$w_pass = $this->host->get($this, "wallabag_password");
$w_url = $this->host->get($this, "wallabag_url");
$w_cid = $this->host->get($this, "wallabag_client_id");
$w_csec = $this->host->get($this, "wallabag_client_secret");
$w_access = $this->host->get($this, "wallabag_access_token");

print "<div dojoType=\"dijit.layout.AccordionPane\"
title=\" <i class='material-icons'>share</i> ".__("Wallabag v2")."\">";
print "<br/>";
print "<form dojoType=\"dijit.form.Form\">";
?>
<div dojoType='dijit.layout.AccordionPane'
title="<i class='material-icons'>share</i> <?= __('Wallabag v2') ?>">
<br/>
<form dojoType='dijit.form.Form'>

print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
evt.preventDefault();
if (this.validate()) {
console.log(dojo.objectToQuery(this.getValues()));
new Ajax.Request('backend.php', {
parameters: dojo.objectToQuery(this.getValues()),
onComplete: function(transport) {
Notify.info(transport.responseText);
<?= \Controls\pluginhandler_tags($this, "save") ?>
<script type="dojo/method" event="onSubmit" args="evt">
evt.preventDefault();
if (this.validate()) {
Notify.progress('Saving wallabag configuration...', true);
xhr.post("backend.php", this.getValues(), (reply) => {
Notify.info(reply);
})
}
});
//this.reset();
}
</script>";
</script>

print_hidden("op", "pluginhandler");
print_hidden("method", "save");
print_hidden("plugin", "wallabag_v2");
print "<table width=\"100%\" class=\"prefPrefsList\">";
print "<tr><td width=\"40%\">".__("Wallabag URL (No trailing slash!)")."</td>";
print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" name=\"wallabag_url\" regExp='^(http|https)://.*' value=\"$w_url\"></td></tr>";
print "<tr><td width=\"40%\">".__("Wallabag Username")."</td>";
print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"wallabag_username\" regExp='\w{0,64}' value=\"$w_user\"></td></tr>";
print "<tr><td width=\"40%\">".__("Wallabag Password")."</td>";
print "<td class=\"prefValue\"><input type=\"password\" dojoType=\"dijit.form.ValidationTextBox\" name=\"wallabag_password\" regExp='.{0,64}' value=\"$w_pass\"></td></tr>";
print "<tr><td width=\"40%\">".__("Wallabag Client ID")."</td>";
print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"wallabag_client_id\" regExp='.{0,64}' value=\"$w_cid\"></td></tr>";
print "<tr><td width=\"40%\">".__("Wallabag Client Secret")."</td>";
print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"wallabag_client_secret\" regExp='.{0,64}' value=\"$w_csec\"></td></tr>";
print "</table>";
print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".__("Save")."</button>";
if($w_access == null || $w_access == false|| $w_access == "") {
print "<strong style=\"color:red;\"> Alert</strong>: No OAuth tokens in Database! Submit Username and Password to retrieve new tokens.";
} else {
print " Submit this form without a Username and Password to reset the Wallabag OAuth Tokens to a null value.";
}
print "</form>";
print "</div>"; #pane
<table width='100%' class='prefPrefsList'>
<tr><td width='40%'> <?= __("Wallabag URL (No trailing slash!)") ?></td>
<td class='prefValue'><input dojoType='dijit.form.ValidationTextBox' required='true' name='wallabag_url' regExp='^(http|https)://.*' value='<?= $w_url ?>'></td></tr>
<tr><td width='40%'><?= __("Wallabag Username") ?></td>
<td class='prefValue'><input dojoType='dijit.form.ValidationTextBox' name='wallabag_username' regExp='\w{0,64}' value='<?= $w_user ?>'></td></tr>
<tr><td width='40%'><?= __("Wallabag Password") ?></td>
<td class='prefValue'><input type='password' dojoType='dijit.form.ValidationTextBox' name='wallabag_password' regExp='.{0,64}' value='<?= $w_pass ?>'></td></tr>
<tr><td width='40%'><?= __("Wallabag Client ID") ?></td>
<td class='prefValue'><input dojoType='dijit.form.ValidationTextBox' name='wallabag_client_id' regExp='.{0,64}' value='<?= $w_cid ?>'></td></tr>
<tr><td width='40%'><?= __("Wallabag Client Secret") ?></td>
<td class='prefValue'><input dojoType='dijit.form.ValidationTextBox' name='wallabag_client_secret' regExp='.{0,64}' value='<?= $w_csec ?>'></td></tr>
</table>

<?= \Controls\submit_tag(__("Save")) ?>
<?php if($w_access == null || $w_access == false|| $w_access == "") { ?>
<strong style='color:red;'> Alert</strong>: No OAuth tokens in Database! Submit Username and Password to retrieve new tokens.
<?php } else { ?>
Submit this form without a Username and Password to reset the Wallabag OAuth Tokens to a null value.
<?php } ?>
</form>
</div>
<?php
}

function save() {
Expand Down
28 changes: 13 additions & 15 deletions wallabag_v2/wallabag_v2.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
function postArticleToWallabag(id) {
try {
Notify.progress("Saving to Wallabag …", true);
new Ajax.Request("backend.php", {
parameters: {
xhr.json("backend.php",
{
'op': 'pluginhandler',
'plugin': 'wallabag_v2',
'method': 'getwallabagInfo',
'id': encodeURIComponent(id)
},
onSuccess: function(transport) {
var ti = JSON.parse(transport.responseText);
if (ti.status) {
if (ti.status=="200") {
Notify.info("Saved to Wallabag: <em>" + ti.title + "</em>");
} else {
Notify.error("<strong>Error saving to Wallabag!</strong>: ("+ti.status+": "+ti.error+") "+ti.error_msg+"");
}
} else {
Notify.error("The Wallabag_v2 plugin needs to be configured. See the README for help", true);
(reply) => {
if (reply.status) {
if (reply.status=="200") {
Notify.info("Saved to Wallabag: <em>" + reply.title + "</em>");
} else {
Notify.error("<strong>Error saving to Wallabag!</strong>: ("+reply.status+": "+reply.error+") "+reply.error_msg+"");
}
}
});
} else {
Notify.error("The Wallabag_v2 plugin needs to be configured. See the README for help", true);
}
});
} catch (e) {
exception_error("wallabagArticle", e);
Notify.error("wallabagArticle", e);
}
}

Expand Down

0 comments on commit d8e4767

Please sign in to comment.