diff options
-rw-r--r-- | css/settings.css | 1 | ||||
-rw-r--r-- | js/news.js | 71 | ||||
-rw-r--r-- | js/settings.js | 65 | ||||
-rw-r--r-- | lib/utils.php | 7 | ||||
-rw-r--r-- | opmlparser.php | 7 | ||||
-rw-r--r-- | settings.php | 5 | ||||
-rw-r--r-- | templates/main.php | 5 | ||||
-rw-r--r-- | templates/settings.php (renamed from templates/part.importdialog.php) | 7 |
8 files changed, 91 insertions, 77 deletions
diff --git a/css/settings.css b/css/settings.css new file mode 100644 index 000000000..3141a584e --- /dev/null +++ b/css/settings.css @@ -0,0 +1 @@ +#cloudlink { color: red !important; }
\ No newline at end of file diff --git a/js/news.js b/js/news.js index 91ce532b2..19adacb89 100644 --- a/js/news.js +++ b/js/news.js @@ -27,26 +27,6 @@ News={ }else{ $('#dialog_holder').load(OC.filePath('news', 'ajax', dialogfile), function(jsondata){ if(jsondata.status != 'error'){ - if(dialogtype == '#import_dialog') { - //TODO: group all the following calls in a method - $('#browsebtn, #cloudbtn, #importbtn').hide(); - $('#cloudbtn, #cloudlink').click(function() { - /* - * it needs to be filtered by MIME type, but there are too many MIME types corresponding to opml - * and filepicker doesn't support multiple MIME types filter. - */ - OC.dialogs.filepicker(t('news', 'Select file'), News.Opml.cloudFileSelected, false, '', true); - }); - $('#browsebtn, #browselink').click(function() { - $('#file_upload_start').trigger('click'); - }); - $('#file_upload_start').change(function() { - News.Opml.browseFile(this.files); - }); - $('#importbtn').click(function() { - News.Opml.import(this); - }); - } $(dialogtype).dialog({ dialogClass:'dialog', minWidth: 600, @@ -62,51 +42,6 @@ News={ return false; } }, - Opml: { - importpath:'', - importkind:'', - cloudFileSelected:function(path){ - $.getJSON(OC.filePath('news', 'ajax', 'selectfromcloud.php'),{'path':path},function(jsondata){ - if(jsondata.status == 'success'){ - $('#browsebtn, #cloudbtn, #importbtn').show(); - $("#opml_file").text(t('news', 'File ') + path + t('news', ' loaded from cloud.')); - News.Opml.importkind = 'cloud'; - News.Opml.importpath = jsondata.data.tmp; - } - else{ - OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); - } - }); - }, - browseFile:function(filelist){ - if(!filelist) { - OC.dialogs.alert(t('news','No files selected.'), t('news', 'Error')); - return; - } - var file = filelist[0]; - $("#browsebtn, #cloudbtn, #importbtn").show(); - $("#opml_file").text(t('news', 'File ') + file.name + t('news', ' loaded from local filesystem.')); - $("#opml_file").prop('value', file.name); - }, - import:function(button){ - $(button).attr("disabled", true); - $(button).prop('value', t('news', 'Importing...')); - - var path = ''; - if (News.Opml.importkind == 'cloud') { - path = News.Opml.importpath; - } else { - - } - - $.post(OC.filePath('news', 'ajax', 'importopml.php'), { path: path }, function(jsondata){ - if (jsondata.status == 'success') { - alert(jsondata.data.title); - } - }); - - } - }, Folder: { submit:function(button){ var displayname = $("#folder_add_name").val().trim(); @@ -310,9 +245,9 @@ $(document).ready(function(){ $('#addfeedfolder').click(function(event) { event.stopPropagation(); }); - - $('#settingsbtn').click(function() { - News.UI.overview('#import_dialog', 'importdialog.php'); + + $('#settingsbtn').on('click keydown', function() { + OC.appSettings({appid:'news', loadJS:true}); }); setupFeedList(); diff --git a/js/settings.js b/js/settings.js new file mode 100644 index 000000000..b1f81410e --- /dev/null +++ b/js/settings.js @@ -0,0 +1,65 @@ +News={ + Settings: { + importpath:'', + importkind:'', + cloudFileSelected:function(path){ + $.getJSON(OC.filePath('news', 'ajax', 'selectfromcloud.php'),{'path':path},function(jsondata){ + if(jsondata.status == 'success'){ + $('#browsebtn, #cloudbtn, #importbtn').show(); + $('#opml_file').text(t('news', 'File ') + path + t('news', ' loaded from cloud.')); + News.Settings.importkind = 'cloud'; + News.Settings.importpath = jsondata.data.tmp; + } + else{ + OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); + } + }); + }, + browseFile:function(filelist){ + if(!filelist) { + OC.dialogs.alert(t('news','No files selected.'), t('news', 'Error')); + return; + } + var file = filelist[0]; + $('#browsebtn, #cloudbtn, #importbtn').show(); + $('#opml_file').text(t('news', 'File ') + file.name + t('news', ' loaded from local filesystem.')); + $('#opml_file').prop('value', file.name); + }, + import:function(button){ + $(button).attr("disabled", true); + $(button).prop('value', t('news', 'Importing...')); + + var path = ''; + if (News.Settings.importkind == 'cloud') { + path = News.Settings.importpath; + } else { + + } + + $.post(OC.filePath('news', 'ajax', 'importopml.php'), { path: path }, function(jsondata){ + if (jsondata.status == 'success') { + alert(jsondata.data.title); + } + }); + + } + } +} + +$('#browsebtn, #cloudbtn, #importbtn').hide(); +$('#cloudbtn, #cloudlink').click(function() { + /* + * it needs to be filtered by MIME type, but there are too many MIME types corresponding to opml + * and filepicker doesn't support multiple MIME types filter. + */ + OC.dialogs.filepicker(t('news', 'Select file'), News.Settings.cloudFileSelected, false, '', true); +}); +$('#browsebtn, #browselink').click(function() { + $('#file_upload_start').trigger('click'); +}); +$('#file_upload_start').change(function() { + News.Settings.browseFile(this.files); +}); +$('#importbtn').click(function() { + News.Settings.import(this); +}); diff --git a/lib/utils.php b/lib/utils.php index cc3b6aa09..ce7712e9a 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -30,6 +30,8 @@ class OC_News_Utils { return null; } + //I understand this try-catch sucks, but SimplePie gives weird errors sometimes + try { $spfeed->handle_content_type(); $title = $spfeed->get_title(); @@ -57,7 +59,10 @@ class OC_News_Utils { $feed->setFavicon($webFavicon); } return $feed; - + } + catch (Exception $e) { + return null; + } } public static function checkFavicon($favicon) { diff --git a/opmlparser.php b/opmlparser.php index 072c74b86..34f8f115e 100644 --- a/opmlparser.php +++ b/opmlparser.php @@ -56,13 +56,14 @@ class OPMLParser { private function parseFeed($rawfeed) { $url = (string)$rawfeed['xmlUrl']; - + echo $url; + $feed = OC_News_Utils::fetch($url); - if ($feed !== null) { + + if ($feed != null) { $title = $rawfeed['title']; $feed->setTitle($title); } - echo $url; return $feed; } diff --git a/settings.php b/settings.php new file mode 100644 index 000000000..e2a56c88c --- /dev/null +++ b/settings.php @@ -0,0 +1,5 @@ +<?php + +$tmpl = new OCP\Template( 'news', 'settings' ); + +$tmpl->printPage(); diff --git a/templates/main.php b/templates/main.php index a3bac4921..700acd244 100644 --- a/templates/main.php +++ b/templates/main.php @@ -14,8 +14,10 @@ <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> </li> - <li><button class="svg" title="<?php echo $l->t('Change View'); ?>">Eye</button></li> <li> + <button class="svg" title="<?php echo $l->t('Change View'); ?>">Eye</button> + </li> + <li style="float: right"> <button class="svg" id="settingsbtn" title="<?php echo $l->t('Settings'); ?>"><img class="svg" src="<?php echo OCP\Util::imagePath('core','actions/settings.png'); ?>" alt="<?php echo $l->t('Settings'); ?>" /></button> </li> <ul> @@ -30,6 +32,7 @@ echo $this->inc("part.nofeeds"); } ?> + <div id="appsettings" class="popup bottomleft hidden"></div> </div> <!-- Dialogs --> diff --git a/templates/part.importdialog.php b/templates/settings.php index 3aa2aca88..a4d6ec80d 100644 --- a/templates/part.importdialog.php +++ b/templates/settings.php @@ -1,6 +1,5 @@ -<div id="import_dialog" title="<?php echo $l->t("Settings"); ?>"> <dl> - <dt><?php echo $l->t('Import'); ?></dt> + <dt><?php echo $l->t('Import feeds'); ?></dt> <dd><button class="svg" id="browsebtn" title="<?php echo $l->t('Upload file from desktop'); ?>" onclick="News.DropDownMenu.fade('ul#feedfoldermenu')"><img class="svg" src="<?php echo OCP\Util::imagePath('core','actions/upload.svg'); ?>" alt="<?php echo $l->t('Upload'); ?>" /></button> <button class="svg" id="cloudbtn" title="<?php echo $l->t('Select file from ownCloud'); ?>"><img class="svg" src="<?php echo OCP\Util::imagePath('core','actions/upload.svg'); ?>" alt="<?php echo $l->t('Select'); ?>" /></button> <span id="opml_file"> @@ -9,6 +8,6 @@ </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> - <dt><?php echo $l->t('Export'); ?></dt> + <dt><?php echo $l->t('Export feeds'); ?></dt> <dd></dd> -</dl>
\ No newline at end of file +</dl>
\ No newline at end of file |