Cotton code
391 lines · 10.0 KB · JSONRaw
{  "format_version": 1,  "id": "page",  "name": "Article",  "plural": "Articles",  "builtin": true,  "visibility": "owner",  "date": "created_at",  "title": "title",  "columns": [    {      "key": "url",      "name": "Link",      "type": "text",      "readonly": true,      "required": true    },    {      "key": "host",      "name": "Site",      "type": "text",      "readonly": true    },    {      "key": "title",      "type": "text"    },    {      "key": "read_at",      "name": "Read",      "type": "date",      "readonly": true    },    {      "key": "source_inbox_id",      "type": "text",      "readonly": true    },    {      "key": "archived_at",      "name": "Removed",      "type": "date"    },    {      "key": "text_state",      "name": "Text kept",      "type": "choice",      "choices": [        "kept",        "unreachable",        "unreadable"      ],      "labels": {        "kept": "Kept",        "unreachable": "Unreachable",        "unreadable": "Unreadable"      },      "readonly": true    },    {      "key": "state",      "name": "Reading",      "type": "choice",      "choices": [        "unread",        "reading",        "read"      ],      "labels": {        "unread": "Unread",        "reading": "Reading",        "read": "Read"      }    },    {      "key": "text",      "name": "Text",      "type": "longtext",      "readonly": true    },    {      "key": "trashed_at",      "type": "date",      "format": "calendar-datetime",      "readonly": true    },    {      "key": "created_at",      "name": "Saved",      "type": "date",      "readonly": true    }  ],  "instructions": "An article is a web page kept to read, with its text. Save the exact link the person shared; the serving Mac then pulls the article's text in, so it can be read and searched here without the site — text_state says whether it was kept, or why not (unreachable: the site did not answer; unreadable: the page held no article). The site is derived from the link. state is unread, reading or read: opening an article makes it reading and stamps the read date; the person marks it read. A title can be filled in later.",  "tables": [    {      "name": "cotton_pages",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 1        },        {          "name": "url",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    url TEXT NOT NULL",          "position": 2        },        {          "name": "host",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    host TEXT NOT NULL",          "position": 3        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    title TEXT",          "position": 4        },        {          "name": "read_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    read_at TEXT",          "position": 5        },        {          "name": "source_inbox_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    source_inbox_id TEXT",          "position": 6        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 7        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 8        },        {          "name": "archived_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    archived_at TEXT",          "position": 9        },        {          "name": "text_state",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    text_state TEXT CHECK (text_state IS NULL OR text_state IN ('kept', 'unreachable', 'unreadable'))",          "position": 10        },        {          "name": "state",          "type": "TEXT",          "default": "'unread'",          "nullable": false,          "primary_key": false,          "declaration": "\n    state TEXT NOT NULL DEFAULT 'unread' CHECK (state IN ('unread', 'reading', 'read'))",          "position": 11        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 12        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 13        },        {          "name": "text",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    text TEXT",          "position": 14        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " trashed_at TEXT",          "position": 15        }      ],      "constraints": [        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 16        }      ],      "prefix": "CREATE TABLE cotton_pages (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_pages_workspace ON cotton_pages (workspace_id)",        "CREATE INDEX IF NOT EXISTS idx_cotton_pages_author ON cotton_pages (substr(_hlc, 20), _hlc)"      ],      "full_text": [        "CREATE VIRTUAL TABLE fts_pages USING fts5(\n       title, text, content = 'cotton_pages', content_rowid = 'rowid',\n       tokenize = 'unicode61 remove_diacritics 2'\n     )"      ],      "triggers": [        "CREATE TRIGGER fts_pages_ai AFTER INSERT ON cotton_pages WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_pages'), 0) BEGIN\n       INSERT INTO fts_pages (rowid, title, text) VALUES (new.rowid, new.title, new.text);\n     END",        "CREATE TRIGGER fts_pages_ad AFTER DELETE ON cotton_pages WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_pages'), 0) BEGIN\n       INSERT INTO fts_pages (fts_pages, rowid, title, text) VALUES ('delete', old.rowid, old.title, old.text);\n     END",        "CREATE TRIGGER fts_pages_au AFTER UPDATE OF title, text ON cotton_pages\n       FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_pages'), 0) AND (new.title IS NOT old.title OR new.text IS NOT old.text) BEGIN\n       INSERT INTO fts_pages (fts_pages, rowid, title, text) VALUES ('delete', old.rowid, old.title, old.text);\n       INSERT INTO fts_pages (rowid, title, text) VALUES (new.rowid, new.title, new.text);\n     END"      ]    }  ],  "picture": {    "photo": "photo:f045559f91e07d7b160011022a20c0b291611054b6089a4050fc7440888a3e5f",    "object": "tool-reader"  },  "engine": "reader",  "project": null,  "order": null,  "slip": {    "title": "title",    "subtitle": "host",    "trailing": null,    "photo": null,    "toggle": null,    "title_fallback": "host"  },  "tile": {    "face": "cover-grid"  },  "page": [    {      "heading": null,      "columns": [        "title"      ]    },    {      "heading": null,      "columns": [        "state"      ]    },    {      "heading": null,      "columns": [        "text"      ]    },    {      "heading": "On the web",      "web": "url"    },    {      "heading": "Details",      "columns": [        "host",        "created_at",        "read_at",        "text_state",        "url"      ]    }  ],  "archived": "archived_at",  "record_route": "/reader/page/[id]",  "projects_read": {    "kind": "page",    "read": "page",    "families": [      "core",      "projects"    ]  },  "layout": "cards",  "opened": "read_at",  "empty": {    "title": "Nothing saved to read.",    "message": "Share a link to Cotton, or capture one on its own."  },  "delete": false,  "groups": {    "stack": "covers"  },  "tool": {    "views": [      {        "id": "all",        "label": "All",        "visibility": "owner",        "is_default": true,        "read": {          "table": "page"        }      }    ],    "name": "Articles",    "purpose": "Saved articles and pages to read.",    "key": "reader",    "icon": "book-open-text",    "card_stock": "grey",    "route": "/reader",    "figures": [      {        "read": "unreadPages",        "many": "{n} unread"      }    ]  },  "parts": {    "shape": "desk",    "head": {      "facts": []    },    "links": [],    "body": "text",    "lists": [],    "acts": {      "more": []    },    "strip": [      {        "column": "host"      },      {        "column": "read_at"      },      {        "column": "text_state",        "object": "bookmark"      },      {        "column": "url",        "object": "link"      }    ]  }}