import OPML

This commit is contained in:
Jeremie Panzer
2013-03-25 12:24:00 +01:00
parent fa18c80e84
commit f0c4733b76
30 changed files with 307 additions and 24 deletions

View File

@@ -1,5 +1,16 @@
<div>
<button class="btn" ng-click="open()">Subscribe</button>
<div class="btn-group">
<button class="btn" ng-click="open()">Subscribe</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a ng-click="open()">Subscribe</a>
</li>
<li><a ng-click="openImport()">Import</a></li>
</ul>
</div>
<div modal="isOpen" close="close()" options="opts">
<div class="modal-header">
<button type="button" class="close" ng-click="close()">&times;</button>
@@ -32,4 +43,27 @@
<button class="btn btn-primary ok" ng-click="save()">Save</button>
</div>
</div>
<div modal="isOpenImport" close="closeImport()" options="opts">
<div class="modal-header">
<button type="button" class="close" ng-click="closeImport()">&times;</button>
<h4>Import</h4>
</div>
<form ng-upload class="form-horizontal" action="rest/subscriptions/import">
<div class="modal-body">
<div class="control-group">
<span>Select the subscriptions.xml file you got from the zip file on google.com/takeout</span>
</div>
<div class="control-group">
<label class="control-label">XML File</label>
<div class="controls">
<input type="file" name="file"></input>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-warning cancel" ng-click="closeImport()">Cancel</button>
<button class="btn btn-primary ok" type="submit" upload-submit="uploadComplete(contents, completed)">Import</button>
</div>
</form>
</div>
</div>

View File

@@ -44,6 +44,9 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location,
$scope.formatFeedName = function(feed) {
var label = feed.name;
if (feed.message) {
label = "!!! " + label;
}
if (feed.unread > 0) {
label = label + " (" + feed.unread + ")";
}

View File

@@ -1,6 +1,6 @@
var module = angular.module('commafeed.directives', []);
module.directive('subscribe', function() {
module.directive('subscribe', function(SubscriptionService) {
return {
scope : {},
restrict : 'E',
@@ -13,6 +13,7 @@ module.directive('subscribe', function() {
};
$scope.isOpen = false;
$scope.isOpenImport = false;
$scope.sub = {};
$scope.SubscriptionService = SubscriptionService;
@@ -31,6 +32,19 @@ module.directive('subscribe', function() {
$scope.close();
});
};
$scope.openImport = function() {
$scope.isOpenImport = true;
};
$scope.closeImport = function() {
$scope.isOpenImport = false;
};
$scope.uploadComplete = function(contents, completed) {
SubscriptionService.init();
$scope.closeImport();
};
}
};
});

View File

@@ -1,6 +1,6 @@
var app = angular
.module('commafeed', [ 'ui', 'ui.bootstrap', 'commafeed.directives',
'commafeed.controllers', 'commafeed.services', 'ngSanitize' ]);
var app = angular.module('commafeed', [ 'ui', 'ui.bootstrap',
'commafeed.directives', 'commafeed.controllers', 'commafeed.services',
'ngSanitize', 'ngUpload' ]);
app.config([ '$routeProvider', function($routeProvider) {
$routeProvider.when('/feeds/view/:_type/:_id', {

View File

@@ -0,0 +1 @@
angular.module("ngUpload",[]).directive("uploadSubmit",["$parse",function(t){return{restrict:"AC",link:function(a,e,n){var o={};o.enableControls=n.uploadOptionsEnableControls;var i=e.parents("form[ng-upload]")||e.parents("form.ng-upload"),r=t(n.uploadSubmit);if(!angular.isFunction(r)){var l="The expression on the ngUpload directive does not point to a valid function.";throw l+"\n"}e.bind("click",function(t){t.preventDefault=!0;var n=angular.element("<iframe id='upload_iframe' name='upload_iframe' border='0' width='0' height='0' style='width: 0px; height: 0px; border: none; display: none' />");n.bind("load",function(){var t=n.contents().find("body").text();a.$apply(function(){r(a,{content:t,completed:!0})}),""!==t&&setTimeout(function(){n.remove()},250),e.attr("disabled",null),e.attr("title","Click to start upload.")}),i.parent().append(n),a.$apply(function(){r(a,{content:"Please wait...",completed:!1})});var l=!0;o.enableControls||(e.attr("disabled","disabled"),l=!1),e.attr("title",(l?"[ENABLED]: ":"[DISABLED]: ")+"Uploading, please wait..."),i.submit()}).attr("title","Click to start upload.")}}}]).directive("ngUpload",["$parse",function(){return{restrict:"AC",link:function(t,a){a.attr("target","upload_iframe"),a.attr("method","post"),a.attr("action",a.attr("action")+"?_t="+(new Date).getTime()),a.attr("enctype","multipart/form-data"),a.attr("encoding","multipart/form-data")}}}]);