summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajax/importantitem.php42
-rw-r--r--css/news.css58
-rw-r--r--js/news.js38
-rw-r--r--templates/main.php13
-rw-r--r--templates/part.items.header.php2
-rw-r--r--templates/part.items.php22
6 files changed, 137 insertions, 38 deletions
diff --git a/ajax/importantitem.php b/ajax/importantitem.php
new file mode 100644
index 000000000..72a07f747
--- /dev/null
+++ b/ajax/importantitem.php
@@ -0,0 +1,42 @@
+<?php
+/**
+* ownCloud - News app
+*
+* @author Bernhard Posselt
+* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+*
+* This file is licensed under the Affero General Public License version 3 or later.
+* See the COPYING-README file
+*
+*/
+
+// Check if we are a user
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('news');
+OCP\JSON::callCheck();
+
+$itemId = $_POST['itemId'];
+$isImportant = $_POST['isImportant'];
+
+$itemMapper = new OCA\News\ItemMapper();
+$item = $itemMapper->find($itemId);
+
+if($isImportant){
+ $item->setImportant();
+} else {
+ $item->setUnimportant();
+}
+
+$success = $itemMapper->update($item);
+
+$l = OC_L10N::get('news');
+
+if(!$success) {
+ OCP\JSON::error(array('data' => array('message' => $l->t('Error marking item as important.'))));
+ OCP\Util::writeLog('news','ajax/importantitem.php: Error marking item as important: '.$_POST['itemId'], OCP\Util::ERROR);
+ exit();
+}
+
+//TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations
+OCP\JSON::success(array('data' => array('itemId' => $itemId)));
+
diff --git a/css/news.css b/css/news.css
index eeff10e49..a1fcd85c4 100644
--- a/css/news.css
+++ b/css/news.css
@@ -40,7 +40,7 @@ div.collapsable:hover { background-color: rgb(221, 221, 221); }
#addfeed { background: url('%appswebroot%/news/img/rss.svg') no-repeat left center; padding-left: 20px !important; }
/* #feeds a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; } */
-#bottomcontrols { padding: 0; bottom:0px; overflow:visible; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
+#feedcontrols { padding: 0; bottom:0px; overflow:visible; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
ul.controls li { float: left; }
@@ -58,31 +58,45 @@ ul.controls li { float: left; }
height: 100%;
}
+#feed_items h1.item_title { }
+#feed_items .title_unread h1.item_title { font-weight: bold; border-bottom: 1px solid #222; }
+#feed_items .title_unread h1.item_title a { color: #222; }
+#feed_items .title_unread h1.item_title,
+#feed_items .title_read h1.item_title { padding: 15px 10px 10px 10px; font-size: 1.5em; }
+#feed_items .title_read h1.item_title { font-weight: normal; border-bottom: 1px solid #ccc; }
+#feed_items .title_read h1.item_title a { color: #888; }
+#feed_items .title_read a:hover, #feed_items .title_unread a:hover { text-decoration: underline; }
+
+#feed_items .item_utils {
+ float: left;
+ padding: 15px 10px 10px;
+}
+#feed_items .item_utils ul {}
+#feed_items .item_utils ul li { display: inline-block; }
+#feed_items .item_utils ul li.star {
+ background-image: url('%appswebroot%/news/img/inactive_star.svg');
+ background-repeat: no-repeat;
+ background-size: 100%;
+ height: 1.5em;
+ width: 1.5em;
+}
+#feed_items .item_utils ul li.star.important,
+#feed_items .item_utils ul li.star:hover {
+ background-image: url('%appswebroot%/news/img/active_star.svg');
+}
-#rightcontent ul { }
-
-#rightcontent div.body { padding: 15px 25px 10px 25px; }
-#rightcontent div.body p { line-height: 1.5; margin: 10px 0; }
-#rightcontent div.body a { color: #0000ff; text-decoration: underline; }
-#rightcontent div.body ul { padding-left: 15px; list-style-type: disc; }
-#rightcontent div.body ul li { cursor: default; }
-#rightcontent li:active { background: none; }
-#rightcontent div.body pre { padding: 5px; background-color: #dadada; border: 1px solid #ccc; }
-#rightcontent div.body pre code { font-family: monospace; font-size: 1.5em; }
-
-#rightcontent .title_unread h1.item_title,
-#rightcontent .title_read h1.item_title { padding: 15px 10px 10px 10px; font-size: 1.5em; }
-
-#rightcontent .title_unread h1.item_title { font-weight: bold; border-bottom: 1px solid #222; }
-
-#rightcontent .title_unread h1.item_title a { color: #222; }
-#rightcontent .title_read h1.item_title { font-weight: normal; border-bottom: 1px solid #ccc; }
-#rightcontent .title_read h1.item_title a { color: #888; }
+#feed_items div.body { padding: 15px 25px 10px 25px; }
+#feed_items div.body p { line-height: 1.5; margin: 10px 0; }
+#feed_items div.body a { color: #0000ff; text-decoration: underline; }
+#feed_items div.body ul { padding-left: 15px; list-style-type: disc; }
+#feed_items div.body ul li { cursor: default; }
+#feed_items li:active { background: none; }
+#feed_items div.body pre { padding: 5px; background-color: #dadada; border: 1px solid #ccc; }
+#feed_items div.body pre code { font-family: monospace; font-size: 1.5em; }
-#rightcontent .title_read a:hover, #rightcontent .title_unread a:hover { text-decoration: underline; }
-#rightcontent div.rightcontentmsg { padding-left: 10px; background-color: yellow; }
+#feed_items div.rightcontentmsg { padding-left: 10px; background-color: yellow; }
/* dialog/menues */
diff --git a/js/news.js b/js/news.js
index 0e0c2a843..2be7499ed 100644
--- a/js/news.js
+++ b/js/news.js
@@ -210,6 +210,26 @@ News={
News.Feed.markItem(itemId, feedId);
});
},
+ setImportant:function(isImportant, itemId, feedId){
+ var $currentItem = $('#feed_items [data-id="' + itemId + '"][data-feedid="' + feedId + '"]');
+ var $currentStar = $currentItem.children('.item_utils').children('ul').children('li.star');
+ data = {
+ isImportant: isImportant,
+ itemId: itemId,
+ feedId: feedId
+ };
+ $.post(OC.filePath('news', 'ajax', 'importantitem.php'), data, function(jsondata){
+ if(jsondata.status == 'success'){
+ if(isImportant){
+ $currentStar.removeClass('important');
+ } else {
+ $currentStar.addClass('important');
+ }
+ } else{
+ OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
+ }
+ });
+ },
load:function(feedid) {
$.post(OC.filePath('news', 'ajax', 'loadfeed.php'),{'feedid':feedid},function(jsondata) {
if(jsondata.status == 'success'){
@@ -368,13 +388,23 @@ function bindItemEventListeners(){
})
});
- // single click on item should mark it as read too
- $('#feed_items ul li').click(function(){
- var itemId = $(this).data('id');
- var feedId = $(this).data('feedid');
+ // single hover on item should mark it as read too
+ $('#feed_items h1.item_title a').click(function(){
+ var $item = $(this).parent().parent('.news_item');
+ var itemId = $item.data('id');
+ var feedId = $item.data('feedid');
News.Feed.markItem(itemId, feedId);
})
+ // mark or unmark as important
+ $('#feed_items li.star').click(function(){
+ var important = $(this).hasClass('important');
+ var $item = $(this).parent().parent().parent('.news_item');
+ var itemId = $item.data('id');
+ var feedId = $item.data('feedid');
+ News.Feed.setImportant(important, itemId, feedId);
+ })
+
// bind the mark all as read button
$('#mark_all_as_read').click(function(){
News.Feed.markAllItems();
diff --git a/templates/main.php b/templates/main.php
index db3abe34a..8f6bba595 100644
--- a/templates/main.php
+++ b/templates/main.php
@@ -4,12 +4,7 @@
</ul>
</div>
-<ul class="menu" id="feedfoldermenu">
- <li class="menuItem" id="addfeed"><?php echo $l->t('Feed'); ?></li>
- <li class="menuItem" id="addfolder"><?php echo $l->t('Folder'); ?></li>
-</ul>
-
-<div id="bottomcontrols">
+<div id="feedcontrols">
<ul class="controls">
<li>
<button class="svg" id="addfeedfolder" title="<?php echo $l->t('Add Feed/Folder'); ?>" onclick="News.DropDownMenu.fade('ul#feedfoldermenu')"><img class="svg" src="<?php echo OCP\Util::linkTo('news', 'img/add.svg'); ?>" alt="<?php echo $l->t('Add Feed/Folder'); ?>" /></button>
@@ -23,6 +18,12 @@
</ul>
</div>
+<ul class="menu" id="feedfoldermenu">
+ <li class="menuItem" id="addfeed"><?php echo $l->t('Feed'); ?></li>
+ <li class="menuItem" id="addfolder"><?php echo $l->t('Folder'); ?></li>
+</ul>
+
+
<div id="rightcontent" class="rightcontent" data-id="<?php echo $_['feedid']; ?>">
<?php
if ($_['feedid']){
diff --git a/templates/part.items.header.php b/templates/part.items.header.php
index c4c9666bb..ac2add0d4 100644
--- a/templates/part.items.header.php
+++ b/templates/part.items.header.php
@@ -17,6 +17,6 @@ if(isset($_['feedid'])){
<input type="button" value="<?php echo $l->t('Mark all as read'); ?>" id="mark_all_as_read" />
<select id="feed_filter">
<option value="all"><?php echo $l->t('Show all articles'); ?></option>
- <option value="newest"><?php echo $l->t('Show newest articles'); ?></option>
+ <option value="newest"><?php echo $l->t('Show only unread articles'); ?></option>
</select>
</div> \ No newline at end of file
diff --git a/templates/part.items.php b/templates/part.items.php
index ff372fafb..7334fa35a 100644
--- a/templates/part.items.php
+++ b/templates/part.items.php
@@ -8,15 +8,27 @@ $items = $itemmapper->findAll($feedid);
echo '<div id="feed_items">';
echo '<ul>';
foreach($items as $item) {
+
if($item->isRead()){
- $readClass = "title_read";
+ $newsItemClass = "title_read";
} else {
- $readClass = "title_unread";
+ $newsItemClass = "title_unread";
+ }
+
+ if($item->isImportant()){
+ $starClass = 'important';
+ $startTitle = $l->t('Mark as unimportant');
+ } else {
+ $starClass = '';
+ $startTitle = $l->t('Mark as important');
}
- echo '<li class="news_item ' . $readClass .'" data-id="' . $item->getId() . '" data-feedid="' . $feedid . '">';
- echo '<h1 class="item_title"><a href="' . $item->getUrl() . '">' . $item->getTitle() . '</a></h1>';
- echo '<div class="body">' . $item->getBody() . '</div>';
+ echo '<li class="news_item ' . $newsItemClass .'" data-id="' . $item->getId() . '" data-feedid="' . $feedid . '">';
+ echo '<div class="item_utils"><ul>';
+ echo '<li class="star ' . $starClass . '" title="' . $startTitle . '"></li>';
+ echo '</ul></div>';
+ echo '<h1 class="item_title"><a target="_blank" href="' . $item->getUrl() . '">' . $item->getTitle() . '</a></h1>';
+ echo '<div class="body">' . $item->getBody() . '</div>';
echo '</li>';
}