예제 #1
0
	def admin(self):
		pages = HtmlPage.query.all()
		if self.template_path:
			templates = Environment(loader=FileSystemLoader(os.path.join(self.template_path, "user"))).list_templates(extensions=["html"])
		page_htmls = []
		for page in pages:
			page_html = self.html(page)
			page_htmls.append(page_html)
		return Template.text_by_path("htmlpagecomponent/admin/main.html", {"pages": page_htmls, "templates": templates})
예제 #2
0
 def content(self, page):
     plugins = []
     for pl_name, pl_code in ComponentInterface.plugins_and_names(fullname=False, lowercase=True):
         if pl_name != self.__class__.__name__:
             pl_title = "Unknown plugin"
             if hasattr(pl_code, "title"):
                 pl_title = pl_code.title()
             if hasattr(pl_code, "admin"):
                 plugins.append((pl_name, pl_title, pl_code.admin()))
     return Template.text_by_path(page.template, {"plugins": plugins})
예제 #3
0
	def edit(self, page, placeholder):
		context = {}
		context["page"] = page.id
		context["placeholder"] = placeholder
		try:
			block = PageBlock.get_by(page=page, placeholder=placeholder)
			if block and not isinstance(block, HtmlBlock):
				return None
			context["body"] = block.body
		except:
			pass
		return Template.text_by_path("htmlblockmodule/admin/default.html", context)
예제 #4
0
	def edit(self, page, placeholder):
		context = {}
		context["page"] = page.id
		context["placeholder"] = placeholder
		templates = []
		template_names = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates/user"))).list_templates(extensions=["html"])
		for tn in template_names:
			templates.append((tn, "videoblockmodule/user/"+tn))
		context["templates"] = templates
		try:
			video = PageBlock.get_by(page=page, placeholder=placeholder)
			if video and not isinstance(video, VideoBlock):
				return None
			context["link"] = video.link
			context["template"] = video.template
		except:
			pass
		return Template.text_by_path("videoblockmodule/admin/main.html", context)
예제 #5
0
	def html(self, page):
		tmpl = Application().templates_environment.loader.get_source(Application().templates_environment, page.template)
		placeholders = re.findall(r"""{{[ ]?placeholder[ ]?\([ ]?"(?P<placeholder>[a-zA-Z0-9]+)"[ ]?\)[ ]?}}""", unicode(tmpl))
		page.blocks = []
		for placeholder in placeholders:
			exists = False
			if PageBlock.query.filter_by(page=page, placeholder=placeholder).count() > 0:
				for block_plugin in ModuleInterface.plugins():
					title = u"unknown plugin"
					if hasattr(block_plugin, "title"):
						title = block_plugin.title()
					if hasattr(block_plugin, "admin"):
						block_plugin_admin_page = block_plugin.admin(page, placeholder)
						if block_plugin_admin_page:
							page.blocks.append((placeholder, title, block_plugin_admin_page))
							exists = True
							break
			if not exists:
				page.blocks.append((placeholder, None, None))			
		block_plugins = []
		for bp_name, bp_code in ModuleInterface.plugins_and_names(fullname=False, lowercase=True):
			block_plugins.append((bp_name, bp_code.title(), bp_code))
		return Template.text_by_path("htmlpagecomponent/admin/page.html", {"page": page, "block_plugins": block_plugins})
예제 #6
0
	def content(self, block):
		template = "videoblockmodule/user/youtube.html"
		if hasattr(block, "template") and block.template:
			template = block.template
		return Template.text_by_path(template, {"video_block": block})
예제 #7
0
	def content(self, page):
		return Template.text_by_path(page.template, {"page": page})
예제 #8
0
	def content(self, block):
		return Template.text_by_path(block.template, {"menu": block})