diff --git a/core/images/add-comment.tid b/core/images/add-comment.tid new file mode 100644 index 000000000..3e77ed518 --- /dev/null +++ b/core/images/add-comment.tid @@ -0,0 +1,4 @@ +title: $:/core/images/add-comment +tags: $:/tags/Image + + \ No newline at end of file diff --git a/editions/prerelease/tiddlywiki.info b/editions/prerelease/tiddlywiki.info index 2a3216490..7ca277ce2 100644 --- a/editions/prerelease/tiddlywiki.info +++ b/editions/prerelease/tiddlywiki.info @@ -15,7 +15,8 @@ "tiddlywiki/savetrail", "tiddlywiki/external-attachments", "tiddlywiki/dynaview", - "tiddlywiki/codemirror" + "tiddlywiki/codemirror", + "tiddlywiki/comments" ], "themes": [ "tiddlywiki/vanilla", diff --git a/plugins/tiddlywiki/comments/EnableFilter.tid b/plugins/tiddlywiki/comments/EnableFilter.tid new file mode 100644 index 000000000..c5d46cec8 --- /dev/null +++ b/plugins/tiddlywiki/comments/EnableFilter.tid @@ -0,0 +1,3 @@ +title: $:/config/Comments/EnableFilter + +[all[current]!is[system]] diff --git a/plugins/tiddlywiki/comments/add-comment-button.tid b/plugins/tiddlywiki/comments/add-comment-button.tid new file mode 100644 index 000000000..49110c5ec --- /dev/null +++ b/plugins/tiddlywiki/comments/add-comment-button.tid @@ -0,0 +1,10 @@ +title: $:/plugins/tiddlywiki/comments/add-comment-button + +<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="div" class="tc-comment-button"> +<$button class="tc-btn-invisible"> +<$set name="username" value={{$:/status/UserName}} emptyValue="(anonymous)"> +<$action-createtiddler $basetitle={{{ [[Comment by ']addsuffixaddsuffix[' on ']addsuffixaddsuffix[']] }}} comment-target=<> text="" edit-mode="yes"/> +$set> +add comment {{$:/core/images/add-comment}} +$button> +$reveal> diff --git a/plugins/tiddlywiki/comments/comments-template.tid b/plugins/tiddlywiki/comments/comments-template.tid new file mode 100644 index 000000000..485e1d3c9 --- /dev/null +++ b/plugins/tiddlywiki/comments/comments-template.tid @@ -0,0 +1,49 @@ +title: $:/plugins/tiddlywiki/comments/comments-template + + + +<$list filter="[all[tiddlers+shadows]comment-targetsort[created]!has[draft.of]]"> + + + +<$link>{{!!creator}} at <$view field="modified" format="date" template="0hh:0mm:0ss DDD DDth MMM YYYY"/>$link> +<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="span"> +<$reveal type="match" state="!!edit-mode" text="yes"> +<$button> +<$action-setfield $tiddler=<> $field="edit-mode" $value="no"/> +<$action-setfield $tiddler=<> $field="text" $value={{!!saved-text}}/> +cancel +$button> +<$button> +<$action-deletetiddler $tiddler=<>/> +delete +$button> +<$button> +<$action-setfield $tiddler=<> $field="edit-mode" $value="no"/> +save +$button> +$reveal> +<$reveal type="nomatch" state="!!edit-mode" text="yes"> +<$button> +<$action-setfield $tiddler=<> $field="edit-mode" $value="yes"/> +<$action-setfield $tiddler=<> $field="saved-text" $value={{!!text}}/> +edit +$button> +$reveal> +$reveal> + + +<$reveal type="match" state="!!edit-mode" text="yes"> +<$edit-text tiddler=<> tag="textarea"/> +$reveal> +<$reveal type="nomatch" state="!!edit-mode" text="yes"> +<$transclude tiddler=<> mode="block"/> +<$transclude tiddler="$:/plugins/tiddlywiki/comments/add-comment-button" mode="inline"/> +$reveal> + + +<$transclude tiddler="$:/plugins/tiddlywiki/comments/comments-template" mode="inline"/> + +$list> + + diff --git a/plugins/tiddlywiki/comments/config.tid b/plugins/tiddlywiki/comments/config.tid new file mode 100644 index 000000000..5a58c659d --- /dev/null +++ b/plugins/tiddlywiki/comments/config.tid @@ -0,0 +1,18 @@ +title: $:/plugins/tiddlywiki/comments/config + +\define select(description,filter) +<$button> +<$action-setfield $tiddler="$:/config/Comments/EnableFilter" $value=<<__filter__>>/> +$description$ +$button> +\end + +This filter expression determines which tiddlers will have commenting enabled: + +<$edit-text tiddler="$:/config/Comments/EnableFilter" tag="input"/> + +Or you can choose a preselected filter: + +* <> +* <> +* <> diff --git a/plugins/tiddlywiki/comments/footer-view-template-segment.tid b/plugins/tiddlywiki/comments/footer-view-template-segment.tid new file mode 100644 index 000000000..0df67d7c2 --- /dev/null +++ b/plugins/tiddlywiki/comments/footer-view-template-segment.tid @@ -0,0 +1,10 @@ +title: $:/plugins/tiddlywiki/comments/footer-view-template-segment +tags: $:/tags/ViewTemplate +list-after: $:/core/ui/ViewTemplate/body + +<$list filter={{$:/config/Comments/EnableFilter}} variable="ignore"> + +<$transclude tiddler="$:/plugins/tiddlywiki/comments/add-comment-button" mode="inline"/> +<$transclude tiddler="$:/plugins/tiddlywiki/comments/comments-template" mode="inline"/> + +$list> \ No newline at end of file diff --git a/plugins/tiddlywiki/comments/header-view-template-segment.tid b/plugins/tiddlywiki/comments/header-view-template-segment.tid new file mode 100644 index 000000000..0a2d539d3 --- /dev/null +++ b/plugins/tiddlywiki/comments/header-view-template-segment.tid @@ -0,0 +1,9 @@ +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"> + +This tiddler is a comment on <$link to={{!!comment-target}}><$text text={{!!comment-target}}/>$link> + +$list> diff --git a/plugins/tiddlywiki/comments/plugin.info b/plugins/tiddlywiki/comments/plugin.info new file mode 100644 index 000000000..8be289f4b --- /dev/null +++ b/plugins/tiddlywiki/comments/plugin.info @@ -0,0 +1,7 @@ +{ + "title": "$:/plugins/tiddlywiki/comments", + "description": "Comments", + "author": "JeremyRuston", + "core-version": ">=5.0.0", + "list": "readme config" +} diff --git a/plugins/tiddlywiki/comments/readme.tid b/plugins/tiddlywiki/comments/readme.tid new file mode 100644 index 000000000..cbf5c7256 --- /dev/null +++ b/plugins/tiddlywiki/comments/readme.tid @@ -0,0 +1,10 @@ +title: $:/plugins/tiddlywiki/comments/readme + +This plugin provides a simple means for adding threaded comments to tiddlers. + +* Click the "add comment" button to make a new comment, and then click the "save" button to save it +* You can comment on a tiddler itself, or add a comment to an existing comment +* The sidebar tab ''Comments'' lists a timeline of all comments +* Comments are attributed to the username stored in the system tiddler [[$:/status/UserName]] +* 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` diff --git a/plugins/tiddlywiki/comments/sidebar.tid b/plugins/tiddlywiki/comments/sidebar.tid new file mode 100644 index 000000000..40f32e755 --- /dev/null +++ b/plugins/tiddlywiki/comments/sidebar.tid @@ -0,0 +1,16 @@ +title: $:/plugins/tiddlywiki/comments/sidebar +tags: $:/tags/SideBar +caption: Comments + + +<$list filter="[all[tiddlers+shadows]has[comment-target]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]]"> + +<$link>Comment by '<$view field="modifier">(anonymous)$view>' on <$text text={{!!comment-target}}/>$link> + +$list> + +$list> + diff --git a/plugins/tiddlywiki/comments/styles.tid b/plugins/tiddlywiki/comments/styles.tid new file mode 100644 index 000000000..d8d9a9c1c --- /dev/null +++ b/plugins/tiddlywiki/comments/styles.tid @@ -0,0 +1,61 @@ +title: $:/plugins/tiddlywiki/comments/styles +tags: [[$:/tags/Stylesheet]] + +\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline + +.tc-is-comment-header { + background: #c1e1e9; + padding: 0.25em; +} + +.tc-comments-segment { + border-top: 2px solid #c1e1e9; +} + +.tc-comment-button button { + width: 100%; + text-align: right; +} + +.tc-comment-button button svg { + fill: #26cb56; + height: 2em; + width: 2em; +} + +.tc-comments { +} + +.tc-comment-list { + list-style: none; + padding-left: 0; +} + +.tc-comment-list .tc-comments { + padding-left: 1em; +} + +.tc-comment-entry { + border: 1px solid #c1e1ea; + margin: 0.5em 0 0 0; + background: #dbf6ff; +} + +.tc-comment-entry-heading { + font-size: 0.7em; + font-weight: bold; + text-transform: uppercase; + background: #c1e1ea; + color: #5B6D80; + padding: 0 0.5em; +} + +.tc-comment-entry-body { + font-size: 0.8em; + padding: 0 0.5em; +} + +.tc-comment-entry-body textarea { + font-size: 1.1em; + width: 100% +}
+<$list filter="[all[tiddlers+shadows]comment-targetsort[created]!has[draft.of]]">
+-
+
+
+<$link>{{!!creator}} at <$view field="modified" format="date" template="0hh:0mm:0ss DDD DDth MMM YYYY"/>$link>
+<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="span">
+<$reveal type="match" state="!!edit-mode" text="yes">
+<$button>
+<$action-setfield $tiddler=<> $field="edit-mode" $value="no"/>
+<$action-setfield $tiddler=<> $field="text" $value={{!!saved-text}}/>
+cancel
+$button>
+<$button>
+<$action-deletetiddler $tiddler=<>/>
+delete
+$button>
+<$button>
+<$action-setfield $tiddler=<> $field="edit-mode" $value="no"/>
+save
+$button>
+$reveal>
+<$reveal type="nomatch" state="!!edit-mode" text="yes">
+<$button>
+<$action-setfield $tiddler=<> $field="edit-mode" $value="yes"/>
+<$action-setfield $tiddler=<> $field="saved-text" $value={{!!text}}/>
+edit
+$button>
+$reveal>
+$reveal>
+
+
+<$reveal type="match" state="!!edit-mode" text="yes">
+<$edit-text tiddler=<> tag="textarea"/>
+$reveal>
+<$reveal type="nomatch" state="!!edit-mode" text="yes">
+<$transclude tiddler=<> mode="block"/>
+<$transclude tiddler="$:/plugins/tiddlywiki/comments/add-comment-button" mode="inline"/>
+$reveal>
+
+
+<$transclude tiddler="$:/plugins/tiddlywiki/comments/comments-template" mode="inline"/>
+
+$list>
+
+