Ejemplo n.º 1
0
def process_html_for_module(module, text):
	language_code, (font, size, gui) = \
		fonts.get_font_params(module)

	text = convert_language(text, language_code)
		
	return '<span module="%s" lang="%s">%s</span>' % (module.Name(), language_code, text)
Ejemplo n.º 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))
Ejemplo n.º 3
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))