Add direct URL to files

Ability to download files directly via pre-configured webserver. Simply
supply the base URL and links will be added to each file in the details
section.
This commit is contained in:
Nicholas Orr 2015-04-29 01:31:04 +08:00
parent e2176862ee
commit 77785173bf
7 changed files with 41 additions and 3 deletions

View File

@ -12,7 +12,8 @@ angular
/*-----------------------------*/ /*-----------------------------*/
// user: '*YOUR_USERNAME*', // user: '*YOUR_USERNAME*',
// pass: '*YOUR_SECRET_PASS*' // pass: '*YOUR_SECRET_PASS*'
} },
directURL: '' // If supplied, links will be created to enable direct download from the aria2 server, requires appropriate webserver to be configured
}) })
.constant('$enable', { .constant('$enable', {

View File

@ -100,3 +100,6 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.download-files a {
color: #fff;
}

View File

@ -44,6 +44,7 @@
<script src="js/directives/fselect.js"></script> <script src="js/directives/fselect.js"></script>
<script src="js/filters/bytes.js"></script> <script src="js/filters/bytes.js"></script>
<script src="js/filters/url.js"></script>
<script src="js/services/deps.js"></script> <script src="js/services/deps.js"></script>
<script src="js/services/base64.js"></script> <script src="js/services/base64.js"></script>
@ -584,7 +585,10 @@
<li class="label label-default" title="Download Path"><i class="fa fa-fw fa-folder-open">&nbsp;</i> <span class="download-dir">{{download.dir}}</span></li> <li class="label label-default" title="Download Path"><i class="fa fa-fw fa-folder-open">&nbsp;</i> <span class="download-dir">{{download.dir}}</span></li>
</ul> </ul>
<ul class="download-files hidden-phone download-item"> <ul class="download-files hidden-phone download-item">
<li class="label label-default" ng-repeat="file in download.files" ng-class="{'label-success': file.selected}">{{file.relpath}} ({{file.fmtLength}})</li> <li class="label label-default" ng-repeat="file in download.files" ng-class="{'label-success': file.selected}">
<a ng-if="hasDirectURL()" ng-click="$event.stopPropagation()" ng-href="{{getDirectURL()}}{{file.relpath | encodeURI}}" target="download">{{file.relpath}} ({{file.fmtLength}})</a>
<span ng-if="!hasDirectURL()">{{file.relpath}} ({{file.fmtLength}})</span>
</li>
</ul> </ul>
<div ng-show="hasStatus(download, 'active')" class="download-item hidden-phone"> <div ng-show="hasStatus(download, 'active')" class="download-item hidden-phone">
<div class="download-graph" dspeed="download.downloadSpeed" uspeed="download.uploadSpeed" xticks="7" yticks="7" dgraph draw="!download.collapsed"></div> <div class="download-graph" dspeed="download.downloadSpeed" uspeed="download.uploadSpeed" xticks="7" yticks="7" dgraph draw="!download.collapsed"></div>
@ -988,6 +992,21 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4 --out=file2.mp4
</div> </div>
</div> </div>
</fieldset> </fieldset>
<fieldset>
<legend>Direct Download</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Enter base URL (optional):</label>
<div class="col-sm-9 controls">
<input type="text" class="form-control input-xlarge"
ng-model="connection.conf.directURL"/>
<p class="help-block">
If supplied, links will be created to enable direct download from the
aria2 server, requires appropriate webserver to be configured
</p>
</div>
</div>
</fieldset>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -357,6 +357,14 @@ function(
return downloads; return downloads;
} }
scope.hasDirectURL = function() {
return rpc.getDirectURL() != '';
}
scope.getDirectURL = function() {
return rpc.getDirectURL();
}
// convert the donwload form aria2 to once used by the view, // convert the donwload form aria2 to once used by the view,
// minor additions of some fields and checks // minor additions of some fields and checks
scope.getCtx = function(d, ctx) { scope.getCtx = function(d, ctx) {

4
js/filters/url.js Normal file
View File

@ -0,0 +1,4 @@
angular.module('webui.filters.url', ["webui.services.utils"])
.filter('encodeURI', function() {
return window.encodeURIComponent;
});

View File

@ -3,7 +3,7 @@ var webui = angular.module('webui', [
'webui.services.configuration', 'webui.services.rpc', 'webui.services.configuration', 'webui.services.rpc',
'webui.services.modals', 'webui.services.alerts', 'webui.services.modals', 'webui.services.alerts',
'webui.services.settings', 'webui.services.settings.filters', 'webui.services.settings', 'webui.services.settings.filters',
'webui.filters.bytes', 'webui.filters.bytes','webui.filters.url',
'webui.directives.chunkbar', 'webui.directives.dgraph', 'webui.directives.fselect', 'webui.directives.chunkbar', 'webui.directives.dgraph', 'webui.directives.fselect',
'webui.ctrls.download', 'webui.ctrls.nav', 'webui.ctrls.modal', 'webui.ctrls.alert', 'webui.ctrls.download', 'webui.ctrls.nav', 'webui.ctrls.modal', 'webui.ctrls.alert',
'webui.ctrls.props', 'webui.ctrls.props',

View File

@ -171,6 +171,9 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) {
// get current configuration being used // get current configuration being used
getConfiguration: function() { return currentConf }, getConfiguration: function() { return currentConf },
// get currently configured directURL
getDirectURL : function() { return currentConf.directURL },
// syscall is done only once, delay is optional // syscall is done only once, delay is optional
// and pass true to only dispatch it in the global timeout // and pass true to only dispatch it in the global timeout
// which can be used to batch up once calls // which can be used to batch up once calls