def html_content(self, context): """ returns the generatet html code from the content applyed the markup. """ return apply_markup( content = self.content, context = context, markup_no = self.markup )
def _render_cms_page(request, context, page_content=None): """ render the cms page. - render a normal cms request - render a _command request: The page.content is the output from the plugin. """ if request.anonymous_view == False: # TODO: remove in v0.9, see: ticket:161 # context["robots"] was set in contex_processors.static() # Hide the response from search engines context["robots"] = "NONE,NOARCHIVE" context["anonymous_view"] = request.anonymous_view current_page = context["PAGE"] if page_content: # The page content comes e.g. from the _command plugin # current_page.content = page_content page_content = escape_django_tags(page_content) else: # get the current page data from the db page_content = current_page.content markup_no = current_page.markup page_content = apply_markup(page_content, context, markup_no) # Render only the CMS page content: try: page_content = render_string_template(page_content, context) # If a user access a public viewable cms page, but in the page content # is a lucidTag witch is a restricted method, the pylucid plugin # manager would normaly raise a AccessDenied. # The Problem is, if settings.TEMPLATE_DEBUG is on, we didn't get a # AccessDenied directly, we always get a TemplateSyntaxError! All # other errors will catched and raised a TemplateSyntaxError, too. # See django/template/debug.py # TODO: Instead of a redirect to the login command, we can insert # the ouput from auth.login directly except TemplateSyntaxError, err: # Check if it was a AccessDenied exception if hasattr(err, "exc_info"): # sys.exc_info() added in django/template/debug.py error_class = err.exc_info[1] if isinstance(error_class, AccessDenied): return _redirect_access_denied(request) raise # raise the original error
def all_pages(self): current_page = self.context["PAGE"] current_page.title = "all pages" current_page_id = current_page.id # page_data = Page.objects.values( # "id", "parent", "shortcut", "name", "title", # "template", "content", "markup" # ).order_by("position") pages = Page.objects.all().order_by("position") page_data = [] for page in pages: content = escape_django_tags(page.content) parent = getattr(page.parent, "id", None) url = page.get_absolute_url() page_data.append({ "id": page.id, "parent": parent, "shortcut": page.shortcut, "name": page.name, "title": page.title, "content": content, "template": page.template.id, "markup": page.markup, "url": url, }) # self.page_msg(page_data) tree = TreeGenerator(page_data) page_list = tree.get_group_list( group_key="template", id=current_page_id )[1:] for page in page_list: content = page["content"] markup_object = page["markup"] content = apply_markup(content, self.context, markup_object) page["content"] = content # self.page_msg(page_list) context = { "page_list": page_list, } self._render_template("all_pages", context)#, debug=True)
def _preview(self, context, page_form, markup_form): # Apply the markup witch is selected in the form content = apply_markup( page_form.cleaned_data["content"], self.context, markup_form.cleaned_data["markup"] ) if "submit_dest_markup" in self.request.POST: # We should convert the markup self._convert_markup(content, page_form, markup_form) preview_escape = page_form.cleaned_data["preview_escape"] if preview_escape == True: # escape django template tags for preview content = escape_django_tags(content) content = render_string_template(content, self.context) context["preview_content"] = content
def _create_or_edit(self, blog_obj = None): """ Create a new or edit a existing blog entry. """ context = { "url_abort": self.URLs.methodLink("lucidTag") } if blog_obj == None: # a new blog entry should be created context["legend"] = _("Create a new blog entry") else: context["legend"] = _("Edit a existing blog entry") if self.request.method == 'POST': form = BlogEntryForm(self.request.POST) #self.page_msg(self.request.POST) if form.is_valid() and "preview" in self.request.POST: # Do only a preview of the blog content with the markup preview_content = apply_markup( content = form.cleaned_data["content"], context = self.context, markup_no = form.cleaned_data["markup"], ) context["preview_content"] = preview_content elif form.is_valid(): # Save the new/edited blog entry new_tags = form.cleaned_data.pop("new_tags") # ListCharField if blog_obj == None: # a new blog entry should be created # take the many-to-many tags objects, for later assign tags = form.cleaned_data.pop("tags") form.cleaned_data["createby"] = self.request.user # Create new blog entry blog_obj = BlogEntry(**form.cleaned_data) blog_obj.save() # Add all tags from the many-to-many tags field blog_obj.tags.add(*tags) self.page_msg.green("New blog entry created.") else: # Update a existing blog entry self.page_msg.green("Update existing blog entry.") blog_obj.lastupdateby = self.request.user for k,v in form.cleaned_data.iteritems(): setattr(blog_obj, k, v) if new_tags != []: # There are new tags to create incoming via ListCharField # Create the new tags and add them to the blog entry new_tags = BlogTag.objects.add_new_tags(new_tags, blog_obj) if new_tags: self.page_msg(_("New tags created: %s") % new_tags) blog_obj.save() return self.lucidTag() else: if blog_obj == None: form = BlogEntryForm( initial={"markup": self.preferences["default_markup"],} ) else: form = BlogEntryForm(instance=blog_obj) context["form"]= form self._render_template("edit_blog_entry", context)#, debug=True)
if markup_id == 6: # Creole wiki markup sheet_url = self.internal_page.get_url( internal_page_name = "creole_cheat_sheet", slug = "png" ) if not sheet_url: self.page_msg.red("creole_cheat_sheet.png not found!") context["sheet_url"] = sheet_url #self.page_msg(markup_id, internal_page_name, context) content = self._get_rendered_template(internal_page_name, context) if markup_id == 2: # textile # Use tinyTextile markup content = apply_markup(content, self.context, markup_id) # insert CSS data from the internal page into the rendered page: content = replace_add_data(self.context, content) return HttpResponse(content) #___________________________________________________________________________ def tag_list(self): """ Render a help page with a list of all available django template tags and all available lucidTag's (List of all available plugins which provide lucidTag method). """ def _get_method_syntax(method): """