From bcb833ad0db3163901d60f5d1bc98278eb48eb27 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Mon, 16 Dec 2013 21:07:34 +0100 Subject: [PATCH] remove PocketSharp dependency from Reader; move PocketArticle into Reader project; --- PocketSharp.Reader/Fody.targets | 89 ++++++++++++++++++++ PocketSharp.Reader/FodyWeavers.xml | 4 + PocketSharp.Reader/IPocketReader.cs | 18 +--- PocketSharp.Reader/PocketArticle.cs | 36 ++++++++ PocketSharp.Reader/PocketReader.cs | 39 ++------- PocketSharp.Reader/PocketSharp.Reader.csproj | 15 +++- PocketSharp.Reader/packages.config | 2 + 7 files changed, 153 insertions(+), 50 deletions(-) create mode 100644 PocketSharp.Reader/Fody.targets create mode 100644 PocketSharp.Reader/FodyWeavers.xml create mode 100644 PocketSharp.Reader/PocketArticle.cs diff --git a/PocketSharp.Reader/Fody.targets b/PocketSharp.Reader/Fody.targets new file mode 100644 index 0000000..a668a51 --- /dev/null +++ b/PocketSharp.Reader/Fody.targets @@ -0,0 +1,89 @@ + + + + + + $(NCrunchOriginalSolutionDir) + + + + + $(SolutionDir) + + + + + $(MSBuildProjectDirectory)\..\ + + + + + + + $(KeyOriginatorFile) + + + + + $(AssemblyOriginatorKeyFile) + + + + + + + + + + $(ProjectDir)$(IntermediateOutputPath) + Low + $(SignAssembly) + $(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Reader/FodyWeavers.xml b/PocketSharp.Reader/FodyWeavers.xml new file mode 100644 index 0000000..bb0f322 --- /dev/null +++ b/PocketSharp.Reader/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/PocketSharp.Reader/IPocketReader.cs b/PocketSharp.Reader/IPocketReader.cs index 510140e..864654d 100644 --- a/PocketSharp.Reader/IPocketReader.cs +++ b/PocketSharp.Reader/IPocketReader.cs @@ -6,30 +6,18 @@ namespace PocketSharp { public interface IPocketReader { - /// - /// Reads article content from the given URI. - /// This method does not use the official Article View API, which is private. - /// The PocketReader is based on a custom PCL port of NReadability and SgmlReader. - /// - /// An URI. - /// if set to true [only body is returned]. - /// if set to true [no headline (h1) is included]. - /// A Pocket article with extracted content and title. - /// - Task Read(Uri uri, bool bodyOnly = true, bool noHeadline = false); - /// /// Reads article content from the given PocketItem. /// This method does not use the official Article View API, which is private. /// The PocketReader is based on a custom PCL port of NReadability and SgmlReader. /// - /// The pocket item. + /// An URI to extract the content from. /// if set to true [only body is returned]. /// if set to true [no headline (h1) is included]. /// /// A Pocket article with extracted content and title. /// - /// - Task Read(PocketItem item, bool bodyOnly = true, bool noHeadline = false); + /// + Task Read(Uri uri, bool bodyOnly = true, bool noHeadline = false); } } \ No newline at end of file diff --git a/PocketSharp.Reader/PocketArticle.cs b/PocketSharp.Reader/PocketArticle.cs new file mode 100644 index 0000000..90716c8 --- /dev/null +++ b/PocketSharp.Reader/PocketArticle.cs @@ -0,0 +1,36 @@ +using PropertyChanged; +using System; + +namespace PocketSharp.Models +{ + /// + /// Readable article + /// + [ImplementPropertyChanged] + public class PocketArticle + { + /// + /// Gets or sets the content. + /// + /// + /// The content. + /// + public string Content { get; set; } + + /// + /// Gets or sets the title. + /// + /// + /// The title. + /// + public string Title { get; set; } + + /// + /// Gets or sets the next page URL. + /// + /// + /// The next page URL. + /// + public Uri NextPage { get; set; } + } +} diff --git a/PocketSharp.Reader/PocketReader.cs b/PocketSharp.Reader/PocketReader.cs index b7bb936..a1f2e1b 100644 --- a/PocketSharp.Reader/PocketReader.cs +++ b/PocketSharp.Reader/PocketReader.cs @@ -61,41 +61,19 @@ namespace PocketSharp - /// - /// Reads article content from the given URI. - /// This method does not use the official Article View API, which is private. - /// The PocketReader is based on a custom PCL port of NReadability and SgmlReader. - /// - /// An URI. - /// if set to true [only body is returned]. - /// if set to true [no headline (h1) is included]. - /// - /// A Pocket article with extracted content and title. - /// - public async Task Read(Uri uri, bool bodyOnly = true, bool noHeadline = false) - { - return await Read(new PocketItem() - { - ID = null, - Uri = uri - }, bodyOnly, noHeadline); - } - - - /// /// Reads article content from the given PocketItem. /// This method does not use the official Article View API, which is private. /// The PocketReader is based on a custom PCL port of NReadability and SgmlReader. /// - /// The pocket item. + /// An URI to extract the content from. /// if set to true [only body is returned]. /// if set to true [no headline (h1) is included]. /// /// A Pocket article with extracted content and title. /// - /// - public async Task Read(PocketItem item, bool bodyOnly = true, bool noHeadline = false) + /// + public async Task Read(Uri uri, bool bodyOnly = true, bool noHeadline = false) { // initialize transcoder NReadabilityTranscoder transcoder = new NReadabilityTranscoder( @@ -108,12 +86,12 @@ namespace PocketSharp ); // get HTML string from URI - string htmlResponse = await Request(item.Uri); + string htmlResponse = await Request(uri); // set properties for processing TranscodingInput transcodingInput = new TranscodingInput(htmlResponse) { - Url = item.Uri.ToString(), + Url = uri.ToString(), DomSerializationParams = new DomSerializationParams() { BodyOnly = bodyOnly, @@ -133,8 +111,7 @@ namespace PocketSharp { Content = transcodingResult.ExtractedContent, Title = transcodingResult.ExtractedTitle, - NextPage = transcodingResult.NextPageUrl != null ? new Uri(transcodingResult.NextPageUrl, UriKind.Absolute) : null, - PocketItemID = item.ID + NextPage = transcodingResult.NextPageUrl != null ? new Uri(transcodingResult.NextPageUrl, UriKind.Absolute) : null }; } @@ -157,7 +134,7 @@ namespace PocketSharp } catch (HttpRequestException exc) { - throw new PocketException(exc.Message, exc); + throw new Exception(exc.Message, exc); } // validate HTTP response @@ -165,7 +142,7 @@ namespace PocketSharp { string exceptionString = String.Format("Request error: {0} ({1})", response.ReasonPhrase, (int)response.StatusCode); - throw new PocketException(exceptionString); + throw new Exception(exceptionString); } // read response diff --git a/PocketSharp.Reader/PocketSharp.Reader.csproj b/PocketSharp.Reader/PocketSharp.Reader.csproj index 447366e..611e575 100644 --- a/PocketSharp.Reader/PocketSharp.Reader.csproj +++ b/PocketSharp.Reader/PocketSharp.Reader.csproj @@ -16,6 +16,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\ true + ..\packages\Fody.1.19.1.0 true @@ -36,10 +37,12 @@ + + @@ -50,6 +53,10 @@ ..\packages\Microsoft.Bcl.Async.1.0.165\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.Extensions.dll + + ..\packages\PropertyChanged.Fody.1.43.0.0\Lib\portable-net4+sl4+wp7+win8+MonoAndroid16+MonoTouch40\PropertyChanged.dll + False + ..\packages\Microsoft.Bcl.1.1.6\lib\portable-net40+sl4+win8+wp71\System.IO.dll @@ -70,15 +77,14 @@ - - {817200c3-a327-4e35-9b5f-63a51c088577} - PocketSharp - {14c3ee6a-54a4-4a37-8b56-d52a3802f1c2} NReadability + + + @@ -86,6 +92,7 @@ +