Skip to content

Commit

Permalink
实现savesession
Browse files Browse the repository at this point in the history
重写了启动aria2方法已实现savesession
  • Loading branch information
yangshun1029 authored and yangshun1029 committed Dec 7, 2015
1 parent 33e97fd commit 276b349
Show file tree
Hide file tree
Showing 592 changed files with 119,618 additions and 5,468 deletions.
8 changes: 6 additions & 2 deletions Aria2GUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
01D045B01C035821001468EF /* aria2c in Resources */ = {isa = PBXBuildFile; fileRef = 01D045AF1C035821001468EF /* aria2c */; };
01D045B91C035C4B001468EF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01D045B71C035C4B001468EF /* MainMenu.xib */; };
01D045BA1C035C4B001468EF /* Window.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01D045B81C035C4B001468EF /* Window.xib */; };
01D2CA7F1C1054F2003EA537 /* startaria.sh in Resources */ = {isa = PBXBuildFile; fileRef = 01D2CA7E1C1054F2003EA537 /* startaria.sh */; };
1495814F15C15CCC00E1CFE5 /* Notice.m in Sources */ = {isa = PBXBuildFile; fileRef = 1495814E15C15CCC00E1CFE5 /* Notice.m */; };
6F169DA718CC332E005EDDF3 /* Command.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F169DA618CC332E005EDDF3 /* Command.m */; };
6F169DAA18CC35FD005EDDF3 /* CallbackDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F169DA918CC35FD005EDDF3 /* CallbackDelegate.m */; };
Expand Down Expand Up @@ -59,6 +60,7 @@
01D045AF1C035821001468EF /* aria2c */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = aria2c; path = MacGap/aria2c; sourceTree = "<group>"; };
01D045B71C035C4B001468EF /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = "<group>"; };
01D045B81C035C4B001468EF /* Window.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Window.xib; sourceTree = "<group>"; };
01D2CA7E1C1054F2003EA537 /* startaria.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = startaria.sh; sourceTree = "<group>"; };
1495814D15C15CCC00E1CFE5 /* Notice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Notice.h; path = Classes/Commands/Notice.h; sourceTree = "<group>"; };
1495814E15C15CCC00E1CFE5 /* Notice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Notice.m; path = Classes/Commands/Notice.m; sourceTree = "<group>"; };
6F169DA518CC332E005EDDF3 /* Command.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Command.h; path = Classes/Commands/Command.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -234,6 +236,7 @@
FAE451C414BA79C600190544 /* MacGap */ = {
isa = PBXGroup;
children = (
01D2CA7E1C1054F2003EA537 /* startaria.sh */,
01D045B71C035C4B001468EF /* MainMenu.xib */,
01D045B81C035C4B001468EF /* Window.xib */,
FA3250E014BA87B800BF0781 /* Classes */,
Expand Down Expand Up @@ -309,6 +312,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
01D2CA7F1C1054F2003EA537 /* startaria.sh in Resources */,
FA3250E514BA883A00BF0781 /* public in Resources */,
01D045B01C035821001468EF /* aria2c in Resources */,
FAE451C914BA79C600190544 /* InfoPlist.strings in Resources */,
Expand Down Expand Up @@ -432,7 +436,7 @@
GCC_PREFIX_HEADER = "MacGap/Aria2GUI-Prefix.pch";
GCC_VERSION = "";
INFOPLIST_FILE = "MacGap/Aria2GUI-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = "com.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Aria2GUI;
SDKROOT = macosx;
Expand All @@ -454,7 +458,7 @@
GCC_PREFIX_HEADER = "MacGap/Aria2GUI-Prefix.pch";
GCC_VERSION = "";
INFOPLIST_FILE = "MacGap/Aria2GUI-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = "com.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Aria2GUI;
SDKROOT = macosx;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
3 changes: 2 additions & 1 deletion MacGap/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#import <Cocoa/Cocoa.h>
#import "Classes/ContentView.h"

#import "WindowController.h"


@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (retain, nonatomic) WindowController *windowController;


@end
36 changes: 34 additions & 2 deletions MacGap/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#import "AppDelegate.h"

@implementation AppDelegate

@synthesize windowController;


- (void) applicationWillFinishLaunching:(NSNotification *)aNotification
{

Expand All @@ -26,12 +26,44 @@ -(BOOL)applicationShouldHandleReopen:(NSApplication*)application
return YES;
}

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.windowController = [[WindowController alloc] initWithURL: kStartPage];
[self.windowController showWindow: [NSApplication sharedApplication].delegate];
self.windowController.contentView.webView.alphaValue = 1.0;
self.windowController.contentView.alphaValue = 1.0;
[self.windowController showWindow:self];
[self startAria2];

}


-(void)applicationWillTerminate:(NSNotification *)notification
{
[self closeAria2];
}

//-(void)showbadge {
// [[[NSApplication sharedApplication] dockTile] setBadgeLabel:[NSString stringWithFormat:]];
//}

-(void)startAria2
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"startaria" ofType:@"sh"];
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/bin/sh";
task.arguments = @[path];
[task launch];
//NSArray *arguments = [NSArray arrayWithObjects: @"--enable-rpc=true", @"--check-integrity=true",@"--rpc-listen-all=true", @"--rpc-allow-origin-all", @"--max-connection-per-server=10",@"--max-concurrent-downloads=10",@"--min-split-size=10M",@"--split=10",@"--bt-enable-lpd=true",@"--bt-max-peers=55",@"--bt-require-crypto=true",@"-c",@"-D", @"-d",savePath, nil];
}

-(void)closeAria2
{
NSArray *arg =[NSArray arrayWithObjects:@"aria2c",nil];
NSTask *task=[[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/killall"];
[task setArguments:arg];
[task launch];
}

@end
2 changes: 1 addition & 1 deletion MacGap/Aria2GUI-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 0 additions & 1 deletion MacGap/Classes/ContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ - (void) awakeFromNib
[self.webView setPolicyDelegate:self.delegate];
[self.webView setDrawsBackground:NO];
[self.webView setShouldCloseWithWindow:NO];

[self.webView setGroupName:@"MacGap"];

}
Expand Down
2 changes: 2 additions & 0 deletions MacGap/Classes/WebViewDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ - (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary
[listener ignore];
}



#pragma mark WebScripting protocol

+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector
Expand Down
10 changes: 5 additions & 5 deletions MacGap/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="14F1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
Expand All @@ -11,7 +11,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="546" customClass="AppDelegate"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<items>
Expand All @@ -37,7 +37,7 @@
<menuItem isSeparatorItem="YES" id="144">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Hide MacGap" keyEquivalent="h" id="134">
<menuItem title="Hide Aria2GUI" keyEquivalent="h" id="134">
<connections>
<action selector="hide:" target="-1" id="367"/>
</connections>
Expand All @@ -56,7 +56,7 @@
<menuItem isSeparatorItem="YES" id="149">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Quit MacGap" keyEquivalent="q" id="136">
<menuItem title="Quit Arai2GUI" keyEquivalent="q" id="136">
<connections>
<action selector="terminate:" target="-3" id="449"/>
</connections>
Expand Down Expand Up @@ -92,7 +92,7 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="491">
<items>
<menuItem title="MacGap Help" keyEquivalent="?" id="492">
<menuItem title="Aria2GUI Help" keyEquivalent="?" id="492">
<connections>
<action selector="showHelp:" target="-1" id="493"/>
</connections>
Expand Down
4 changes: 2 additions & 2 deletions MacGap/Window.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="14F1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
Expand All @@ -20,7 +20,7 @@
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="1280" height="720"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
<value key="minSize" type="size" width="500" height="500"/>
<value key="minSize" type="size" width="1040" height="700"/>
<view key="contentView" id="2" customClass="ContentView">
<rect key="frame" x="0.0" y="0.0" width="1280" height="720"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
5 changes: 3 additions & 2 deletions MacGap/WindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

}

- (id) initWithURL:(NSString *) url;
- (id) initWithRequest: (NSURLRequest *)request;
- (id) initWithURL:(NSString *) url; //WindowController方法1
- (id) initWithRequest: (NSURLRequest *)request; //WindowController方法2

@property (retain) NSURL * url;
@property (retain) IBOutlet ContentView *contentView;

Expand Down
20 changes: 7 additions & 13 deletions MacGap/WindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,20 @@ -(void) notificationCenter{

- (void)windowDidLoad
{
[super windowDidLoad];


if (self.url != nil) {
[self.contentView.webView setMainFrameURL:[self.url absoluteString]];
}


//set savepath
NSString *savePath = [@"~/Downloads/" stringByExpandingTildeInPath];


//run aria2
NSArray *arguments = [NSArray arrayWithObjects: @"--enable-rpc=true", @"--check-integrity=true",@"--rpc-listen-all=true", @"--rpc-allow-origin-all", @"--max-connection-per-server=10",@"--max-concurrent-downloads=10",@"--min-split-size=10M",@"--split=10",@"--bt-enable-lpd=true",@"--bt-max-peers=55",@"--bt-require-crypto=true",@"-c",@"-D", @"-d",savePath, nil];
NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *exePath = [NSString stringWithFormat:@"%@/aria2c",resourcesPath];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:exePath];
[task setArguments:arguments];
[task launch];

}







@end
2 changes: 1 addition & 1 deletion MacGap/en.lproj/Credits.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ MacGap\'b7\'e2\'d7\'b0\
{\field{\*\fldinst{HYPERLINK "https://github.com/MacGapProject/MacGap2"}}{\fldrslt https://github.com/MacGapProject/MacGap1}}\
\
WebUI\
{\field{\*\fldinst{HYPERLINK "https://github.com/ziahamza/webui-aria2"}}{\fldrslt https://github.com/binux/yaaw}}}
{\field{\*\fldinst{HYPERLINK "https://github.com/ziahamza/webui-aria2"}}{\fldrslt https://github.com/ziahamza/webui-aria2}}}
9 changes: 9 additions & 0 deletions MacGap/startaria.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# startaria.sh
# bilibili
#
# Created by TYPCN on 2015/9/6.
# Copyright (c) 2015 TYPCN. All rights reserved.
touch "/Users/Shared/aria2.session"
/Applications/Aria2GUI.app/Contents/Resources/aria2c --input-file="/Users/Shared/aria2.session" --save-session="/Users/Shared/aria2.session" --save-session-interval=10 --dir="$HOME/Downloads/" --max-connection-per-server=10 --max-concurrent-downloads=10 --continue=true --split=10 --min-split-size=10M --enable-rpc=true --rpc-listen-all=false --rpc-listen-port=6800 --rpc-allow-origin-all --check-integrity=true --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43" -c -D
29 changes: 29 additions & 0 deletions public/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM debian:8

# less priviledge user, the id should map the user the downloaded files belongs to
RUN groupadd -r dummy && useradd -r -g dummy dummy -u 1000

# webui + aria2
RUN apt-get update \
&& apt-get install -y aria2 busybox curl \
&& rm -rf /var/lib/apt/lists/*

ADD . /webui-aria2

# gosu install latest
RUN GITHUB_REPO="https://github.com/tianon/gosu" \
&& LATEST=`curl -s $GITHUB_REPO"/releases/latest" | grep -Eo "[0-9].[0-9]"` \
&& curl -L $GITHUB_REPO"/releases/download/"$LATEST"/gosu-amd64" > /usr/local/bin/gosu \
&& chmod +x /usr/local/bin/gosu

# goreman supervisor install latest
RUN GITHUB_REPO="https://github.com/mattn/goreman" \
&& LATEST=`curl -s $GITHUB_REPO"/releases/latest" | grep -Eo "v[0-9]*.[0-9]*.[0-9]*"` \
&& curl -L $GITHUB_REPO"/releases/download/"$LATEST"/goreman_linux_amd64.tar.gz" > goreman.tar.gz \
&& tar -xvzf goreman.tar.gz && mv /goreman_linux_amd64/goreman /usr/local/bin/goreman && rm -R goreman*

# goreman setup
RUN echo -e "web: gosu dummy /bin/busybox httpd -f -p 8080 -h /webui-aria2\nbackend: gosu dummy /usr/bin/aria2c --enable-rpc --rpc-listen-all --dir=/data" > Procfile

EXPOSE 8080 6800
CMD ["goreman", "start"]
7 changes: 7 additions & 0 deletions public/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2012 Hamza Zia

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60 changes: 60 additions & 0 deletions public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
webui-aria2
===========

![Main interface](/screenshots/overview.png?raw=true)

The aim for this project is to create the worlds best and hottest interface to interact with aria2. aria2 is the worlds best file downloader, but sometimes the command line brings more power than necessary. The project was initially created as part of the GSOC scheme, however it has rapidly grown and changed with tremendous support and feedback from the aria2 community.

Very simple to use, no build scripts, no installation scripts. First start aria2 in the background either in your local machine or in a remote one. You can do that as follows:
````bash
aria2c --enable-rpc --rpc-listen-all
````


If aria2 is not installed in your local machine then head on to http://aria2.sourceforge.net/ and follow the instructions there.

Then download the webui, you can either do that by downloading this repository and running index.html in the browser. Or you could just head on to http://ziahamza.github.io/webui-aria2/ and just start downloading files! After that you can also save it for offline use by saving from the browser save page as option.

Tips
====
1. You can always select which files to download in case of torrents or metalinks. Just pause a download and a list icon should appear next to the settings button. To select which files to download before starting the download, give the flag --pause-metadata to aria2. See [link](http://aria2.sourceforge.net/manual/en/html/aria2c.html#cmdoption--pause-metadata)

Configuration
=============
Read and edit [configuration.js](configuration.js).

DirectURL
---------
This feature allows users to download files that they download from aria2 directly from the webui dashboard. If you are familiar with how webservers work, setup a http server that points at the configured aria2 download directory, check permissions. Then Specify a full url: ```http://server:port/``` in the webui directURL configuration.

If the above is not obvious, keep reading what this is about in [directurl.md](directurl.md)

Dependencies
============
Well, you need aria2. And a web browser (if that even counts!)

Docker support
==============
You can also try or use webui-aria2 in your LAN inside a Docker sandbox.

Build the image

````bash
sudo docker build -t yourname/webui-aria2 .
````

..and run it! It will be available at: `http://localhost:9100`

````bash
sudo docker run -v /Downloads:/data -p 6800:6800 -p 9100:8080 --name="webui-aria2" yourname/webui-aria2
````

`/Downloads` is the directory in the host where you want to keep the downloaded files

Support
=======
For any support, feature request and bug report add an issue in the github project. [link](https://github.com/ziahamza/webui-aria2/issues)

License
=======
Refer to the LICENSE file (MIT License). If the more liberal license is needed then add it as an issue
Loading

0 comments on commit 276b349

Please sign in to comment.