diff options
-rw-r--r-- | ajax/createfeed.php | 6 | ||||
-rw-r--r-- | ajax/feeddialog.php | 2 | ||||
-rw-r--r-- | ajax/folderdialog.php | 2 | ||||
-rw-r--r-- | css/news.css | 9 | ||||
-rw-r--r-- | js/news.js | 13 | ||||
-rw-r--r-- | lib/foldermapper.php | 15 | ||||
-rw-r--r-- | lib/utils.php | 10 | ||||
-rw-r--r-- | templates/part.feeddialog.php (renamed from templates/part.addfeed.php) | 0 | ||||
-rw-r--r-- | templates/part.feeds.php | 25 | ||||
-rw-r--r-- | templates/part.folderdialog.php (renamed from templates/part.addfolder.php) | 0 |
10 files changed, 37 insertions, 45 deletions
diff --git a/ajax/createfeed.php b/ajax/createfeed.php index 754d87495..3b20b3ce9 100644 --- a/ajax/createfeed.php +++ b/ajax/createfeed.php @@ -32,6 +32,10 @@ if(!$feedid) { exit(); } +$tmpl = new OCP\Template("news", "part.listfeed"); +$tmpl->assign('child', $feed); +$listitem = $tmpl->fetchPage(); + //TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations -OCP\JSON::success(array('data' => array('message' => $l->t('Feed added!')))); +OCP\JSON::success(array('data' => array('message' => $l->t('Feed added!'), 'listitem' => $listitem))); diff --git a/ajax/feeddialog.php b/ajax/feeddialog.php index b1e41a6ff..9130eddfe 100644 --- a/ajax/feeddialog.php +++ b/ajax/feeddialog.php @@ -2,6 +2,6 @@ include("populateroot.php"); -$output = new OCP\Template("news", "part.addfeed"); +$output = new OCP\Template("news", "part.feeddialog"); $output->assign('allfeeds', $allfeeds); $output->printpage();
\ No newline at end of file diff --git a/ajax/folderdialog.php b/ajax/folderdialog.php index bb1c37cf3..95d96d09d 100644 --- a/ajax/folderdialog.php +++ b/ajax/folderdialog.php @@ -2,6 +2,6 @@ include("populateroot.php"); -$output = new OCP\Template("news", "part.addfolder"); +$output = new OCP\Template("news", "part.folderdialog"); $output->assign('allfeeds', $allfeeds); $output->printpage();
\ No newline at end of file diff --git a/css/news.css b/css/news.css index b09ccb49f..f42802d1b 100644 --- a/css/news.css +++ b/css/news.css @@ -1,5 +1,4 @@ -.collapsable { background: url('%webroot%/core/img/places/folder.svg') no-repeat left center; padding: 0 0 0 20px; } .news_input { float:left; font-size:12px; padding:4px 2px; border:solid 1px #aacfe4; width:200px; } .svg { border: inherit; background: inherit; } @@ -8,8 +7,8 @@ #feeds { background: #fff; width: 19.7em; left: 12.5em; top: 3.7em; bottom:3em; position: fixed; overflow: auto; padding: 0; margin: 0 0 0 0.3em;} /* #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;} -#feeds_delete { position: absolute; right: 0px; background: url('%webroot%/core/img/actions/delete.svg') no-repeat center; display: inline; } -#feeds_edit { position: absolute; right: 1.6em; background: url('%webroot%/core/img/actions/rename.svg') no-repeat center; display: inline; } +#feeds_delete { position: absolute; right: 0px; background: url('%webroot%/core/img/actions/delete.svg') no-repeat center; display: none; } +#feeds_edit { position: absolute; right: 1.6em; background: url('%webroot%/core/img/actions/rename.svg') no-repeat center; display: none; } #dropdownBtn { width: 9em; padding-left: 0; padding-right:20px; background: url('%webroot%/core/img/actions/triangle-s.svg') no-repeat right center; } @@ -58,14 +57,14 @@ li.menuItem { margin-left:0.7em; margin-right:0.7em; float: none !important; tex li.feeds_list { margin-left: 16px !important; text-align: right; border-radius: 5px; padding-left: 5px !important; background-color: rgb(255,255,255) !important; } li.feeds_list a { padding: 0 0 0 20px !important; overflow: hidden; text-overflow: ellipsis; text-align: left; width: 65%; } li.folder_list { background-color: rgb(255,255,255) !important; } -div.collapsable_container { padding-left: 5px !important; border-radius: 5px; } +div.collapsable { background: url('%webroot%/core/img/places/folder.svg') no-repeat 5px; padding: 0 0 0 25px; border-radius: 5px; } ul.folders { margin-left: 16px !important; } li.folder_list:hover { color: rgb(0, 0, 0) !important; background-color: rgb(255,255,255) !important; } li.feeds_list:hover { background-color: rgb(221, 221, 221) !important; } -div.collapsable_container:hover { background-color: rgb(221, 221, 221); } +div.collapsable:hover { background-color: rgb(221, 221, 221); } div.add_parentfolder { position: relative; } div.dialog { overflow: visible; } diff --git a/js/news.js b/js/news.js index 3bd51a375..3084ef455 100644 --- a/js/news.js +++ b/js/news.js @@ -108,6 +108,8 @@ News={ $.post(OC.filePath('news', 'ajax', 'createfeed.php'), { feedurl: feedurl, folderid: folderid }, function(jsondata){ if(jsondata.status == 'success'){ + $('div[data-id="' + folderid + '"] > ul').before(jsondata.data.listitem); + setupFeedList(); OC.dialogs.alert(jsondata.data.message, t('news', 'Success!')); } else { OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); @@ -203,9 +205,8 @@ News={ } function setupFeedList() { - $('.collapsable_container').click(function(){ - $(this).parent().children().toggle(); - $(this).toggle(); + $('.collapsable').click(function(){ + $(this).parent().children('ul').toggle(); }); var list = $('.collapsable,.feeds_list').hover( @@ -228,6 +229,7 @@ $(document).ready(function(){ $('#addfeed').click(function() { News.UI.overview('#addfeed_dialog','feeddialog.php'); }); + $('#addfolder').click(function() { News.UI.overview('#addfolder_dialog','folderdialog.php'); }); @@ -245,13 +247,13 @@ $(document).ready(function(){ $('#addfeedfolder').click(function(event) { event.stopPropagation(); }); - + $('#settingsbtn').on('click keydown', function() { try { OC.appSettings({appid:'news', loadJS:true}); } catch(e) { alert(e); - } + } }); setupFeedList(); @@ -259,7 +261,6 @@ $(document).ready(function(){ News.Feed.updateAll(); var updateInterval = 200000; //how often the feeds should update (in msec) setInterval('News.Feed.updateAll()', updateInterval); - }); $(document).click(function(event) { diff --git a/lib/foldermapper.php b/lib/foldermapper.php index 19d7e56a5..b875f1369 100644 --- a/lib/foldermapper.php +++ b/lib/foldermapper.php @@ -34,6 +34,15 @@ class OC_News_FolderMapper { */ public function populate($name, $id){ $root = new OC_News_Folder($name, $id); + + // first add child feeds + $feedmapper = new OC_News_FeedMapper(); + $feeds = $feedmapper->findByFolderId($id); + foreach ($feeds as $feed){ + $root->addChild($feed); + } + + // and second child folders $stmt = OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE user_id = ? AND parent_id = ?'); @@ -44,12 +53,6 @@ class OC_News_FolderMapper { $root->addChild($child); } - $feedmapper = new OC_News_FeedMapper(); - $feeds = $feedmapper->findByFolderId($id); - foreach ($feeds as $feed){ - $root->addChild($feed); - } - return $root; } diff --git a/lib/utils.php b/lib/utils.php index ce7712e9a..b7750e71a 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -19,22 +19,22 @@ class OC_News_Utils { /** * @brief Fetch a feed from remote * @param url remote url of the feed - * @returns + * @returns an instance of OC_News_Feed */ public static function fetch($url){ $spfeed = new SimplePie_Core(); $spfeed->set_feed_url( $url ); $spfeed->enable_cache( false ); - + if (!$spfeed->init()) { return null; } - + //I understand this try-catch sucks, but SimplePie gives weird errors sometimes try { $spfeed->handle_content_type(); $title = $spfeed->get_title(); - + $items = array(); if ($spitems = $spfeed->get_items()) { foreach($spitems as $spitem) { //FIXME: maybe we can avoid this loop @@ -45,7 +45,7 @@ class OC_News_Utils { $items[] = new OC_News_Item($itemUrl, $itemTitle, $itemGUID, $itemBody); } } - + $feed = new OC_News_Feed($url, $title, $items); $favicon = $spfeed->get_image_url(); diff --git a/templates/part.addfeed.php b/templates/part.feeddialog.php index 6807f3c5b..6807f3c5b 100644 --- a/templates/part.addfeed.php +++ b/templates/part.feeddialog.php diff --git a/templates/part.feeds.php b/templates/part.feeds.php index dd6a93c5f..fbf702387 100644 --- a/templates/part.feeds.php +++ b/templates/part.feeds.php @@ -1,38 +1,23 @@ <?php function print_folder(OC_News_Folder $folder, $depth){ $l = new OC_l10n('news'); + include("part.listfolder.php"); - echo '<ul class="folders"' . (($depth == 0) ? 'style="margin-left: 0px !important;"' : '') .'> <li class="folder_list" >' . - '<div class="collapsable_container">' . - '<div class="collapsable" >' . strtoupper($folder->getName()) . - ( ($depth != 0) ? '<button class="svg action" id="feeds_delete" onClick="(News.Folder.delete(' . $folder->getId(). '))" title="' . $l->t('Delete folder') . '"></button>' . - '<button class="svg action" id="feeds_edit" title="' . $l->t('Rename folder') . '"></button>': '' ) . - '</div>' . - '</div>'; - echo '<ul>'; $children = $folder->getChildren(); foreach($children as $child) { if ($child instanceOf OC_News_Folder){ print_folder($child, $depth+1); } elseif ($child instanceOf OC_News_Feed) { //onhover $(element).attr('id', 'newID'); - $favicon = $child->getFavicon(); - if ($favicon == null) { - $favicon = OCP\Util::imagePath('news', 'rss.svg'); - } - echo '<li class="feeds_list" data-id="' . $child->getId() . '"><a href="' . OCP\Util::linkTo('news', 'index.php'). '?feedid=' . $child->getId() . '" style="background: url(' . $favicon . ') left center no-repeat; background-size:16px 16px;">' . $child->getTitle() .'</a>'; - countUnreadItems($child->getId()); - echo '<button class="svg action" id="feeds_delete" onClick="(News.Feed.delete(' . $child->getId(). '))" title="' . $l->t('Delete feed') . '"></button>'; - echo '<button class="svg action" id="feeds_edit" title="' . $l->t('Edit feed') . '"></button>'; - echo '</li>'; + $tmpl = new OCP\Template("news", "part.listfeed"); + $tmpl->assign('child', $child); + $tmpl->printpage(); } else { //TODO:handle error in this case } } - echo '</ul></li></ul>'; + echo '</ul></div></li></ul>'; } - - include("part.itemcounter.php"); print_folder($_['allfeeds'], 0); ?>
\ No newline at end of file diff --git a/templates/part.addfolder.php b/templates/part.folderdialog.php index e1217160c..e1217160c 100644 --- a/templates/part.addfolder.php +++ b/templates/part.folderdialog.php |