예제 #1
0
        private static void WriteIndexFile(string filename, Core.Models.Index index)
        {
            index.Editions = index.Editions.OrderByDescending(o => o.Id).ToList();

            string indexJson = JsonConvert.SerializeObject(index,
                                                           Formatting.Indented,
                                                           new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
            });

            File.WriteAllText(filename, indexJson);
        }
예제 #2
0
        private static void UpdateIndexFile(Core.Models.Index indexData, List <Edition> curatedEditions)
        {
            // create an index file
            //var indexData = new WeeklyXamarin.Core.Models.Index();
            //indexData.UpdatedTimeStamp = DateTime.UtcNow;

            //indexData.Editions = new List<Core.Models.Edition>();
            foreach (var edition in CuratedEditions)
            {
                Core.Models.Edition ed;
                ed = indexData.Editions.FirstOrDefault(e => e.Id == edition.Number.ToString());
                if (ed == null)
                {
                    ed = edition.ToCoreEdition();
                    indexData.Editions.Add(ed);
                }
                else
                {
                    // update data?
                }
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            // work out our paths
            // TODO: These should probably by derived from args
            string executeLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;

            basePath        = System.IO.Path.GetDirectoryName(executeLocation);
            outputPath      = Path.Combine(basePath, "Output");
            curatedDataPath = Path.Combine(basePath, "CuratedExport");
            lookupDataPath  = Path.Combine(basePath, "LookupData");

            // for debug override the basepath
            basePath        = @"D:\GitHub\weeklyxamarin\WeeklyXamarin.content\content";
            outputPath      = basePath;
            curatedDataPath = @"D:\github\WeeklyXamarin\WeeklyXamarin.content\curateddata\published";
            planetXamarinAuthorsDataPath = @"D:\github\planetxamarin\planetxamarin\src\Firehose.Web\Authors";
            lookupDataPath = basePath;

            // load up the editions from curated files
            CuratedEditions = LoadupCuratedEditions(curatedDataPath);

            // create the index file - before we have the articles
            Core.Models.Index indexLookup = LoadIndexFile(Path.Combine(lookupDataPath, IndexFile));
            UpdateIndexFile(indexLookup, CuratedEditions);
            WriteIndexFile(Path.Combine(outputPath, IndexFile), indexLookup);

            // load up the authors lookup file which is used
            // to try and identify authors via multiple means
            AuthorLookup = LoadAuthorLookup(Path.Combine(lookupDataPath, AuthorsFile));

            ProcessEditions();
            //ProcessPlanetXamarinAuthors();


            // finally we have an authors
            WriteAuthorsFile(Path.Combine(outputPath, AuthorsFile), AuthorLookup);

            OutputEditions(outputPath, Editions);
        }