Beispiel #1
0
 public IEnumerable <News> EnumerateAll()
 {
     foreach (var x in EnumerateNewsFiles())
     {
         yield return(GetSingle(GlobalizationFileFinder.GetFileId(x)));
     }
 }
Beispiel #2
0
        public List <TokenIncubatorUpdateModel> GetTokenIncubatorUpdates(string tokenId, string cultureStr)
        {
            var folderPath = Path.Combine(tokenFolderAbsolutePath, tokenId, "updates");

            if (!Directory.Exists(folderPath))
            {
                return(null);
            }

            var availableFiles = GlobalizationFileFinder.GetCultureFiles(folderPath, cultureStr, ".json").ToList();
            var mainFile       = availableFiles.FirstOrDefault(x => x.EndsWith(".json"));

            if (!string.IsNullOrWhiteSpace(mainFile))
            {
                var updateList = JsonConvert.DeserializeObject <List <TokenIncubatorUpdateModel> >(System.IO.File.ReadAllText(mainFile));
                if (updateList != null)
                {
                    foreach (var u in updateList)
                    {
                        var contentPath = Path.Combine(folderPath, u.Content);
                        if (!string.IsNullOrWhiteSpace(u.Content) && File.Exists(contentPath))
                        {
                            u.Content = System.IO.File.ReadAllText(contentPath);
                        }
                    }
                }
                return(updateList);
            }
            return(null);
        }
Beispiel #3
0
        public News GetSingle(object id)
        {
            var path   = GlobalizationFileFinder.GetFilePathById(_path, id.ToString(), _lang);
            var md     = File.ReadAllText(path);
            var result = AnnotationParser.Parse(md);

            return(new News
            {
                Id = id.ToString(),
                Title = result.Annotations.ContainsKey("Title") ? result.Annotations["Title"] : null,
                PublishedAt = result.Annotations.ContainsKey("Published at") ? Convert.ToDateTime(result.Annotations["Published at"]) : DateTime.MinValue,
                IsPinned = result.Annotations.ContainsKey("Pinned") ? Convert.ToBoolean(result.Annotations["Pinned"]) : false,
                Content = result.PlainMarkdown
            });
        }
Beispiel #4
0
        public string GetTokenIncubationDetail(string tokenId, string cultureStr)
        {
            var folderPath = Path.Combine(tokenFolderAbsolutePath, tokenId, "incubator");

            if (!Directory.Exists(folderPath))
            {
                return(null);
            }

            var availablePath = GlobalizationFileFinder.GetCultureFiles(folderPath, cultureStr, ".md").Where(x => Path.GetFileNameWithoutExtension(x).StartsWith("detail.")).FirstOrDefault();

            if (availablePath != null)
            {
                return(File.ReadAllText(availablePath));
            }
            return(null);
        }
Beispiel #5
0
        public IEnumerable <string> GetTokenIncubationBannereRelativePaths(string tokenId, string cultureStr)
        {
            var sliderFolderPath = Path.Combine(tokenFolderAbsolutePath, tokenId, "slides");

            if (!Directory.Exists(sliderFolderPath))
            {
                yield return(null);
            }

            var availablePaths = GlobalizationFileFinder.GetCultureFiles(sliderFolderPath, cultureStr, ".png").ToList();

            foreach (var path in availablePaths)
            {
                Uri    absolutePath = new Uri(path);
                Uri    folderPath   = new Uri(tokenFolderAbsolutePath + "/");
                string relativePath = folderPath.MakeRelativeUri(absolutePath).ToString();
                yield return(relativePath);
            }
            ;
        }
Beispiel #6
0
        public string GetWhitePaper(string tokenId, string cultureStr)
        {
            var sliderFolderPath = Path.Combine(tokenFolderAbsolutePath, tokenId, "whitepaper");

            if (!Directory.Exists(sliderFolderPath))
            {
                return(null);
            }

            var availablePaths = GlobalizationFileFinder.GetCultureFiles(sliderFolderPath, cultureStr, ".pdf").ToList();

            if (availablePaths.Count >= 1)
            {
                var    path         = availablePaths.FirstOrDefault();
                Uri    absolutePath = new Uri(path);
                Uri    folderPath   = new Uri(tokenFolderAbsolutePath + "/");
                string relativePath = folderPath.MakeRelativeUri(absolutePath).ToString();
                return(relativePath);
            }
            ;
            return(null);
        }
Beispiel #7
0
 private IEnumerable <string> EnumerateNewsFiles()
 {
     return(GlobalizationFileFinder.GetCultureFiles(_path, _lang));
 }