def html(self): return render( "main", v.Page( title="login", content=render("login"), user=self.user, ), )
def html(self, user: str): _ = self.require_authentication(user) return render( "main", v.Page( title="import pinboard data", content=render("import"), user=self.user, ), )
def html(self, slug: str, link_id: str): u = self.require_authentication(slug) all_tags = u.get_tags() link = u.get_link(int(link_id)) return render( "main", v.Page( title="login", content=render("edit_link", v.SingleLink(link, all_tags)), user=self.user, ), )
def html(self, user: str, link_id: str): link = m.User.by_slug(user).get_link(int(link_id)) return render( "main", v.Page( title=f"link {link.name}", content=render( "linklist", v.LinkList([link.to_view(self.user)], [], user=user)), user=self.user, ), )
def html(self, user: str): u = self.require_authentication(user) status_msg = flask.request.args.get("m", None) if status_msg is not None: status_msg = int(status_msg) return render( "main", v.Page( title="configuration", content=render("config", u.get_config(status_msg)), user=self.user, ), )
def html(self, slug: str): u = m.User.by_slug(slug) pg = int(flask.request.args.get("page", 1)) tags = u.get_tags() links, pages = u.get_links(as_user=self.user, page=pg) linklist = v.LinkList(links=links, user=slug, pages=pages, tags=tags) return render( "main", v.Page( title=f"user {u.name}", content=render("linklist", linklist), user=self.user, ), )
def html(self): pg = int(flask.request.args.get("page", 1)) links, pages = m.Link.get_all(as_user=self.user, page=pg) linklist = v.LinkList(links=links, pages=pages, user="", tags=[]) return render( "main", v.Page( title="main", content=render("linklist", linklist), user=self.user, ), )
def html(self, user: str, tag: str): u = m.User.by_slug(user) pg = int(flask.request.args.get("page", 1)) t = u.get_tag(tag) links, pages = t.get_links(as_user=self.user, page=pg) tags = u.get_related_tags(t) linklist = v.LinkList(links=links, pages=pages, tags=tags, user=user) return render( "main", v.Page( title=f"tag {tag}", content=render("linklist", linklist), user=self.user, ), )
def html(self, user: str, needle: str): u = m.User.by_slug(user) pg = int(flask.request.args.get("page", 1)) links, pages = u.get_string_search(needle=needle, as_user=self.user, page=pg) tags = u.get_tags() linklist = v.LinkList(links=links, pages=pages, tags=tags, user=user) return render( "main", v.Page( title=f"search for '{needle}'", content=render("linklist", linklist), user=self.user, ), )
def html(self): if self.user: raise e.LCRedirect(f"/u/{self.user.name}") token = flask.request.args.get("token") if not token: raise e.LCRedirect("/") add_user = v.AddUser(token=token) return render( "main", v.Page( title="add user", user=self.user, content=render("add_user", add_user), ), )
def html(self, user: str): u = self.require_authentication(user) url = flask.request.args.get("url", "") name = flask.request.args.get("name", "") tags = u.get_tags() defaults = v.AddLinkDefaults( user=user, name=name, url=url, all_tags=tags, ) return render( "main", v.Page( title="login", content=render("add_link", defaults), user=self.user, ), )
def handle_500(e): c.log(f"Internal error: {e}") error = v.Error(code=500, message="An unexpected error occurred") page = v.Page(title="500", content=render("error", error), user=None) return render("main", page)
def handle_404(e): url = flask.request.path error = v.Error(code=404, message=f"Page {url} not found") page = v.Page(title="not found", content=render("error", error), user=None) return render("main", page)
def render_error(self, exn: e.LCException) -> str: error = v.Error(code=exn.http_code(), message=str(exn)) page = v.Page(title="error", content=render("error", error), user=self.user) return render("main", page)