From f210b75a302fdc422d829b105e90909df947b537 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 15 Aug 2018 13:50:29 +0100 Subject: [PATCH] Comments plugin: Switch to using the list field to attach comments https://github.com/Jermolene/TiddlyWiki5/issues/3378#issuecomment-413137626 --- .../comments/add-comment-button-actions.tid | 4 +++- plugins/tiddlywiki/comments/comments-template.tid | 2 +- plugins/tiddlywiki/comments/filter-all-comments.tid | 2 +- .../comments/header-view-template-segment.tid | 11 +++++++++-- plugins/tiddlywiki/comments/readme.tid | 12 ++++++++++++ plugins/tiddlywiki/comments/sidebar.tid | 9 ++++++--- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/plugins/tiddlywiki/comments/add-comment-button-actions.tid b/plugins/tiddlywiki/comments/add-comment-button-actions.tid index bbf326161..3f2db2df2 100644 --- a/plugins/tiddlywiki/comments/add-comment-button-actions.tid +++ b/plugins/tiddlywiki/comments/add-comment-button-actions.tid @@ -1,5 +1,7 @@ title: $:/plugins/tiddlywiki/comments/add-comment-button-actions <$set name="username" value={{$:/status/UserName}} emptyValue="(anonymous)"> -<$action-createtiddler $basetitle={{{ [[Comment by ']addsuffixaddsuffix[' on ']addsuffixaddsuffix[']] }}} comment-target=<> text="" edit-mode="yes"/> +<$set name="target" filter="[]"> +<$action-createtiddler $basetitle={{{ [[Comment by ']addsuffixaddsuffix[' on ']addsuffixaddsuffix[']] }}} role="comment" list=<> text="" edit-mode="yes"/> + diff --git a/plugins/tiddlywiki/comments/comments-template.tid b/plugins/tiddlywiki/comments/comments-template.tid index 95b9ae797..e8c52da3d 100644 --- a/plugins/tiddlywiki/comments/comments-template.tid +++ b/plugins/tiddlywiki/comments/comments-template.tid @@ -2,7 +2,7 @@ title: $:/plugins/tiddlywiki/comments/comments-template
    -<$list filter="[all[tiddlers+shadows]comment-targetsort[created]!has[draft.of]]"> +<$list filter="[all[tiddlers+shadows]role[comment]containssort[created]!has[draft.of]]">
  1. diff --git a/plugins/tiddlywiki/comments/filter-all-comments.tid b/plugins/tiddlywiki/comments/filter-all-comments.tid index c024caba8..179236d55 100644 --- a/plugins/tiddlywiki/comments/filter-all-comments.tid +++ b/plugins/tiddlywiki/comments/filter-all-comments.tid @@ -1,5 +1,5 @@ title: $:/plugins/tiddlywiki/comments/filter-all-comments tags: $:/tags/Filter -filter: [has[comment-target]!sort[modified]] +filter: [role[comment]!sort[modified]] description: All comments diff --git a/plugins/tiddlywiki/comments/header-view-template-segment.tid b/plugins/tiddlywiki/comments/header-view-template-segment.tid index 0a2d539d3..09f45d01d 100644 --- a/plugins/tiddlywiki/comments/header-view-template-segment.tid +++ b/plugins/tiddlywiki/comments/header-view-template-segment.tid @@ -2,8 +2,15 @@ title: $:/plugins/tiddlywiki/comments/header-view-template-segment tags: $:/tags/ViewTemplate list-before: $:/core/ui/ViewTemplate/body -<$list filter="[all[current]has[comment-target]]" variable="ignore"> +<$list filter="[all[current]role[comment]]" variable="ignore">
    -This tiddler is a comment on <$link to={{!!comment-target}}><$text text={{!!comment-target}}/> +This tiddler is a comment on: +
      +<$list filter="[listsort[title]]"> +
    • +<$link to=<>><$text text=<>/> +
    • + +
    diff --git a/plugins/tiddlywiki/comments/readme.tid b/plugins/tiddlywiki/comments/readme.tid index 70d8b7172..82336ce1c 100644 --- a/plugins/tiddlywiki/comments/readme.tid +++ b/plugins/tiddlywiki/comments/readme.tid @@ -9,3 +9,15 @@ This plugin provides a simple means for adding threaded comments to tiddlers. * By default, comments are available on all non-system tiddlers. The ''config'' tab lets you customise which tiddlers can accept comments by specifying a filter extension * The buttons for adding and editing comments are only available if the system tiddler [[$:/status/IsReadOnly]] is not set to `yes` * Use the "All comments" option in the $:/AdvancedSearch ''Filter'' tab to see or export all comments + +!! Data Model + +The data model employed by the comments plugin is very simple: + +* Comment tiddlers are identified by the `role` field being set to `comment` +* The `list` field of comment tiddlers lists the tiddlers to which this comment applies +** It is thus possible for a comment to be applied to multiple tiddlers at once +** The links between comments can be preserved when renaming them by using the relink checkbox in the edit template +* The `edit-mode` field of comment tiddlers is set to `yes` to display it in edit mode, or `no` to display it in view mode +* The `saved-text` field is updated when switching to edit mode so that it can be restored if the user cancels + diff --git a/plugins/tiddlywiki/comments/sidebar.tid b/plugins/tiddlywiki/comments/sidebar.tid index 40f32e755..e7da164aa 100644 --- a/plugins/tiddlywiki/comments/sidebar.tid +++ b/plugins/tiddlywiki/comments/sidebar.tid @@ -3,12 +3,15 @@ tags: $:/tags/SideBar caption: Comments
    -<$list filter="[all[tiddlers+shadows]has[comment-target]has[modified]!sort[modified]eachday[modified]]"> +<$list filter="[all[tiddlers+shadows]role[comment]has[modified]!sort[modified]eachday[modified]]">
    <$view field="modified" format="date" template="DDth MMM YYYY"/> -<$list filter="[all[tiddlers+shadows]has[comment-target]sameday:modified{!!modified}!sort[modified]]"> +<$list filter="[all[tiddlers+shadows]role[comment]sameday:modified{!!modified}!sort[modified]]">
    -<$link>Comment by '<$view field="modifier">(anonymous)' on <$text text={{!!comment-target}}/> +<$link>Comment by '<$view field="modifier">(anonymous)' on +<$list filter="[listsort[title]]"> +<$link to=<>><$text text=<>/> +