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() {
$id = Model\decode_item_id(Request\param('id'));
@ -191,8 +199,31 @@ Router\post_action('mark-item-unread', function() {
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'));
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'));
Model\set_item_unstarred($id);
Response\Redirect('?action=starred');
});
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'));
Response\Redirect('?action=default');
});

View File

@ -255,7 +255,7 @@ function get_unread_items()
{
return \PicoTools\singleton('db')
->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')
->eq('status', 'unread')
->desc('updated')
@ -267,11 +267,13 @@ function get_read_items()
{
return \PicoTools\singleton('db')
->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')
->eq('status', 'read')
->desc('updated')
->findAll();
}
@ -359,7 +361,7 @@ function set_item_removed($id)
\PicoTools\singleton('db')
->table('items')
->eq('id', $id)
->save(array('status' => 'removed'));
->save(array('status' => 'removed','starred' => 'unstarred'));
}

View File

@ -1,5 +1,4 @@
<?php if (empty($items)): ?>
<p class="alert alert-info"><?= t('No history') ?></p>
<?php else: ?>
@ -24,10 +23,21 @@
</a>
</h2>
<p>
<?= Helper\get_host_from_url($item['url']) ?> |
<?= 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="<?= $item['url'] ?>"

View File

@ -3,6 +3,7 @@
<p class="alert alert-info"><?= t('Item not found') ?></p>
<?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']) ?>">
<h1>
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-item"><?= Helper\escape($item['title']) ?></a>
@ -11,7 +12,12 @@
<p class="infos">
<?= Helper\get_host_from_url($item['url']) ?> |
<?= 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>
<?= $item['content'] ?>

View File

@ -23,7 +23,7 @@
<p>
<?= Helper\get_host_from_url($item['url']) ?> |
<?= 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="<?= $item['url'] ?>"

View File

@ -28,7 +28,14 @@
</p>
<p>
<?= 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="<?= $item['url'] ?>"