├── README.md
├── README
├── CHANGELOG.tid
├── FAQ.tid
├── README.tid
└── setup.tid
├── macro
└── comments.js
├── plugin.info
├── settings
├── filter.tid
├── label-hide.tid
├── label-show.tid
├── settings.tid
└── theme.tid
├── stylesheet.tid
├── template.tid
└── viewtoolbar
├── github-comments-open-listener.js
└── github-comments-open.tid
/README.md:
--------------------------------------------------------------------------------
1 | # GitHub comments for TiddlyWiki
2 | Use this plugin to give your visitors the opportunity to comment on your tiddlers without changing the wiki itself. See the bottom of this tiddler for example. Please add a star if you like the plugin'!
3 |
4 | This plugin uses [utterances](https://utteranc.es/), a lightweight comments widget built on GitHub issues.
5 |
6 | ## Installation instructions
7 |
8 | ### Drag'n'drop
9 | - Open the demo TiddlyWiki: https://tw5-github-comments.joseli.to
10 | - Drag-n-drop the plugin tiddler in to your wiki
11 |
12 | ### Copy to a Node.js based wiki
13 | - Create a `github-comments` folder inside yours wiki `plugins` folder
14 | - Clone this repo inside `github-comments` folder
15 |
16 | ## Special thanks
17 | This plugin is heavily inspired and based on [@bimlas](https://github.com/bimlas/tw5-disqus)'s work on the [tw5-disqus plugin](https://github.com/bimlas/tw5-disqus). If you may visit his repo and give a star.
--------------------------------------------------------------------------------
/README/CHANGELOG.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/plugins/breakzplatform/github-comments/README/CHANGELOG
3 | type: text/vnd.tiddlywiki
4 |
5 | I'm trying to follow the rules of [[Semantic Versioning|https://semver.org/]].
6 |
7 | !! 0.0.1
8 |
9 | * First public release
10 |
--------------------------------------------------------------------------------
/README/FAQ.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/plugins/breakzplatform/github-comments/README/FAQ
3 | type: text/vnd.tiddlywiki
4 |
5 | ! Frequently asked questions
6 |
7 | !! Can I use on "read only" on wiki?
8 |
9 | ~GitHub is responsible for storing and managing comments, there is nothing to store in ~TiddlyWiki other than settings.
10 |
11 | !! Will I be notified when a new comment is posted?
12 |
13 | Every comment will be added to a issue on your ~GitHub repo. Learn more about [[GitHub notifications|https://docs.github.com/pt/account-and-profile/managing-subscriptions-and-notifications-on-github/setting-up-notifications/configuring-notifications]] to be notified when a new comment is added on a issue.
--------------------------------------------------------------------------------
/README/README.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/plugins/breakzplatform/github-comments/README/README
3 | type: text/vnd.tiddlywiki
4 |
5 | ! ~GitHub comments
6 |
7 | Use this plugin to give your visitors the opportunity to comment on your
8 | tiddlers without changing the wiki itself. See the bottom of this tiddler for example.
9 |
10 | * https://github.com/breakzplatform/tw5-github-comments (main repository, ''please add a star if you like the plugin'')
11 |
12 | This plugin uses [[utterances|https://utteranc.es/]], a lightweight comments widget built on ~GitHub issues.
13 |
14 | !! Installation instructions
15 |
16 | To add the plugin to your own ~TiddlyWiki5, just drag this link to the browser window:
17 |
18 | $:/plugins/breakzplatform/github-comments
19 |
20 | For other installation options see the repo above.
21 |
22 | //Select the next tab to continue.//
--------------------------------------------------------------------------------
/README/setup.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/plugins/breakzplatform/github-comments/README/setup
3 | type: text/vnd.tiddlywiki
4 |
5 | ! Setup
6 |
7 | Before you using the plugin, you need to configure [utterances|https://utteranc.es/] to work with your GitHub repository.
8 |
9 | * Make sure the repo is public, otherwise your readers will not be able to view the issues/comments.
10 | * Make sure the [utterances app|https://github.com/apps/utterances] is installed on the repo, otherwise users will not be able to post comments.
11 | * If your repo is a fork, navigate to its settings tab and confirm the issues feature is turned on.
12 | * Fill out the repo and website URL and add to the [[settings of the plugin|$:/plugins/breakzplatform/github-comments/settings/settings]] (next tab)
13 | * Complete the setup and refresh your wiki
14 | * Profit!
15 |
16 | //Select the next tab to continue.//
17 |
--------------------------------------------------------------------------------
/macro/comments.js:
--------------------------------------------------------------------------------
1 | /*\
2 | module-type: macro
3 | tags: $:/tags/Macro
4 | title: $:/plugins/breakzplatform/github-comments/macro/comments
5 | type: application/javascript
6 |
7 | Display GitHub comments
8 |
9 | \*/
10 | (function () {
11 |
12 | /*jslint node: true, browser: true */
13 | /*global $tw: false */
14 | "use strict";
15 |
16 | exports.name = "github-comments";
17 |
18 | exports.params = [
19 | { "name": "current" },
20 | ];
21 |
22 | /*
23 | Run the macro
24 | */
25 | exports.run = function (current) {
26 | // Interactive DOM not available when generating static pages
27 | if (!$tw.browser) return;
28 |
29 | /* Remove current Utteranc.es parent element */
30 | const currentGhCommentsEL = document.getElementById("gh-comments");
31 | if (currentGhCommentsEL !== null) {
32 | currentGhCommentsEL.remove()
33 | }
34 |
35 | /* Load Utteranc.es */
36 | const utterancesEl = document.createElement('script');
37 | utterancesEl.async = true
38 | utterancesEl.src = 'https://utteranc.es/client.js'
39 | utterancesEl.setAttribute('repo', $tw.wiki.getTiddlerText('$:/config/breakzplatform/github-comments/repo'))
40 | utterancesEl.setAttribute('issue-term', '[' + $tw.wiki.getTiddlerText('$:/config/breakzplatform/github-comments/url') + '] ' + current)
41 | utterancesEl.setAttribute('theme', $tw.wiki.getTiddlerText('$:/config/breakzplatform/github-comments/theme'))
42 | utterancesEl.setAttribute('crossorigin', 'anonymous')
43 |
44 | /* Create Github Comments Element */
45 | const ghCommentsEl = document.createElement('div');
46 | ghCommentsEl.id = "gh-comments";
47 | ghCommentsEl.appendChild(utterancesEl);
48 |
49 | /* Append to Wrapper */
50 | document.querySelector('div[data-tiddler-title="' + current + '"] .gh-comments-wrapper')
51 | .appendChild(ghCommentsEl);
52 |
53 | $tw.utils.nextTick(function () {
54 | $tw.rootWidget.dispatchEvent({
55 | type: "github-comments-did-insert-element",
56 | target: ghCommentsEl
57 | });
58 | });
59 | };
60 | })();
61 |
--------------------------------------------------------------------------------
/plugin.info:
--------------------------------------------------------------------------------
1 | {
2 | "title": "$:/plugins/breakzplatform/github-comments",
3 | "description": "Github Comments",
4 | "author": "breakzplatform",
5 | "version": "0.0.1",
6 | "core-version": ">=5.1.23",
7 | "source": "https://github.com/breakzplatform/tw5-github-comments",
8 | "plugin-type": "plugin",
9 | "list": "README/README README/setup settings/settings README/FAQ README/CHANGELOG"
10 | }
11 |
--------------------------------------------------------------------------------
/settings/filter.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/config/breakzplatform/github-comments/filter
3 | type: text/vnd.tiddlywiki
4 |
5 | [!is[system]]
--------------------------------------------------------------------------------
/settings/label-hide.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/config/breakzplatform/github-comments/label-hide
3 | type: text/vnd.tiddlywiki
4 |
5 | Hide ~GitHub comments
--------------------------------------------------------------------------------
/settings/label-show.tid:
--------------------------------------------------------------------------------
1 | tags:
2 | title: $:/config/breakzplatform/github-comments/label-show
3 | type: text/vnd.tiddlywiki
4 |
5 | Show ~GitHub comments
--------------------------------------------------------------------------------
/settings/settings.tid:
--------------------------------------------------------------------------------
1 | tags: $:/tags/ControlPanel
2 | title: $:/plugins/breakzplatform/github-comments/settings/settings
3 | type: text/vnd.tiddlywiki
4 | caption: Github comments
5 |
6 | <$list filter="[[$:/ControlPanel]!is[current]]">
7 | Configuration for the plugin can be done from within the Github comments tab in the [[ControlPanel|$:/ControlPanel]] as well.
8 | $list>
9 | <$list filter="[[$:/ControlPanel]is[current]]">
10 | Configuration for the [[Github comments plugin|$:/plugins/breakzplatform/github-comments]].
11 | $list>
12 |
13 | |[[GitHub Repository|$:/config/breakzplatform/github-comments/repo]] |<$edit-text tiddler="$:/config/breakzplatform/github-comments/repo" default="" tag="input"/>
//Use ''user/repo'' format. For example ''breakzplatform/tw5-github-comments'' // |
14 | |[[Website's URL|$:/config/breakzplatform/github-comments/url]] |<$edit-text tiddler="$:/config/breakzplatform/github-comments/url" default="" tag="input"/>
//For example ''breakzplatform.github.io'' or ''joseli.to/pt''. // |
15 | |[[Theme|$:/config/breakzplatform/github-comments/theme]]|<$edit-text tiddler="$:/config/breakzplatform/github-comments/theme" default="" tag="input"/> |
16 | |[[Filter|$:/config/breakzplatform/github-comments/filter]]
Which tiddlers would you like to comment on?|<$edit-text tiddler="$:/config/breakzplatform/github-comments/filter" default="" tag="input"/> | 17 | |[[Show label text|$:/config/breakzplatform/github-comments/label-show]]|<$edit-text tiddler="$:/config/breakzplatform/github-comments/label-show" default="" tag="input"/> | 18 | |[[Hide label text|$:/config/breakzplatform/github-comments/label-hide]]|<$edit-text tiddler="$:/config/breakzplatform/github-comments/label-hide" default="" tag="input"/> | -------------------------------------------------------------------------------- /settings/theme.tid: -------------------------------------------------------------------------------- 1 | tags: 2 | title: $:/config/breakzplatform/github-comments/theme 3 | type: text/vnd.tiddlywiki 4 | 5 | github-light -------------------------------------------------------------------------------- /stylesheet.tid: -------------------------------------------------------------------------------- 1 | tags: $:/tags/Stylesheet 2 | title: $:/plugins/breakzplatform/github-comments/stylesheet 3 | type: text/css 4 | 5 | .breakzplatform-github-comments-toggle { 6 | display: block; 7 | width: 100%; 8 | text-align: right; 9 | } 10 | 11 | .breakzplatform-github-comments-toggle img { 12 | height: 1rem; 13 | } 14 | 15 | .gh-comments-wrapper { 16 | min-height: 100px; 17 | } -------------------------------------------------------------------------------- /template.tid: -------------------------------------------------------------------------------- 1 | tags: $:/tags/ViewTemplate 2 | title: $:/plugins/breakzplatform/github-comments/template 3 | type: text/vnd.tiddlywiki 4 | 5 | <$list filter="[all[current]subfilter{$:/config/breakzplatform/github-comments/filter}]" variable="doNotOverrideCurrent"> 6 | <$set name="stateTiddler" value="$:/state/breakzplatform/github-comments"> 7 | <$reveal type="nomatch" state=<