Example #1
0
 private IDictionary<string, object> LoadMetadata()
 {
     var metadata = new Dictionary<string, object> ();
     foreach (var file in Files.GetAllFiles (BaseDir)) {
         var map = ProcessMetadata (file);
         if (map != null) {
             metadata.AddAll (map);
         }
     }
     return metadata;
 }
Example #2
0
        public void Init()
        {
            var parent = Path.GetDirectoryName (DiskPath);
            var siblings = new SortedDictionary<string, Page> ();

            foreach (var i in Tacker.Pages) {
                if (i.DiskPath.Equals (parent)) {
                    Parent = i;
                }
                if (parent.Equals (Path.GetDirectoryName (i.DiskPath)) &&
                    i != this && !i.IsFloating) {
                    siblings.Add (Path.GetFileName (i.DiskPath), i);
                }
            }

            Siblings = new List<Page> (siblings.Values);

            var metadata = new Dictionary<string, object> ();
            var assets = new HashSet<string> ();

            foreach (var i in Files.GetAllFiles (DiskPath)) {
                var md = Tacker.ProcessMetadata (i);
                if (md != null) {
                    Template = Template ?? Path.GetFileNameWithoutExtension (i);
                    metadata.AddAll (md);
                    continue;
                }
                var markup = Tacker.ProcessMarkup (i);
                if (markup != null) {
                    metadata.Add (Path.GetFileNameWithoutExtension (i), markup);
                    continue;
                }

                assets.Add (i);
            }

            var pagePaths = new HashSet<string> ();
            foreach (var page in Tacker.Pages) {
                pagePaths.Add (page.DiskPath);
            }

            foreach (var subdir in Files.EnumerateAllSubdirs (DiskPath)) {
                if (!pagePaths.Contains (subdir)) {
                    assets.AddAll (Files.GetAllFiles (subdir));
                }
            }

            Assets = new HashSet<string> (assets.Select (x => x.Replace (DiskPath, "")));
            Variables = metadata;
            inited = true;
        }
        public async override Task<Dictionary<string, string>> RequestSearchIndexAsync(CancellationToken ct)
        {
            var index = new Dictionary<string, string>();

            string site = await Util.RequestSimplifiedHtmlSiteAsync(GetWebsiteLink() + "cartoon-list/");
            ct.ThrowIfCancellationRequested();
            index.AddAll(ParseSeriesOverview(site));
            int nextIndex = site.IndexOf("next page-numbers");
            while (nextIndex != -1)
            {
                ct.ThrowIfCancellationRequested();
                string nextPage = site.GetSubstringBetween(nextIndex, "href=\"", "\"");
                site = await Util.RequestSimplifiedHtmlSiteAsync(nextPage);
                index.AddAll(ParseSeriesOverview(site));
                nextIndex = site.IndexOf("next page-numbers");
            }
            ct.ThrowIfCancellationRequested();
            site = await Util.RequestSimplifiedHtmlSiteAsync(GetWebsiteLink() + "anime-dubbed/");
            index.AddAll(ParseSeriesOverview(site));
            nextIndex = site.IndexOf("next page-numbers");
            while (nextIndex != -1)
            {
                ct.ThrowIfCancellationRequested();
                string nextPage = site.GetSubstringBetween(nextIndex, "href=\"", "\"");
                site = await Util.RequestSimplifiedHtmlSiteAsync(nextPage);
                index.AddAll(ParseSeriesOverview(site));
                nextIndex = site.IndexOf("next page-numbers");
            }
            ct.ThrowIfCancellationRequested();
            return index;
        }