Example #1
0
def placeholder(context, placeholder):
	page = context["page"]
	block = PageBlock.get_by(page=page, placeholder=placeholder)
	if block:
		cnt = ModuleInterface.plugin(block.plugin.name, fullname=False, ignorecase=True).content(block)
		return Markup(cnt)
	return Markup("")
Example #2
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})