1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

First stab at a threaded commenting plugin

This commit is contained in:
Jermolene 2018-06-21 08:36:15 +01:00
parent 23797b05a1
commit acaa07a964
12 changed files with 199 additions and 1 deletions

View File

@ -0,0 +1,4 @@
title: $:/core/images/add-comment
tags: $:/tags/Image
<svg class="tc-image-add-comment tc-image-button" width="22pt" height="22pt" viewBox="0 0 128 128"><path d="M56 56H36a8 8 0 1 0 0 16h20v20a8 8 0 1 0 16 0V72h20a8 8 0 1 0 0-16H72V36a8 8 0 1 0-16 0v20zm-12.595 58.362c-6.683 7.659-20.297 12.903-36.006 12.903-2.196 0-4.35-.102-6.451-.3 9.652-3.836 17.356-12.24 21.01-22.874C8.516 94.28 0 79.734 0 63.5 0 33.953 28.206 10 63 10s63 23.953 63 53.5S97.794 117 63 117c-6.841 0-13.428-.926-19.595-2.638z" fill-rule="evenodd"/></svg>

View File

@ -15,7 +15,8 @@
"tiddlywiki/savetrail",
"tiddlywiki/external-attachments",
"tiddlywiki/dynaview",
"tiddlywiki/codemirror"
"tiddlywiki/codemirror",
"tiddlywiki/comments"
],
"themes": [
"tiddlywiki/vanilla",

View File

@ -0,0 +1,3 @@
title: $:/config/Comments/EnableFilter
[all[current]!is[system]]

View File

@ -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 ']addsuffix<username>addsuffix[' on ']addsuffix<currentTiddler>addsuffix[']] }}} comment-target=<<currentTiddler>> text="" edit-mode="yes"/>
</$set>
add comment {{$:/core/images/add-comment}}
</$button>
</$reveal>

View File

@ -0,0 +1,49 @@
title: $:/plugins/tiddlywiki/comments/comments-template
<div class="tc-comments">
<ol class="tc-comment-list">
<$list filter="[all[tiddlers+shadows]comment-target<currentTiddler>sort[created]!has[draft.of]]">
<li>
<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>
</div>
<div class="tc-comment-entry-body">
<$reveal type="match" state="!!edit-mode" text="yes">
<$edit-text tiddler=<<currentTiddler>> tag="textarea"/>
</$reveal>
<$reveal type="nomatch" state="!!edit-mode" text="yes">
<$transclude tiddler=<<currentTiddler>> mode="block"/>
<$transclude tiddler="$:/plugins/tiddlywiki/comments/add-comment-button" mode="inline"/>
</$reveal>
</div>
</div>
<$transclude tiddler="$:/plugins/tiddlywiki/comments/comments-template" mode="inline"/>
</li>
</$list>
</ol>
</div>

View File

@ -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:
* <<select "All tiddlers except system tiddlers" "[all[current]!is[system]]">>
* <<select "Only tiddlers tagged 'commentable'" "[all[current]tag[commentable]]">>
* <<select "Disable all commenting" "">>

View File

@ -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">
<div class="tc-comments-segment">
<$transclude tiddler="$:/plugins/tiddlywiki/comments/add-comment-button" mode="inline"/>
<$transclude tiddler="$:/plugins/tiddlywiki/comments/comments-template" mode="inline"/>
</div>
</$list>

View File

@ -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">
<div class="tc-is-comment-header">
This tiddler is a comment on <$link to={{!!comment-target}}><$text text={{!!comment-target}}/></$link>
</div>
</$list>

View File

@ -0,0 +1,7 @@
{
"title": "$:/plugins/tiddlywiki/comments",
"description": "Comments",
"author": "JeremyRuston",
"core-version": ">=5.0.0",
"list": "readme config"
}

View File

@ -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`

View File

@ -0,0 +1,16 @@
title: $:/plugins/tiddlywiki/comments/sidebar
tags: $:/tags/SideBar
caption: Comments
<div class="tc-timeline">
<$list filter="[all[tiddlers+shadows]has[comment-target]has[modified]!sort[modified]eachday[modified]]">
<div class="tc-menu-list-item">
<$view field="modified" format="date" template="DDth MMM YYYY"/>
<$list filter="[all[tiddlers+shadows]has[comment-target]sameday:modified{!!modified}!sort[modified]]">
<div class="tc-menu-list-subitem">
<$link>Comment by '<$view field="modifier">(anonymous)</$view>' on <$text text={{!!comment-target}}/></$link>
</div>
</$list>
</div>
</$list>
</div>

View File

@ -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%
}