summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controllers/controllers.php3
-rw-r--r--lib/helpers.php32
-rw-r--r--schema/migrations/0006.sql2
-rw-r--r--schema/mysql.sql1
-rw-r--r--schema/sqlite.sql5
-rw-r--r--views/dashboard.php34
-rw-r--r--views/layout.php16
-rw-r--r--views/new-post.php4
-rw-r--r--views/settings.php15
9 files changed, 92 insertions, 20 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php
index 9a49305..237c4bb 100644
--- a/controllers/controllers.php
+++ b/controllers/controllers.php
@@ -47,7 +47,8 @@ $app->get('/dashboard', function() use($app) {
if($user=require_login($app)) {
render('dashboard', array(
'title' => 'Dashboard',
- 'authorizing' => false
+ 'authorizing' => false,
+ 'user' => $user,
));
}
});
diff --git a/lib/helpers.php b/lib/helpers.php
index bfcdf63..d714c23 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -288,12 +288,19 @@ function get_micropub_config(&$user, $query=[]) {
$user->syndication_targets = json_encode($targets);
$media_endpoint = false;
- if($r['data'] && is_array($r['data']) && array_key_exists('media-endpoint', $r['data'])) {
- $media_endpoint = $r['data']['media-endpoint'];
- $user->micropub_media_endpoint = $media_endpoint;
+ $supported_post_types = false;
+ if($r['data'] && is_array($r['data'])) {
+ if(isset($r['data']['media-endpoint'])) {
+ $media_endpoint = $r['data']['media-endpoint'];
+ $user->micropub_media_endpoint = $media_endpoint;
+ }
+ if(isset($r['data']['post-types'])) {
+ $supported_post_types = json_encode($r['data']['post-types']);
+ $user->supported_post_types = $supported_post_types;
+ }
}
- if(count($targets) || $media_endpoint) {
+ if(count($targets) || $media_endpoint || $supported_post_types) {
$user->save();
}
@@ -303,6 +310,23 @@ function get_micropub_config(&$user, $query=[]) {
];
}
+function supports_post_type(&$user, $type) {
+ if(!$user->supported_post_types)
+ return true;
+
+ $types = json_decode($user->supported_post_types, true);
+ if(!is_array($types))
+ return true; // syntax error in response, fail safely
+
+ foreach($types as $t) {
+ if(is_array($t) && isset($t['type']) && $t['type'] == $type) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
function get_micropub_source(&$user, $url, $properties) {
$r = micropub_get($user->micropub_endpoint, [
'q' => 'source',
diff --git a/schema/migrations/0006.sql b/schema/migrations/0006.sql
new file mode 100644
index 0000000..3ca725c
--- /dev/null
+++ b/schema/migrations/0006.sql
@@ -0,0 +1,2 @@
+ALTER TABLE users
+ADD COLUMN `supported_post_types` LONGTEXT;
diff --git a/schema/mysql.sql b/schema/mysql.sql
index 402218a..bbe0dd4 100644
--- a/schema/mysql.sql
+++ b/schema/mysql.sql
@@ -24,5 +24,6 @@ CREATE TABLE `users` (
`instagram_access_token` text,
`email_username` varchar(255) DEFAULT NULL,
`default_timezone` varchar(255) DEFAULT NULL,
+ `supported_post_types` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/schema/sqlite.sql b/schema/sqlite.sql
index 00e5f1c..948b3ef 100644
--- a/schema/sqlite.sql
+++ b/schema/sqlite.sql
@@ -23,5 +23,6 @@ CREATE TABLE users (
twitter_username TEXT,
instagram_access_token TEXT,
email_username TEXT,
- default_timezone TEXT
-); \ No newline at end of file
+ default_timezone TEXT,
+ supported_post_types TEXT,
+);
diff --git a/views/dashboard.php b/views/dashboard.php
index adde977..7b8af63 100644
--- a/views/dashboard.php
+++ b/views/dashboard.php
@@ -3,14 +3,30 @@
<div style=" margin-top: 4em; margin-bottom: 4em;">
<ul class="post-type-icons">
- <li><a href="/editor">📄</a></li>
- <li><a href="/new">✏️</a></li>
- <li><a href="/event">📅</a></li>
- <li><a href="/bookmark">🔖</a></li>
- <li><a href="/favorite">👍</a></li>
- <li><a href="/repost">♺</a></li>
- <li><a href="/itinerary">✈️</a></li>
- <li><a href="/review">⭐️</a></li>
+ <?php if(supports_post_type($this->user, 'article')): ?>
+ <li><a href="/editor">📄</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'note')): ?>
+ <li><a href="/new">✏️</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'event')): ?>
+ <li><a href="/event">📅</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'bookmark')): ?>
+ <li><a href="/bookmark">🔖</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'like')): ?>
+ <li><a href="/favorite">👍</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'repost')): ?>
+ <li><a href="/repost">♺</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'itinerary')): ?>
+ <li><a href="/itinerary">✈️</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'review')): ?>
+ <li><a href="/review">⭐️</a></li>
+ <?php endif; ?>
<li><a href="/email">✉️</a></li>
<li><a href="/settings">⚙</a></li>
</ul>
@@ -27,4 +43,4 @@
float: left;
margin-right: 12px;
}
-</style> \ No newline at end of file
+</style>
diff --git a/views/layout.php b/views/layout.php
index 0850537..450d982 100644
--- a/views/layout.php
+++ b/views/layout.php
@@ -77,10 +77,18 @@
<ul class="nav navbar-nav">
<?php if(session('me')) { ?>
- <li><a href="/editor">📄 Editor</a></li>
- <li><a href="/new">✏️ Note</a></li>
- <li><a href="/bookmark">🔖 Bookmark</a></li>
- <li><a href="/favorite">👍 Favorite</a></li>
+ <?php if(supports_post_type($this->user, 'article')): ?>
+ <li><a href="/editor">📄 Editor</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'note')): ?>
+ <li><a href="/new">✏️ Note</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'bookmark')): ?>
+ <li><a href="/bookmark">🔖 Bookmark</a></li>
+ <?php endif; ?>
+ <?php if(supports_post_type($this->user, 'like')): ?>
+ <li><a href="/favorite">👍 Favorite</a></li>
+ <?php endif; ?>
<?php } ?>
<li><a href="/docs">Docs</a></li>
diff --git a/views/new-post.php b/views/new-post.php
index 02733bc..69e3a84 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -65,11 +65,15 @@
<input type="text" id="note_slug" value="" class="form-control">
</div>
+ <?php if(supports_post_type($this->user, 'photo')): ?>
+
<div class="form-group hidden" id="photo-previews">
</div>
<a href="javascript:addNewPhoto();" id="expand-photo-section"><i class="glyphicon glyphicon-camera" style="color: #aaa; font-size: 36px;"></i></a>
+ <?php endif ?>
+
<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">
diff --git a/views/settings.php b/views/settings.php
index 6b69bc2..247aaf6 100644
--- a/views/settings.php
+++ b/views/settings.php
@@ -20,6 +20,21 @@
<td>media endpoint</td>
<td><?= $this->user->micropub_media_endpoint ? '<code>'.$this->user->micropub_media_endpoint.'</code>' : '<a href="https://www.w3.org/TR/micropub/#media-endpoint">no media endpoint</a>' ?></td>
</tr>
+ <?php if($this->user->supported_post_types): ?>
+ <tr>
+ <td>supported post types</td>
+ <td>
+ <ul>
+ <?php
+ $types = json_decode($this->user->supported_post_types, true);
+ foreach($types as $type) {
+ echo '<li>'.htmlspecialchars($type['name']).' ('.$type['type'].')</li>';
+ }
+ ?>
+ </ul>
+ </td>
+ </tr>
+ <?php endif ?>
<tr>
<td width="140">access token</td>
<td><code style="word-break: break-word; white-space: pre-wrap;"><?= $this->user->micropub_access_token ?></code></td>