1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Comments plugin: several enhancements

As proposed in #3378

* Experimental support for comments on the entire wiki (enable in the plugin config panel). Implemented as comments on $:/SiteTitle, with the comments appearing at the top of the story river
* Refactor the "add comment" button actions so that they can be reused
* Refactor the comment toolbar to be extensible via a system tag
* Add an $:/AdvancedSearch canned filter for accessing all comments
This commit is contained in:
Jermolene 2018-08-07 21:37:07 +01:00
parent 097c87fa7b
commit ec18a55033
13 changed files with 86 additions and 28 deletions

View File

@ -0,0 +1,8 @@
title: $:/plugins/tiddlywiki/comments/above-story
tags: $:/tags/AboveStory
<$reveal state="$:/config/Comments/EnableWikiComments" type="match" text="yes" default="no">
<$tiddler tiddler="$:/SiteTitle">
<$transclude tiddler="$:/plugins/tiddlywiki/comments/comments-template" mode="inline"/>
</$tiddler>
</$reveal>

View File

@ -1,10 +1,7 @@
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 ']addsuffix<username>addsuffix[' on ']addsuffix<currentTiddler>addsuffix[']] }}} comment-target=<<currentTiddler>> text="" edit-mode="yes"/>
</$set>
<$button class="tc-btn-invisible" actions={{$:/plugins/tiddlywiki/comments/add-comment-button}}>
add comment {{$:/core/images/add-comment}}
</$button>
</$reveal>

View File

@ -7,30 +7,9 @@ title: $:/plugins/tiddlywiki/comments/comments-template
<div class="tc-comment-entry">
<div class="tc-comment-entry-heading">
<$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=<<currentTiddler>> $field="edit-mode" $value="no"/>
<$action-setfield $tiddler=<<currentTiddler>> $field="text" $value={{!!saved-text}}/>
cancel
</$button>
<$button>
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
delete
</$button>
<$button>
<$action-setfield $tiddler=<<currentTiddler>> $field="edit-mode" $value="no"/>
save
</$button>
</$reveal>
<$reveal type="nomatch" state="!!edit-mode" text="yes">
<$button>
<$action-setfield $tiddler=<<currentTiddler>> $field="edit-mode" $value="yes"/>
<$action-setfield $tiddler=<<currentTiddler>> $field="saved-text" $value={{!!text}}/>
edit
</$button>
</$reveal>
</$reveal>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/CommentToolbarButton]!has[draft.of]]" variable="listItem">
<$transclude tiddler=<<listItem>> mode="inline"/>
</$list>
</div>
<div class="tc-comment-entry-body">
<$reveal type="match" state="!!edit-mode" text="yes">

View File

@ -7,6 +7,12 @@ $description$
</$button>
\end
! Wiki Comments
<$checkbox tiddler="$:/config/Comments/EnableWikiComments" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Comments/EnableWikiComments">Allow wiki-level comments as well as tiddler comments</$link> </$checkbox>
! Tiddler Comments
This filter expression determines which tiddlers will have commenting enabled:
<$edit-text tiddler="$:/config/Comments/EnableFilter" tag="input"/>

View File

@ -0,0 +1,5 @@
title: $:/plugins/tiddlywiki/comments/filter-all-comments
tags: $:/tags/Filter
filter: [has[comment-target]!sort[modified]]
description: All comments

View File

@ -8,3 +8,4 @@ This plugin provides a simple means for adding threaded comments to tiddlers.
* 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`
* Use the "All comments" option in the $:/AdvancedSearch ''Filter'' tab to see or export all comments

View File

@ -0,0 +1,9 @@
title: $:/plugins/tiddlywiki/comments/sidebar-segment
tags: $:/tags/SideBarSegment
list-after: $:/core/ui/SideBarSegments/site-subtitle
<$reveal state="$:/config/Comments/EnableWikiComments" type="match" text="yes" default="no">
<$tiddler tiddler="$:/SiteTitle">
<$transclude tiddler="$:/plugins/tiddlywiki/comments/add-comment-button" mode="inline"/>
</$tiddler>
</$reveal>

View File

@ -17,6 +17,11 @@ tags: [[$:/tags/Stylesheet]]
text-align: right;
}
.tc-sidebar-scrollable .tc-comment-button button {
width: auto;
text-align: right;
}
.tc-comment-button button svg {
fill: #26cb56;
height: 2em;

View File

@ -0,0 +1,2 @@
title: $:/tags/CommentToolbarButton
list: [[$:/plugins/tiddlywiki/comments/toolbar-button-cancel]] [[$:/plugins/tiddlywiki/comments/toolbar-button-delete]] [[$:/plugins/tiddlywiki/comments/toolbar-button-save]] [[$:/plugins/tiddlywiki/comments/toolbar-button-edit]]

View File

@ -0,0 +1,12 @@
title: $:/plugins/tiddlywiki/comments/toolbar-button-cancel
tags: $:/tags/CommentToolbarButton
<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="span">
<$reveal type="match" state="!!edit-mode" text="yes">
<$button>
<$action-setfield $tiddler=<<currentTiddler>> $field="edit-mode" $value="no"/>
<$action-setfield $tiddler=<<currentTiddler>> $field="text" $value={{!!saved-text}}/>
cancel
</$button>
</$reveal>
</$reveal>

View File

@ -0,0 +1,11 @@
title: $:/plugins/tiddlywiki/comments/toolbar-button-delete
tags: $:/tags/CommentToolbarButton
<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="span">
<$reveal type="match" state="!!edit-mode" text="yes">
<$button>
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
delete
</$button>
</$reveal>
</$reveal>

View File

@ -0,0 +1,12 @@
title: $:/plugins/tiddlywiki/comments/toolbar-button-edit
tags: $:/tags/CommentToolbarButton
<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="span">
<$reveal type="nomatch" state="!!edit-mode" text="yes">
<$button>
<$action-setfield $tiddler=<<currentTiddler>> $field="edit-mode" $value="yes"/>
<$action-setfield $tiddler=<<currentTiddler>> $field="saved-text" $value={{!!text}}/>
edit
</$button>
</$reveal>
</$reveal>

View File

@ -0,0 +1,11 @@
title: $:/plugins/tiddlywiki/comments/toolbar-button-save
tags: $:/tags/CommentToolbarButton
<$reveal state="$:/status/IsReadOnly" type="match" text="no" default="no" tag="span">
<$reveal type="match" state="!!edit-mode" text="yes">
<$button>
<$action-setfield $tiddler=<<currentTiddler>> $field="edit-mode" $value="no"/>
save
</$button>
</$reveal>
</$reveal>