home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

14 rows where issue = 727802081 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 14

issue 1

  • Plugin hook for loading templates · 14 ✖

author_association 1

  • OWNER 14
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
715643763 https://github.com/simonw/datasette/issues/1042#issuecomment-715643763 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTY0Mzc2Mw== simonw 9599 2020-10-24T00:34:31Z 2020-10-24T00:34:52Z OWNER

I'm going to rename that to template variable from select_templates to templates_considered too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715643646 https://github.com/simonw/datasette/issues/1042#issuecomment-715643646 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTY0MzY0Ng== simonw 9599 2020-10-24T00:33:46Z 2020-10-24T00:33:46Z OWNER

I'd like to do this all in the datasette.render_template() method to ensure it's available to plugins as well, not just core code that uses the BaseView class.

This code is the problem: https://github.com/simonw/datasette/blob/d3e9b0aecb6f8e9b2befd9c654ccb7ce852db3e7/datasette/views/base.py#L114-L133

I think I'll fix this by moving the select_templates mechanism into datasette.render_templates().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715618333 https://github.com/simonw/datasette/issues/1042#issuecomment-715618333 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTYxODMzMw== simonw 9599 2020-10-23T22:33:24Z 2020-10-23T22:33:24Z OWNER

It wouldn't be a disaster if template-loading plugins were unable to hook into the /{slug1}/{slug2}.html custom page mechanism, since plugins can define their own pages already using register_routes().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715618077 https://github.com/simonw/datasette/issues/1042#issuecomment-715618077 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTYxODA3Nw== simonw 9599 2020-10-23T22:32:24Z 2020-10-23T22:32:24Z OWNER

Another option: the first version of the plugin hook could accept only the template filename. Subsequent releases could add more arguments, since Pluggy allows new arguments to be added without breaking backwards compatibility.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715617830 https://github.com/simonw/datasette/issues/1042#issuecomment-715617830 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTYxNzgzMA== simonw 9599 2020-10-23T22:31:26Z 2020-10-23T22:31:26Z OWNER

So maybe this should be a register_template_loader mechanism that returns a Jinja loader after all? That would mean that only the template filename could be used as the input to the plugin, which doesn't seem as useful as emulating the extra_template_vars() interface.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715617405 https://github.com/simonw/datasette/issues/1042#issuecomment-715617405 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTYxNzQwNQ== simonw 9599 2020-10-23T22:29:53Z 2020-10-23T22:29:53Z OWNER

Also consider that DatasetteRouter uses .list_templates() to gather together {slug}.html style templates for the custom page templates mechanism: https://github.com/simonw/datasette/blob/976e5f74aae1fa0d406df6691dc8b5feeebe8788/datasette/app.py#L949-L967

For that to work with the new plugin hook, custom template providing plugins will need a way to provide a list of templates that they know about.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715616757 https://github.com/simonw/datasette/issues/1042#issuecomment-715616757 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTYxNjc1Nw== simonw 9599 2020-10-23T22:27:28Z 2020-10-23T22:27:28Z OWNER

Almost all of the core template loading happens in the BaseView.render method: https://github.com/simonw/datasette/blob/976e5f74aae1fa0d406df6691dc8b5feeebe8788/datasette/views/base.py#L114-L133

The one exception is the 404 handling code here: https://github.com/simonw/datasette/blob/976e5f74aae1fa0d406df6691dc8b5feeebe8788/datasette/app.py#L1034-L1042

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715614971 https://github.com/simonw/datasette/issues/1042#issuecomment-715614971 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTYxNDk3MQ== simonw 9599 2020-10-23T22:20:14Z 2020-10-23T22:23:51Z OWNER

Alternative plugin hook idea: python @hookspec def load_template(template, database, table, columns, view_name, request, datasette): "Load the specified template, returning the template code as a string" Imitating the existing extra_template_vars family of hooks: https://docs.datasette.io/en/stable/plugin_hooks.html#extra-template-vars-template-database-table-columns-view-name-request-datasette

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715497419 https://github.com/simonw/datasette/issues/1042#issuecomment-715497419 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTQ5NzQxOQ== simonw 9599 2020-10-23T18:12:40Z 2020-10-23T18:12:40Z OWNER

Maybe the template loader can optionally return some extra context to pass to the template. That could be used to solve the templates considered comment.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715496859 https://github.com/simonw/datasette/issues/1042#issuecomment-715496859 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTQ5Njg1OQ== simonw 9599 2020-10-23T18:11:27Z 2020-10-23T18:11:27Z OWNER

When loading a template the filename is required, but you can optionally also send a set of extra arguments which the template loader can take into consideration.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
715490532 https://github.com/simonw/datasette/issues/1042#issuecomment-715490532 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNTQ5MDUzMg== simonw 9599 2020-10-23T17:57:34Z 2020-10-23T17:57:34Z OWNER

A better version of this hook would be passed the database, table and query name depending on what was being rendered.

This would require some re-thinking of how core templates are loaded, especially since I would want the templates considered comment to continue working.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
714868867 https://github.com/simonw/datasette/issues/1042#issuecomment-714868867 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNDg2ODg2Nw== simonw 9599 2020-10-23T02:31:17Z 2020-10-23T02:31:17Z OWNER

I'll build this in conjunction with a plugin that supports editing templates stored in SQLite.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
714868624 https://github.com/simonw/datasette/issues/1042#issuecomment-714868624 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNDg2ODYyNA== simonw 9599 2020-10-23T02:30:27Z 2020-10-23T02:30:37Z OWNER

Maybe register_template_loader(datasette) which returns an object which is added in at the beginning of the list passed to ChoiceLoader here.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  
714868207 https://github.com/simonw/datasette/issues/1042#issuecomment-714868207 https://api.github.com/repos/simonw/datasette/issues/1042 MDEyOklzc3VlQ29tbWVudDcxNDg2ODIwNw== simonw 9599 2020-10-23T02:29:12Z 2020-10-23T02:29:12Z OWNER

Relevant code: https://github.com/simonw/datasette/blob/d0cc6f4c32e1f89238ddec782086b3122f445bd4/datasette/app.py#L288-L311

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for loading templates 727802081  

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 22.182ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows