1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

Merge branch 'master' into multi-wiki-support

This commit is contained in:
Jeremy Ruston 2024-07-15 20:58:31 +01:00
commit 882438db14
5 changed files with 131 additions and 11 deletions

30
.github/workflows/cla-check.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: Check CLA Signature
on:
pull_request_target:
types:
- opened
- reopened
paths-ignore:
- 'licenses/cla-individual.md'
jobs:
check_cla:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ (github.event.pull_request.user.login != github.repository_owner) }}
steps:
- run: |
if ! curl -s https://raw.githubusercontent.com/Jermolene/TiddlyWiki5/tiddlywiki-com/licenses/cla-individual.md | grep -o "@$USER,"; then
echo "CLA not signed"
gh pr comment "$NUMBER" -b "@$USER It appears that this is your first contribution to the project, welcome.
With apologies for the bureaucracy, please could you prepare a separate PR to the 'tiddlywiki-com' branch with your signature for the Contributor License Agreement (see [contributing.md](https://github.com/Jermolene/TiddlyWiki5/blob/master/contributing.md))."
else
echo "CLA already signed"
gh pr comment "$NUMBER" -b "**$USER** has signed the Contributor License Agreement (see [contributing.md](https://github.com/Jermolene/TiddlyWiki5/blob/master/contributing.md))"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
USER: ${{ github.actor }}

70
.github/workflows/cla-signed.yml vendored Normal file
View File

@ -0,0 +1,70 @@
name: CLA Signed
on:
pull_request_target:
types:
- opened
- closed
paths:
- 'licenses/cla-individual.md'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
AUTHOR: ${{ github.event.pull_request.user.login }}
jobs:
# check if PRs updating the CLA are targetting the tiddlywiki-com branch
check-signature-branch:
if: (github.event.pull_request.merged != true) && (github.event.pull_request.user.login != github.repository_owner)
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- run: |
if ! $BRANCH == "tiddlywiki-com"; then
echo "This CLA signature targets the wrong branch"
gh pr comment "$NUMBER" -b "@$AUTHOR Signatures to the CLA must target the 'tiddlywiki-com' branch."
fi
env:
BRANCH: ${{ github.event.pull_request.base.ref }}
# leave a comment on each open PR by a given author when their signature is added to the CLA
cla-signed:
if: (github.event.pull_request.merged == true) && (github.event.pull_request.user.login != github.repository_owner)
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: List open PRs by user
id: list-prs
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const owner = context.repo.owner,
repo = context.repo.repo,
author = context.payload.pull_request.user.login;
const { data: pullRequests } = await github.rest.pulls.list({
owner: owner,
repo: repo,
state: 'open',
sort: 'created',
direction: 'desc',
per_page: 100
});
const userPullRequests = pullRequests.filter(pr => pr.user.login === author),
prNumbers = userPullRequests.map(pr => pr.number).join(',');
console.log(`Open pull requests by ${author}:${prNumbers}`);
return prNumbers;
- name: Comment open PRs by the same author
run: |
prs=($(echo ${{ steps.list-prs.outputs.result }} | tr "," "\n"))
for number in "${prs[@]}"
do
gh pr comment "$number" -b "**$AUTHOR** has signed the Contributor License Agreement (see [contributing.md](https://github.com/Jermolene/TiddlyWiki5/blob/master/contributing.md))"
done

View File

@ -560,18 +560,22 @@ exports.extractTranscludes = function(parseTreeRoot, title) {
for(var t=0; t<parseTree.length; t++) {
var parseTreeNode = parseTree[t];
if(parseTreeNode.type === "transclude") {
if(parseTreeNode.attributes.$tiddler && parseTreeNode.attributes.$tiddler.type === "string") {
var value;
// if it is Transclusion with Templates like `{{Index||$:/core/ui/TagTemplate}}`, the `$tiddler` will point to the template. We need to find the actual target tiddler from parent node
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
// Empty value (like `{{!!field}}`) means self-referential transclusion.
value = parentNode.attributes.tiddler.value || title;
} else {
value = parseTreeNode.attributes.$tiddler.value;
if(parseTreeNode.attributes.$tiddler) {
if(parseTreeNode.attributes.$tiddler.type === "string") {
var value;
// if it is Transclusion with Templates like `{{Index||$:/core/ui/TagTemplate}}`, the `$tiddler` will point to the template. We need to find the actual target tiddler from parent node
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
// Empty value (like `{{!!field}}`) means self-referential transclusion.
value = parentNode.attributes.tiddler.value || title;
} else {
value = parseTreeNode.attributes.$tiddler.value;
}
}
} else if(parseTreeNode.attributes.tiddler) {
if (parseTreeNode.attributes.tiddler.type === "string") {
// Old transclude widget usage
value = parseTreeNode.attributes.tiddler.value;
}
} else if(parseTreeNode.attributes.tiddler && parseTreeNode.attributes.tiddler.type === "string") {
// Old transclude widget usage
value = parseTreeNode.attributes.tiddler.value;
} else if(parseTreeNode.attributes.$field && parseTreeNode.attributes.$field.type === "string") {
// Empty value (like `<$transclude $field='created'/>`) means self-referential transclusion.
value = title;

View File

@ -220,6 +220,22 @@ describe('Backtranscludes and transclude filter tests', function() {
});
});
describe('exclude self when target tiddler is not string', function() {
var wiki = new $tw.Wiki();
wiki.addTiddler({
title: 'TestOutgoing',
text: "<$transclude $tiddler={{TestOutgoing!!title}} $field='created'/> and <$transclude tiddler={{TestOutgoing!!title}} field='created'/>"});
it('should have no transclude', function() {
expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('');
});
it('should have no back transcludes', function() {
expect(wiki.filterTiddlers('TestOutgoing +[backtranscludes[]]').join(',')).toBe('');
});
});
describe('recognize transclusion defined by widget', function() {
var wiki = new $tw.Wiki();