예제 #1
0
def get_content(module_name="ESV", verse_per_line=False):
	biblemgr.temporary_state(biblemgr.plainstate)
	old_expand_crossref = filterutils.filter_settings["footnote_ellipsis_level"]
	try:
		book = biblemgr.get_module_book_wrapper(module_name)
		biblemgr.set_option("Footnotes", True)
		biblemgr.set_option("Cross-references", True)
		filterutils.filter_settings["footnote_ellipsis_level"] = 0
		content = []

		#vk = VK()
		for bible_book in [bible_book for bible_book in UserVK.books
			#if len(bible_book.chapters) < N
			if not RESTRICTED or (
				bible_book.bookname in ("Psalms", "Matthew")
			)
		]:#VK.books:
			print "Processing", bible_book
			content.append(get_book(book, bible_book, verse_per_line=verse_per_line))
		#	if bible_book.bookname == "Genesis": break
		#	if bible_book.bookname == "Joshua": break
	finally:
		filterutils.filter_settings["footnote_ellipsis_level"] = old_expand_crossref
		biblemgr.restore_state()
	
	return content
예제 #2
0
	def _get_document_parts_for_ref(self, module_name, ref, do_current_ref=True):
		t = default_timer()

		stylesheets = list(self.bible_stylesheets)
		scripts = self.standard_scripts + self.bible_scripts + ["highlight.js", "bpbible_html.js", "contrib/hyphenate.js", "columns.js"]

		book = biblemgr.get_module_book_wrapper(module_name)
		assert book, "Module wrapper not found for book " + module_name
		module = book.mod
		if book.chapter_view:
			scripts.append("bpbible_html_chapter_view.js")
			#stylesheets.append("bpbible_chapter_view.css")
			#stylesheets.append("bpbible://content/quotes_skin/")
		else:
			scripts.append("bpbible_html_page_view.js")
			stylesheets.append("bpbible_page_view.css")			
	
		if is_debugging():
			stylesheets.append("bpbible_html_debug.css")

		if book.is_verse_keyed:
			if book.chapter_view:
				if do_current_ref:
					c = book.GetChapter(ref, ref, config.current_verse_template)
				else:
					c = book.GetChapter(ref)

				ref_id = VK(ref).get_chapter_osis_ref()
				
			else:
				c = book.GetReference(ref, headings=True)
				ref_id = VK(ref).getOSISRef()


		elif book.is_dictionary:
			c = book.GetReference(ref)
			ref_id = ref

		elif book.is_genbook:
			c = book.GetReference(ref)
			ref_id = ref
		else:
			dprint(ERROR, "Book `%s' not found." % module_name)
			c = ''
		c = c.replace("<!P>", "</p><p>")

		clas = ""
		if not c:
			clas = " nocontent"

		lang = module.Lang() if module else "en",
		c = convert_language(c, lang)
		c = '<div class="segment%s" ref_id="%s">%s</div>' % (clas, urllib.quote(ref_id.encode("utf8")), c)

		return dict(
			module=module, content=c,
			bodyattrs=self._get_body_attrs(module),
			stylesheets=stylesheets,
			scripts=scripts,
			timer="<div class='timer'>Time taken: %.3f (ref_id %s)</div>" % (default_timer() - t, ref_id))
예제 #3
0
def get_content(module_name="ESV", verse_per_line=False):
    biblemgr.temporary_state(biblemgr.plainstate)
    old_expand_crossref = filterutils.filter_settings[
        "footnote_ellipsis_level"]
    try:
        book = biblemgr.get_module_book_wrapper(module_name)
        biblemgr.set_option("Footnotes", True)
        biblemgr.set_option("Cross-references", True)
        filterutils.filter_settings["footnote_ellipsis_level"] = 0
        content = []

        #vk = VK()
        for bible_book in [
                bible_book for bible_book in UserVK.books
                #if len(bible_book.chapters) < N
                if not RESTRICTED or (bible_book.bookname in ("Psalms",
                                                              "Matthew"))
        ]:  #VK.books:
            print "Processing", bible_book
            content.append(
                get_book(book, bible_book, verse_per_line=verse_per_line))
        #	if bible_book.bookname == "Genesis": break
        #	if bible_book.bookname == "Joshua": break
    finally:
        filterutils.filter_settings[
            "footnote_ellipsis_level"] = old_expand_crossref
        biblemgr.restore_state()

    return content
예제 #4
0
    def get_document(self, path):
        module_name = path

        book = biblemgr.get_module_book_wrapper(module_name)
        if not book:
            dprint(ERROR, "Book `%s' not found." % module_name)
            return "Error: Book `%s' not found." % module_name

        module = book.mod
        return self._get_moduleinfo(module)
예제 #5
0
	def get_document(self, path):
		module_name = path

		book = biblemgr.get_module_book_wrapper(module_name)
		if not book:
			dprint(ERROR, "Book `%s' not found." % module_name)
			return "Error: Book `%s' not found." % module_name

		module = book.mod
		return self._get_moduleinfo(module)
예제 #6
0
	def book(self):
		return biblemgr.get_module_book_wrapper(self.version)
예제 #7
0
 def book(self):
     return biblemgr.get_module_book_wrapper(self.version)
예제 #8
0
    def get_document(self, path):
        module_name, rest = path.split("/", 1)
        ref, direction = rest.rsplit("/", 1)
        assert direction in ("next", "previous")

        dir = {"next": 1, "previous": -1}[direction]
        book = biblemgr.get_module_book_wrapper(module_name)
        mod = book.mod
        no_more = False
        if book.is_verse_keyed:
            vk = VK(ref, headings=not book.chapter_view)
            if book.chapter_view:
                vk.chapter += dir
                if vk.Error():
                    print "No more in that direction", dir
                    no_more = True
                else:

                    # go back just a little, so that when we go forward on the module
                    # we won't overshoot... (at least, that is our plan - we hope it
                    # won't be baffled...)
                    vk.Verse(vk.Verse() - dir)
                    if vk.Error():
                        print "VK had an error taking away a verse", dir

            if not no_more:
                old_mod_skiplinks = mod.getSkipConsecutiveLinks()
                mod.setSkipConsecutiveLinks(True)
                try:
                    vk.Persist(1)
                    mod.setKey(vk)
                    #print repr(mod.Error())
                    mod.increment(dir)

                    if mod.Error() != '\x00':
                        print "Mod had an error"
                        no_more = True
                    else:
                        if book.chapter_view:
                            new_ref = vk.get_chapter_osis_ref()
                        else:
                            new_ref = vk.getOSISRef()
                finally:
                    mod.setKey(SW.Key())
                    mod.setSkipConsecutiveLinks(old_mod_skiplinks)

        elif book.is_dictionary:
            # XXX: Would using an index rather than a reference (as the XUL code did) be more efficient?
            book.snap_text(ref)
            book.mod.increment(dir)
            if mod.Error() == '\x00' and book.mod.getKey().getText():
                new_ref = to_unicode(mod.getKey().getText(), mod)
            else:
                no_more = True

        elif book.is_genbook:
            ref = "/" + ref
            tk = book.GetKey()
            tk.Persist(1)
            assert tk.thisown
            newtk = book.GetKey()
            newtk.thisown = True
            mod.setKey(tk)
            print "Getting next for", ref
            tk.set_text(ref)
            print tk.getText()
            if mod.Error() != '\x00':
                print "Error on initial set?"
            mod.increment(dir)
            if mod.Error() == '\x00' and tk.getText():
                new_ref = to_unicode(tk.getText(),
                                     mod)[1:]  # trim off the leading /
            else:
                no_more = True

            mod.setKey(newtk)
        else:
            print "Book type not handled", module_name

        if no_more:
            message = (_("You are at the start of this book.")
                       if dir == -1 else _("You are at the end of this book."))
            class_name = "book-%s" % ("start" if dir == -1 else "end")
            return '''
			<div class="page_segment" empty="true">
				<div class='no_more_text %(class_name)s'>
					%(message)s
				</div>
			</div>''' % locals()

        return '<div class="page_segment">%(content)s%(timer)s</div>' % self._get_document_parts_for_ref(
            module_name, new_ref, do_current_ref=False)
예제 #9
0
    def _get_document_parts_for_ref(self,
                                    module_name,
                                    ref,
                                    do_current_ref=True):
        t = default_timer()

        stylesheets = list(self.bible_stylesheets)
        scripts = self.standard_scripts + self.bible_scripts + [
            "highlight.js", "bpbible_html.js", "contrib/hyphenate.js",
            "columns.js"
        ]

        book = biblemgr.get_module_book_wrapper(module_name)
        assert book, "Module wrapper not found for book " + module_name
        module = book.mod
        if book.chapter_view:
            scripts.append("bpbible_html_chapter_view.js")
            #stylesheets.append("bpbible_chapter_view.css")
            #stylesheets.append("bpbible://content/quotes_skin/")
        else:
            scripts.append("bpbible_html_page_view.js")
            stylesheets.append("bpbible_page_view.css")

        if is_debugging():
            stylesheets.append("bpbible_html_debug.css")

        if book.is_verse_keyed:
            if book.chapter_view:
                if do_current_ref:
                    c = book.GetChapter(ref, ref,
                                        config.current_verse_template)
                else:
                    c = book.GetChapter(ref)

                ref_id = VK(ref).get_chapter_osis_ref()

            else:
                c = book.GetReference(ref, headings=True)
                ref_id = VK(ref).getOSISRef()

        elif book.is_dictionary:
            c = book.GetReference(ref)
            ref_id = ref

        elif book.is_genbook:
            c = book.GetReference(ref)
            ref_id = ref
        else:
            dprint(ERROR, "Book `%s' not found." % module_name)
            c = ''
        c = c.replace("<!P>", "</p><p>")

        clas = ""
        if not c:
            clas = " nocontent"

        lang = module.Lang() if module else "en",
        c = convert_language(c, lang)
        c = '<div class="segment%s" ref_id="%s">%s</div>' % (
            clas, urllib.quote(ref_id.encode("utf8")), c)

        return dict(
            module=module,
            content=c,
            bodyattrs=self._get_body_attrs(module),
            stylesheets=stylesheets,
            scripts=scripts,
            timer="<div class='timer'>Time taken: %.3f (ref_id %s)</div>" %
            (default_timer() - t, ref_id))
예제 #10
0
	def get_document(self, path):
		module_name, rest = path.split("/", 1)
		ref, direction = rest.rsplit("/", 1)
		assert direction in ("next", "previous")

		dir = {"next": 1, "previous": -1}[direction]
		book = biblemgr.get_module_book_wrapper(module_name)
		mod = book.mod		
		no_more = False
		if book.is_verse_keyed:
			vk = VK(ref, headings=not book.chapter_view)
			if book.chapter_view:
				vk.chapter += dir
				if vk.Error():
					print "No more in that direction", dir
					no_more = True
				else:
				
					# go back just a little, so that when we go forward on the module
					# we won't overshoot... (at least, that is our plan - we hope it
					# won't be baffled...)
					vk.Verse(vk.Verse() - dir)
					if vk.Error():
						print "VK had an error taking away a verse", dir
	
			if not no_more:
				old_mod_skiplinks = mod.getSkipConsecutiveLinks()
				mod.setSkipConsecutiveLinks(True)
				try:
					vk.Persist(1)
					mod.setKey(vk)
					#print repr(mod.Error())
					mod.increment(dir)

					if mod.Error() != '\x00':
						print "Mod had an error"
						no_more = True
					else:
						if book.chapter_view:
							new_ref = vk.get_chapter_osis_ref()
						else:
							new_ref = vk.getOSISRef()
				finally:
					mod.setKey(SW.Key())
					mod.setSkipConsecutiveLinks(old_mod_skiplinks)
		
		elif book.is_dictionary:
			# XXX: Would using an index rather than a reference (as the XUL code did) be more efficient?
			book.snap_text(ref)
			book.mod.increment(dir)
			if mod.Error() == '\x00' and book.mod.getKey().getText():
				new_ref = to_unicode(mod.getKey().getText(), mod)
			else:
				no_more = True
			
		elif book.is_genbook:
			ref = "/" + ref
			tk = book.GetKey()
			tk.Persist(1)
			assert tk.thisown
			newtk = book.GetKey()
			newtk.thisown = True
			mod.setKey(tk)
			print "Getting next for", ref
			tk.set_text(ref)
			print tk.getText()
			if mod.Error() != '\x00':
				print "Error on initial set?"
			mod.increment(dir)
			if mod.Error() == '\x00' and tk.getText():
				new_ref = to_unicode(tk.getText(), mod)[1:] # trim off the leading /
			else:
				no_more = True
			
			mod.setKey(newtk)
		else:
			print "Book type not handled", module_name
		
		if no_more:
			message = (_("You are at the start of this book.") if dir == -1
				else _("You are at the end of this book."))
			class_name = "book-%s" % ("start" if dir == -1 else "end")
			return '''
			<div class="page_segment" empty="true">
				<div class='no_more_text %(class_name)s'>
					%(message)s
				</div>
			</div>''' % locals()
		
		return '<div class="page_segment">%(content)s%(timer)s</div>' % self._get_document_parts_for_ref(module_name, new_ref, do_current_ref=False)