Browse Source

add a dropdown to choose post visibility

pull/111/head
Aaron Parecki 5 years ago
parent
commit
f0c5635c2f
No known key found for this signature in database GPG Key ID: 276C2817346D6056
7 changed files with 41 additions and 3 deletions
  1. +1
    -0
      controllers/controllers.php
  2. +1
    -1
      controllers/micropub.php
  3. +5
    -0
      lib/helpers.php
  4. +2
    -0
      schema/migrations/0007.sql
  5. +1
    -0
      schema/mysql.sql
  6. +2
    -1
      schema/sqlite.sql
  7. +29
    -1
      views/new-post.php

+ 1
- 0
controllers/controllers.php View File

@ -72,6 +72,7 @@ $app->get('/new', function() use($app) {
'micropub_access_token' => $user->micropub_access_token,
'response_date' => $user->last_micropub_response_date,
'syndication_targets' => json_decode($user->syndication_targets, true),
'supported_visibility' => json_decode($user->supported_visibility, true),
'location_enabled' => $user->location_enabled,
'user' => $user,
'authorizing' => false

+ 1
- 1
controllers/micropub.php View File

@ -2,7 +2,7 @@
$app->get('/micropub/syndications', function() use($app) {
if($user=require_login($app)) {
$data = get_micropub_config($user, ['q'=>'syndicate-to']);
$data = get_micropub_config($user);
$app->response()['Content-type'] = 'application/json';
$app->response()->body(json_encode(array(
'targets' => $data['targets'],

+ 5
- 0
lib/helpers.php View File

@ -298,6 +298,7 @@ function get_micropub_config(&$user, $query=[]) {
// Reset the values so they can be overwritten
$user->syndication_targets = '';
$user->supported_post_types = '';
$user->supported_visibility = '';
$user->micropub_media_endpoint = '';
if(count($targets))
@ -316,6 +317,10 @@ function get_micropub_config(&$user, $query=[]) {
}
}
if(isset($r['data']['visibility']) && is_array($r['data']['visibility'])) {
$user->supported_visibility = json_encode($r['data']['visibility']);
}
$user->save();
return [

+ 2
- 0
schema/migrations/0007.sql View File

@ -0,0 +1,2 @@
ALTER TABLE users
ADD COLUMN `supported_visibility` LONGTEXT;

+ 1
- 0
schema/mysql.sql View File

@ -25,5 +25,6 @@ CREATE TABLE `users` (
`email_username` varchar(255) DEFAULT NULL,
`default_timezone` varchar(255) DEFAULT NULL,
`supported_post_types` longtext,
`supported_visibility` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 2
- 1
schema/sqlite.sql View File

@ -24,5 +24,6 @@ CREATE TABLE users (
instagram_access_token TEXT,
email_username TEXT,
default_timezone TEXT,
supported_post_types TEXT
supported_post_types TEXT,
supported_visibility TEXT
);

+ 29
- 1
views/new-post.php View File

@ -79,8 +79,23 @@
<?php endif ?>
<?php if($this->supported_visibility): ?>
<div class="form-group" style="margin-top: 1em;">
<label for="visibility">Visibility</label>
<select class="form-control" id="visibility">
<?php
foreach(['Public','Unlisted','Private'] as $v):
if(in_array(strtolower($v), $this->supported_visibility)):
echo '<option value="'.strtolower($v).'">'.$v.'</option>';
endif;
endforeach;
?>
</select>
</div>
<?php endif ?>
<?php if($this->syndication_targets): ?>
<div class="form-group" style="margin-top: 1em;">
<div id="syndication-targets" 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
@ -562,6 +577,14 @@ $(function(){
}
});
$("#visibility").on('change', function(e){
if($(this).val() == 'private') {
$("#syndication-targets").addClass('hidden');
} else {
$("#syndication-targets").removeClass('hidden');
}
});
$("#expand-reply").click(function(){
$('.reply-section').removeClass('hidden');
$(this).addClass('hidden');
@ -740,6 +763,11 @@ $(function(){
entry["rsvp"] = $("#note_rsvp").val();
}
if($("#visibility").val()) {
formData.append("visibility", $("#visibility").val());
entry["visibility"] = $("#visibility").val();
}
function appendPhotoToFormData(photo, prop) {
if(photo.external) {
if(photo.alt) {

Loading…
Cancel
Save