Exemple #1
0
        private void GenerateVerses(string path)
        {
            Razor.Compile(_versesTemplate, "versesTemplate");

            for (int i = 1; i < _english.Books.Count + 1; i++)
            {
                string bookPath = path + Path.DirectorySeparatorChar + i;
                Directory.CreateDirectory(bookPath);

                Book englishBook   = _english.Books[i - 1];
                Book malayalamBook = _malayalam.Books[i - 1];
                Book hindiBook     = _hindi.Books[i - 1];

                Log.Info("Generating " + englishBook.Name);

                for (int j = 1; j < englishBook.Chapters.Count + 1; j++)
                {
                    string chapterPath = bookPath + Path.DirectorySeparatorChar + j;
                    Directory.CreateDirectory(chapterPath);

                    Chapter englishChapter   = englishBook.Chapters[j - 1];
                    Chapter malayalamChapter = malayalamBook.Chapters[j - 1];
                    Chapter hindiChapter     = hindiBook.Chapters[j - 1];

                    BookChapter bookChapter = new BookChapter(englishBook.Name + " " + englishChapter.Id);

                    if (englishBook.Id == 1 && englishChapter.Id == 1)
                    {
                        bookChapter.HasBack = false;
                    }
                    else
                    {
                        int backBook    = englishBook.Id;
                        int backChapter = englishChapter.Id - 1;
                        if (backChapter == 0)
                        {
                            backBook--;
                            backChapter = Book.ChaptersPerBook[backBook];
                        }
                        bookChapter.BackPath = string.Format("../../{0}/{1}/index.html", backBook, backChapter);
                    }
                    if (englishBook.Id == 66 && englishChapter.Id == 22)
                    {
                        bookChapter.HasForward = false;
                    }
                    else
                    {
                        int forwardBook    = englishBook.Id;
                        int forwardChapter = englishChapter.Id + 1;
                        if (forwardChapter > Book.ChaptersPerBook[forwardBook])
                        {
                            forwardBook++;
                            forwardChapter = 1;
                        }
                        bookChapter.ForwardPath = string.Format("../../{0}/{1}/index.html", forwardBook, forwardChapter);
                    }

                    int maxVerses = Math.Max(Math.Max(englishChapter.Verses.Count, malayalamChapter.Verses.Count), hindiChapter.Verses.Count);
                    for (int k = 0; k < maxVerses; k++)
                    {
                        BookChapterVerse verse = new BookChapterVerse();
                        if (k < englishChapter.Verses.Count)
                        {
                            verse.InEnglish = true;
                            verse.English   = englishChapter.Verses[k];
                        }
                        if (k < malayalamChapter.Verses.Count)
                        {
                            verse.InMalayalam = true;
                            verse.Malayalam   = malayalamChapter.Verses[k];
                        }
                        if (k < hindiChapter.Verses.Count)
                        {
                            verse.InHindi = true;
                            verse.Hindi   = hindiChapter.Verses[k];
                        }
                        bookChapter.Verses.Add(verse);
                    }

                    string template = File.ReadAllText(_versesTemplate);
                    string result   = Razor.Parse(template, bookChapter);

                    //string result = Razor.Run("versesTemplate", bookChapter);

                    File.WriteAllText(chapterPath + Path.DirectorySeparatorChar + "index.html", result);
                }
            }
        }
        private void GenerateVerses(string path)
        {
            Razor.Compile(_versesTemplate, "versesTemplate");

            for (int i = 1; i < _english.Books.Count + 1; i++)
            {
                string bookPath = path + Path.DirectorySeparatorChar + i;
                Directory.CreateDirectory(bookPath);

                Book englishBook = _english.Books[i - 1];
                Book malayalamBook = _malayalam.Books[i - 1];
                Book hindiBook = _hindi.Books[i - 1];

                Log.Info("Generating " + englishBook.Name);

                for (int j = 1; j < englishBook.Chapters.Count + 1; j++)
                {
                    string chapterPath = bookPath + Path.DirectorySeparatorChar + j;
                    Directory.CreateDirectory(chapterPath);

                    Chapter englishChapter = englishBook.Chapters[j - 1];
                    Chapter malayalamChapter = malayalamBook.Chapters[j - 1];
                    Chapter hindiChapter = hindiBook.Chapters[j - 1];

                    BookChapter bookChapter = new BookChapter(englishBook.Name + " " + englishChapter.Id);

                    if (englishBook.Id == 1 && englishChapter.Id == 1)
                    {
                        bookChapter.HasBack = false;
                    }
                    else
                    {
                        int backBook = englishBook.Id;
                        int backChapter = englishChapter.Id - 1;
                        if (backChapter == 0)
                        {
                            backBook--;
                            backChapter = Book.ChaptersPerBook[backBook];
                        }
                        bookChapter.BackPath = string.Format("../../{0}/{1}/index.html", backBook, backChapter);
                    }
                    if (englishBook.Id == 66 && englishChapter.Id == 22)
                    {
                        bookChapter.HasForward = false;
                    }
                    else
                    {
                        int forwardBook = englishBook.Id;
                        int forwardChapter = englishChapter.Id + 1;
                        if (forwardChapter > Book.ChaptersPerBook[forwardBook])
                        {
                            forwardBook++;
                            forwardChapter = 1;
                        }
                        bookChapter.ForwardPath = string.Format("../../{0}/{1}/index.html", forwardBook, forwardChapter);
                    }

                    int maxVerses = Math.Max(Math.Max(englishChapter.Verses.Count, malayalamChapter.Verses.Count), hindiChapter.Verses.Count);
                    for (int k = 0; k < maxVerses; k++)
                    {
                        BookChapterVerse verse = new BookChapterVerse();
                        if (k < englishChapter.Verses.Count)
                        {
                            verse.InEnglish = true;
                            verse.English = englishChapter.Verses[k];
                        }
                        if (k < malayalamChapter.Verses.Count)
                        {
                            verse.InMalayalam = true;
                            verse.Malayalam = malayalamChapter.Verses[k];
                        }
                        if (k < hindiChapter.Verses.Count)
                        {
                            verse.InHindi = true;
                            verse.Hindi = hindiChapter.Verses[k];
                        }
                        bookChapter.Verses.Add(verse);
                    }

                    string template = File.ReadAllText(_versesTemplate);
                    string result = Razor.Parse(template, bookChapter);

                    //string result = Razor.Run("versesTemplate", bookChapter);

                    File.WriteAllText(chapterPath + Path.DirectorySeparatorChar + "index.html", result);
                }
            }
        }