diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2012-08-14 23:09:23 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2012-08-14 23:09:23 +0200 |
commit | 598ce8cb29880b0c06fd51c0402fcaf8e27dfd08 (patch) | |
tree | 2e54c6d2df5448c680ff904ed8c502785d73cc0c | |
parent | 9b06280402269bd3ee92038160f0f269311558a0 (diff) | |
parent | 51bf7344a712d0ce140020e75099b11a8d007639 (diff) |
Merge branch 'newsapp' of git://gitorious.org/owncloud/apps into newsapp
-rw-r--r-- | css/news.css | 8 | ||||
-rw-r--r-- | js/news.js | 45 | ||||
-rw-r--r-- | js/settings.js | 11 | ||||
-rw-r--r-- | lib/utils.php | 7 | ||||
-rw-r--r-- | templates/addBm.php | 11 | ||||
-rw-r--r-- | templates/bookmarklet.php | 8 | ||||
-rw-r--r-- | templates/part.items.php | 2 | ||||
-rw-r--r-- | templates/part.nofeeds.php | 11 | ||||
-rw-r--r-- | templates/settings.php | 7 |
9 files changed, 99 insertions, 11 deletions
diff --git a/css/news.css b/css/news.css index 2ea444083..fe19bc56c 100644 --- a/css/news.css +++ b/css/news.css @@ -30,21 +30,23 @@ div.add_parentfolder { #firstrun { width: 100%; position: absolute; - top: 5em; + top: 3em; left: 0; text-align: center; font-weight:bold; font-size:1.5em; color:#777; } + #firstrun small { display: block; font-weight: normal; font-size: 0.8em; margin-bottom: 1em; } + #firstrun .button { font-size: 0.7em; } #firstrun #selections { font-size:0.8em; - margin: 2em auto auto auto; + margin: 2em auto 2em auto; clear: both; } - + /** * View above the feeds which shows the feed title * and the controls diff --git a/js/news.js b/js/news.js index 373562e5e..257d67e2d 100644 --- a/js/news.js +++ b/js/news.js @@ -159,6 +159,51 @@ News={ } }); }, + submitFirstRun:function(button){ + + var feedurl = $("#feed_add_url").val().trim(); + + if(feedurl.length == 0) { + OC.dialogs.alert(t('news', 'URL cannot be empty.'), t('news', 'Error')); + return false; + } + + $(button).attr("disabled", true); + $(button).prop('value', t('news', 'Adding...')); + + $.ajax({ + type: "POST", + url: OC.filePath('news', 'ajax', 'createfeed.php'), + data: { 'feedurl': feedurl, 'folderid': folderid }, + dataType: "json", + success: function(jsondata){ + if(jsondata.status == 'success'){ + $('.collapsable_container[data-id="' + folderid + '"] > ul').append(jsondata.data.listfeed); + setupFeedList(); + News.Feed.load(jsondata.data.feedid); + window.reload(); + + OC.dialogs.confirm(t('news', 'Do you want to add another feed?'), t('news', 'Feed added!'), function(answer) { + if(!answer) { + $('#addfeed_dialog').dialog('destroy').remove(); + $('ul.accordion').before(jsondata.data.part_newfeed); + } + }); + } else { + OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); + } + $("#feed_add_url").val(''); + $(button).attr("disabled", false); + $(button).prop('value', t('news', 'Add feed')); + }, + error: function(xhr) { + OC.dialogs.alert(t('news', 'Error while parsing the feed'), t('news', 'Fatal Error')); + $("#feed_add_url").val(''); + $(button).attr("disabled", false); + $(button).prop('value', t('news', 'Add feed')); + } + }); + }, 'delete':function(feedid) { $('.feeds_delete').tipsy('hide'); OC.dialogs.confirm(t('news', 'Are you sure you want to delete this feed?'), t('news', 'Warning'), function(answer) { diff --git a/js/settings.js b/js/settings.js index c5a7e43ce..6709884ec 100644 --- a/js/settings.js +++ b/js/settings.js @@ -27,7 +27,7 @@ News.Settings={ $('#opml_file').text(t('news', 'File ') + file.name + t('news', ' loaded from local filesystem.')); $('#opml_file').prop('value', file.name); }, - import:function(button){ + importOpml:function(button){ $(button).attr("disabled", true); $(button).prop('value', t('news', 'Importing...')); @@ -51,6 +51,10 @@ News.Settings={ $(button).prop('value', t('news', 'Import')); $(button).attr("disabled", false); }); + }, + exportOpml:function(button){ + //TODO + alert("test"); } } @@ -73,6 +77,9 @@ $('#file_upload_start').change(function() { }); $('#importbtn').click(function() { - News.Settings.import(this); + News.Settings.importOpml(this); }); +$('#exportbtn').click(function() { + News.Settings.exportOpml(this); +}); diff --git a/lib/utils.php b/lib/utils.php index e67ea21f5..5def91e4a 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -13,7 +13,7 @@ namespace OCA\News; // load SimplePie library -//TODO: is this file a suitable place for the following require? +//TODO: is this a suitable place for the following require? require_once('news/3rdparty/SimplePie/autoloader.php'); class Utils { @@ -44,7 +44,10 @@ class Utils { $itemTitle = $spitem->get_title(); $itemGUID = $spitem->get_id(); $itemBody = $spitem->get_content(); - $items[] = new Item($itemUrl, $itemTitle, $itemGUID, $itemBody); + $itemAuthor = $spitem->get_author(); + $item = new Item($itemUrl, $itemTitle, $itemGUID, $itemBody); + $item->setAuthor($itemAuthor->get_name()); + $items[] = $item; } } diff --git a/templates/addBm.php b/templates/addBm.php new file mode 100644 index 000000000..e9132ca57 --- /dev/null +++ b/templates/addBm.php @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Subsribe - News - ownCloud</title> + </head> + <body> + <div class="message"><h1>Saved!</h1></div> + <a href="javascript:self.close()" >Close the window</a> + </body> +</html>
\ No newline at end of file diff --git a/templates/bookmarklet.php b/templates/bookmarklet.php new file mode 100644 index 000000000..31a654b86 --- /dev/null +++ b/templates/bookmarklet.php @@ -0,0 +1,8 @@ +<?php + +function createBookmarklet() { + $l = OC_L10N::get('news'); + echo '<small>' . $l->t('Drag this to your browser bookmarks and click on it whenever you want to subscribe to a webpage quickly:') . '</small>' + . '<a class="button bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OCP\Util::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">' + . $l->t('Subscribe') . '</a>'; +} diff --git a/templates/part.items.php b/templates/part.items.php index ed9eb61ec..afac3e10a 100644 --- a/templates/part.items.php +++ b/templates/part.items.php @@ -42,7 +42,7 @@ foreach($items as $item) { echo '<h1 class="item_title"><a target="_blank" href="' . $item->getUrl() . '">' . $item->getTitle() . '</a></h1>'; - echo '<h2 class="item_author">' . $l->t('from') . ' ' . parse_url($item->getUrl(), PHP_URL_PATH) . '</h2>'; + echo '<h2 class="item_author">' . $l->t('from') . ' ' . parse_url($item->getUrl(), PHP_URL_HOST) . '</h2>'; echo '<div class="body">' . $item->getBody() . '</div>'; diff --git a/templates/part.nofeeds.php b/templates/part.nofeeds.php index 3a9c14b14..c1e639321 100644 --- a/templates/part.nofeeds.php +++ b/templates/part.nofeeds.php @@ -2,7 +2,16 @@ <div id="firstrun"> <?php echo $l->t('You have no feeds in your reader.') ?> <div id="selections"> - <input type="button" id="addfeedbtn" value="<?php echo $l->t('Add feed') ?>" /> + <input type="button" id="addfeedbtn" value="<?php echo $l->t('Add feed') ?>" /><br /> <input type="button" id="importopmlbtn" value="<?php echo $l->t('Import OPML') ?>" /> </div> + <div> + <?php + require_once(OC_App::getAppPath('news') .'/templates/bookmarklet.php'); + echo $l->t('Or... '); + ?> + <div> + <?php createBookmarklet(); ?> + </div> + </div> </div>
\ No newline at end of file diff --git a/templates/settings.php b/templates/settings.php index 94b8fc2f6..b063fc1ed 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -7,7 +7,10 @@ <?php echo $l->t(' or '); ?><a href='#' class="settings" id="cloudlink"><?php echo $l->t('cloud');?></a>. </span> <input type="file" id="file_upload_start" name="files[]" /> - <input style="float: right" id="importbtn" type="submit" value="<?php echo $l->t('Import');?>" /></dd> + <input style="float: right" id="importbtn" type="submit" value="<?php echo $l->t('Import');?>" /> + </dd> <dt><?php echo $l->t('Export feeds'); ?></dt> - <dd></dd> + <dd> + <button id="exportbtn" title="<?php echo $l->t('Download OPML'); ?>">Download OPML</button> + </dd> </dl>
\ No newline at end of file |