improve navigation with starred/unstarred items

This commit is contained in:
MonsieurPaulLeBoulanger 2013-06-10 14:50:06 +02:00
parent 3758237bb4
commit e56cfa612a
6 changed files with 68 additions and 27 deletions

View File

@ -160,6 +160,14 @@ Router\get_action('mark-item-unread', function() {
}); });
Router\get_action('mark-read-item-unread', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_unread($id);
Response\Redirect('?action=history');
});
Router\get_action('mark-item-removed', function() { Router\get_action('mark-item-removed', function() {
$id = Model\decode_item_id(Request\param('id')); $id = Model\decode_item_id(Request\param('id'));
@ -191,8 +199,31 @@ Router\post_action('mark-item-unread', function() {
Response\json(array('Ok')); Response\json(array('Ok'));
}); });
Router\get_action('mark-read-item-starred', function() {
Router\get_action('mark-item-starred', function() { $id = Model\decode_item_id(Request\param('id'));
Model\set_item_starred($id);
Response\Redirect('?action=history');
});
Router\get_action('mark-read-item-unstarred', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_unstarred($id);
Response\Redirect('?action=history');
});
Router\get_action('mark-starred-item-unstarred', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_unstarred($id);
Response\Redirect('?action=starred');
});
Router\get_action('mark-unread-item-starred', function() {
$id = Model\decode_item_id(Request\param('id')); $id = Model\decode_item_id(Request\param('id'));
Model\set_item_starred($id); Model\set_item_starred($id);
@ -200,26 +231,11 @@ Router\get_action('mark-item-starred', function() {
}); });
Router\get_action('mark-item-unstarred', function() { Router\get_action('mark-unread-item-unstarred', function() {
$id = Model\decode_item_id(Request\param('id')); $id = Model\decode_item_id(Request\param('id'));
Model\set_item_unstarred($id); Model\set_item_unstarred($id);
Response\Redirect('?action=starred'); Response\Redirect('?action=default');
});
Router\post_action('mark-item-starred', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_starred($id);
Response\json(array('Ok'));
});
Router\post_action('mark-item-unstarred', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_unstarred($id);
Response\json(array('Ok'));
}); });

View File

@ -255,7 +255,7 @@ function get_unread_items()
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
->table('items') ->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url', 'items.content') ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url', 'items.content','starred')
->join('feeds', 'id', 'feed_id') ->join('feeds', 'id', 'feed_id')
->eq('status', 'unread') ->eq('status', 'unread')
->desc('updated') ->desc('updated')
@ -267,11 +267,13 @@ function get_read_items()
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
->table('items') ->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url') ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url','starred')
->join('feeds', 'id', 'feed_id') ->join('feeds', 'id', 'feed_id')
->eq('status', 'read') ->eq('status', 'read')
->desc('updated') ->desc('updated')
->findAll(); ->findAll();
} }
@ -359,7 +361,7 @@ function set_item_removed($id)
\PicoTools\singleton('db') \PicoTools\singleton('db')
->table('items') ->table('items')
->eq('id', $id) ->eq('id', $id)
->save(array('status' => 'removed')); ->save(array('status' => 'removed','starred' => 'unstarred'));
} }

View File

@ -1,5 +1,4 @@
<?php if (empty($items)): ?> <?php if (empty($items)): ?>
<p class="alert alert-info"><?= t('No history') ?></p> <p class="alert alert-info"><?= t('No history') ?></p>
<?php else: ?> <?php else: ?>
@ -24,10 +23,21 @@
</a> </a>
</h2> </h2>
<p> <p>
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> | <?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
<a href="?action=mark-item-starred&amp;id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
<a href="?action=mark-item-unread&amp;id=<?= $item_id ?>"><?= t('mark as unread') ?></a> |
<?php if (isset($item['starred']) && $item['starred']=='starred'): ?>
<a href="?action=mark-unread-item-unstarred&amp;id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
<?php else: ?>
<a href="?action=mark-unread-item-starred&amp;id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
<?php endif ?>
<a href="?action=mark-read-item-unread&amp;id=<?= $item_id ?>"><?= t('mark as unread') ?></a> |
<a href="?action=mark-item-removed&amp;id=<?= $item_id ?>"><?= t('remove') ?></a> | <a href="?action=mark-item-removed&amp;id=<?= $item_id ?>"><?= t('remove') ?></a> |
<a <a
href="<?= $item['url'] ?>" href="<?= $item['url'] ?>"

View File

@ -3,6 +3,7 @@
<p class="alert alert-info"><?= t('Item not found') ?></p> <p class="alert alert-info"><?= t('Item not found') ?></p>
<?php else: ?> <?php else: ?>
<?php $item_id = Model\encode_item_id($item['id']) ?>
<article class="item" id="current-item" data-item-id="<?= Model\encode_item_id($item['id']) ?>"> <article class="item" id="current-item" data-item-id="<?= Model\encode_item_id($item['id']) ?>">
<h1> <h1>
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-item"><?= Helper\escape($item['title']) ?></a> <a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-item"><?= Helper\escape($item['title']) ?></a>
@ -11,7 +12,12 @@
<p class="infos"> <p class="infos">
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> | <?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
<a href="?action=mark-item-starred&amp;id=<?= $item_id ?>"><?= t('mark as starred') ?></a> <?php if (isset($item['starred']) && $item['starred']=='starred'): ?>
<a href="?action=mark-read-item-unstarred&amp;id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a>
<?php else: ?>
<a href="?action=mark-read-item-starred&amp;id=<?= $item_id ?>"><?= t('mark as starred') ?></a>
<?php endif ?>
</p> </p>
<?= $item['content'] ?> <?= $item['content'] ?>

View File

@ -23,7 +23,7 @@
<p> <p>
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> | <?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
<a href="?action=mark-item-unstarred&amp;id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> | <a href="?action=mark-starred-item-unstarred&amp;id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
<a href="?action=mark-starred-item-removed&amp;id=<?= $item_id ?>"><?= t('remove') ?></a> | <a href="?action=mark-starred-item-removed&amp;id=<?= $item_id ?>"><?= t('remove') ?></a> |
<a <a
href="<?= $item['url'] ?>" href="<?= $item['url'] ?>"

View File

@ -28,7 +28,14 @@
</p> </p>
<p> <p>
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<a href="?action=mark-item-starred&amp;id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
<?php if (isset($item['starred']) && $item['starred']=='starred'): ?>
<a href="?action=mark-unread-item-unstarred&amp;id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
<?php else: ?>
<a href="?action=mark-unread-item-starred&amp;id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
<?php endif ?>
<a href="?action=mark-item-read&amp;id=<?= $item_id ?>"><?= t('mark as read') ?></a> | <a href="?action=mark-item-read&amp;id=<?= $item_id ?>"><?= t('mark as read') ?></a> |
<a <a
href="<?= $item['url'] ?>" href="<?= $item['url'] ?>"