home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

2 rows where author_association = "OWNER", issue = 733499930 and "updated_at" is on date 2020-10-31 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 1

  • simonw 2

issue 1

  • load_template hook doesn't work for include/extends · 2 ✖

author_association 1

  • OWNER · 2 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
719986698 https://github.com/simonw/datasette/issues/1072#issuecomment-719986698 https://api.github.com/repos/simonw/datasette/issues/1072 MDEyOklzc3VlQ29tbWVudDcxOTk4NjY5OA== simonw 9599 2020-10-31T20:48:17Z 2020-10-31T20:48:17Z OWNER

Here's the datasette-edit-templates plugin WIP I had before removing the hook: https://github.com/simonw/datasette-edit-templates/tree/82855c2612b84bc09c48fca885f831633a0d1552

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
load_template hook doesn't work for include/extends 733499930  
719955491 https://github.com/simonw/datasette/issues/1072#issuecomment-719955491 https://api.github.com/repos/simonw/datasette/issues/1072 MDEyOklzc3VlQ29tbWVudDcxOTk1NTQ5MQ== simonw 9599 2020-10-31T16:20:58Z 2020-10-31T16:20:58Z OWNER

Here's the proof of concept FunctionLoader that showed me that this wasn't going to work: ```diff diff --git a/datasette/app.py b/datasette/app.py index 4b28e71..b076be7 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -21,7 +21,7 @@ from pathlib import Path from markupsafe import Markup from itsdangerous import URLSafeSerializer import jinja2 -from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader +from jinja2 import ChoiceLoader, Environment, FileSystemLoader, FunctionLoader, PrefixLoader from jinja2.environment import Template from jinja2.exceptions import TemplateNotFound import uvicorn @@ -300,6 +300,7 @@ class Datasette: template_paths.append(default_templates) template_loader = ChoiceLoader( [ + FunctionLoader(self._load_template_from_plugins), FileSystemLoader(template_paths), # Support {% extends "default:table.html" %}: PrefixLoader( @@ -322,6 +323,17 @@ class Datasette: self._root_token = secrets.token_hex(32) self.client = DatasetteClient(self)

  • def _load_template_from_plugins(self, template):
  • "If auto reloading is enabled it’s called to check if the template changed"

  • uptodatefunc = lambda: True
  • source = pm.hook.load_template(
  • template=template,
  • datasette=self,
  • )
  • if source is None:
  • return None
  • return source, template, uptodatefunc + @property def urls(self): return Urls(self) @@ -719,35 +731,7 @@ class Datasette: else: if isinstance(templates, str): templates = [templates] -
  • Give plugins first chance at loading the template

  • break_outer = False
  • plugin_template_source = None
  • plugin_template_name = None
  • template_name = None
  • for template_name in templates:
  • if break_outer:
  • break
  • plugin_template_source = pm.hook.load_template(
  • template=template_name,
  • request=request,
  • datasette=self,
  • )
  • plugin_template_source = await await_me_maybe(plugin_template_source)
  • if plugin_template_source:
  • break_outer = True
  • plugin_template_name = template_name
  • break
  • if plugin_template_source is not None:
  • template = self.jinja_env.from_string(plugin_template_source)
  • else:
  • template = self.jinja_env.select_template(templates)
  • for template_name in templates:
  • from_plugin = template_name == plugin_template_name
  • used = from_plugin or template_name == template.name
  • templates_considered.append(
  • {"name": template_name, "used": used, "from_plugin": from_plugin}
  • )
  • template = self.jinja_env.select_template(templates) body_scripts = [] # pylint: disable=no-member for extra_script in pm.hook.extra_body_script( diff --git a/datasette/hookspecs.py b/datasette/hookspecs.py index ca84b35..7804def 100644 --- a/datasette/hookspecs.py +++ b/datasette/hookspecs.py @@ -50,7 +50,7 @@ def extra_template_vars(

@hookspec(firstresult=True) -def load_template(template, request, datasette): +def load_template(template, datasette): "Load the specified template, returning the template code as a string"

diff --git a/docs/plugin_hooks.rst b/docs/plugin_hooks.rst index 3c57b6a..8f2704e 100644 --- a/docs/plugin_hooks.rst +++ b/docs/plugin_hooks.rst @@ -273,15 +273,12 @@ Example: `datasette-cluster-map <https://github.com/simonw/datasette-cluster-map

.. _plugin_hook_load_template:

-load_template(template, request, datasette)

+load_template(template, datasette) +----------------------------------

template - string The template that is being rendered, e.g. database.html

-request - object or None - The current HTTP :ref:internals_request. This can be None if the request object is not available. - datasette - :ref:internals_datasette You can use this to access plugin configuration options via datasette.plugin_config(your_plugin_name) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
load_template hook doesn't work for include/extends 733499930  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 53.167ms · About: github-to-sqlite