Browse Source

if no syndication targets are found, hide the section

add syndication reload button to the settings screen
pull/108/head
Aaron Parecki 3 years ago
parent
commit
57c82d830d
No known key found for this signature in database GPG Key ID: 276C2817346D6056
4 changed files with 55 additions and 10 deletions
  1. +1
    -0
      controllers/controllers.php
  2. +3
    -5
      views/new-bookmark.php
  3. +3
    -5
      views/new-post.php
  4. +48
    -0
      views/settings.php

+ 1
- 0
controllers/controllers.php View File

@ -483,6 +483,7 @@ $app->get('/settings', function() use($app) {
render('settings', [
'title' => 'Settings',
'user' => $user,
'syndication_targets' => json_decode($user->syndication_targets, true),
'authorizing' => false
]);
}

+ 3
- 5
views/new-bookmark.php View File

@ -32,11 +32,11 @@
<input type="text" id="note_category" value="<?= $this->bookmark_tags ?>" class="form-control" placeholder="e.g. web, personal">
</div>
<?php if($this->syndication_targets): ?>
<div class="form-group">
<label for="note_syndicate-to">Syndicate <a href="javascript:reload_syndications()">refresh</a></label>
<div id="syndication-container">
<?php
if($this->syndication_targets) {
echo '<ul>';
foreach($this->syndication_targets as $syn) {
echo '<li>'
@ -47,13 +47,11 @@
. '</li>';
}
echo '</ul>';
} else {
?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
You can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
}
?>
</div>
</div>
<?php endif ?>
</form>

+ 3
- 5
views/new-post.php View File

@ -78,11 +78,12 @@
<?php endif ?>
<?php if($this->syndication_targets): ?>
<div class="form-group" style="margin-top: 1em;">
<label for="note_syndicate-to">Syndicate <a href="javascript:reload_syndications()">(refresh list)</a></label>
<div id="syndication-container">
<?php
if($this->syndication_targets) {
echo '<ul>';
foreach($this->syndication_targets as $syn) {
echo '<li>'
@ -93,13 +94,10 @@
. '</li>';
}
echo '</ul>';
} else {
?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
You can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
}
?>
</div>
</div>
<?php endif ?>
<div class="form-group">
<label for="note_location">Location</label>

+ 48
- 0
views/settings.php View File

@ -50,11 +50,39 @@
</table>
<h3>Syndication Targets</h3>
<div class="form-group">
<label for="note_syndicate-to"><a href="javascript:reload_syndications()">Reload</a></label>
<div id="syndication-container">
<?php
if($this->syndication_targets) {
echo '<ul>';
foreach($this->syndication_targets as $syn) {
echo '<li>'
. '<button data-syndicate-to="'.(isset($syn['uid']) ? htmlspecialchars($syn['uid']) : htmlspecialchars($syn['target'])).'" class="btn btn-default btn-block">'
. ($syn['favicon'] ? '<img src="'.htmlspecialchars($syn['favicon']).'" width="16" height="16"> ' : '')
. htmlspecialchars($syn['target'])
. '</button>'
. '</li>';
}
echo '</ul>';
} else {
?><div class="bs-callout bs-callout-warning">No syndication targets were found on your site.
Your server can provide a <a href="/docs#syndication">list of supported syndication targets</a> that will appear as checkboxes here.</div><?php
}
?>
</div>
</div>
<h3>Twitter</h3>
<p>Connecting a Twitter account will automatically "favorite" and "retweet" tweets on Twitter when you favorite and retweet a Twitter URL in Quill.</p>
<input type="button" id="twitter-button" value="Checking" class="btn">
<h3>Backwards Compatibility</h3>
<p>You can customize some of the properties that are sent in the Micropub request to work with your specific endpoint.</p>
@ -139,5 +167,25 @@ $(function(){
});
});
});
function reload_syndications() {
$.getJSON("/micropub/syndications", function(data){
if(data.targets) {
$("#syndication-container").html('<ul></ul>');
for(var i in data.targets) {
var target = data.targets[i].target;
var uid = data.targets[i].uid;
var favicon = data.targets[i].favicon;
$("#syndication-container ul").append('<li><button data-syndicate-to="'+htmlspecialchars(uid ? uid : target)+'" class="btn btn-default btn-block">'+(favicon ? '<img src="'+htmlspecialchars(favicon)+'" width="16" height="16"> ':'')+htmlspecialchars(target)+'</button></li>');
}
bind_syndication_buttons();
} else {
}
console.log(data);
});
}
</script>

Loading…
Cancel
Save