def show_dataobj(dataobj_id): dataobj = data.get_item(dataobj_id) if not dataobj: flash("Data could not be found!", "error") return redirect("/") if request.args.get("raw") == "1": return frontmatter.dumps(dataobj) backlinks = [] if app.config["SEARCH_CONF"]["enabled"]: incoming_links = search(f"/{dataobj_id}\)]]") if incoming_links: for hit in incoming_links: if hit["id"] != dataobj_id: backlinks.append({"title": hit["title"], "id": hit["id"]}) return render_template( "dataobjs/show.html", title=dataobj["title"], dataobj=dataobj, backlinks=backlinks, current_path=dataobj["dir"], form=forms.DeleteDataForm(), view_only=0, search_enabled=app.config["SEARCH_CONF"]["enabled"], )
def show_dataobj(dataobj_id): dataobj = data.get_item(dataobj_id) if not dataobj: flash("Data could not be found!", "error") return redirect("/") if request.args.get("raw") == "1": return frontmatter.dumps(dataobj) return render_template("dataobjs/show.html", title=dataobj["title"], dataobj=dataobj, form=forms.DeleteDataForm())
def show_dataobj(dataobj_id): dataobj = data.get_item(dataobj_id) if not dataobj: flash("Data could not be found!", "error") return redirect("/") if request.args.get("raw") == "1": return frontmatter.dumps(dataobj) backlinks = [] if app.config["SEARCH_CONF"]["enabled"]: if app.config["SEARCH_CONF"]["engine"] == "ripgrep": query = f"/{dataobj_id}\)]]" # escape query for rg else: query = f"/{dataobj_id})]]" incoming_links = search(query, strict=True) if incoming_links: for hit in incoming_links: if hit["id"] != dataobj_id: backlinks.append({"title": hit["title"], "id": hit["id"]}) # Form for moving data into another folder move_form = forms.MoveDataForm() move_form.path.choices = [("", "root directory")] + [ (pathname, pathname) for pathname in data.get_dirs() ] post_title_form = forms.TitleForm() post_title_form.title.data = dataobj["title"] return render_template( "dataobjs/show.html", title=dataobj["title"], dataobj=dataobj, backlinks=backlinks, current_path=dataobj["dir"], form=forms.DeleteDataForm(), view_only=0, search_enabled=app.config["SEARCH_CONF"]["enabled"], post_title_form=post_title_form, move_form=move_form, )
def show_dataobj(dataobj_id): dataobj = data.get_item(dataobj_id) if not dataobj: flash("Data could not be found!") return redirect("/") if request.args.get("raw") == "1": return frontmatter.dumps(dataobj) extra_pandoc_args = ["--highlight-style=" + app.config['PANDOC_HIGHLIGHT_THEME'], "--standalone"] content = pypandoc.convert_text(dataobj.content, 'html', format='md', extra_args=extra_pandoc_args) return render_template( "dataobjs/show.html", title=dataobj["title"], dataobj=dataobj, content=content, form=forms.DeleteDataForm())