Browse Source

Change something

HonorLee 8 years ago
parent
commit
50347c7d55

File diff suppressed because it is too large
+ 53 - 1
ShareSupport/Base.lproj/MainInterface.storyboard


+ 111 - 0
ShareSupport/HTMLNode.h

@@ -0,0 +1,111 @@
+//
+//  HTMLNode.h
+//  StackOverflow
+//
+//  Created by Ben Reeves on 09/03/2010.
+//  Copyright 2010 Ben Reeves. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "libxml2/HTMLparser.h"
+#import "HTMLParser.h"
+
+@class HTMLParser;
+
+#define ParsingDepthUnlimited 0
+#define ParsingDepthSame -1
+#define ParsingDepth size_t
+
+typedef enum
+{
+	HTMLHrefNode,
+	HTMLTextNode,
+	HTMLUnkownNode,
+	HTMLCodeNode,
+	HTMLSpanNode,
+	HTMLPNode,
+	HTMLLiNode,
+	HTMLUlNode,
+	HTMLImageNode,
+	HTMLOlNode,
+	HTMLStrongNode,
+	HTMLPreNode,
+	HTMLBlockQuoteNode,
+} HTMLNodeType;
+
+@interface HTMLNode : NSObject 
+{
+@public
+	xmlNode * _node;
+}
+
+//Init with a lib xml node (shouldn't need to be called manually)
+//Use [parser doc] to get the root Node
+-(id)initWithXMLNode:(xmlNode*)xmlNode;
+
+//Returns a single child of class
+-(HTMLNode*)findChildOfClass:(NSString*)className;
+
+//Returns all children of class
+-(NSArray*)findChildrenOfClass:(NSString*)className;
+
+//Finds a single child with a matching attribute 
+//set allowPartial to match partial matches 
+//e.g. <img src="http://www.google.com> [findChildWithAttribute:@"src" matchingName:"google.com" allowPartial:TRUE]
+-(HTMLNode*)findChildWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
+
+//Finds all children with a matching attribute
+-(NSArray*)findChildrenWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
+
+//Gets the attribute value matching tha name
+-(NSString*)getAttributeNamed:(NSString*)name;
+
+//Find childer with the specified tag name
+-(NSArray*)findChildTags:(NSString*)tagName;
+
+//Looks for a tag name e.g. "h3"
+-(HTMLNode*)findChildTag:(NSString*)tagName;
+
+//Returns the first child element
+-(HTMLNode*)firstChild;
+
+//Returns the plaintext contents of node
+-(NSString*)contents;
+
+//Returns the plaintext contents of this node + all children
+-(NSString*)allContents;
+
+//Returns the html contents of the node 
+-(NSString*)rawContents;
+
+//Returns next sibling in tree
+-(HTMLNode*)nextSibling;
+
+//Returns previous sibling in tree
+-(HTMLNode*)previousSibling;
+
+//Returns the class name
+-(NSString*)className;
+
+//Returns the tag name
+-(NSString*)tagName;
+
+//Returns the parent
+-(HTMLNode*)parent;
+
+//Returns the first level of children
+-(NSArray*)children;
+
+//Returns the node type if know
+-(HTMLNodeType)nodetype;
+
+
+//C functions for minor performance increase in tight loops
+NSString * getAttributeNamed(xmlNode * node, const char * nameStr);
+void setAttributeNamed(xmlNode * node, const char * nameStr, const char * value);
+HTMLNodeType nodeType(xmlNode* node);
+NSString * allNodeContents(xmlNode*node);
+NSString * rawContentsOfNode(xmlNode * node);
+
+
+@end

+ 412 - 0
ShareSupport/HTMLNode.m

@@ -0,0 +1,412 @@
+//
+//  HTMLNode.m
+//  StackOverflow
+//
+//  Created by Ben Reeves on 09/03/2010.
+//  Copyright 2010 Ben Reeves. All rights reserved.
+//
+
+#import "HTMLNode.h"
+#import <libxml/HTMLtree.h>
+
+@implementation HTMLNode
+
+-(HTMLNode*)parent
+{
+	return [[HTMLNode alloc] initWithXMLNode:_node->parent];	
+}
+
+-(HTMLNode*)nextSibling {
+	return [[HTMLNode alloc] initWithXMLNode:_node->next];
+}
+
+-(HTMLNode*)previousSibling {
+	return [[HTMLNode alloc] initWithXMLNode:_node->prev];
+}
+
+void setAttributeNamed(xmlNode * node, const char * nameStr, const char * value) {
+	
+	char * newVal = (char *)malloc(strlen(value)+1);
+	memcpy (newVal, value, strlen(value)+1);
+
+	for(xmlAttrPtr attr = node->properties; NULL != attr; attr = attr->next)
+	{
+		if (strcmp((char*)attr->name, nameStr) == 0)
+		{				
+			for(xmlNode * child = attr->children; NULL != child; child = child->next)
+			{
+				free(child->content);
+				child->content = (xmlChar*)newVal;
+				break;
+			}
+			break;
+		}
+	}
+	
+	
+}
+
+NSString * getAttributeNamed(xmlNode * node, const char * nameStr)
+{
+	for(xmlAttrPtr attr = node->properties; NULL != attr; attr = attr->next)
+	{
+		if (strcmp((char*)attr->name, nameStr) == 0)
+		{				
+			for(xmlNode * child = attr->children; NULL != child; child = child->next)
+			{
+				return [NSString stringWithCString:(void*)child->content encoding:NSUTF8StringEncoding];
+				
+			}
+			break;
+		}
+	}
+	
+	return NULL;
+}
+
+-(NSString*)getAttributeNamed:(NSString*)name
+{	
+	const char * nameStr = [name UTF8String];
+	
+	return getAttributeNamed(_node, nameStr);
+}
+
+//Returns the class name
+-(NSString*)className
+{
+	return [self getAttributeNamed:@"class"];
+}
+
+//Returns the tag name
+-(NSString*)tagName
+{
+	return [NSString stringWithCString:(void*)_node->name encoding:NSUTF8StringEncoding];
+}
+
+
+-(HTMLNode*)firstChild
+{
+	return [[HTMLNode alloc] initWithXMLNode:_node->children];
+}
+
+
+-(void)findChildrenWithAttribute:(const char*)attribute matchingName:(const char*)className inXMLNode:(xmlNode *)node inArray:(NSMutableArray*)array allowPartial:(BOOL)partial
+{
+	xmlNode *cur_node = NULL;
+	const char * classNameStr = className;
+	//BOOL found = NO;
+	
+    for (cur_node = node; cur_node; cur_node = cur_node->next) 
+	{				
+		for(xmlAttrPtr attr = cur_node->properties; NULL != attr; attr = attr->next)
+		{
+			
+			if (strcmp((char*)attr->name, attribute) == 0)
+			{				
+				for(xmlNode * child = attr->children; NULL != child; child = child->next)
+				{
+					
+					BOOL match = NO;
+					if (!partial && strcmp((char*)child->content, classNameStr) == 0)
+						match = YES;
+					else if (partial && strstr ((char*)child->content, classNameStr) != NULL)
+						match = YES;
+
+					if (match)
+					{
+						//Found node
+						HTMLNode * nNode = [[HTMLNode alloc] initWithXMLNode:cur_node];
+						[array addObject:nNode];
+						break;
+					}
+				}
+				break;
+			}
+		}
+		
+		[self findChildrenWithAttribute:attribute matchingName:className inXMLNode:cur_node->children inArray:array allowPartial:partial];
+	}	
+	
+}
+
+-(void)findChildTags:(NSString*)tagName inXMLNode:(xmlNode *)node inArray:(NSMutableArray*)array
+{
+	xmlNode *cur_node = NULL;
+	const char * tagNameStr =  [tagName UTF8String];
+	
+	if (tagNameStr == nil)
+		return;
+	
+    for (cur_node = node; cur_node; cur_node = cur_node->next) 
+	{				
+		if (cur_node->name && strcmp((char*)cur_node->name, tagNameStr) == 0)
+		{
+			HTMLNode * node = [[HTMLNode alloc] initWithXMLNode:cur_node];
+			[array addObject:node];
+			
+		}
+		
+		[self findChildTags:tagName inXMLNode:cur_node->children inArray:array];
+	}	
+}
+
+
+-(NSArray*)findChildTags:(NSString*)tagName
+{
+	NSMutableArray * array = [NSMutableArray array];
+	
+	[self findChildTags:tagName inXMLNode:_node->children inArray:array];
+	
+	return array;
+}
+
+-(HTMLNode*)findChildTag:(NSString*)tagName inXMLNode:(xmlNode *)node
+{
+	xmlNode *cur_node = NULL;
+	const char * tagNameStr =  [tagName UTF8String];
+	
+    for (cur_node = node; cur_node; cur_node = cur_node->next) 
+	{				
+		if (cur_node && cur_node->name && strcmp((char*)cur_node->name, tagNameStr) == 0)
+		{
+			return [[HTMLNode alloc] initWithXMLNode:cur_node];
+		}
+		
+		HTMLNode * cNode = [self findChildTag:tagName inXMLNode:cur_node->children];
+		if (cNode != NULL)
+		{
+			return cNode;
+		}
+	}	
+	
+	return NULL;
+}
+
+-(HTMLNode*)findChildTag:(NSString*)tagName
+{
+	return [self findChildTag:tagName inXMLNode:_node->children];
+}
+
+
+-(NSArray*)children
+{
+	xmlNode *cur_node = NULL;
+	NSMutableArray * array = [NSMutableArray array]; 
+
+	for (cur_node = _node->children; cur_node; cur_node = cur_node->next) 
+	{	
+		HTMLNode * node = [[HTMLNode alloc] initWithXMLNode:cur_node];
+		[array addObject:node];
+	}
+	
+	return array;
+}
+
+/*
+-(NSString*)description
+{
+	NSString * string = [NSString stringWithFormat:@"<%s>%@\n", _node->name, [self contents]];
+	
+	for (HTMLNode * child in [self children])
+	{
+		string = [string stringByAppendingString:[child description]];
+	}
+	
+	string = [string stringByAppendingString:[NSString stringWithFormat:@"<%s>\n", _node->name]];
+
+	return string;
+}*/
+
+-(HTMLNode*)findChildWithAttribute:(const char*)attribute matchingName:(const char*)name inXMLNode:(xmlNode *)node allowPartial:(BOOL)partial
+{
+	xmlNode *cur_node = NULL;
+	const char * classNameStr = name;
+	//BOOL found = NO;
+
+	if (node == NULL)
+		return NULL;
+	
+    for (cur_node = node; cur_node; cur_node = cur_node->next) 
+	{		
+		for(xmlAttrPtr attr = cur_node->properties; NULL != attr; attr = attr->next)
+		{			
+			if (strcmp((char*)attr->name, attribute) == 0)
+			{				
+				for(xmlNode * child = attr->children; NULL != child; child = child->next)
+				{
+					
+					BOOL match = NO;
+					if (!partial && strcmp((char*)child->content, classNameStr) == 0)
+						match = YES;
+					else if (partial && strstr ((char*)child->content, classNameStr) != NULL)
+						match = YES;
+					
+					if (match)
+					{
+						return [[HTMLNode alloc] initWithXMLNode:cur_node];
+					}
+				}
+				break;
+			}
+		}
+		
+		HTMLNode * cNode = [self findChildWithAttribute:attribute matchingName:name inXMLNode:cur_node->children allowPartial:partial];
+		if (cNode != NULL)
+		{
+			return cNode;
+		}
+	}	
+		
+	return NULL;
+}
+
+-(HTMLNode*)findChildWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial
+{
+	return [self findChildWithAttribute:[attribute UTF8String] matchingName:[className UTF8String] inXMLNode:_node->children allowPartial:partial];
+}
+
+-(HTMLNode*)findChildOfClass:(NSString*)className
+{	
+	HTMLNode * node = [self findChildWithAttribute:"class" matchingName:[className UTF8String]  inXMLNode:_node->children allowPartial:NO];
+	return node;
+}
+
+-(NSArray*)findChildrenWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial
+{
+	NSMutableArray * array = [NSMutableArray array];
+
+	[self findChildrenWithAttribute:[attribute UTF8String] matchingName:[className UTF8String] inXMLNode:_node->children inArray:array allowPartial:partial];
+	
+	return array;
+}
+
+
+-(NSArray*)findChildrenOfClass:(NSString*)className
+{	
+	return [self findChildrenWithAttribute:@"class" matchingName:className allowPartial:NO];
+}
+
+-(id)initWithXMLNode:(xmlNode*)xmlNode
+{
+	if (self = [super init])
+	{
+		_node = xmlNode;
+	}
+	return self;
+}
+
+-(void)appendChildContentsToString:(NSMutableString*)string inNode:(xmlNode*)node
+{
+	if (node == NULL)
+		return;
+	
+	xmlNode *cur_node = NULL;	
+    for (cur_node = node; cur_node; cur_node = cur_node->next) 
+	{
+		if (cur_node->content)
+		{			
+			[string appendString:[NSString stringWithCString:(void*)cur_node->content encoding:NSUTF8StringEncoding]];
+		}
+		
+		[self appendChildContentsToString:string inNode:cur_node->children];
+	}
+}
+
+-(NSString*)contents
+{
+	if (_node->children && _node->children->content)
+	{
+		return [NSString stringWithCString:(void*)_node->children->content encoding:NSUTF8StringEncoding];
+	}
+	
+	return nil;
+}
+
+HTMLNodeType nodeType(xmlNode * _node)
+{
+	if (_node == NULL || _node->name == NULL)
+		return HTMLUnkownNode;
+	
+	const char * tagName = (const char*)_node->name;
+	if (strcmp(tagName, "a") == 0)
+		return HTMLHrefNode;
+	else if (strcmp(tagName, "text") == 0)
+		return HTMLTextNode;
+	else if (strcmp(tagName, "code") == 0)
+		return HTMLCodeNode;
+	else if (strcmp(tagName, "span") == 0)
+		return HTMLSpanNode;
+	else if (strcmp(tagName, "p") == 0)
+		return HTMLPNode;
+	else if (strcmp(tagName, "ul") == 0)
+		return HTMLUlNode;
+	else if (strcmp(tagName, "li") == 0)
+		return HTMLLiNode;
+	else if (strcmp(tagName, "image") == 0)
+		return HTMLImageNode;
+	else if (strcmp(tagName, "ol") == 0)
+		return HTMLOlNode;
+	else if (strcmp(tagName, "strong") == 0)
+		return HTMLStrongNode;
+	else if (strcmp(tagName, "pre") == 0)
+		return HTMLPreNode;
+	else if (strcmp(tagName, "blockquote") == 0)
+		return HTMLBlockQuoteNode;
+	else
+		return HTMLUnkownNode;
+	
+}
+
+-(HTMLNodeType)nodetype
+{
+	return nodeType(_node);
+}
+
+NSString * allNodeContents(xmlNode*node)
+{
+	if (node == NULL)
+		return nil;
+	
+	void * contents = xmlNodeGetContent(node);
+	if (contents)
+	{
+		
+		NSString * string = [NSString stringWithCString:contents encoding:NSUTF8StringEncoding];
+		xmlFree(contents);
+		return string;
+	}
+	
+	return @"";
+}
+
+-(NSString*)allContents
+{
+	return allNodeContents(_node);
+}
+
+NSString * rawContentsOfNode(xmlNode * node)
+{	
+	xmlBufferPtr buffer = xmlBufferCreateSize(1000);
+	xmlOutputBufferPtr buf = xmlOutputBufferCreateBuffer(buffer, NULL);
+	
+	htmlNodeDumpOutput(buf, node->doc, node, (const char*)node->doc->encoding);
+		
+	xmlOutputBufferFlush(buf);
+		
+	NSString * string = nil;
+	
+	if (buffer->content) {
+		string = [[NSString alloc] initWithBytes:(const void *)xmlBufferContent(buffer) length:xmlBufferLength(buffer) encoding:NSUTF8StringEncoding];
+	}
+	
+	xmlOutputBufferClose(buf);
+	xmlBufferFree(buffer);
+	
+	return string;
+}
+
+-(NSString*)rawContents {
+	return rawContentsOfNode(_node);
+}
+
+@end

+ 36 - 0
ShareSupport/HTMLParser.h

@@ -0,0 +1,36 @@
+//
+//  HTMLParser.h
+//  StackOverflow
+//
+//  Created by Ben Reeves on 09/03/2010.
+//  Copyright 2010 Ben Reeves. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "libxml/HTMLParser.h"
+#import "HTMLNode.h"
+@class HTMLNode;
+
+@interface HTMLParser : NSObject 
+{
+	@public
+	htmlDocPtr _doc;
+}
+
+-(id)initWithContentsOfURL:(NSURL*)url error:(NSError**)error;
+-(id)initWithData:(NSData*)data error:(NSError**)error;
+-(id)initWithString:(NSString*)string error:(NSError**)error;
+
+//Returns the doc tag
+-(HTMLNode*)doc;
+
+//Returns the body tag
+-(HTMLNode*)body;
+
+//Returns the html tag
+-(HTMLNode*)html;
+
+//Returns the head tag
+- (HTMLNode*)head;
+
+@end

+ 130 - 0
ShareSupport/HTMLParser.m

@@ -0,0 +1,130 @@
+//
+//  HTMLParser.m
+//  StackOverflow
+//
+//  Created by Ben Reeves on 09/03/2010.
+//  Copyright 2010 Ben Reeves. All rights reserved.
+//
+
+#import "HTMLParser.h"
+
+
+@implementation HTMLParser
+
+-(HTMLNode*)doc
+{
+	if (_doc == NULL)
+		return NULL;
+	
+	return [[HTMLNode alloc] initWithXMLNode:(xmlNode*)_doc];
+}
+
+-(HTMLNode*)html
+{
+	if (_doc == NULL)
+		return NULL;
+	
+	return [[self doc] findChildTag:@"html"];
+}
+
+-(HTMLNode*)head
+{
+	if (_doc == NULL)
+		return NULL;
+
+	return [[self doc] findChildTag:@"head"];
+}
+
+-(HTMLNode*)body
+{
+	if (_doc == NULL)
+		return NULL;
+	
+	return [[self doc] findChildTag:@"body"];
+}
+
+-(id)initWithString:(NSString*)string error:(NSError**)error
+{ 
+	if (self = [super init])
+	{
+		_doc = NULL;
+		
+		if ([string length] > 0)
+		{
+			CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding);
+			CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
+			const char *enc = CFStringGetCStringPtr(cfencstr, 0);
+			// _doc = htmlParseDoc((xmlChar*)[string UTF8String], enc);
+			int optionsHtml = HTML_PARSE_RECOVER;
+			optionsHtml = optionsHtml | HTML_PARSE_NOERROR; //Uncomment this to see HTML errors
+			optionsHtml = optionsHtml | HTML_PARSE_NOWARNING;
+			_doc = htmlReadDoc ((xmlChar*)[string UTF8String], NULL, enc, optionsHtml);
+		}
+		else 
+		{
+			if (error) {
+				*error = [NSError errorWithDomain:@"HTMLParserdomain" code:1 userInfo:nil];
+			}
+		}
+	}
+	
+	return self;
+}
+
+-(id)initWithData:(NSData*)data error:(NSError**)error
+{
+	if (self = [super init])
+	{
+		_doc = NULL;
+
+		if (data)
+		{
+			CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding);
+			CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
+			const char *enc = CFStringGetCStringPtr(cfencstr, 0);
+			//_doc = htmlParseDoc((xmlChar*)[data bytes], enc);
+			
+			_doc = htmlReadDoc((xmlChar*)[data bytes],
+							 "",
+							enc,
+							XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
+		}
+		else
+		{
+			if (error) 
+			{
+				*error = [NSError errorWithDomain:@"HTMLParserdomain" code:1 userInfo:nil];
+			}
+
+		}
+	}
+	
+	return self;
+}
+
+-(id)initWithContentsOfURL:(NSURL*)url error:(NSError**)error
+{
+	
+	NSData * _data = [[NSData alloc] initWithContentsOfURL:url options:0 error:error];
+
+	if (_data == nil || *error)
+	{
+		return nil;
+	}
+	
+	self = [self initWithData:_data error:error];
+	
+	return self;
+}
+
+
+-(void)dealloc
+{
+	if (_doc)
+	{
+		xmlFreeDoc(_doc);
+	}
+
+}
+
+@end

+ 1 - 1
ShareSupport/ShareSupport.entitlements

@@ -4,7 +4,7 @@
 <dict>
 	<key>com.apple.security.application-groups</key>
 	<array>
-		<string>group.honorlee.TumblrDownloader</string>
+		<string>group.honorlee.TDGroup</string>
 	</array>
 </dict>
 </plist>

+ 7 - 1
ShareSupport/ShareViewController.h

@@ -9,6 +9,12 @@
 #import <UIKit/UIKit.h>
 #import <Social/Social.h>
 
-@interface ShareViewController : SLComposeServiceViewController
+@interface ShareViewController : UIViewController
+@property (strong, nonatomic) IBOutlet UIView *FirstView;
+@property (strong, nonatomic) IBOutlet UIView *SecondView;
+@property (strong, nonatomic) IBOutlet UILabel *FistViewURLText;
+- (IBAction)Cancel:(id)sender;
+- (IBAction)Analyse:(id)sender;
+@property (strong, nonatomic) IBOutlet UIBarButtonItem *FirstNextBtn;
 
 @end

+ 63 - 8
ShareSupport/ShareViewController.m

@@ -8,21 +8,27 @@
 
 #import "ShareViewController.h"
 #import <MobileCoreServices/MobileCoreServices.h>
+#import <libxml/HTMLparser.h>
+
+
 @interface ShareViewController ()
 @property NSUserDefaults *userDefaults;
+@property UIView *AnalyseView;
+@property NSString *SharedURL;
+@property UILabel *AnalyseViewLabel;
+@property NSString *CurrentStatus;
+@property UIActivityIndicatorView *indicator;
 @end
 
 @implementation ShareViewController
-
 - (BOOL)isContentValid {
     // Do validation of contentText and/or NSExtensionContext attachments here
     return YES;
 }
 
 - (void)didSelectPost {
-   
     // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
-    _userDefaults = [[NSUserDefaults alloc]initWithSuiteName:@"group.honorlee.TumblrDownloader"];
+    _userDefaults = [[NSUserDefaults alloc]initWithSuiteName:@"group.honorlee.TDGroup"];
     [_userDefaults synchronize];
     NSMutableArray *tmpData = [NSMutableArray arrayWithArray:(NSMutableArray *)[_userDefaults objectForKey:@"tasks"]];
     NSLog(@"%lu",(unsigned long)[tmpData count]);
@@ -32,21 +38,70 @@
     NSItemProvider *itemProvider = content.attachments.firstObject;
     if([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeURL]){
         [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *url,NSError *err) {
-            [tmpData addObject:url.absoluteString];
-            [_userDefaults setObject:tmpData forKey:@"tasks"];
-            [_userDefaults synchronize];
+            NSString *sharedURL = url.absoluteString;
+            if([sharedURL containsString:@"tumblr.com"]){
+                [tmpData addObject:sharedURL];
+                [_userDefaults setObject:tmpData forKey:@"tasks"];
+                [_userDefaults synchronize];
+            }else{
+                NSLog(@"Not tumblr");
+            }
         }];
     }
     
-    [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
+    
 //    NSString *type = (NSString *)
     // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
     
 }
-
+-(void)viewDidLoad{
+    UIView *backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
+    [backgroundView setBackgroundColor:[UIColor blackColor]];
+    [backgroundView setAlpha:0.6];
+    [self.view sendSubviewToBack:backgroundView];
+    [self.view addSubview:backgroundView];
+    [self.view bringSubviewToFront:_FirstView];
+    _FirstView.layer.cornerRadius = 5;
+    _FirstView.layer.masksToBounds = YES;
+    NSExtensionItem *content = self.extensionContext.inputItems[0];
+    NSItemProvider *itemProvider = content.attachments.firstObject;
+    if([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeURL]){
+        [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *url,NSError *err) {
+            _SharedURL = url.absoluteString;
+            dispatch_async(dispatch_get_main_queue(), ^{
+                 [_FistViewURLText setText:_SharedURL];
+            });
+            if(![_SharedURL containsString:@"tumblr.com"]){
+                //[_FirstNextBtn setEnabled:NO];
+            }
+        }];
+    }
+}
 - (NSArray *)configurationItems {
     // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
     return @[];
 }
 
+// Cancel
+- (IBAction)Cancel:(id)sender {
+    [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
+}
+
+- (IBAction)Analyse:(id)sender {
+    _AnalyseView = [[UIView alloc] initWithFrame:CGRectMake((self.view.frame.size.width-300)/2, (self.view.frame.size.height-140)/2, 300, 140)];
+    [_AnalyseView setBackgroundColor:[UIColor whiteColor]];
+    [_AnalyseView.layer setCornerRadius:5];
+    [_AnalyseView.layer setMasksToBounds:YES];
+    _indicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
+    [self.view addSubview:_AnalyseView];
+    [_AnalyseView addSubview:_indicator];
+    [_indicator startAnimating];
+    [UIView transitionFromView:_FirstView toView:_AnalyseView duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve completion:^(BOOL finished) {
+        [_FirstView removeFromSuperview];
+    }];
+}
+#pragma AnalyseURL
+-(void)ChangeStatus{
+    
+}
 @end

+ 20 - 8
TumblrDownloader.xcodeproj/project.pbxproj

@@ -7,6 +7,9 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		D30DC0C01C4F68C300545EF1 /* TumblrDownloader.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = D386B1301C469FDB00D7E0C5 /* TumblrDownloader.entitlements */; };
+		D30DC0C11C4F68C700545EF1 /* ShareSupport.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = D386B1311C46A0F900D7E0C5 /* ShareSupport.entitlements */; };
+		D30DC0CC1C4FA2E200545EF1 /* libxml2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D30DC0CA1C4FA28200545EF1 /* libxml2.tbd */; };
 		D3166D7C1C48F3F50003B6B8 /* Downloader.m in Sources */ = {isa = PBXBuildFile; fileRef = D3166D7B1C48F3F50003B6B8 /* Downloader.m */; };
 		D3166D811C48F9C20003B6B8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D3166D831C48F9C20003B6B8 /* Localizable.strings */; };
 		D36ACDC71C44D07E00B2C7CF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D36ACDC61C44D07E00B2C7CF /* main.m */; };
@@ -62,6 +65,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		D30DC0CA1C4FA28200545EF1 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; };
 		D3166D7A1C48F3F50003B6B8 /* Downloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Downloader.h; sourceTree = "<group>"; };
 		D3166D7B1C48F3F50003B6B8 /* Downloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Downloader.m; sourceTree = "<group>"; };
 		D3166D821C48F9C20003B6B8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -120,6 +124,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				D30DC0CC1C4FA2E200545EF1 /* libxml2.tbd in Frameworks */,
 				D386B17E1C4BEE8C00D7E0C5 /* MobileCoreServices.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -130,6 +135,7 @@
 		D36ACDB91C44D07E00B2C7CF = {
 			isa = PBXGroup;
 			children = (
+				D30DC0CA1C4FA28200545EF1 /* libxml2.tbd */,
 				D386B17D1C4BEE8C00D7E0C5 /* MobileCoreServices.framework */,
 				D36ACDC41C44D07E00B2C7CF /* TumblrDownloader */,
 				D386B1211C46991400D7E0C5 /* ShareSupport */,
@@ -269,7 +275,7 @@
 				TargetAttributes = {
 					D36ACDC11C44D07E00B2C7CF = {
 						CreatedOnToolsVersion = 7.2;
-						DevelopmentTeam = G3JVW2BPA6;
+						DevelopmentTeam = 2U8FMACLL7;
 						SystemCapabilities = {
 							com.apple.ApplicationGroups.iOS = {
 								enabled = 1;
@@ -281,7 +287,7 @@
 					};
 					D386B11F1C46991400D7E0C5 = {
 						CreatedOnToolsVersion = 7.2;
-						DevelopmentTeam = G3JVW2BPA6;
+						DevelopmentTeam = 2U8FMACLL7;
 						SystemCapabilities = {
 							com.apple.ApplicationGroups.iOS = {
 								enabled = 1;
@@ -329,6 +335,7 @@
 				D386B1691C4B871B00D7E0C5 /* tab_help@2x.png in Resources */,
 				D386B1631C4B861D00D7E0C5 /* tab_download@2x.png in Resources */,
 				D386B15F1C4B73EB00D7E0C5 /* tab_stored@2x.png in Resources */,
+				D30DC0C11C4F68C700545EF1 /* ShareSupport.entitlements in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -336,6 +343,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				D30DC0C01C4F68C300545EF1 /* TumblrDownloader.entitlements in Resources */,
 				D386B1271C46991400D7E0C5 /* MainInterface.storyboard in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -451,7 +459,7 @@
 				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
+				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				MTL_ENABLE_DEBUG_INFO = YES;
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
@@ -488,7 +496,7 @@
 				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
+				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
 				VALIDATE_PRODUCT = YES;
@@ -504,7 +512,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = TumblrDownloader/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader;
+				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.Main;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE = "";
 			};
@@ -519,7 +527,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = TumblrDownloader/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader;
+				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.Main;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE = "";
 			};
@@ -533,10 +541,12 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = ShareSupport/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.ShareSupport;
+				OTHER_LDFLAGS = "";
+				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.Main.ShareReciever;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE = "";
 				SKIP_INSTALL = YES;
+				USER_HEADER_SEARCH_PATHS = /usr/include/libxml;
 			};
 			name = Debug;
 		};
@@ -548,10 +558,12 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = ShareSupport/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.ShareSupport;
+				OTHER_LDFLAGS = "";
+				PRODUCT_BUNDLE_IDENTIFIER = org.honorlee.TumblrDownloader.Main.ShareReciever;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE = "";
 				SKIP_INSTALL = YES;
+				USER_HEADER_SEARCH_PATHS = /usr/include/libxml;
 			};
 			name = Release;
 		};

BIN
TumblrDownloader.xcodeproj/project.xcworkspace/xcuserdata/HonorLee.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 6
TumblrDownloader/Base.lproj/Main.storyboard

@@ -25,11 +25,11 @@
                                         <rect key="frame" x="0.0" y="28" width="600" height="44"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="4y4-cp-ZPb" id="xxK-hZ-vB4">
-                                            <rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="SwI-IC-cbA">
-                                                    <rect key="frame" x="15" y="0.0" width="570" height="43"/>
+                                                    <rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
@@ -42,7 +42,7 @@
                                         <rect key="frame" x="0.0" y="72" width="600" height="44"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="FkJ-Bj-VLX" id="fYq-6I-gKJ">
-                                            <rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                         </tableViewCellContentView>
                                     </tableViewCell>
@@ -148,9 +148,6 @@
                                     <navigationItem title="下载队列" id="1bI-kf-fwy"/>
                                 </items>
                             </navigationBar>
-                            <stackView opaque="NO" contentMode="scaleToFill" fixedFrame="YES" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="dWa-A4-DPo">
-                                <rect key="frame" x="0.0" y="64" width="600" height="487"/>
-                            </stackView>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                         <constraints>

+ 6 - 6
TumblrDownloader/Info.plist

@@ -2,12 +2,6 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>LSApplicationQueriesSchemes</key>
-	<array>
-		<string>tumblr</string>
-	</array>
-	<key>UIViewControllerBasedStatusBarAppearance</key>
-	<true/>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>en</string>
 	<key>CFBundleExecutable</key>
@@ -26,6 +20,10 @@
 	<string>????</string>
 	<key>CFBundleVersion</key>
 	<string>1</string>
+	<key>LSApplicationQueriesSchemes</key>
+	<array>
+		<string>tumblr</string>
+	</array>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>UIFileSharingEnabled</key>
@@ -42,5 +40,7 @@
 	<array>
 		<string>UIInterfaceOrientationPortrait</string>
 	</array>
+	<key>UIViewControllerBasedStatusBarAppearance</key>
+	<true/>
 </dict>
 </plist>

+ 1 - 1
TumblrDownloader/TasksViewController.m

@@ -26,7 +26,7 @@
     [_TaskTableView addSubview:_uirefresh];
     [_uirefresh addTarget:self action:@selector(pullToRefresh) forControlEvents:UIControlEventValueChanged];
     
-    _userDefaults = [[NSUserDefaults alloc]initWithSuiteName:@"group.honorlee.TumblrDownloader"];
+    _userDefaults = [[NSUserDefaults alloc]initWithSuiteName:@"group.honorlee.TDGroup"];
     
 }
 

+ 1 - 1
TumblrDownloader/TumblrDownloader.entitlements

@@ -4,7 +4,7 @@
 <dict>
 	<key>com.apple.security.application-groups</key>
 	<array>
-		<string>group.honorlee.TumblrDownloader</string>
+		<string>group.honorlee.TDGroup</string>
 	</array>
 </dict>
 </plist>