Merge tag 'v0.3.0' from upstream

This commit is contained in:
Jacob Kiers 2022-11-13 21:29:50 +01:00
commit ca830713d3
53 changed files with 376 additions and 22 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ venv/
cli_docs/_build/
dist/
build/
.pypi_token

View File

@ -18,9 +18,9 @@ copyright = '2021 Soren Bjornstad'
author = 'Soren Bjornstad'
# The short X.Y version
version = "0.2.0"
version = "0.3.0"
# The full version, including alpha/beta/rc tags
release = "0.2.0"
release = "0.3.0"
# -- General configuration ---------------------------------------------------

File diff suppressed because one or more lines are too long

View File

@ -6,4 +6,4 @@ rm -rf build/
rm -f dist/*
mkdir -p dist
python setup.py sdist bdist_wheel
twine upload dist/*
TWINE_PASSWORD=$(cat .pypi_token) twine upload --username '__token__' dist/*

View File

@ -9,7 +9,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="tzk",
version="0.2.0",
version="0.3.0",
author="Soren I. Bjornstad",
author_email="zettelkasten@sorenbjornstad.com",
description="Build tool for TiddlyWiki Zettelkasten",

View File

@ -13,6 +13,7 @@ information about the defined products without actually running any build steps.
from collections.abc import Mapping
from contextlib import contextmanager
import functools
import itertools
import os
from pathlib import Path
import re
@ -367,11 +368,11 @@ def _privatize_line(line: str, replacement_table: Dict[str, str],
Basics:
>>> _privatize_line("MsAlice is a test person.", {'MsAlice': 'A.'})
'<<privateperson "A.">> is a test person.'
'[[A.|PrivatePerson]] is a test person.'
>>> _privatize_line("This woman, known as MsAlice, is a test person.", \
{'MsAlice': 'A.'})
'This woman, known as <<privateperson "A.">>, is a test person.'
'This woman, known as [[A.|PrivatePerson]], is a test person.'
>>> _privatize_line("[[MsAlice]] is a test person.", {'MsAlice': 'A.'})
'[[A.|PrivatePerson]] is a test person.'
@ -380,6 +381,12 @@ def _privatize_line(line: str, replacement_table: Dict[str, str],
"sentence, that's fine too.", {'MsAlice': 'A.'})
"When we talk about [[A.|PrivatePerson]] in the middle of a sentence, that's fine too."
Content inside a macro:
>>> _privatize_line('''Text with a footnote.''' \
'''<<fnote "Here's my footnote about MsAlice.">>''', \
{'MsAlice': 'A.'})
'Text with a footnote.<<fnote "Here\\'s my footnote about [[A.|PrivatePerson]].">>'
Links with different text and target:
>>> _privatize_line("We can talk about [[Alice|MsAlice]] " \
"with different text.", {'MsAlice': 'A.'})
@ -388,12 +395,12 @@ def _privatize_line(line: str, replacement_table: Dict[str, str],
Multiple replacements with different people:
>>> _privatize_line("We can have [[MsAlice]] and MrBob talk to each other " \
"in the same line.", {'MsAlice': 'A.', 'MrBob': 'B.'})
'We can have [[A.|PrivatePerson]] and <<privateperson "B.">> talk to each other in the same line.'
'We can have [[A.|PrivatePerson]] and [[B.|PrivatePerson]] talk to each other in the same line.'
Multiple replacements with the same person:
>>> _privatize_line("We can have MsAlice talk to herself (MsAlice) " \
"in the same line.", {'MsAlice': 'A.'})
'We can have <<privateperson "A.">> talk to herself (<<privateperson "A.">>) in the same line.'
'We can have [[A.|PrivatePerson]] talk to herself ([[A.|PrivatePerson]]) in the same line.'
>>> _privatize_line("Likewise [[MsAlice]] can do it with brackets " \
"([[MsAlice]]).", {'MsAlice': 'A.'})
@ -401,7 +408,7 @@ def _privatize_line(line: str, replacement_table: Dict[str, str],
>>> _privatize_line('We can talk about [[Alice|MsAlice]] lots of ways, ' \
'like MsAlice and [[MsAlice]].', {'MsAlice': 'A.'})
'We can talk about [[Alice|PrivatePerson]] lots of ways, like <<privateperson "A.">> and [[A.|PrivatePerson]].'
'We can talk about [[Alice|PrivatePerson]] lots of ways, like [[A.|PrivatePerson]] and [[A.|PrivatePerson]].'
Replacements with alternate link text:
>>> _privatize_line('We can talk about [[Alice|MsAlice]] and [[Bob|MrBob]] as well', \
@ -477,7 +484,7 @@ def _privatize_line(line: str, replacement_table: Dict[str, str],
if not is_spurious_substring():
new_line = (line[0:start_idx]
+ f'<<privateperson "{replace_initials}">>'
+ f'[[{replace_initials}|PrivatePerson]]'
+ line[end_idx:])
elif is_bare_bracketed_link(start_idx, end_idx):
# link with the person as the target and text
@ -553,7 +560,8 @@ def replace_private_people(initialer: Callable[[str], str] = None, replace_link_
assert 'public_wiki_folder' in build_state
replacement_table = _private_people_replacement_table(initialer)
tid_files = (Path(build_state['public_wiki_folder']) / "tiddlers").glob("**/*.tid")
root = (Path(build_state['public_wiki_folder']) / "tiddlers")
tid_files = itertools.chain(root.glob("**/*.tid"), root.glob("**/*.json"))
for tiddler in tid_files:
dirty = False

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/appear/defaults/button-class
tc-btn-invisible tc-tiddlylink

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/appear/defaults/default-state
$:/temp/appear/

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/appear/defaults/keep
yes

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/appear/defaults/mode
block

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/appear/defaults/show
»

View File

@ -0,0 +1,13 @@
/*\
title: $:/plugins/tobibeer/appear/popup.js
type: application/javascript
module-type: utils
An enhanced version of the core Popup to support:
* absolute popups
* preview popups
* popup z-index
@preserve
\*/
(function(){"use strict";var t=require("$:/core/modules/utils/dom/popup.js").Popup,e=require("$:/core/modules/widgets/reveal.js").reveal,s=e.prototype.refresh;t.prototype.show=function(t){var e,s=t.domNode,p=$tw.utils.hasClass(s,"tc-popup-absolute"),o=this.popupInfo(s),i=function(t){var e=t,s=0,p=0;do{s+=e.offsetLeft||0;p+=e.offsetTop||0;e=e.offsetParent}while(e);return{left:s,top:p}},l={left:s.offsetLeft,top:s.offsetTop};e=o.popupLevel;if(o.isHandle){e++}this.cancel(e);if(this.findPopup(t.title)===-1){this.popups.push({title:t.title,wiki:t.wiki,domNode:s})}l=p?i(s):l;t.wiki.setTextReference(t.title,"("+l.left+","+l.top+","+s.offsetWidth+","+s.offsetHeight+")");if(this.popups.length>0){this.rootElement.addEventListener("click",this,true)}};t.prototype.popupInfo=function(t){var e,s=false,p=t;while(p&&e===undefined){if($tw.utils.hasClass(p,"tc-popup-handle")||$tw.utils.hasClass(p,"tc-popup-keep")){s=true}if($tw.utils.hasClass(p,"tc-reveal")&&($tw.utils.hasClass(p,"tc-popup")||$tw.utils.hasClass(p,"tc-popup-handle"))){e=parseInt(p.style.zIndex)-1e3}p=p.parentNode}var o={popupLevel:e||0,isHandle:s};return o};t.prototype.handleEvent=function(t){if(t.type==="click"){var e=this.popupInfo(t.target),s=e.popupLevel-1;if(e.isHandle){if(s<0){s=1}else{s++}}this.cancel(s)}};e.prototype.refresh=function(){var t,e,p=this.isOpen;e=s.apply(this,arguments);t=this.domNodes[0];if(this.isOpen&&(p!==this.isOpen||!t.style.zIndex)&&t&&(this.type==="popup"||$tw.utils.hasClass(t,"tc-block-dropdown")&&$tw.utils.hasClass(t,"tc-reveal"))){t.style.zIndex=1e3+$tw.popup.popups.length}return e}})();

View File

@ -0,0 +1,3 @@
module-type: utils
title: $:/plugins/tobibeer/appear/popup.js
type: application/javascript

View File

@ -0,0 +1,31 @@
title: $:/plugins/tobibeer/appear/readme
This plugin provides the ''$appear'' widget that can render popups and sliders (inline or block) as well as accordion menus.
!! Attributes
; type
: set to `popup` to have the content appear as a popup
; show
: the button label
; hide
: the hide button label
; mode
: either `block` or `inline`, with respect to the inner content
: any other mode is interpreted as block mode, without the default styles applying, e.g. drop-shadows
; once
: allows to click the button once, then hides it (unless the state is deleted)
; $state
: the widget calculates a state for you, use this to append a simple id
; state
: alternatively, specify a fully qualified state
; keep
: make popups sticky when `yes` or `true`
; handle / handler / variables
: allows to take the popup contents out of the flow and render them elsewhere on the page
: required to properly create popups in table cells and other constained elements
: specify variables to take along
<br>
; documentation / examples / demos...
: http://tobibeer.github.io/tw5-plugins#appear

View File

@ -0,0 +1,21 @@
tags: $:/tags/Stylesheet
title: $:/plugins/tobibeer/appear/styles
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html
<pre>.tc-reveal.appear-block,
.tc-popup.appear {
border-radius: 5px;
padding: 1px 1em;
<<box-shadow "2px 2px 4px rgba(0,0,0,0.3)">>;
}
.tc-popup.appear {
padding: 0 1em;
background: <<colour background>>;
}
.appear-reveal.appear-inline{
margin-left:5px;
}
.appear-reveal.appear-inline.appear-once{
margin-left:0;
}</pre>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
module-type: widget
title: $:/plugins/tobibeer/appear/widget.js
type: application/javascript

View File

@ -0,0 +1,15 @@
{
"author": "Tobias Beer",
"core-version": ">=5.1.9",
"created": "20220505135225785",
"dependents": "",
"description": "Create popups, sliders or accordion menus with the appear widget.",
"documentation": "https://tobibeer.github.io/tw5-appear",
"list": "readme",
"modified": "20220505135225785",
"plugin-type": "plugin",
"requires": "",
"source": "https://github.com/tobibeer/tw5-appear",
"title": "$:/plugins/tobibeer/appear",
"version": "0.6.2"
}

View File

@ -0,0 +1,20 @@
title: $:/plugins/tobibeer/preview/config
\define default()
<dt>$(defaults)$$(option)$</dt>
<dd>
//{{$:/plugins/tobibeer/preview/lingo/$(option)$}}<$list
filter="[[$(option)$]prefix[template]]">
{{$(defaults)$$(option)$}}</$list>://<br>
<$edit-text tag=input tiddler="$(defaults)$$(option)$"/>
</dd>
\end
<dl class="preview-defaults">
<$vars defaults="$:/plugins/tobibeer/preview/defaults/">
<$list filter="[all[tiddlers+shadows]removeprefix<defaults>sort[title]]" variable="option">
<<default>>
</$list>
</$vars>
</dl>
<style>.preview-defaults input {width:90%;}</style>

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/defaults/class
tc-popup-keep

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/defaults/delay
1500

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/defaults/exclude
[is[system]] [all[shadows]] [!has[text]]

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/defaults/keys
CTRL

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/defaults/not
tc-drop-down tc-sidebar-scrollable tc-topbar tc-tiddler-title

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/defaults/template
$:/plugins/tobibeer/preview/template

View File

@ -0,0 +1,11 @@
/*\
title: $:/plugins/tobibeer/preview/keyboard.js
type: application/javascript
module-type: utils
Fixes $:/core/modules/utils/dom/keyboard.js by providing an alternative.
Do not use as an API, let's fix the core.
@preserve
\*/
(function(){"use strict";var e={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46};exports.parseKeyDescriptorTB=function(t){var l,r,y,s=t.toUpperCase().split("+"),K={keyCode:null,shiftKey:false,altKey:false,ctrlKey:false};for(y=0;y<s.length;y++){l=false;r=s[y];if(r.substr(0,1)==="!"){l=true;r=r.substr(1)}if(r==="CTRL"){K.ctrlKey=l?null:true}else if(r==="SHIFT"){K.shiftKey=l?null:true}else if(r==="ALT"){K.altKey=l?null:true}else if(r==="META"){K.metaKey=l?null:true}else if(e[r]){K.keyCode=e[r]}else{K.keyCode=r.charCodeAt(0)}}return K};exports.checkKeyDescriptorTB=function(e,t){var l=!!t.metaKey;return(t.keyCode===null||e.keyCode===t.keyCode)&&(t.shiftKey===null?!e.shiftKey:e.shiftKey===t.shiftKey)&&(t.altKey===null?!e.altKey:e.altKey===t.altKey)&&(t.ctrlKey===null?!e.ctrlKey:e.ctrlKey===t.ctrlKey)&&(t.metaKey===null?!e.metaKey:e.metaKey===l)}})();

View File

@ -0,0 +1,3 @@
module-type: utils
title: $:/plugins/tobibeer/preview/keyboard.js
type: application/javascript

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/class
css classes applied to the popup

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/delay
delay popup for this many milliseconds

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/exclude
no preview for links to tiddlers matching this filter

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/keys
modifier keys to trigger popup directly on-hover (ctrl, alt+shift, meta, etc...)

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/not
no preview for links inside elements with these classes

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/open
view at ''<<WIKI>>''

View File

@ -0,0 +1,3 @@
title: $:/plugins/tobibeer/preview/lingo/template
the preview template

View File

@ -0,0 +1,10 @@
/*\
title: $:/plugins/tobibeer/preview/link.js
type: application/javascript
module-type: startup
Enhances the link widget for on-hover previews
@preserve
\*/
(function(){var e,t=require("$:/core/modules/widgets/link.js").link,i=t.prototype.render,o=t.prototype.handleClickEvent;t.prototype.render=function(){i.apply(this,arguments);var t=this,o=this.wiki,p=this.domNodes[0],r=o.getTiddler(t.to),n="$:/plugins/tobibeer/preview/defaults/",u="$:/temp/tobibeer/preview-",l=$tw.utils.parseKeyDescriptorTB(o.getTextReference(n+"keys","").toUpperCase()),s=o.getTextReference(n+"delay").toUpperCase(),a=function(e){var i=$tw.popup.popupInfo(e),p=i.popupLevel;return o.getTextReference(u+p)&&o.getTextReference(u+p+"-tiddler")===t.to?null:i},f=function(){var i,r=a(p);if(r){i=r.popupLevel;clearTimeout(t.previewTimeout);$tw.popup.cancel(i);i++;o.setText(u+i+"-tiddler","text",null,t.to);if($tw.popup.findPopup(u+i)===-1){setTimeout(function(){$tw.popup.triggerPopup({domNode:p,title:u+i,wiki:o});e=0},50)}}},d=function(){var e,i,r=1,u=o.getTextReference(n+"not","");if(u){$tw.utils.each(u.split(" "),function(e){var t=p;while(t&&r){if($tw.utils.hasClass(t,e)){r=0;return false}t=t.parentNode}})}if(r){i=o.getTextReference(n+"exclude","");e=i?o.filterTiddlers(i):[];if(e.indexOf(t.to)>=0){r=0}}return r};s=s!==undefined?parseInt(s):null;if(s!==null&&isNaN(s)){s=0}if(r){$tw.utils.addClass(p,"tc-popup-handle");$tw.utils.addClass(p,"tc-popup-absolute");["mouseover","mouseout"].forEach(function(i){p.addEventListener(i,function(o){var p=o||window.event;if(i==="mouseover"){if(d()){if(!p.keyCode){p.keyCode=0}if($tw.utils.checkKeyDescriptorTB(p,l)){if(!e){e=1;f()}}else if(s!==null){e=0;t.previewTimeout=setTimeout(f,s)}}}else{e=0;clearTimeout(t.previewTimeout)}})})}};t.prototype.handleClickEvent=function(){o.apply(this,arguments);clearTimeout(this.previewTimeout);$tw.popup.cancel(Math.max(0,$tw.popup.popupInfo(this.domNodes[0]).popupLevel))}})();

View File

@ -0,0 +1,3 @@
module-type: startup
title: $:/plugins/tobibeer/preview/link.js
type: application/javascript

View File

@ -0,0 +1,24 @@
tags: $:/tags/PageTemplate
title: $:/plugins/tobibeer/preview/popups
\define state(num)
$:/temp/tobibeer/preview-$num$
\end
\define classes(num)
tc-popup appear appear-block appear-reveal tc-preview-tiddler tc-preview-tiddler-$num$ $(default-classes)$
\end
\define level(num)
<$reveal tag="div" type="popup" state=<<state $num$>> class=<<classes $num$>>>
<$tiddler tiddler={{$:/temp/tobibeer/preview-$num$-tiddler}}>
<$transclude tiddler={{$:/plugins/tobibeer/preview/defaults/template}} mode="block"/>
</$tiddler>
</$reveal>
\end
<$vars default-classes={{$:/plugins/tobibeer/preview/defaults/class}}>
<$list filter="1 2 3 4 5 6 7 8 9">
<$macrocall $name="level" num={{!!title}}/>
</$list>
</$vars>

View File

@ -0,0 +1,8 @@
title: $:/plugins/tobibeer/preview/readme
The plugin $:/plugins/tobibeer/preview enhances the core <<x LinkWidget>> to display a preview of tiddlers when hovering an internal link.
<br>
; documentation / examples / demos...
: http://tobibeer.github.io/tw5-plugins#preview

View File

@ -0,0 +1,8 @@
tags: $:/tags/Stylesheet
title: $:/plugins/tobibeer/preview/styles
.tc-popup.tc-preview-tiddler{
max-width:600px;
width:100%;
padding:1em;
}

View File

@ -0,0 +1,5 @@
title: $:/plugins/tobibeer/preview/template
{{||$:/core/ui/ViewTemplate/tags}}
<$transclude mode="block"/>

View File

@ -0,0 +1,15 @@
{
"author": "Tobias Beer",
"core-version": ">=5.1.9",
"created": "20220505135243990",
"dependents": "",
"description": "Shows a tiddler preview when hovering internal links",
"documentation": "https://tobibeer.github.io/tw5-preview",
"list": "readme config",
"modified": "20220505135243990",
"plugin-type": "plugin",
"requires": "[[tobibeer/appear|http://tobibeer.github.io/tw5-plugins/#appear]]",
"source": "https://github.com/tobibeer/tw5-preview",
"title": "$:/plugins/tobibeer/preview",
"version": "0.5.6"
}

View File

@ -1,6 +1,8 @@
created: 20200121230518238
modified: 20210410005001202
creator: soren
modified: 20220622234624323
modifier: soren
title: $:/config/RelinkOnRename
type: text/vnd.tiddlywiki
yes
no

View File

@ -0,0 +1,8 @@
created: 20220622212041227
creator: soren
modified: 20220622212041250
modifier: soren
title: $:/config/shortcuts-mac/save-tiddler
type: text/vnd.tiddlywiki
cmd-Enter

View File

@ -0,0 +1,8 @@
created: 20220622212047526
creator: soren
modified: 20220622212047547
modifier: soren
title: $:/config/shortcuts-not-mac/save-tiddler
type: text/vnd.tiddlywiki
ctrl-Enter

View File

@ -0,0 +1,6 @@
created: 20220622212052270
creator: soren
modified: 20220622212052289
modifier: soren
title: $:/config/shortcuts/save-tiddler
type: text/vnd.tiddlywiki

View File

@ -2,7 +2,7 @@ caption: Spoiler banner
created: 20210622003118415
creator: soren
description: Display a warning banner on fiction tiddlers (any tiddler with a non-empty `universe` field) noting that we don't try to hide spoilers.
modified: 20220201042246695
modified: 20220502164810636
modifier: soren
private: no
public: no

View File

@ -0,0 +1,8 @@
created: 20220505135343597
creator: soren
modified: 20220505135454120
modifier: soren
title: $:/plugins/tobibeer/preview/defaults/delay
type: text/vnd.tiddlywiki
500

View File

@ -0,0 +1,8 @@
created: 20220505135432323
creator: soren
modified: 20220505135433494
modifier: soren
title: $:/plugins/tobibeer/preview/defaults/exclude
type: text/vnd.tiddlywiki
[is[system]] [all[shadows]]

View File

@ -0,0 +1,8 @@
created: 20220505135435971
creator: soren
modified: 20220505135437221
modifier: soren
title: $:/plugins/tobibeer/preview/defaults/keys
type: text/vnd.tiddlywiki
Ctrl

View File

@ -0,0 +1,11 @@
created: 20220505135633168
creator: soren
modified: 20220505135638189
modifier: soren
title: $:/plugins/tobibeer/preview/template
type: text/vnd.tiddlywiki
{{||$:/core/ui/ViewTemplate/subtitle}}
{{||$:/core/ui/ViewTemplate/tags}}
<$transclude mode="block"/>

View File

@ -1,8 +1,10 @@
caption: new source
created: 20200822190145295
creator: soren
description: Create a new source tiddler
list-after: $:/core/ui/Buttons/new-tiddler
modified: 20210522014032330
modified: 20220504192240445
modifier: soren
tags: $:/tags/PageControls
title: $:/sib/Buttons/NewSource
type: text/vnd.tiddlywiki
@ -25,6 +27,6 @@ type: text/vnd.tiddlywiki
readstatus="unread"
author=""
completed=""
year="2021"
year=<<now YYYY>>
/>
</$button>

View File

@ -3,7 +3,7 @@ created: 20210701023215046
creator: soren
description: Items we're currently working on but don't need to leave open. Drag and drop a link to a tiddler to add it.
list:
modified: 20211026030511257
modified: 20220716205827340
modifier: soren
tags: Meta Tool
title: $:/sib/Tools/Tray

View File

@ -10,7 +10,7 @@ import sys
from typing import Any, Callable, Dict, NoReturn
TZK_VERSION = "0.2.0"
TZK_VERSION = "0.3.0"
class BuildError(Exception):