Render attachments with shortcodes rather than slugs
The attachments should now be rendered using `{attachment slug}` instead of `@[slug]`. The `link` attribute can be specified in the shortcode (for attachments that support it), rather than in the attachment itself. The attachment subdocument is now reduced to `{oid: File ObjectID}`, and nodes without attachments should NOT have an `attachment` property at all (previously it would be an empty dict). This makes querying for nodes with/out attachments easier. The CLI command `upgrade_attachment_schema` can do dry-run and remove empty attachments: - Added --go to actually perform the database changes. - Remove empty attachments, so that a node either has one or more attachments or no attachments sub-document at all. The CLI command `upgrade_attachment_usage` converts `@[slug]` to `{attachment slug}`. It also takes into account 'link' and 'link_custom' fields on the attachment. After conversion those fields are removed from the attachment itself. Simplified maintentance CLI commands that iterate over all projects: I've moved the common approach (either run on one project or all of them, skipping deleted ones, giving a message upon dry-run, and showing duration of the command) to a new _db_projects() function. The new function is now used by two recently-touched CLI commands; more of them could be migrated to use this.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
| {% if 'link' in attachment and attachment['link'] != 'none' %}
|
||||
| {% if attachment['link'] == 'self' %}
|
||||
| {% if 'link' in tag_args and tag_args['link'] != 'none' %}
|
||||
| {% if tag_args['link'] == 'self' %}
|
||||
a(href="{{ vars['l'].link }}")
|
||||
img(src="{{ vars['l'].link }}", alt="{{ file.filename }}")
|
||||
| {% elif attachment['link'] == 'custom' %}
|
||||
a(href="{{ attachment['link_custom'] }}")
|
||||
| {% else %}
|
||||
a(href="{{ tag_args['link'] }}", target="_blank")
|
||||
img(src="{{ vars['l'].link }}", alt="{{ file.filename }}")
|
||||
| {% endif %}
|
||||
| {% endif %}
|
||||
| {% else %}
|
||||
img(src="{{ vars['l'].link }}", alt="{{ file.filename }}")
|
||||
| {% endif %}
|
||||
|
Reference in New Issue
Block a user