public string VygenerovatHtml(Bible bible, bool dlouhaCislaVerse)
        {
            PouzitePoznamky.Clear();

            string pracovniAdresar = Environment.CurrentDirectory;

            string htmlSoubor = Path.Combine(
                pracovniAdresar,
                $"{bible.Metadata.Nazev}-{bible.Revize.Datum.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)}" +
                $"{(dlouhaCislaVerse ? "-l" : string.Empty)}.html");

            if (File.Exists(htmlSoubor))
            {
                File.Delete(htmlSoubor);
            }

            List <string> sekce  = new List <string>();
            List <string> obsahy = new List <string>();

            foreach (Kniha kniha in bible.Knihy)
            {
                sekce.Add($"<a class=\"dropdown-item\" href=\"#{kniha.Id}\">{bible.MapovaniZkratekKnih[kniha.Id].Nadpis}</a>");
                obsahy.Add($"<a class=\"anchor\" id=\"{kniha.Id}\"></a><h1>{bible.MapovaniZkratekKnih[kniha.Id].Nadpis}</h1>" + VygenerovatKnihu(kniha, bible, dlouhaCislaVerse));
            }

            File.WriteAllText(
                htmlSoubor,
                Properties.Resources.bible_online_cela
                .Replace("{0}", bible.Metadata.Nazev)
                .Replace("{1}", string.Join("\n", sekce))
                .Replace("{2}", string.Join("\n", obsahy)),
                Encoding.UTF8);

            return(htmlSoubor);
        }
Example #2
0
        private static void Main(string[] args)
        {
            var outputPath = "../../output/";

            var reader = new JsonReader();
            var pol    = reader.Read <Pol>(outputPath + "pol.json").ToList();
            var byz    = reader.Read <Byz>(outputPath + "byz.json").ToList();
            var link   = reader.Read <Link>(outputPath + "link.json");

            var translator = new Translator();
            var words      = translator.Translate(pol, byz, link);

            var generator = new ModelBuilder();
            var book      = generator.GenerateBook("Mathew", words);

            Bible bible = new Bible();

            bible.Books.Add(book);

            var path = outputPath + "bible_content.xml";
            var xml  = new XmlBibleWriter();

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            xml.Convert(path, bible);

            //var path = outputPath + "bible_content.tex";
            //var expex = new ExpexBibleWriter();
            //expex.Convert(path, bible);

            Console.WriteLine("done.");
        }
Example #3
0
        public async Task <IActionResult> OnGetAsync(int Id, string BibleId)
        {
            IdentityUser user = await _userManager.GetUserAsync(User);

            PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); // Static method not requiring an instance

            Template = await _context.PredefinedQuizzes.FindAsync(Id);

            if (Template == null)
            {
                return(RedirectToPage("/error", new { errorMessage = "Thats Odd! We were unable to find this Quiz Template" }));
            }

            if (!PBEUser.IsValidPBEQuestionBuilder() || PBEUser != Template.QuizUser)
            {
                return(RedirectToPage("/error", new { errorMessage = "Sorry! You do not have sufficient rights to configure this Quiz Template" }));
            }

            this.BibleId = await Bible.GetValidPBEBibleIdAsync(_context, BibleId);

            //Initialize Our Template
            _context.Entry(Template).Collection(T => T.PredefinedQuizQuestions).Load();
            Questions = Template.IntiQuestionListForAddEdit();
            // Initialize Template Books
            TemplateBooks = await Template.GetTemplateBooksAsync(_context, this.BibleId);

            JSONBooks = JsonSerializer.Serialize(TemplateBooks);
            // Build Select Lists
            foreach (PredefinedQuizQuestion Question in Questions)
            {
                Question.AddChapterSelectList(TemplateBooks);
            }
            ViewData["BookSelectList"] = MinBook.GetMinBookSelectListFromList(TemplateBooks);
            return(Page());
        }
Example #4
0
        public static Bible Run()
        {
            Bible bible = new Bible("English");

            XDocument doc          = XDocument.Load("ESV.xml");
            var       bookElements = doc.Root.Elements("b");

            for (int i = 1; i < bookElements.Count() + 1; i++)
            {
                var    bookElement = bookElements.ElementAt(i - 1);
                string bookName    = bookElement.Attribute("n").Value;
                Book   book        = new Book(i, bookName);
                bible.Books.Add(book);

                foreach (var chapterElement in bookElement.Elements("c"))
                {
                    int     chapterId = Int32.Parse(chapterElement.Attribute("n").Value);
                    Chapter chapter   = new Chapter(chapterId);
                    book.Chapters.Add(chapter);

                    foreach (var verseElement in chapterElement.Elements("v"))
                    {
                        int    verseId = Int32.Parse(verseElement.Attribute("n").Value);
                        string text    = verseElement.Value;
                        Verse  verse   = new Verse(verseId, text);
                        chapter.Verses.Add(verse);
                    }
                }
            }

            return(bible);
        }
        public IHttpActionResult PostBible(Bible bible)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            bible.Id = Guid.NewGuid();

            db.Bibles.Add(bible);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (BibleExists(bible.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(bible));
        }
Example #6
0
        public void NestedSpans()
        {
            var location = VerseHelper.Find("Psalms", 11, 1);
            var verse    = Bible.FormattedVerse(location.AbsoluteVerseNumber);

            Assert.Equal(" To the chief Musician, A Psalm of David. In the LORD put I my trust: how say ye to my soul, Flee as a bird to your mountain?", verse.Text);
            Assert.Equal(new[]
            {
                new FormattedVerse.Span
                {
                    Type  = FormattedVerse.SpanType.Colophon,
                    Begin = 1,
                    End   = 41,
                },
                new FormattedVerse.Span
                {
                    Type  = FormattedVerse.SpanType.Italics,
                    Begin = 24,
                    End   = 31,
                },
                new FormattedVerse.Span
                {
                    Type  = FormattedVerse.SpanType.Italics,
                    Begin = 98,
                    End   = 100,
                },
            }, verse.Spans, Comparers.SpanComparer);
        }
        /// <summary>
        /// Returns all matches of the query from a given bible
        /// </summary>
        /// <param name="searchBible">The bible to search from</param>
        /// <param name="ignoreCase">Whether the search should be case-insensitive. By default, it is true</param>
        /// <param name="onProgressUpdate">The IProgress</param>
        /// <param name="ct">The CancellationToken</param>
        /// <returns></returns>
        public IEnumerable <BibleReference> GetResults(Bible searchBible, bool ignoreCase = true, IProgress <float> onProgressUpdate = null, CancellationToken ct = default)
        {
            Regex r = new Regex(SearchString, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None);
            float CurrentProgress = 0, ProgressInc = 1.0f / 66.0f;

            foreach (KeyValuePair <BibleBook, Book> bk in searchBible.Books)
            {
                foreach (KeyValuePair <byte, Dictionary <byte, string> > ch in bk.Value.Chapter)
                {
                    foreach (KeyValuePair <byte, string> v in ch.Value)
                    {
                        if (ct.CanBeCanceled && ct.IsCancellationRequested)
                        {
                            goto ex;
                        }
                        if (r.Match(v.Value).Success)
                        {
                            yield return(new BibleReference()
                            {
                                Book = bk.Key, Chapter = ch.Key, Verse = v.Key
                            });
                        }
                    }
                }
                onProgressUpdate?.Report(CurrentProgress += ProgressInc);
            }
            ex :;
        }
Example #8
0
        public void Hyphen_IncludesZeroWidthSpace()
        {
            var location = VerseHelper.Find("Genesis", 33, 20);
            var verse    = Bible.FormattedVerse(location.AbsoluteVerseNumber);

            Assert.Equal(" And he erected there an altar, and called it Elelohe-\u200BIsrael.", verse.Text);
        }
Example #9
0
        public async Task <IBible> GetBibleFromTxtAsync(string fileName)
        {
            if (File.Exists(fileName))
            {
                var bible = new Bible();

                using (var sr = new StreamReader(fileName))
                {
                    var txt = sr.ReadToEnd();

                    var parts = Regex.Split(txt, $"{Environment.NewLine} {Environment.NewLine}");

                    var counter = default(int);
                    foreach (var part in parts)
                    {
                        var book = await _bookFormatterEngine.Process(part);

                        if (book != null)
                        {
                            book.Number = ++counter;
                            bible.Collection.Add(book);
                        }
                    }
                }

                return(bible);
            }

            return(null);
        }
Example #10
0
        protected override async Task <List <Book> > GetBooksOnlineAsync(Bible bible)
        {
            // TODO: WhenAll?
            var tasks = new[]
            {
                client.PostAndGetStringAsync("/bible_otnt_exc.asp", new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("bible_idx", "1"),
                    new KeyValuePair <string, string>("otnt", "1"),
                })),
                client.PostAndGetStringAsync("/bible_otnt_exc.asp", new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("bible_idx", "1"),
                    new KeyValuePair <string, string>("otnt", "2"),
                })),
            };
            var data    = string.Join("", await Task.WhenAll(tasks));
            var matches = Regex.Matches(data, @"""idx"":(\d+).+?""bible_name"":""(.+?)"".+?""max_jang"":(\d+)");

            return(matches.Cast <Match>().Select(i => new Book
            {
                OnlineId = i.Groups[1].Value,
                Name = i.Groups[2].Value,
                ChapterCount = int.Parse(i.Groups[3].Value),
            }).ToList());
        }
        public async Task <IActionResult> OnGetAsync(string BibleId, int Id)
        {
            IdentityUser user = await _userManager.GetUserAsync(User);

            PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); // Static method not requiring an instance

            if (!PBEUser.IsQuizModerator())
            {
                return(RedirectToPage("/error", new { errorMessage = "Sorry! You do not have sufficient rights to edit a PBE BookList" }));
            }

            BookList = await _context.QuizBookLists.FindAsync(Id);

            if (BookList == null)
            {
                return(RedirectToPage("/error", new { errorMessage = "That's Odd! We weren't able to find this Book List" }));
            }

            this.BibleId = await Bible.GetValidPBEBibleIdAsync(_context, BibleId);

            //Initialize Books
            await _context.Entry(BookList).Collection(L => L.QuizBookListBookMaps).LoadAsync();

            BookList.PadBookListBookMapsForEdit();
            Books = BookList.QuizBookListBookMaps.ToList();
            Name  = BookList.BookListName;
            ViewData["BookSelectList"] = await BibleBook.GetBookSelectListAsync(_context, BibleId);

            return(Page());
        }
 public SearchByKeywordViewModel(Bible bible)
 {
     this.Verses     = new ObservableCollection <Verse>();
     this.bible      = bible;
     this.apiService = new ApiService();
     this.LoadBooks();
 }
        private void OptionMenuAction(String sender)
        {
            switch (sender)
            {
            case "next":
                var nextList = dataAccess.GetBible(BibleDataAccess.Mode.Next);
                if (nextList != null)
                {
                    var next = new ObservableCollection <Bible>(nextList);
                    Bible.Clear();
                    Bible = next;
                }
                break;

            case "prev":
                var prevList = dataAccess.GetBible(BibleDataAccess.Mode.Prev);
                if (prevList != null)
                {
                    var prev = new ObservableCollection <Bible>(prevList);
                    Bible.Clear();
                    Bible = prev;
                }
                break;

            case "note":
                break;

            case "sermon":
                break;
            }
        }
Example #14
0
        public async void InsertBibleText(string[] bibleText, Register register)
        {
            Bible        bible        = new Bible();
            BibleContext bibleContext = new BibleContext();

            const string pattern = @"(\d{1,3}\w)\s(\d{1,3})\s(\d{1,3})\s*\d*\s*\s*([\ \S*]*)";
            //(\d{1,3}\w)\W(\d{1,3})\W(\d{1,3})\W{1,2}\d{1,7}\W{1}([\ \S*]*)";

            // Instantiate the regular expression object.
            Regex r = new Regex(pattern, RegexOptions.IgnoreCase);

            for (int i = 8; i < bibleText.Length; i++)
            {
                Match m = r.Match(bibleText[i]);

                if (m.Groups.Count >= 4)
                {
                    bible.Id               = 0;
                    bible.Version          = register.Abbreviation;
                    bible.BookChapterVerse = m.Groups[1].ToString() + "|" + m.Groups[2].ToString() + "|" + m.Groups[3].ToString();
                    bible.Book             = m.Groups[1].ToString();
                    bible.Chapter          = m.Groups[2].ToString();
                    bible.Verse            = m.Groups[3].ToString();
                    bible.BibleText        = m.Groups[4].ToString();
                    bibleContext.Add(bible);
                    await bibleContext.SaveChangesAsync();
                }
            }
        }
        public IHttpActionResult PutBible(Guid id, Bible bible)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bible.Id)
            {
                return(BadRequest());
            }

            db.Entry(bible).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BibleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #16
0
        public void Gen1_1_Formatted()
        {
            var verse = Bible.FormattedVerse(0);

            Assert.Equal(" In the beginning God created the heaven and the earth.", verse.Text);
            Assert.Empty(verse.Spans);
        }
Example #17
0
 public void Setup()
 {
     _ctx   = new Context();
     _bible = new Bible {
         Id = Guid.Parse("088ff243-c402-485f-8a22-3b7e3919c4b1"), Code = Core.Models.Enums.BibleVersion.KJV, NumOfBooks = 66
     };
 }
Example #18
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     BibleStore.BibleStore.LoadNames("en", "data/en_names.yml");
     BibleStore.BibleStore.LoadNames("zh", "data/zh_names.yml");
     ChiBible = BibleStore.BibleStore.LoadOSIS("data/Chi-Union.xml");
     EngBible = BibleStore.BibleStore.LoadOSIS("data/NKJV.xml");
 }
        public ActionResult Index(string translation = "TMSG")
        {
            ViewBag.Title        = "Resource Bible Study";
            BibleContent         = _bibleRepository.GetBible();
            ViewBag.BibleContent = BibleContent;

            return(View());
        }
        /// <summary>
        /// Bible Index
        /// </summary>
        /// <param name="translation"></param>
        /// <returns></returns>
        // GET: /Administrator/ BibleReading/
        public ActionResult Index(BibleConstants.BibleVersions translation = BibleConstants.BibleVersions.Msg)
        {
            BibleContent = _bibleRepository.GetBible(translation);

            ViewBag.BibleContent = BibleContent;

            return(View());
        }
Example #21
0
        public void Adding_null_value_to_Books_collection_should_throw()
        {
            var bible = new Bible();
            IBook book = null;

            // ReSharper disable AssignNullToNotNullAttribute
            Assert.Throws<ArgumentException>(() => bible.Books.Add(BookName.Genesis, book));
        }
 private void VygenerovatOdstavec(CastTextu cast, Bible bible, Kniha kniha)
 {
     AktualniTextVerse += "<br/>";
     foreach (CastTextu potomek in cast.Potomci)
     {
         VygenerovatCastSql(potomek, bible, kniha);
     }
 }
Example #23
0
        public void DoubleCapitalization()
        {
            // A few words in the text have the first *two* letters capitalized.
            var location = VerseHelper.Find("John", 3, 23);
            var verse    = Bible.FormattedVerse(location.AbsoluteVerseNumber);

            Assert.Equal(" And John also was baptizing in AEnon near to Salim, because there was much water there: and they came, and were baptized.", verse.Text);
        }
Example #24
0
        public void LongHyphen_DoesNotIncludeZeroWidthSpace()
        {
            // This is the only verse with a long hyphen.
            var location = VerseHelper.Find("Exodus", 32, 32);
            var verse    = Bible.FormattedVerse(location.AbsoluteVerseNumber);

            Assert.Equal(" Yet now, if thou wilt forgive their sin—; and if not, blot me, I pray thee, out of thy book which thou hast written.", verse.Text);
        }
        private void VygenerovatKnihu(CastTextu cast, Bible bible, Kniha kniha)
        {
            foreach (CastTextu potomek in cast.Potomci)
            {
                VygenerovatCastSql(potomek, bible, kniha);

                PridatRozpracovanyVers();
            }
        }
        private void VygenerovatRadekPoezie(CastTextu cast, Bible bible, Kniha kniha)
        {
            foreach (CastTextu potomek in cast.Potomci)
            {
                VygenerovatCastSql(potomek, bible, kniha);
            }

            AktualniTextVerse += "<br/>";
        }
        private void VygenerovatCastKnihy(CastTextu cast, Bible bible, Kniha kniha)
        {
            VlozitSqlNadpis(cast is HlavniCastKnihy knihy ? knihy.Nadpis : ((CastKnihy)cast).Nadpis);

            foreach (CastTextu potomek in cast.Potomci)
            {
                VygenerovatCastSql(potomek, bible, kniha);
            }
        }
 /// <summary>
 /// Loads the Bible from the asset
 /// </summary>
 /// <param name="loadedBible">The bible queried to load.</param>
 /// <returns>The bible object deserialized from the asset file</returns>
 public ChapterwiseBible(Bible loadedBible)
 {
     LoadedBible       = loadedBible;
     CurrentAllBooks   = LoadedBible.Value.Books.Keys.ToArray();
     _currentBookIndex = 0;
     CurrentChapter    = 1;
     LoadedChapter     = null;
     LoadChapter(CurrentAllBooks[0], 1);
 }
Example #29
0
        public void Books_collection_should_allow_setting_an_item()
        {
            var bible = new Bible();
            var book = new BookStub();

            bible.Books[BookName.Genesis] = book;

            Assert.That(bible.Books[BookName.Genesis], Is.SameAs(book));
        }
Example #30
0
        public void Convert(string fileName, Bible bible)
        {
            var serializer = new XmlSerializer(typeof(Bible));

            using (var stream = new FileStream(fileName, FileMode.CreateNew))
            {
                serializer.Serialize(stream, bible);
            }
        }
Example #31
0
        public Bible LoadMeta(string fileName)
        {
            var b = new Bible();

            // Read a document
            var textReader = new XmlTextReader(fileName);

            // Read until end of file
            while (textReader.Read())
            {
                if (textReader.NodeType == XmlNodeType.Element && textReader.Name.ToLower() == "xmlbible")
                {
                    while (textReader.Read())
                    {
                        if (textReader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "title", ref b, "Title"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "description", ref b, "Description"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "contributors", ref b, "Contributors"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "language", ref b, "Language"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "publisher", ref b, "Publisher"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "date", ref b, "Source"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "source", ref b, "Date"))
                        {
                            continue;
                        }
                        if (GetNodeText(textReader, "identifier", ref b, "Identifier"))
                        {
                        }
                    }
                    break;
                }
            }
            return(b);
        }
 private void VygenerovatCastPoezie(CastTextu cast, Bible bible, Kniha kniha)
 {
     if (!string.IsNullOrEmpty(AktualniTextVerse))
     {
         AktualniTextVerse += "<br/>";
     }
     foreach (CastTextu potomek in cast.Potomci)
     {
         VygenerovatCastSql(potomek, bible, kniha);
     }
 }
Example #33
0
        public void Setting_null_value_into_Books_collection_should_throw()
        {
            var bible = new Bible();

            Assert.Throws<ArgumentException>(() => bible.Books[BookName.Genesis] = null);
        }
Example #34
0
 public static void setInstance(Bible.BibleEnvironment e)
 {
     if (e != null)
         mEnvironment = e;
 }