Esempio n. 1
0
        public TitleDistill(Uri address, IWebsiteHost hostData, ILogger log)
            : base(address, log)
        {
            if (address == null)
            {
                log.Error("Address cannot be null");
                throw new NullReferenceException("Address cannot be null");
            }

            HostData = hostData;

            /// Sets the host URI of the series.
            HostVariables.Add("host", address.Host);

            /// Sets the host URI of the series including its scheme (ie. https://).
            HostVariables.Add("host_and_scheme", string.Concat(address.Scheme, Uri.SchemeDelimiter, address.Host));

            /// Sets the series' main address.
            HostVariables.Add("series_address", address.ToString());

            /// Set the the trimmed address for the main series page.
            HostVariables.Add("series_address_trimmed", address.ToString().Substring(0, address.ToString().LastIndexOf('/')));

            /// Sets the series name.
            HostVariables.Add("series_name", this.SeriesTitle);

            if (IsAddressChapterUri())
            {
                IsChapter = true;
            }
        }
Esempio n. 2
0
        public ChapterDistill(string name, Uri address, IWebsiteHost hostData, ILogger log)
            : base(name, address, log)
        {
            log.Trace("Entering ChapterDistill() constructor");

            if (hostData == null)
            {
                log.Error("Variable 'hostData' cannot be null.");
                throw new ArgumentNullException("Variable 'hostData' cannot be null.");
            }
            else
            {
                HostData = hostData;

                /// Sets the chapter's name according to the host.
                Parsing.RegisterChapterVariable(Name, HostVariables);
                log.Info("Chapter 'name' variable: {0}", HostVariables[Parsing.CHAPTER_VARIABLE]);

                /// Sets the chapter's address.
                HostVariables.Add("address", address.ToString());
                log.Info("Chapter 'address' value: {0}", HostVariables["address"]);

                /// Sets a trimmed version of the chapter's address.
                HostVariables.Add("address_trimmed", address.ToString().Substring(0, address.ToString().LastIndexOf('/')));
                log.Info("Chapter 'address_trimmed' value: {0}", HostVariables["address_trimmed"]);

                // Short-circuit the page listing if all of the 'pages' (chapter images) are in a single HTML page.
                SinglePage = HostData.Host.SinglePage;
                log.Info("Is single page: {0}", SinglePage);

                log.Info("No chapter directory: {0}", hostData.Chapters.NoChapterDirectory);

                if (hostData.Chapters.NoChapterDirectory)
                {
                    FormattedChapterName = string.Empty;
                    //log.Debug("Setting chapter path to '{0}'", ChapterPath);
                }
                else
                {
                    FormattedChapterName = Name;
                }
            }
        }
Esempio n. 3
0
        public static bool TryGetDistilledHost(Uri uri, out IWebsiteHost result)
        {
            var isDistilledHost = false;

            result = LoadConfigFile(uri);

            if (result != null)
            {
                /// Todo: Refactor, check if the chapter URI is not null and if chapter URI are the only supported URIs.
                /// If so, then don't return true when matching the host name. e.g. Chapter URI > Host URI

                var regexOption = RegexOptions.Compiled | RegexOptions.IgnoreCase;

                // Assumes regex.
                if (Regex.IsMatch(uri.Host, result.Host.HostUriPattern, regexOption) ||
                    (result.Host.ChapterUriPattern != null && Regex.IsMatch(uri.ToString(), result.Host.ChapterUriPattern, regexOption)))
                {
                    isDistilledHost = true;
                }
            }

            return(isDistilledHost);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns whether the application has support for distilled host plugins.
        /// </summary>
        /// <param name="uri">The service's URI to check.</param>
        /// <returns></returns>
        public static bool IsDistilled(Uri uri)
        {
            IWebsiteHost data = null;

            return(TryGetDistilledHost(uri, out data));
        }
Esempio n. 5
0
 public WebsiteHostDecorator(IWebsiteHost decoratedHost)
 {
     this.decoratedHost = decoratedHost;
 }