1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-05-05 21:21:30 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Jeremy Ruston
c11b04ae9a Fix broken merge 2024-06-06 16:39:06 +01:00
Jeremy Ruston
5d2a59d20d Merge branch 'master' into logging-improvements 2024-06-06 16:32:06 +01:00
Jermolene
22a85e8fc7 Initial improvements 2019-01-17 15:20:24 +00:00
1428 changed files with 5443 additions and 26930 deletions

8
.eslintignore Normal file
View File

@@ -0,0 +1,8 @@
# Ignore "third party" code whose style we will not change.
/boot/sjcl.js
/core/modules/utils/base64-utf8/base64-utf8.module.js
/core/modules/utils/base64-utf8/base64-utf8.module.min.js
/core/modules/utils/diff-match-patch/diff_match_patch.js
/core/modules/utils/diff-match-patch/diff_match_patch_uncompressed.js
/core/modules/utils/dom/csscolorparser.js
/plugins/tiddlywiki/*/files/

283
.eslintrc.yml Normal file
View File

@@ -0,0 +1,283 @@
env:
browser: true
commonjs: true
es2021: true
node: true
extends: 'eslint:recommended'
globals:
"$tw": "writable" # temporary
parserOptions:
ecmaVersion: 5
rules:
array-bracket-newline: 'off'
array-bracket-spacing: 'off'
array-callback-return: 'off'
array-element-newline: 'off'
arrow-body-style: error
arrow-parens:
- error
- as-needed
arrow-spacing:
- error
- after: true
before: true
block-scoped-var: 'off'
block-spacing: 'off'
brace-style: 'off'
callback-return: 'off'
camelcase: 'off'
capitalized-comments: 'off'
class-methods-use-this: error
comma-dangle: 'off'
comma-spacing: 'off'
comma-style: 'off'
complexity: 'off'
computed-property-spacing: 'off'
consistent-return: 'off'
consistent-this: 'off'
curly: 'off'
default-case: 'off'
default-case-last: error
default-param-last: error
dot-location: 'off'
dot-notation: 'off'
eol-last: 'off'
eqeqeq: 'off'
func-call-spacing: 'off'
func-name-matching: 'off'
func-names: 'off'
func-style: 'off'
function-call-argument-newline: 'off'
function-paren-newline: 'off'
generator-star-spacing: error
global-require: 'off'
grouped-accessor-pairs: error
guard-for-in: 'off'
handle-callback-err: 'off'
id-blacklist: error
id-denylist: error
id-length: 'off'
id-match: error
implicit-arrow-linebreak: error
indent: 'off'
indent-legacy: 'off'
init-declarations: 'off'
jsx-quotes: error
key-spacing: 'off'
keyword-spacing:
- error
- before: true
after: false
overrides:
'case':
after: true
'do':
'after': true
'else':
after: true
'return':
after: true
'throw':
after: true
'try':
after: true
line-comment-position: 'off'
linebreak-style: 'off'
lines-around-comment: 'off'
lines-around-directive: 'off'
lines-between-class-members: error
max-classes-per-file: error
max-depth: 'off'
max-len: 'off'
max-lines: 'off'
max-lines-per-function: 'off'
max-nested-callbacks: error
max-params: 'off'
max-statements: 'off'
max-statements-per-line: 'off'
multiline-comment-style: 'off'
multiline-ternary: 'off'
new-parens: 'off'
newline-after-var: 'off'
newline-before-return: 'off'
newline-per-chained-call: 'off'
no-alert: 'off'
no-array-constructor: 'off'
no-await-in-loop: error
no-bitwise: 'off'
no-buffer-constructor: 'off'
no-caller: error
no-catch-shadow: 'off'
no-confusing-arrow: error
no-console: 'off'
no-constant-condition:
- error
- checkLoops: false
no-constructor-return: error
no-continue: 'off'
no-div-regex: 'off'
no-duplicate-imports: error
no-else-return: 'off'
no-empty-function: 'off'
no-eq-null: 'off'
no-eval: 'off'
no-extend-native: 'off'
no-extra-bind: 'off'
no-extra-label: 'off'
no-extra-parens: 'off'
no-floating-decimal: 'off'
no-implicit-coercion:
- error
- boolean: false
number: false
string: false
no-implicit-globals: 'off'
no-implied-eval: error
no-inline-comments: 'off'
no-invalid-this: 'off'
no-iterator: error
no-label-var: 'off'
no-labels: 'off'
no-lone-blocks: 'off'
no-lonely-if: 'off'
no-loop-func: 'off'
no-loss-of-precision: error
no-magic-numbers: 'off'
no-mixed-operators: 'off'
no-mixed-requires: 'off'
no-multi-assign: 'off'
no-multi-spaces: 'off'
no-multi-str: error
no-multiple-empty-lines: 'off'
no-native-reassign: 'off'
no-negated-condition: 'off'
no-negated-in-lhs: error
no-nested-ternary: 'off'
no-new: 'off'
no-new-func: 'off'
no-new-object: 'off'
no-new-require: error
no-new-wrappers: error
no-octal-escape: error
no-param-reassign: 'off'
no-path-concat: error
no-plusplus: 'off'
no-process-env: 'off'
no-process-exit: 'off'
no-promise-executor-return: error
no-proto: 'off'
no-restricted-exports: error
no-restricted-globals: error
no-restricted-imports: error
no-restricted-modules: error
no-restricted-properties: error
no-restricted-syntax: error
no-return-assign: 'off'
no-return-await: error
no-script-url: 'off'
no-self-compare: 'off'
no-sequences: 'off'
no-shadow: 'off'
no-spaced-func: 'off'
no-sync: 'off'
no-tabs: 'off'
no-template-curly-in-string: error
no-ternary: 'off'
no-throw-literal: 'off'
no-trailing-spaces: 'off'
no-undef-init: 'off'
no-undefined: 'off'
no-underscore-dangle: 'off'
no-unmodified-loop-condition: 'off'
no-unneeded-ternary: 'off'
no-unreachable-loop: error
no-unused-expressions: 'off'
no-use-before-define: 'off'
no-useless-backreference: error
no-useless-call: 'off'
no-useless-computed-key: error
no-useless-concat: 'off'
no-useless-constructor: error
no-useless-rename: error
no-useless-return: 'off'
no-var: 'off'
no-void: 'off'
no-warning-comments: 'off'
no-whitespace-before-property: error
nonblock-statement-body-position:
- error
- any
object-curly-newline: 'off'
object-curly-spacing: 'off'
object-property-newline: 'off'
object-shorthand: 'off'
one-var: 'off'
one-var-declaration-per-line: 'off'
operator-assignment: 'off'
operator-linebreak: 'off'
padded-blocks: 'off'
padding-line-between-statements: error
prefer-arrow-callback: 'off'
prefer-const: 'off'
prefer-destructuring: 'off'
prefer-exponentiation-operator: 'off'
prefer-named-capture-group: 'off'
prefer-numeric-literals: error
prefer-object-spread: 'off'
prefer-promise-reject-errors: error
prefer-reflect: 'off'
prefer-regex-literals: 'off'
prefer-rest-params: 'off'
prefer-spread: 'off'
prefer-template: 'off'
quote-props: 'off'
quotes: 'off'
radix: 'off'
require-atomic-updates: error
require-await: error
require-jsdoc: 'off'
require-unicode-regexp: 'off'
rest-spread-spacing: error
semi: 'off'
semi-spacing: 'off'
semi-style: 'off'
sort-imports: error
sort-keys: 'off'
sort-vars: 'off'
space-before-blocks: 'off'
space-before-function-paren: 'off'
space-in-parens: 'off'
space-infix-ops: 'off'
space-unary-ops: 'off'
spaced-comment: 'off'
strict: 'off'
switch-colon-spacing: 'off'
symbol-description: error
template-curly-spacing: error
template-tag-spacing: error
unicode-bom:
- error
- never
valid-jsdoc: 'off'
valid-typeof:
- error
- requireStringLiterals: false
vars-on-top: 'off'
wrap-iife: 'off'
wrap-regex: 'off'
yield-star-spacing: error
yoda: 'off'
# temporary rules
no-useless-escape: 'off'
no-unused-vars: 'off'
no-empty: 'off'
no-extra-semi: 'off'
no-redeclare: 'off'
no-control-regex: "off"
no-mixed-spaces-and-tabs: "off"
no-extra-boolean-cast: "off"
no-prototype-builtins: "off"
no-undef: "off"
no-unreachable: "off"
no-self-assign: "off"

View File

@@ -21,7 +21,7 @@ body:
attributes: attributes:
label: To Reproduce label: To Reproduce
description: "Steps to reproduce the behavior:" description: "Steps to reproduce the behavior:"
placeholder: | value: |
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. Scroll down to '....' 3. Scroll down to '....'
@@ -41,7 +41,7 @@ body:
attributes: attributes:
label: TiddlyWiki Configuration label: TiddlyWiki Configuration
description: please complete the following information description: please complete the following information
placeholder: | value: |
- Version [e.g. v5.1.24] - Version [e.g. v5.1.24]
- Saving mechanism [e.g. Node.js, TiddlyDesktop, TiddlyHost etc] - Saving mechanism [e.g. Node.js, TiddlyDesktop, TiddlyHost etc]
- Plugins installed [e.g. Freelinks, TiddlyMap] - Plugins installed [e.g. Freelinks, TiddlyMap]

View File

@@ -1,7 +1,7 @@
blank_issues_enabled: false blank_issues_enabled: false
contact_links: contact_links:
- name: Discuss feature request - name: Discuss feature request
url: https://github.com/TiddlyWiki/TiddlyWiki5/discussions url: https://github.com/Jermolene/TiddlyWiki5/discussions
about: Open new discussion about new feature about: Open new discussion about new feature
- name: Talk.Tiddlywiki Forum - name: Talk.Tiddlywiki Forum
url: https://talk.tiddlywiki.org url: https://talk.tiddlywiki.org

View File

@@ -4,9 +4,8 @@ on:
branches: branches:
- master - master
- tiddlywiki-com - tiddlywiki-com
- multi-wiki-support
env: env:
NODE_VERSION: "22" NODE_VERSION: "18"
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -83,14 +82,3 @@ jobs:
- run: "./bin/build-tw-org.sh" - run: "./bin/build-tw-org.sh"
env: env:
GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }} GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }}
build-mws-tiddlywiki-com:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/multi-wiki-support'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "${{ env.NODE_VERSION }}"
- run: "./bin/build-mws-site.sh"
env:
GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }}

View File

@@ -1,30 +0,0 @@
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 -io "@$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/TiddlyWiki/TiddlyWiki5/blob/master/contributing.md))."
else
echo "CLA already signed"
gh pr comment "$NUMBER" -b "Confirmed: **$USER** has already signed the Contributor License Agreement (see [contributing.md](https://github.com/TiddlyWiki/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 }}

View File

@@ -1,70 +0,0 @@
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: $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/TiddlyWiki/TiddlyWiki5/blob/master/contributing.md))"
done

2
.gitignore vendored
View File

@@ -5,9 +5,7 @@
tmp/ tmp/
output/ output/
node_modules/ node_modules/
store/
/test-results/ /test-results/
/playwright-report/ /playwright-report/
/playwright/.cache/ /playwright/.cache/
$__StoryList.tid $__StoryList.tid
/editions/test/test-store/*

View File

@@ -1,4 +0,0 @@
The `multi-wiki-support` branch includes some changes that are not intended to be merged into the `master` branch:
* Readme update (see `editions/tw5.com/tiddlers/readme/ReadMe.tid`)
* Remove `multiwikiserver` plugin from `readme-bld.sh` (see `bin/readme-bld.sh`)

View File

@@ -1,97 +0,0 @@
#!/bin/bash
# Build mws.tiddlywiki.com assets.
# Default to the version of TiddlyWiki installed in this repo
if [ -z "$MWSTWCOM_BUILD_TIDDLYWIKI" ]; then
MWSTWCOM_BUILD_TIDDLYWIKI=./tiddlywiki.js
fi
echo "Using MWSTWCOM_BUILD_TIDDLYWIKI as [$MWSTWCOM_BUILD_TIDDLYWIKI]"
# Set up the build details
if [ -z "$MWSTWCOM_BUILD_DETAILS" ]; then
MWSTWCOM_BUILD_DETAILS="$(git symbolic-ref --short HEAD)-$(git rev-parse HEAD) from $(git remote get-url origin)"
fi
echo "Using MWSTWCOM_BUILD_DETAILS as [$MWSTWCOM_BUILD_DETAILS]"
if [ -z "$MWSTWCOM_BUILD_COMMIT" ]; then
MWSTWCOM_BUILD_COMMIT="$(git rev-parse HEAD)"
fi
echo "Using MWSTWCOM_BUILD_COMMIT as [$MWSTWCOM_BUILD_COMMIT]"
# Set up the build output directory
if [ -z "$MWSTWCOM_BUILD_OUTPUT" ]; then
MWSTWCOM_BUILD_OUTPUT=$(mktemp -d)
fi
mkdir -p $MWSTWCOM_BUILD_OUTPUT
if [ ! -d "$MWSTWCOM_BUILD_OUTPUT" ]; then
echo 'A valid MWSTWCOM_BUILD_OUTPUT environment variable must be set'
exit 1
fi
echo "Using MWSTWCOM_BUILD_OUTPUT as [$MWSTWCOM_BUILD_OUTPUT]"
# Pull existing GitHub pages content
git clone --depth=1 --branch=main "https://github.com/TiddlyWiki/mws.tiddlywiki.com-gh-pages.git" $MWSTWCOM_BUILD_OUTPUT
# Make the CNAME file that GitHub Pages requires
echo "mws.tiddlywiki.com" > $MWSTWCOM_BUILD_OUTPUT/CNAME
# Delete any existing static content
mkdir -p $MWSTWCOM_BUILD_OUTPUT/static
rm $MWSTWCOM_BUILD_OUTPUT/static/*
# Put the build details into a .tid file so that it can be included in each build (deleted at the end of this script)
echo -e -n "title: $:/build\ncommit: $MWSTWCOM_BUILD_COMMIT\n\n$MWSTWCOM_BUILD_DETAILS\n" > $MWSTWCOM_BUILD_OUTPUT/build.tid
######################################################
#
# mws.tiddlywiki.com distribution
#
######################################################
# /index.html Main site
# /favicon.ico Favicon for main site
# /static.html Static rendering of default tiddlers
# /alltiddlers.html Static rendering of all tiddlers
# /static/* Static single tiddlers
# /static/static.css Static stylesheet
# /static/favicon.ico Favicon for static pages
node $MWSTWCOM_BUILD_TIDDLYWIKI \
editions/multiwikidocs \
--verbose \
--version \
--load $MWSTWCOM_BUILD_OUTPUT/build.tid \
--output $MWSTWCOM_BUILD_OUTPUT \
--build favicon static index \
|| exit 1
# Delete the temporary build tiddler
rm $MWSTWCOM_BUILD_OUTPUT/build.tid || exit 1
# Push output back to GitHub
# Exit script immediately if any command fails
set -e
pushd $MWSTWCOM_BUILD_OUTPUT
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add -A .
git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))"
git remote add deploy "https://$GH_TOKEN@github.com/TiddlyWiki/mws.tiddlywiki.com-gh-pages.git" &>/dev/null
git push deploy main &>/dev/null
popd

View File

@@ -5,7 +5,7 @@
# Default to the current version number for building the plugin library # Default to the current version number for building the plugin library
if [ -z "$TW5_BUILD_VERSION" ]; then if [ -z "$TW5_BUILD_VERSION" ]; then
TW5_BUILD_VERSION=v5.3.7 TW5_BUILD_VERSION=v5.3.3
fi fi
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]" echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
@@ -97,6 +97,7 @@ if [ -n "$TW5_BUILD_ARCHIVE" ]; then
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
$TW5_BUILD_MAIN_EDITION \ $TW5_BUILD_MAIN_EDITION \
--verbose \
--version \ --version \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_ARCHIVE \ --output $TW5_BUILD_ARCHIVE \
@@ -114,6 +115,7 @@ fi
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
$TW5_BUILD_MAIN_EDITION \ $TW5_BUILD_MAIN_EDITION \
--verbose \
--version \ --version \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
@@ -126,6 +128,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /tiddlywikicore-<version>.js Core plugin javascript # /tiddlywikicore-<version>.js Core plugin javascript
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/empty \ ./editions/empty \
--verbose \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--build empty emptyexternalcore \ --build empty emptyexternalcore \
|| exit 1 || exit 1
@@ -134,6 +137,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /test.html Test edition # /test.html Test edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/test \ ./editions/test \
--verbose \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all test.html text/plain \ --rendertiddler $:/core/save/all test.html text/plain \
|| exit 1 || exit 1
@@ -146,6 +150,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /dev/static/static.css Static stylesheet # /dev/static/static.css Static stylesheet
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/dev \ ./editions/dev \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/dev \ --output $TW5_BUILD_OUTPUT/dev \
--build index favicon static \ --build index favicon static \
@@ -154,13 +159,29 @@ node $TW5_BUILD_TIDDLYWIKI \
# /tour.html tour edition # /tour.html tour edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/tour \ ./editions/tour \
--verbose \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all tour.html text/plain \ --rendertiddler $:/core/save/all tour.html text/plain \
|| exit 1 || exit 1
# /dev/index.html Developer docs
# /dev/favicon.ico Favicon for dev site
# /dev/static.html Static rendering of default tiddlers
# /dev/alltiddlers.html Static rendering of all tiddlers
# /dev/static/* Static single tiddlers
# /dev/static/static.css Static stylesheet
node $TW5_BUILD_TIDDLYWIKI \
./editions/dev \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/dev \
--build index favicon static \
|| exit 1
# /share.html Custom edition for sharing via the URL # /share.html Custom edition for sharing via the URL
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/share \ ./editions/share \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--build share \ --build share \
@@ -169,6 +190,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /upgrade.html Custom edition for performing upgrades # /upgrade.html Custom edition for performing upgrades
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/upgrade \ ./editions/upgrade \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--build upgrade \ --build upgrade \
@@ -177,6 +199,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /encrypted.html Copy of the main file encrypted with the password "password" # /encrypted.html Copy of the main file encrypted with the password "password"
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
$TW5_BUILD_MAIN_EDITION \ $TW5_BUILD_MAIN_EDITION \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--build encrypted \ --build encrypted \
@@ -192,6 +215,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/xlsx-utils/index.html xlsx-utils edition # /editions/xlsx-utils/index.html xlsx-utils edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/xlsx-utils \ ./editions/xlsx-utils \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/xlsx-utils/ \ --output $TW5_BUILD_OUTPUT/editions/xlsx-utils/ \
--build index \ --build index \
@@ -200,6 +224,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/resumebuilder/index.html Resume builder edition # /editions/resumebuilder/index.html Resume builder edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/resumebuilder \ ./editions/resumebuilder \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/resumebuilder/ \ --output $TW5_BUILD_OUTPUT/editions/resumebuilder/ \
--build index \ --build index \
@@ -208,6 +233,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/text-slicer/index.html Text slicer edition # /editions/text-slicer/index.html Text slicer edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/text-slicer \ ./editions/text-slicer \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/text-slicer/ \ --output $TW5_BUILD_OUTPUT/editions/text-slicer/ \
--build index \ --build index \
@@ -216,6 +242,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/translators/index.html Translators edition # /editions/translators/index.html Translators edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/translators \ ./editions/translators \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/translators/ \ --output $TW5_BUILD_OUTPUT/editions/translators/ \
--build index \ --build index \
@@ -224,6 +251,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/introduction/index.html Introduction edition # /editions/introduction/index.html Introduction edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/introduction \ ./editions/introduction \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/introduction/ \ --output $TW5_BUILD_OUTPUT/editions/introduction/ \
--build index \ --build index \
@@ -232,6 +260,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/full/index.html Full edition # /editions/full/index.html Full edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/full \ ./editions/full \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/full/ \ --output $TW5_BUILD_OUTPUT/editions/full/ \
--build index \ --build index \
@@ -240,6 +269,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/tw5.com-docs/index.html tiddlywiki.com docs edition # /editions/tw5.com-docs/index.html tiddlywiki.com docs edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/tw5.com-docs \ ./editions/tw5.com-docs \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/tw5.com-docs/ \ --output $TW5_BUILD_OUTPUT/editions/tw5.com-docs/ \
--build index \ --build index \
@@ -248,6 +278,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /editions/twitter-archivist/index.html Twitter Archivist edition # /editions/twitter-archivist/index.html Twitter Archivist edition
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/twitter-archivist \ ./editions/twitter-archivist \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/editions/twitter-archivist/ \ --output $TW5_BUILD_OUTPUT/editions/twitter-archivist/ \
--build index \ --build index \
@@ -263,6 +294,7 @@ node $TW5_BUILD_TIDDLYWIKI \
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/innerwikidemo \ ./editions/innerwikidemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/innerwiki/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/innerwiki/index.html text/plain \
@@ -273,6 +305,7 @@ node $TW5_BUILD_TIDDLYWIKI \
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/dynaviewdemo \ ./editions/dynaviewdemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/dynaview/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/dynaview/index.html text/plain \
@@ -287,6 +320,7 @@ node $TW5_BUILD_TIDDLYWIKI \
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/katexdemo \ ./editions/katexdemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/katex/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/katex/index.html text/plain \
@@ -297,6 +331,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/tahoelafs/empty.html Empty wiki with Tahoe-LAFS plugin # /plugins/tiddlywiki/tahoelafs/empty.html Empty wiki with Tahoe-LAFS plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/tahoelafs \ ./editions/tahoelafs \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/tahoelafs/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/tahoelafs/index.html text/plain \
@@ -307,6 +342,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/d3/empty.html Empty wiki with D3 plugin # /plugins/tiddlywiki/d3/empty.html Empty wiki with D3 plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/d3demo \ ./editions/d3demo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/d3/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/d3/index.html text/plain \
@@ -317,6 +353,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/codemirror/empty.html Empty wiki with codemirror plugin # /plugins/tiddlywiki/codemirror/empty.html Empty wiki with codemirror plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/codemirrordemo \ ./editions/codemirrordemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/codemirror/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/codemirror/index.html text/plain \
@@ -327,6 +364,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/markdown/empty.html Empty wiki with Markdown plugin # /plugins/tiddlywiki/markdown/empty.html Empty wiki with Markdown plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/markdowndemo \ ./editions/markdowndemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/markdown/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/markdown/index.html text/plain \
@@ -337,6 +375,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/tw2parser/empty.html Empty wiki with tw2parser plugin # /plugins/tiddlywiki/tw2parser/empty.html Empty wiki with tw2parser plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/classicparserdemo \ ./editions/classicparserdemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/tw2parser/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/tw2parser/index.html text/plain \
@@ -347,6 +386,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/highlight/empty.html Empty wiki with highlight plugin # /plugins/tiddlywiki/highlight/empty.html Empty wiki with highlight plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/highlightdemo \ ./editions/highlightdemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/highlight/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/highlight/index.html text/plain \
@@ -357,6 +397,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /plugins/tiddlywiki/geospatial/empty.html Empty wiki with geospatial plugin # /plugins/tiddlywiki/geospatial/empty.html Empty wiki with geospatial plugin
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/geospatialdemo \ ./editions/geospatialdemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/geospatial/index.html text/plain \ --rendertiddler $:/core/save/all plugins/tiddlywiki/geospatial/index.html text/plain \
@@ -384,6 +425,7 @@ rm -rf $TW5_BUILD_OUTPUT/languages/zh-Hant/static/*
# /languages/de-AT/empty.html Empty wiki with de-AT language # /languages/de-AT/empty.html Empty wiki with de-AT language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/de-AT \ ./editions/de-AT \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/de-AT \ --output $TW5_BUILD_OUTPUT/languages/de-AT \
--build favicon empty static index \ --build favicon empty static index \
@@ -393,6 +435,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/de-DE/empty.html Empty wiki with de-DE language # /languages/de-DE/empty.html Empty wiki with de-DE language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/de-DE \ ./editions/de-DE \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/de-DE \ --output $TW5_BUILD_OUTPUT/languages/de-DE \
--build favicon empty static index \ --build favicon empty static index \
@@ -402,6 +445,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/es-ES/empty.html Empty wiki with es-ES language # /languages/es-ES/empty.html Empty wiki with es-ES language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/es-ES \ ./editions/es-ES \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/es-ES \ --output $TW5_BUILD_OUTPUT/languages/es-ES \
--build favicon empty static index \ --build favicon empty static index \
@@ -411,6 +455,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/fr-FR/empty.html Empty wiki with fr-FR language # /languages/fr-FR/empty.html Empty wiki with fr-FR language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/fr-FR \ ./editions/fr-FR \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/fr-FR \ --output $TW5_BUILD_OUTPUT/languages/fr-FR \
--build favicon empty static index \ --build favicon empty static index \
@@ -420,6 +465,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/ja-JP/empty.html Empty wiki with ja-JP language # /languages/ja-JP/empty.html Empty wiki with ja-JP language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/ja-JP \ ./editions/ja-JP \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/ja-JP \ --output $TW5_BUILD_OUTPUT/languages/ja-JP \
--build empty index \ --build empty index \
@@ -429,6 +475,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/ko-KR/empty.html Empty wiki with ko-KR language # /languages/ko-KR/empty.html Empty wiki with ko-KR language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/ko-KR \ ./editions/ko-KR \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/ko-KR \ --output $TW5_BUILD_OUTPUT/languages/ko-KR \
--build favicon empty static index \ --build favicon empty static index \
@@ -438,6 +485,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/zh-Hans/empty.html Empty wiki with zh-Hans language # /languages/zh-Hans/empty.html Empty wiki with zh-Hans language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/zh-Hans \ ./editions/zh-Hans \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/zh-Hans \ --output $TW5_BUILD_OUTPUT/languages/zh-Hans \
--build empty index \ --build empty index \
@@ -447,6 +495,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /languages/zh-Hant/empty.html Empty wiki with zh-Hant language # /languages/zh-Hant/empty.html Empty wiki with zh-Hant language
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/zh-Hant \ ./editions/zh-Hant \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/languages/zh-Hant \ --output $TW5_BUILD_OUTPUT/languages/zh-Hant \
--build empty index \ --build empty index \
@@ -460,6 +509,7 @@ node $TW5_BUILD_TIDDLYWIKI \
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/pluginlibrary \ ./editions/pluginlibrary \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \ --load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT/library/$TW5_BUILD_VERSION \ --output $TW5_BUILD_OUTPUT/library/$TW5_BUILD_VERSION \
--build library\ --build library\

View File

@@ -7,4 +7,4 @@ npm --force install tiddlywiki || exit 1
# Pull existing GitHub pages content # Pull existing GitHub pages content
git clone --depth=1 --branch=master "https://github.com/TiddlyWiki/tiddlywiki.com-gh-pages.git" output git clone --depth=1 --branch=master "https://github.com/Jermolene/jermolene.github.io.git" output

View File

@@ -10,6 +10,6 @@ git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions" git config --global user.name "GitHub Actions"
git add -A . git add -A .
git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))" git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))"
git remote add deploy "https://$GH_TOKEN@github.com/TiddlyWiki/tiddlywiki.com-gh-pages.git" &>/dev/null git remote add deploy "https://$GH_TOKEN@github.com/Jermolene/jermolene.github.io.git" &>/dev/null
git push deploy master &>/dev/null git push deploy master &>/dev/null
cd .. cd ..

View File

@@ -2,8 +2,6 @@
# test TiddlyWiki5 for tiddlywiki.com # test TiddlyWiki5 for tiddlywiki.com
npm install
node ./tiddlywiki.js \ node ./tiddlywiki.js \
./editions/test \ ./editions/test \
--verbose \ --verbose \

View File

@@ -10,17 +10,8 @@ fi
# tw5.com readmes # tw5.com readmes
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
+plugins/tiddlywiki/multiwikiserver \
editions/tw5.com \ editions/tw5.com \
--verbose \ --verbose \
--output . \ --output . \
--build readmes \ --build readmes \
|| exit 1 || exit 1
# tw.org readmes
node $TW5_BUILD_TIDDLYWIKI \
editions/tw.org \
--verbose \
--output . \
--build readmes \
|| exit 1

View File

@@ -386,8 +386,8 @@ $tw.utils.parseDate = function(value) {
parseInt(value.substr(10,2)||"00",10), parseInt(value.substr(10,2)||"00",10),
parseInt(value.substr(12,2)||"00",10), parseInt(value.substr(12,2)||"00",10),
parseInt(value.substr(14,3)||"000",10))); parseInt(value.substr(14,3)||"000",10)));
d.setUTCFullYear(year); // See https://stackoverflow.com/a/5870822 d.setUTCFullYear(year); // See https://stackoverflow.com/a/5870822
return d; return d;
} else if($tw.utils.isDate(value)) { } else if($tw.utils.isDate(value)) {
return value; return value;
} else { } else {

View File

@@ -21,7 +21,7 @@ $tw.boot = $tw.boot || Object.create(null);
// Detect platforms // Detect platforms
if(!("browser" in $tw)) { if(!("browser" in $tw)) {
$tw.browser = typeof(window) !== "undefined" && typeof(document) !== "undefined" ? {} : null; $tw.browser = typeof(window) !== "undefined" ? {} : null;
} }
if(!("node" in $tw)) { if(!("node" in $tw)) {
$tw.node = typeof(process) === "object" ? {} : null; $tw.node = typeof(process) === "object" ? {} : null;

View File

@@ -1 +0,0 @@
<p>This community exists because TiddlyWiki is more useful when people share and work together.</p><p>This community is a beautiful but fragile thing: a collection of diverse people from all over the planet, united in their interest in the project, and their commitment to helping one another achieve and learn more.</p><p>We try to make the community as broad and welcoming as possible by remembering some basic principles of culture and behaviour.</p><p>These principles guide technical and non-technical decisions, and help contributors and leaders support our project and community.</p><ul><li>We are optimistic and hopeful</li><li>We aim to foster a learning environment that is collaborative and safe for everyone</li><li>We recognise that the motivation for sharing and helping is usually for appreciation, and not financial gain, and so we take care to acknowledge and <strong>thank the people who enrich the community by sharing what they have created</strong></li><li>While we are united in our interest in TiddlyWiki, we differ in every other conceivable way. We choose to focus on what unites us, and <strong>avoid unnecessarily mixing contentious topics like religion and politics</strong></li><li>We treat each other with respect, and start with the assumption that <strong>others are acting in good faith</strong></li><li>We avoid discriminatory language</li><li>We try to use our strength as a community to help others</li><li>We avoid responding when angry or upset because we try to de-escalate conflict</li><li>We make sure we critique ideas, not people</li><li>When we disagree with others we do so graciously, and treat others with dignity and respoect</li><li>We do not tolerate intolerance towards others</li><li>We seek first to understand others, and then to be understood</li><li>We have fun</li></ul><p>Our discussions are in English. It is not the first language of many people in the community, nor do we all share the same cultural background and reference points. So we take care to use language that is clear and unambigous, and avoid cultural references or jokes that will not be widely understood.</p><p>It is not acceptable to make jokes or other comments that discriminate by race, gender, sexuality, or other protected characteristic.</p><p>As an inclusive community, we are committed to making sure that TiddlyWiki is an accessible tool that understands the needs of people with disabilities.</p>

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +0,0 @@
title: $:/core/images/discord
tags: $:/tags/Image
\parameters (size:"22pt")
<svg width=<<size>> height=<<size>> class="tc-image-discord tc-image-button" viewBox="0 -28.5 256 256"><path d="M216.856 16.597A208.502 208.502 0 0 0 164.042 0c-2.275 4.113-4.933 9.645-6.766 14.046-19.692-2.961-39.203-2.961-58.533 0-1.832-4.4-4.55-9.933-6.846-14.046a207.809 207.809 0 0 0-52.855 16.638C5.618 67.147-3.443 116.4 1.087 164.956c22.169 16.555 43.653 26.612 64.775 33.193A161.094 161.094 0 0 0 79.735 175.3a136.413 136.413 0 0 1-21.846-10.632 108.636 108.636 0 0 0 5.356-4.237c42.122 19.702 87.89 19.702 129.51 0a131.66 131.66 0 0 0 5.355 4.237 136.07 136.07 0 0 1-21.886 10.653c4.006 8.02 8.638 15.67 13.873 22.848 21.142-6.58 42.646-16.637 64.815-33.213 5.316-56.288-9.08-105.09-38.056-148.36ZM85.474 135.095c-12.645 0-23.015-11.805-23.015-26.18s10.149-26.2 23.015-26.2c12.867 0 23.236 11.804 23.015 26.2.02 14.375-10.148 26.18-23.015 26.18Zm85.051 0c-12.645 0-23.014-11.805-23.014-26.18s10.148-26.2 23.014-26.2c12.867 0 23.236 11.804 23.015 26.2 0 14.375-10.148 26.18-23.015 26.18Z"/></svg>

View File

@@ -1,5 +0,0 @@
title: $:/core/images/input-button
tags: $:/tags/Image
\parameters (size:"22pt")
<svg width=<<size>> height=<<size>> class="tc-image-input-button tc-image-button" viewBox="0 0 22 22"><path d="M1.375 22h19.249c.365 0 .716-.145.973-.404v.001c.258-.257.404-.607.403-.972v-11a1.376 1.376 0 0 0-2.75 0v9.625H2.75V9.625a1.376 1.376 0 0 0-2.75 0v11C0 21.384.617 22 1.375 22Z"/><path d="m9.732 11.904-1.541-1.541a1.375 1.375 0 1 0-1.944 1.944l3.887 3.888c.258.258.608.402.973.402h-.001c.353 0 .705-.134.974-.402l3.888-3.889a1.376 1.376 0 0 0 .001-1.944 1.377 1.377 0 0 0-1.946 0l-1.541 1.542V1.376a1.375 1.375 0 1 0-2.75 0v10.528Z"/></svg>

View File

@@ -80,7 +80,6 @@ NewMarkdown/Caption: new Markdown tiddler
NewMarkdown/Hint: Create a new Markdown tiddler NewMarkdown/Hint: Create a new Markdown tiddler
NewTiddler/Caption: new tiddler NewTiddler/Caption: new tiddler
NewTiddler/Hint: Create a new tiddler NewTiddler/Hint: Create a new tiddler
OpenControlPanel/Hint: Open control panel
OpenWindow/Caption: open in new window OpenWindow/Caption: open in new window
OpenWindow/Hint: Open tiddler in new window OpenWindow/Hint: Open tiddler in new window
Palette/Caption: palette Palette/Caption: palette
@@ -105,8 +104,6 @@ ShowSideBar/Caption: show sidebar
ShowSideBar/Hint: Show sidebar ShowSideBar/Hint: Show sidebar
TagManager/Caption: tag manager TagManager/Caption: tag manager
TagManager/Hint: Open tag manager TagManager/Hint: Open tag manager
TestCaseImport/Caption: import tiddlers
TestCaseImport/Hint: Import tiddlers
Timestamp/Caption: timestamps Timestamp/Caption: timestamps
Timestamp/Hint: Choose whether modifications update timestamps Timestamp/Hint: Choose whether modifications update timestamps
Timestamp/On/Caption: timestamps are on Timestamp/On/Caption: timestamps are on
@@ -133,7 +130,6 @@ Excise/Caption/Replace/Link: link
Excise/Caption/Replace/Transclusion: transclusion Excise/Caption/Replace/Transclusion: transclusion
Excise/Caption/Tag: Tag new tiddler with the title of this tiddler Excise/Caption/Tag: Tag new tiddler with the title of this tiddler
Excise/Caption/TiddlerExists: Warning: tiddler already exists Excise/Caption/TiddlerExists: Warning: tiddler already exists
Excise/DefaultTitle: New Excision
Excise/Hint: Excise the selected text into a new tiddler Excise/Hint: Excise the selected text into a new tiddler
Heading1/Caption: heading 1 Heading1/Caption: heading 1
Heading1/Hint: Apply heading level 1 formatting to lines containing selection Heading1/Hint: Apply heading level 1 formatting to lines containing selection

View File

@@ -96,10 +96,6 @@ Plugins/PluginWillRequireReload: (requires reload)
Plugins/Plugins/Caption: Plugins Plugins/Plugins/Caption: Plugins
Plugins/Plugins/Hint: Plugins Plugins/Plugins/Hint: Plugins
Plugins/Reinstall/Caption: reinstall Plugins/Reinstall/Caption: reinstall
Plugins/Stability/Deprecated: DEPRECATED
Plugins/Stability/Experimental: EXPERIMENTAL
Plugins/Stability/Legacy: LEGACY
Plugins/Stability/Stable: STABLE
Plugins/Themes/Caption: Themes Plugins/Themes/Caption: Themes
Plugins/Themes/Hint: Theme plugins Plugins/Themes/Hint: Theme plugins
Plugins/Update/Caption: update Plugins/Update/Caption: update
@@ -175,8 +171,6 @@ Settings/NavigationPermalinkviewMode/UpdateAddressBar/Description: Update addres
Settings/PerformanceInstrumentation/Caption: Performance Instrumentation Settings/PerformanceInstrumentation/Caption: Performance Instrumentation
Settings/PerformanceInstrumentation/Hint: Displays performance statistics in the browser developer console. Requires reload to take effect Settings/PerformanceInstrumentation/Hint: Displays performance statistics in the browser developer console. Requires reload to take effect
Settings/PerformanceInstrumentation/Description: Enable performance instrumentation Settings/PerformanceInstrumentation/Description: Enable performance instrumentation
Settings/RecentLimit/Caption: Recent Tab Limit
Settings/RecentLimit/Hint: Maximum number of tiddlers to be displayed under the sidebar "Recent" tab
Settings/ToolbarButtonStyle/Caption: Toolbar Button Style Settings/ToolbarButtonStyle/Caption: Toolbar Button Style
Settings/ToolbarButtonStyle/Hint: Choose the style for toolbar buttons: Settings/ToolbarButtonStyle/Hint: Choose the style for toolbar buttons:
Settings/ToolbarButtonStyle/Styles/Borderless: Borderless Settings/ToolbarButtonStyle/Styles/Borderless: Borderless
@@ -204,12 +198,6 @@ Settings/TitleLinks/Yes/Description: Display tiddler titles as links
Settings/MissingLinks/Caption: Wiki Links Settings/MissingLinks/Caption: Wiki Links
Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist yet Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist yet
Settings/MissingLinks/Description: Enable links to missing tiddlers Settings/MissingLinks/Description: Enable links to missing tiddlers
SocialCard/Caption: Social Media Card
SocialCard/Domain/Prompt: Domain name to display for the link (for example, ''tiddlywiki.com'')
SocialCard/Hint: This information is used by social and messaging services to display a preview card for links to this ~TiddlyWiki when hosted online
SocialCard/PreviewUrl/Prompt: Full URL to preview image for this ~TiddlyWiki
SocialCard/PreviewUrl/Preview: Preview image:
SocialCard/Url/Prompt: Full URL of this ~TiddlyWiki
StoryTiddler/Caption: Story Tiddler StoryTiddler/Caption: Story Tiddler
StoryTiddler/Hint: This rule cascade is used to dynamically choose the template for displaying a tiddler in the story river. StoryTiddler/Hint: This rule cascade is used to dynamically choose the template for displaying a tiddler in the story river.
StoryView/Caption: Story View StoryView/Caption: Story View
@@ -247,7 +235,3 @@ ViewTemplateBody/Caption: View Template Body
ViewTemplateBody/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the body of a tiddler. ViewTemplateBody/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the body of a tiddler.
ViewTemplateTitle/Caption: View Template Title ViewTemplateTitle/Caption: View Template Title
ViewTemplateTitle/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the title of a tiddler. ViewTemplateTitle/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the title of a tiddler.
ViewTemplateSubtitle/Caption: View Template Subtitle
ViewTemplateSubtitle/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the subtitle of a tiddler.
ViewTemplateTags/Caption: View Template Tags
ViewTemplateTags/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the tags area of a tiddler.

View File

@@ -65,10 +65,6 @@ sidebar-tab-foreground-selected: Sidebar tab foreground for selected tabs
sidebar-tab-foreground: Sidebar tab foreground sidebar-tab-foreground: Sidebar tab foreground
sidebar-tiddler-link-foreground-hover: Sidebar tiddler link foreground hover sidebar-tiddler-link-foreground-hover: Sidebar tiddler link foreground hover
sidebar-tiddler-link-foreground: Sidebar tiddler link foreground sidebar-tiddler-link-foreground: Sidebar tiddler link foreground
stability-stable: Badge for stability level "stable"
stability-experimental: Badge for stability level "experimental"
stability-deprecated: Badge for stability level "deprecated"
stability-legacy: Badge for stability level "legacy"
testcase-accent-level-1: Test case accent colour with no nesting testcase-accent-level-1: Test case accent colour with no nesting
testcase-accent-level-2: Test case accent colour with 2nd level nesting testcase-accent-level-2: Test case accent colour with 2nd level nesting
testcase-accent-level-3: Test case accent colour with 3rd level nesting or higher testcase-accent-level-3: Test case accent colour with 3rd level nesting or higher

View File

@@ -26,8 +26,6 @@ Tags/ClearInput/Caption: clear input
Tags/ClearInput/Hint: Clear tag input Tags/ClearInput/Hint: Clear tag input
Tags/Dropdown/Caption: tag list Tags/Dropdown/Caption: tag list
Tags/Dropdown/Hint: Show tag list Tags/Dropdown/Hint: Show tag list
Tags/EmptyMessage: No tags found
Tags/EmptyMessage/System: No system tags found
Title/BadCharacterWarning: Warning: avoid using any of the characters <<bad-chars>> in tiddler titles Title/BadCharacterWarning: Warning: avoid using any of the characters <<bad-chars>> in tiddler titles
Title/Exists/Prompt: Target tiddler already exists Title/Exists/Prompt: Target tiddler already exists
Title/Relink/Prompt: Update ''<$text text=<<fromTitle>>/>'' to ''<$text text=<<toTitle>>/>'' in the //tags// and //list// fields of other tiddlers Title/Relink/Prompt: Update ''<$text text=<<fromTitle>>/>'' to ''<$text text=<<toTitle>>/>'' in the //tags// and //list// fields of other tiddlers

View File

@@ -6,8 +6,6 @@ Filter/Hint: Search via a [[filter expression|https://tiddlywiki.com/static/Filt
Filter/Matches: //<small><<resultCount>> matches</small>// Filter/Matches: //<small><<resultCount>> matches</small>//
Matches: //<small><<resultCount>> matches</small>// Matches: //<small><<resultCount>> matches</small>//
Matches/All: All matches: Matches/All: All matches:
Matches/NoMatch: //No match//
Matches/NoResult: //No search result//
Matches/Title: Title matches: Matches/Title: Title matches:
Search: Search Search: Search
Search/TooShort: Search text too short Search/TooShort: Search text too short

View File

@@ -1,7 +0,0 @@
title: $:/language/Snippets/FunctionDefinition
tags: $:/tags/TextEditor/Snippet
caption: Function definition
\function f.name(param1,param2:"default value") [<param1>!is[blank]else<param2>]
<<f.name>>

View File

@@ -1,7 +0,0 @@
title: $:/language/Snippets/ProcedureDefinition
tags: $:/tags/TextEditor/Snippet
caption: Procedure definition
\procedure procName(param1:"default value",param2)
Your text comes here.
\end

View File

@@ -0,0 +1,5 @@
title: $:/language/Docs/Types/image/x-icon
description: ICO icon
name: image/x-icon
group: Image
group-sort: 1

View File

@@ -1,5 +0,0 @@
title: $:/language/Docs/Types/text/vnd.tiddlywiki-multiple
description: Compound tiddler
name: text/vnd.tiddlywiki-multiple
group: Developer
group-sort: 2

View File

@@ -38,13 +38,6 @@ Commander.prototype.log = function(str) {
} }
}; };
/*
Clear pending commands
*/
Commander.prototype.clearCommands = function() {
this.commandTokens = this.commandTokens.slice(0,this.nextToken);
};
/* /*
Write a string if verbose flag is set Write a string if verbose flag is set
*/ */

View File

@@ -24,7 +24,7 @@ var Command = function(params,commander) {
Command.prototype.execute = function() { Command.prototype.execute = function() {
// Get the build targets defined in the wiki // Get the build targets defined in the wiki
var buildTargets = $tw.boot.wikiInfo && $tw.boot.wikiInfo.build; var buildTargets = $tw.boot.wikiInfo.build;
if(!buildTargets) { if(!buildTargets) {
return "No build targets defined"; return "No build targets defined";
} }

View File

@@ -120,7 +120,7 @@ Command.prototype.fetchFile = function(url,options,callback,redirectCount) {
} }
}); });
response.on("error",function(e) { response.on("error",function(e) {
console.log("Error on GET request: " + e); self.commander.log("Error on GET request: " + e);
callback(e); callback(e);
}); });
}); });

View File

@@ -16,7 +16,7 @@ var Server = require("$:/core/modules/server/server.js").Server;
exports.info = { exports.info = {
name: "listen", name: "listen",
synchronous: false, synchronous: true,
namedParameterMode: true, namedParameterMode: true,
mandatoryParameters: [] mandatoryParameters: []
}; };
@@ -38,11 +38,7 @@ Command.prototype.execute = function() {
wiki: this.commander.wiki, wiki: this.commander.wiki,
variables: self.params variables: self.params
}); });
var nodeServer = this.server.listen(null,null,null,{ var nodeServer = this.server.listen();
callback: function() {
self.callback();
}
});
$tw.hooks.invokeHook("th-server-command-post-start",this.server,nodeServer,"tiddlywiki"); $tw.hooks.invokeHook("th-server-command-post-start",this.server,nodeServer,"tiddlywiki");
return null; return null;
}; };

View File

@@ -1,37 +0,0 @@
/*\
title: $:/core/modules/commands/quit.js
type: application/javascript
module-type: command
Immediately ends the TiddlyWiki process
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "quit",
synchronous: true
};
var Command = function(params,commander,callback) {
var self = this;
this.params = params;
this.commander = commander;
this.callback = callback;
};
Command.prototype.execute = function() {
// Clear any pending commands
this.commander.clearCommands();
// We don't actually quit, we just issue the "th-quit" hook to give listeners a chance to exit
$tw.hooks.invokeHook("th-quit");
return null;
};
exports.Command = Command;
})();

View File

@@ -45,22 +45,17 @@ Render individual tiddlers and save the results to the specified files
variableList = variableList.slice(2); variableList = variableList.slice(2);
} }
$tw.utils.each(tiddlers,function(title) { $tw.utils.each(tiddlers,function(title) {
var filenameResults = wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title])); var filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
if(filenameResults.length > 0) { if(self.commander.verbose) {
var filepath = path.resolve(self.commander.outputPath,filenameResults[0]); self.commander.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
if(self.commander.verbose) {
console.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
}
var parser = wiki.parseTiddler(template || title),
widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title,storyTiddler: title})}),
container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
var text = type === "text/html" ? container.innerHTML : container.textContent;
$tw.utils.createFileDirectories(filepath);
fs.writeFileSync(filepath,text,"utf8");
} else {
console.log("Not rendering \"" + title + "\" because the filename filter returned an empty result");
} }
var parser = wiki.parseTiddler(template || title),
widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title,storyTiddler: title})}),
container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
var text = type === "text/html" ? container.innerHTML : container.textContent;
$tw.utils.createFileDirectories(filepath);
fs.writeFileSync(filepath,text,"utf8");
}); });
return null; return null;
}; };
@@ -68,4 +63,4 @@ Render individual tiddlers and save the results to the specified files
exports.Command = Command; exports.Command = Command;
})(); })();

View File

@@ -48,7 +48,7 @@ Saves individual tiddlers in their raw text or binary format to the specified fi
} }
}); });
if(self.commander.verbose) { if(self.commander.verbose) {
console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\""); self.commander.log("Saving \"" + title + "\" to \"" + filepath + "\"");
} }
try { try {
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo); $tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);

View File

@@ -30,7 +30,7 @@ exports.textPrimitives.wikiLink = exports.textPrimitives.upperLetter + "+" +
exports.textPrimitives.upperLetter + exports.textPrimitives.upperLetter +
exports.textPrimitives.anyLetter + "*"; exports.textPrimitives.anyLetter + "*";
exports.htmlEntities = {quot:34, dollar:36, amp:38, apos:39, lt:60, gt:62, nbsp:160, iexcl:161, cent:162, pound:163, curren:164, yen:165, brvbar:166, sect:167, uml:168, copy:169, ordf:170, laquo:171, not:172, shy:173, reg:174, macr:175, deg:176, plusmn:177, sup2:178, sup3:179, acute:180, micro:181, para:182, middot:183, cedil:184, sup1:185, ordm:186, raquo:187, frac14:188, frac12:189, frac34:190, iquest:191, Agrave:192, Aacute:193, Acirc:194, Atilde:195, Auml:196, Aring:197, AElig:198, Ccedil:199, Egrave:200, Eacute:201, Ecirc:202, Euml:203, Igrave:204, Iacute:205, Icirc:206, Iuml:207, ETH:208, Ntilde:209, Ograve:210, Oacute:211, Ocirc:212, Otilde:213, Ouml:214, times:215, Oslash:216, Ugrave:217, Uacute:218, Ucirc:219, Uuml:220, Yacute:221, THORN:222, szlig:223, agrave:224, aacute:225, acirc:226, atilde:227, auml:228, aring:229, aelig:230, ccedil:231, egrave:232, eacute:233, ecirc:234, euml:235, igrave:236, iacute:237, icirc:238, iuml:239, eth:240, ntilde:241, ograve:242, oacute:243, ocirc:244, otilde:245, ouml:246, divide:247, oslash:248, ugrave:249, uacute:250, ucirc:251, uuml:252, yacute:253, thorn:254, yuml:255, OElig:338, oelig:339, Scaron:352, scaron:353, Yuml:376, fnof:402, circ:710, tilde:732, Alpha:913, Beta:914, Gamma:915, Delta:916, Epsilon:917, Zeta:918, Eta:919, Theta:920, Iota:921, Kappa:922, Lambda:923, Mu:924, Nu:925, Xi:926, Omicron:927, Pi:928, Rho:929, Sigma:931, Tau:932, Upsilon:933, Phi:934, Chi:935, Psi:936, Omega:937, alpha:945, beta:946, gamma:947, delta:948, epsilon:949, zeta:950, eta:951, theta:952, iota:953, kappa:954, lambda:955, mu:956, nu:957, xi:958, omicron:959, pi:960, rho:961, sigmaf:962, sigma:963, tau:964, upsilon:965, phi:966, chi:967, psi:968, omega:969, thetasym:977, upsih:978, piv:982, ensp:8194, emsp:8195, thinsp:8201, zwnj:8204, zwj:8205, lrm:8206, rlm:8207, ndash:8211, mdash:8212, lsquo:8216, rsquo:8217, sbquo:8218, ldquo:8220, rdquo:8221, bdquo:8222, dagger:8224, Dagger:8225, bull:8226, hellip:8230, permil:8240, prime:8242, Prime:8243, lsaquo:8249, rsaquo:8250, oline:8254, frasl:8260, nobreak:8288, NoBreak:8288, euro:8364, image:8465, weierp:8472, real:8476, trade:8482, alefsym:8501, larr:8592, uarr:8593, rarr:8594, darr:8595, harr:8596, crarr:8629, lArr:8656, uArr:8657, rArr:8658, dArr:8659, hArr:8660, forall:8704, part:8706, exist:8707, empty:8709, nabla:8711, isin:8712, notin:8713, ni:8715, prod:8719, sum:8721, minus:8722, lowast:8727, radic:8730, prop:8733, infin:8734, ang:8736, and:8743, or:8744, cap:8745, cup:8746, int:8747, there4:8756, sim:8764, cong:8773, asymp:8776, ne:8800, equiv:8801, le:8804, ge:8805, sub:8834, sup:8835, nsub:8836, sube:8838, supe:8839, oplus:8853, otimes:8855, perp:8869, sdot:8901, lceil:8968, rceil:8969, lfloor:8970, rfloor:8971, lang:9001, rang:9002, loz:9674, spades:9824, clubs:9827, hearts:9829, diams:9830 }; exports.htmlEntities = {quot:34, dollar:36, amp:38, apos:39, lt:60, gt:62, nbsp:160, iexcl:161, cent:162, pound:163, curren:164, yen:165, brvbar:166, sect:167, uml:168, copy:169, ordf:170, laquo:171, not:172, shy:173, reg:174, macr:175, deg:176, plusmn:177, sup2:178, sup3:179, acute:180, micro:181, para:182, middot:183, cedil:184, sup1:185, ordm:186, raquo:187, frac14:188, frac12:189, frac34:190, iquest:191, Agrave:192, Aacute:193, Acirc:194, Atilde:195, Auml:196, Aring:197, AElig:198, Ccedil:199, Egrave:200, Eacute:201, Ecirc:202, Euml:203, Igrave:204, Iacute:205, Icirc:206, Iuml:207, ETH:208, Ntilde:209, Ograve:210, Oacute:211, Ocirc:212, Otilde:213, Ouml:214, times:215, Oslash:216, Ugrave:217, Uacute:218, Ucirc:219, Uuml:220, Yacute:221, THORN:222, szlig:223, agrave:224, aacute:225, acirc:226, atilde:227, auml:228, aring:229, aelig:230, ccedil:231, egrave:232, eacute:233, ecirc:234, euml:235, igrave:236, iacute:237, icirc:238, iuml:239, eth:240, ntilde:241, ograve:242, oacute:243, ocirc:244, otilde:245, ouml:246, divide:247, oslash:248, ugrave:249, uacute:250, ucirc:251, uuml:252, yacute:253, thorn:254, yuml:255, OElig:338, oelig:339, Scaron:352, scaron:353, Yuml:376, fnof:402, circ:710, tilde:732, Alpha:913, Beta:914, Gamma:915, Delta:916, Epsilon:917, Zeta:918, Eta:919, Theta:920, Iota:921, Kappa:922, Lambda:923, Mu:924, Nu:925, Xi:926, Omicron:927, Pi:928, Rho:929, Sigma:931, Tau:932, Upsilon:933, Phi:934, Chi:935, Psi:936, Omega:937, alpha:945, beta:946, gamma:947, delta:948, epsilon:949, zeta:950, eta:951, theta:952, iota:953, kappa:954, lambda:955, mu:956, nu:957, xi:958, omicron:959, pi:960, rho:961, sigmaf:962, sigma:963, tau:964, upsilon:965, phi:966, chi:967, psi:968, omega:969, thetasym:977, upsih:978, piv:982, ensp:8194, emsp:8195, thinsp:8201, zwnj:8204, zwj:8205, lrm:8206, rlm:8207, ndash:8211, mdash:8212, lsquo:8216, rsquo:8217, sbquo:8218, ldquo:8220, rdquo:8221, bdquo:8222, dagger:8224, Dagger:8225, bull:8226, hellip:8230, permil:8240, prime:8242, Prime:8243, lsaquo:8249, rsaquo:8250, oline:8254, frasl:8260, euro:8364, image:8465, weierp:8472, real:8476, trade:8482, alefsym:8501, larr:8592, uarr:8593, rarr:8594, darr:8595, harr:8596, crarr:8629, lArr:8656, uArr:8657, rArr:8658, dArr:8659, hArr:8660, forall:8704, part:8706, exist:8707, empty:8709, nabla:8711, isin:8712, notin:8713, ni:8715, prod:8719, sum:8721, minus:8722, lowast:8727, radic:8730, prop:8733, infin:8734, ang:8736, and:8743, or:8744, cap:8745, cup:8746, int:8747, there4:8756, sim:8764, cong:8773, asymp:8776, ne:8800, equiv:8801, le:8804, ge:8805, sub:8834, sup:8835, nsub:8836, sube:8838, supe:8839, oplus:8853, otimes:8855, perp:8869, sdot:8901, lceil:8968, rceil:8969, lfloor:8970, rfloor:8971, lang:9001, rang:9002, loz:9674, spades:9824, clubs:9827, hearts:9829, diams:9830 };
exports.htmlVoidElements = "area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(","); exports.htmlVoidElements = "area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",");

View File

@@ -12,27 +12,20 @@ Text editor operation to excise the selection to a new tiddler
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
function isMarkdown(mediaType) {
return mediaType === 'text/markdown' || mediaType === 'text/x-markdown';
}
exports["excise"] = function(event,operation) { exports["excise"] = function(event,operation) {
var editTiddler = this.wiki.getTiddler(this.editTitle), var editTiddler = this.wiki.getTiddler(this.editTitle),
editTiddlerTitle = this.editTitle, editTiddlerTitle = this.editTitle;
wikiLinks = !isMarkdown(editTiddler.fields.type),
excisionBaseTitle = $tw.language.getString("Buttons/Excise/DefaultTitle");
if(editTiddler && editTiddler.fields["draft.of"]) { if(editTiddler && editTiddler.fields["draft.of"]) {
editTiddlerTitle = editTiddler.fields["draft.of"]; editTiddlerTitle = editTiddler.fields["draft.of"];
} }
var excisionTitle = event.paramObject.title || this.wiki.generateNewTitle(excisionBaseTitle); var excisionTitle = event.paramObject.title || this.wiki.generateNewTitle("New Excision");
this.wiki.addTiddler(new $tw.Tiddler( this.wiki.addTiddler(new $tw.Tiddler(
this.wiki.getCreationFields(), this.wiki.getCreationFields(),
this.wiki.getModificationFields(), this.wiki.getModificationFields(),
{ {
title: excisionTitle, title: excisionTitle,
text: operation.selection, text: operation.selection,
tags: event.paramObject.tagnew === "yes" ? [editTiddlerTitle] : [], tags: event.paramObject.tagnew === "yes" ? [editTiddlerTitle] : []
type: editTiddler.fields.type
} }
)); ));
operation.replacement = excisionTitle; operation.replacement = excisionTitle;
@@ -41,8 +34,7 @@ exports["excise"] = function(event,operation) {
operation.replacement = "{{" + operation.replacement+ "}}"; operation.replacement = "{{" + operation.replacement+ "}}";
break; break;
case "link": case "link":
operation.replacement = wikiLinks ? "[[" + operation.replacement+ "]]" operation.replacement = "[[" + operation.replacement+ "]]";
: ("[" + operation.replacement + "](<#" + operation.replacement + ">)");
break; break;
case "macro": case "macro":
operation.replacement = "<<" + (event.paramObject.macro || "translink") + " \"\"\"" + operation.replacement + "\"\"\">>"; operation.replacement = "<<" + (event.paramObject.macro || "translink") + " \"\"\"" + operation.replacement + "\"\"\">>";

View File

@@ -13,125 +13,37 @@ Text editor operation to wrap the selection with the specified prefix and suffix
"use strict"; "use strict";
exports["wrap-selection"] = function(event,operation) { exports["wrap-selection"] = function(event,operation) {
var o = operation, if(operation.selStart === operation.selEnd) {
prefix = event.paramObject.prefix, // No selection; check if we're within the prefix/suffix
suffix = event.paramObject.suffix, if(operation.text.substring(operation.selStart - event.paramObject.prefix.length,operation.selStart + event.paramObject.suffix.length) === event.paramObject.prefix + event.paramObject.suffix) {
trimSelection = event.paramObject.trimSelection || "no",
selLength = o.selEnd - o.selStart;
// This function detects, if trailing spaces are part of the selection __and__ if the user wants to handle them
// Returns "yes", "start", "end", "no" (default)
// yes .. there are trailing spaces at both ends
// start .. there are trailing spaces at the start
// end .. there are trailing spaces at the end
// no .. no trailing spaces are taken into account
var trailingSpaceAt = function(sel) {
var _start,
_end,
result;
// trimSelection is a user parameter, which this evaluations takes into account
switch(trimSelection) {
case "end":
result = (sel.trimEnd().length !== selLength) ? "end" : "no";
break;
case "yes":
_start = sel.trimStart().length !== selLength;
_end = sel.trimEnd().length !== selLength;
result = (_start && _end) ? "yes" : (_start) ? "start" : (_end) ? "end" : "no";
break;
case "start":
result = (sel.trimStart().length !== selLength) ? "start" : "no";
break;
default:
result = "no";
break;
}
return result;
}
function togglePrefixSuffix() {
if(o.text.substring(o.selStart - prefix.length, o.selStart + suffix.length) === prefix + suffix) {
// Remove the prefix and suffix // Remove the prefix and suffix
o.cutStart = o.selStart - prefix.length; operation.cutStart = operation.selStart - event.paramObject.prefix.length;
o.cutEnd = o.selEnd + suffix.length; operation.cutEnd = operation.selEnd + event.paramObject.suffix.length;
o.replacement = ""; operation.replacement = "";
o.newSelStart = o.cutStart; operation.newSelStart = operation.cutStart;
o.newSelEnd = o.newSelStart; operation.newSelEnd = operation.newSelStart;
} else { } else {
// Wrap the cursor instead // Wrap the cursor instead
o.cutStart = o.selStart; operation.cutStart = operation.selStart;
o.cutEnd = o.selEnd; operation.cutEnd = operation.selEnd;
o.replacement = prefix + suffix; operation.replacement = event.paramObject.prefix + event.paramObject.suffix;
o.newSelStart = o.selStart + prefix.length; operation.newSelStart = operation.selStart + event.paramObject.prefix.length;
o.newSelEnd = o.newSelStart; operation.newSelEnd = operation.newSelStart;
} }
} } else if(operation.text.substring(operation.selStart,operation.selStart + event.paramObject.prefix.length) === event.paramObject.prefix && operation.text.substring(operation.selEnd - event.paramObject.suffix.length,operation.selEnd) === event.paramObject.suffix) {
// options: lenPrefix, lenSuffix
function removePrefixSuffix(options) {
options = options || {};
var _lenPrefix = options.lenPrefix || 0;
var _lenSuffix = options.lenSuffix || 0;
o.cutStart = o.selStart - _lenPrefix;
o.cutEnd = o.selEnd + _lenSuffix;
o.replacement = (_lenPrefix || _lenSuffix) ? o.selection : o.selection.substring(prefix.length, o.selection.length - suffix.length);
o.newSelStart = o.cutStart;
o.newSelEnd = o.cutStart + o.replacement.length;
}
function addPrefixSuffix() {
// remove trailing space if requested
switch(trailingSpaceAt(o.selection)) {
case "no":
// has no trailing spaces
o.cutStart = o.selStart;
o.cutEnd = o.selEnd;
o.replacement = prefix + o.selection + suffix;
o.newSelStart = o.selStart;
o.newSelEnd = o.selStart + o.replacement.length;
break;
case "yes":
// handle both ends
o.cutStart = o.selEnd - (o.selection.trimStart().length);
o.cutEnd = o.selection.trimEnd().length + o.selStart;
o.replacement = prefix + o.selection.trim() + suffix;
o.newSelStart = o.cutStart;
o.newSelEnd = o.cutStart + o.replacement.length;
break;
case "start":
// handle leading
o.cutStart = o.selEnd - (o.selection.trimStart().length);
o.cutEnd = o.selEnd;
o.replacement = prefix + o.selection.trimStart() + suffix;
o.newSelStart = o.cutStart;
o.newSelEnd = o.cutStart + o.replacement.length;
break;
case "end":
// handle trailing
o.cutStart = o.selStart;
o.cutEnd = o.selection.trimEnd().length + o.selStart;
o.replacement = prefix + o.selection.trimEnd() + suffix;
o.newSelStart = o.selStart;
o.newSelEnd = o.selStart + o.replacement.length;
break;
}
}
if(o.selStart === o.selEnd) {
// No selection; Create prefix and suffix. Set cursor in between them: ""|""
togglePrefixSuffix();
} else if(o.text.substring(o.selStart, o.selStart + prefix.length) === prefix &&
o.text.substring(o.selEnd - suffix.length,o.selEnd) === suffix) {
// Prefix and suffix are already present, so remove them // Prefix and suffix are already present, so remove them
removePrefixSuffix(); operation.cutStart = operation.selStart;
} else if(o.text.substring(o.selStart - prefix.length, o.selStart) === prefix && operation.cutEnd = operation.selEnd;
o.text.substring(o.selEnd, o.selEnd + suffix.length) === suffix) { operation.replacement = operation.selection.substring(event.paramObject.prefix.length,operation.selection.length - event.paramObject.suffix.length);
// Prefix and suffix are present BUT not selected -> remove them operation.newSelStart = operation.selStart;
removePrefixSuffix({"lenPrefix": prefix.length, "lenSuffix": suffix.length}); operation.newSelEnd = operation.selStart + operation.replacement.length;
} else { } else {
// Add the prefix and suffix // Add the prefix and suffix
addPrefixSuffix(); operation.cutStart = operation.selStart;
operation.cutEnd = operation.selEnd;
operation.replacement = event.paramObject.prefix + operation.selection + event.paramObject.suffix;
operation.newSelStart = operation.selStart;
operation.newSelEnd = operation.selStart + operation.replacement.length;
} }
}; };

View File

@@ -16,11 +16,11 @@ Filter operator for returning all the backtranscludes from a tiddler
Export our filter function Export our filter function
*/ */
exports.backtranscludes = function(source,operator,options) { exports.backtranscludes = function(source,operator,options) {
var results = new $tw.utils.LinkedList(); var results = [];
source(function(tiddler,title) { source(function(tiddler,title) {
results.pushTop(options.wiki.getTiddlerBacktranscludes(title)); $tw.utils.pushTop(results,options.wiki.getTiddlerBacktranscludes(title));
}); });
return results.makeTiddlerIterator(options.wiki); return results;
}; };
})(); })();

View File

@@ -18,8 +18,8 @@ Export our filter functions
exports.decodebase64 = function(source,operator,options) { exports.decodebase64 = function(source,operator,options) {
var results = []; var results = [];
var binary = operator.suffixes && operator.suffixes[0].indexOf("binary") !== -1; var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes[0].indexOf("urlsafe") !== -1; var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
source(function(tiddler,title) { source(function(tiddler,title) {
results.push($tw.utils.base64Decode(title,binary,urlsafe)); results.push($tw.utils.base64Decode(title,binary,urlsafe));
}); });
@@ -28,8 +28,8 @@ exports.decodebase64 = function(source,operator,options) {
exports.encodebase64 = function(source,operator,options) { exports.encodebase64 = function(source,operator,options) {
var results = []; var results = [];
var binary = operator.suffixes && operator.suffixes[0].indexOf("binary") !== -1; var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes[0].indexOf("urlsafe") !== -1; var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
source(function(tiddler,title) { source(function(tiddler,title) {
results.push($tw.utils.base64Encode(title,binary,urlsafe)); results.push($tw.utils.base64Encode(title,binary,urlsafe));
}); });

View File

@@ -127,7 +127,7 @@ function diffPartsToChars(text1,text2,mode) {
if(lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : (lineHash[line] !== undefined)) { if(lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : (lineHash[line] !== undefined)) {
chars += String.fromCharCode(lineHash[line]); chars += String.fromCharCode(lineHash[line]);
} else { } else {
if(lineArrayLength == maxLines) { if (lineArrayLength == maxLines) {
line = text.substring(lineStart); line = text.substring(lineStart);
lineEnd = text.length; lineEnd = text.length;
} }
@@ -217,10 +217,7 @@ exports.splitregexp = function(source,operator,options) {
return ["RegExp error: " + ex]; return ["RegExp error: " + ex];
} }
source(function(tiddler,title) { source(function(tiddler,title) {
var parts = title.split(regExp).map(function(part){ Array.prototype.push.apply(result,title.split(regExp));
return part || ""; // make sure it's a string
});
Array.prototype.push.apply(result,parts);
}); });
return result; return result;
}; };
@@ -267,7 +264,7 @@ exports.pad = function(source,operator,options) {
} else { } else {
var padString = "", var padString = "",
padStringLength = targetLength - title.length; padStringLength = targetLength - title.length;
while(padStringLength > padString.length) { while (padStringLength > padString.length) {
padString += fill; padString += fill;
} }
//make sure we do not exceed the specified length //make sure we do not exceed the specified length

View File

@@ -20,7 +20,7 @@ exports.transcludes = function(source,operator,options) {
source(function(tiddler,title) { source(function(tiddler,title) {
results.pushTop(options.wiki.getTiddlerTranscludes(title)); results.pushTop(options.wiki.getTiddlerTranscludes(title));
}); });
return results.makeTiddlerIterator(options.wiki); return results.toArray();
}; };
})(); })();

View File

@@ -75,7 +75,7 @@ BackSubIndexer.prototype._getTarget = function(tiddler) {
} }
var parser = this.wiki.parseText(tiddler.fields.type, tiddler.fields.text, {}); var parser = this.wiki.parseText(tiddler.fields.type, tiddler.fields.text, {});
if(parser) { if(parser) {
return this.wiki[this.extractor](parser.tree, tiddler.fields.title); return this.wiki[this.extractor](parser.tree);
} }
return []; return [];
} }

View File

@@ -16,22 +16,20 @@ exports.name = "unusedtitle";
exports.params = [ exports.params = [
{name: "baseName"}, {name: "baseName"},
{name: "separator"}, {name: "separator"},
{name: "template"}, {name: "template"}
{name: "startCount"}
]; ];
/* /*
Run the macro Run the macro
*/ */
exports.run = function(baseName,separator,template,startCount) { exports.run = function(baseName,separator,template) {
separator = separator || " "; separator = separator || " ";
startCount = startCount || 0;
if(!baseName) { if(!baseName) {
baseName = $tw.language.getString("DefaultNewTiddlerTitle"); baseName = $tw.language.getString("DefaultNewTiddlerTitle");
} }
// $tw.wiki.generateNewTitle = function(baseTitle,options) // $tw.wiki.generateNewTitle = function(baseTitle,options)
// options.prefix must be a string! // options.prefix must be a string!
return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template, "startCount": startCount}); return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template});
}; };
})(); })();

View File

@@ -114,7 +114,7 @@ exports.parseStringLiteral = function(source,pos) {
var match = reString.exec(source); var match = reString.exec(source);
if(match && match.index === pos) { if(match && match.index === pos) {
node.value = match[1] !== undefined ? match[1] :( node.value = match[1] !== undefined ? match[1] :(
match[2] !== undefined ? match[2] : match[3] match[2] !== undefined ? match[2] : match[3]
); );
node.end = pos + match[0].length; node.end = pos + match[0].length;
return node; return node;

View File

@@ -29,16 +29,13 @@ exports.init = function(parser) {
exports.parse = function() { exports.parse = function() {
var reEnd = /(\r?\n```$)/mg; var reEnd = /(\r?\n```$)/mg;
var languageStart = this.parser.pos + 3,
languageEnd = languageStart + this.match[1].length;
// Move past the match // Move past the match
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Look for the end of the block // Look for the end of the block
reEnd.lastIndex = this.parser.pos; reEnd.lastIndex = this.parser.pos;
var match = reEnd.exec(this.parser.source), var match = reEnd.exec(this.parser.source),
text, text;
codeStart = this.parser.pos;
// Process the block // Process the block
if(match) { if(match) {
text = this.parser.source.substring(this.parser.pos,match.index); text = this.parser.source.substring(this.parser.pos,match.index);
@@ -51,8 +48,8 @@ exports.parse = function() {
return [{ return [{
type: "codeblock", type: "codeblock",
attributes: { attributes: {
code: {type: "string", value: text, start: codeStart, end: this.parser.pos}, code: {type: "string", value: text},
language: {type: "string", value: this.match[1], start: languageStart, end: languageEnd} language: {type: "string", value: this.match[1]}
} }
}]; }];
}; };

View File

@@ -33,8 +33,7 @@ exports.parse = function() {
// Look for the end marker // Look for the end marker
reEnd.lastIndex = this.parser.pos; reEnd.lastIndex = this.parser.pos;
var match = reEnd.exec(this.parser.source), var match = reEnd.exec(this.parser.source),
text, text;
start = this.parser.pos;
// Process the text // Process the text
if(match) { if(match) {
text = this.parser.source.substring(this.parser.pos,match.index); text = this.parser.source.substring(this.parser.pos,match.index);
@@ -48,9 +47,7 @@ exports.parse = function() {
tag: "code", tag: "code",
children: [{ children: [{
type: "text", type: "text",
text: text, text: text
start: start,
end: this.parser.pos
}] }]
}]; }];
}; };

View File

@@ -6,7 +6,7 @@ module-type: wikirule
Conditional shortcut syntax Conditional shortcut syntax
``` ```
This is a <%if [{something}] %>Elephant<%elseif [{else}] %>Pelican<%else%>Crocodile<%endif%> This is a <% if [{something}] %>Elephant<% elseif [{else}] %>Pelican<% else %>Crocodile<% endif %>
``` ```
\*/ \*/
@@ -27,7 +27,7 @@ exports.init = function(parser) {
}; };
exports.findNextMatch = function(startPos) { exports.findNextMatch = function(startPos) {
// Look for the next <%if shortcut // Look for the next <% if shortcut
this.matchRegExp.lastIndex = startPos; this.matchRegExp.lastIndex = startPos;
this.match = this.matchRegExp.exec(this.parser.source); this.match = this.matchRegExp.exec(this.parser.source);
// If not found then return no match // If not found then return no match

View File

@@ -31,7 +31,6 @@ exports.init = function(parser) {
exports.parse = function() { exports.parse = function() {
// Move past the match // Move past the match
var start = this.parser.pos;
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Create the link unless it is suppressed // Create the link unless it is suppressed
if(this.match[0].substr(0,1) === "~") { if(this.match[0].substr(0,1) === "~") {
@@ -47,7 +46,7 @@ exports.parse = function() {
rel: {type: "string", value: "noopener noreferrer"} rel: {type: "string", value: "noopener noreferrer"}
}, },
children: [{ children: [{
type: "text", text: this.match[0], start: start, end: this.parser.pos type: "text", text: this.match[0]
}] }]
}]; }];
} }

View File

@@ -31,16 +31,6 @@ exports.init = function(parser) {
exports.parse = function() { exports.parse = function() {
// Move past the match // Move past the match
var filterStart = this.parser.pos + 3;
var filterEnd = filterStart + this.match[1].length;
var toolTipStart = filterEnd + 1;
var toolTipEnd = toolTipStart + (this.match[2] ? this.match[2].length : 0);
var templateStart = toolTipEnd + 2;
var templateEnd = templateStart + (this.match[3] ? this.match[3].length : 0);
var styleStart = templateEnd + 2;
var styleEnd = styleStart + (this.match[4] ? this.match[4].length : 0);
var classesStart = styleEnd + 1;
var classesEnd = classesStart + (this.match[5] ? this.match[5].length : 0);
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Get the match details // Get the match details
var filter = this.match[1], var filter = this.match[1],
@@ -52,21 +42,21 @@ exports.parse = function() {
var node = { var node = {
type: "list", type: "list",
attributes: { attributes: {
filter: {type: "string", value: filter, start: filterStart, end: filterEnd}, filter: {type: "string", value: filter}
}, },
isBlock: true isBlock: true
}; };
if(tooltip) { if(tooltip) {
node.attributes.tooltip = {type: "string", value: tooltip, start: toolTipStart, end: toolTipEnd}; node.attributes.tooltip = {type: "string", value: tooltip};
} }
if(template) { if(template) {
node.attributes.template = {type: "string", value: template, start: templateStart, end: templateEnd}; node.attributes.template = {type: "string", value: template};
} }
if(style) { if(style) {
node.attributes.style = {type: "string", value: style, start: styleStart, end: styleEnd}; node.attributes.style = {type: "string", value: style};
} }
if(classes) { if(classes) {
node.attributes.itemClass = {type: "string", value: classes.split(".").join(" "), start: classesStart, end: classesEnd}; node.attributes.itemClass = {type: "string", value: classes.split(".").join(" ")};
} }
return [node]; return [node];
}; };

View File

@@ -30,16 +30,6 @@ exports.init = function(parser) {
}; };
exports.parse = function() { exports.parse = function() {
var filterStart = this.parser.pos + 3;
var filterEnd = filterStart + this.match[1].length;
var toolTipStart = filterEnd + 1;
var toolTipEnd = toolTipStart + (this.match[2] ? this.match[2].length : 0);
var templateStart = toolTipEnd + 2;
var templateEnd = templateStart + (this.match[3] ? this.match[3].length : 0);
var styleStart = templateEnd + 2;
var styleEnd = styleStart + (this.match[4] ? this.match[4].length : 0);
var classesStart = styleEnd + 1;
var classesEnd = classesStart + (this.match[5] ? this.match[5].length : 0);
// Move past the match // Move past the match
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Get the match details // Get the match details
@@ -52,20 +42,20 @@ exports.parse = function() {
var node = { var node = {
type: "list", type: "list",
attributes: { attributes: {
filter: {type: "string", value: filter, start: filterStart, end: filterEnd}, filter: {type: "string", value: filter}
} }
}; };
if(tooltip) { if(tooltip) {
node.attributes.tooltip = {type: "string", value: tooltip, start: toolTipStart, end: toolTipEnd}; node.attributes.tooltip = {type: "string", value: tooltip};
} }
if(template) { if(template) {
node.attributes.template = {type: "string", value: template, start: templateStart, end: templateEnd}; node.attributes.template = {type: "string", value: template};
} }
if(style) { if(style) {
node.attributes.style = {type: "string", value: style, start: styleStart, end: styleEnd}; node.attributes.style = {type: "string", value: style};
} }
if(classes) { if(classes) {
node.attributes.itemClass = {type: "string", value: classes.split(".").join(" "), start: classesStart, end: classesEnd}; node.attributes.itemClass = {type: "string", value: classes.split(".").join(" ")};
} }
return [node]; return [node];
}; };

View File

@@ -45,11 +45,10 @@ exports.parse = function() {
reEnd.lastIndex = this.parser.pos; reEnd.lastIndex = this.parser.pos;
match = reEnd.exec(this.parser.source); match = reEnd.exec(this.parser.source);
if(match) { if(match) {
var start = this.parser.pos;
this.parser.pos = reEnd.lastIndex; this.parser.pos = reEnd.lastIndex;
// Add a line break if the terminator was a line break // Add a line break if the terminator was a line break
if(match[2]) { if(match[2]) {
tree.push({type: "element", tag: "br", start: start, end: this.parser.pos}); tree.push({type: "element", tag: "br"});
} }
} }
} while(match && !match[1]); } while(match && !match[1]);

View File

@@ -30,17 +30,15 @@ exports.parse = function() {
// Move past the !s // Move past the !s
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Parse any classes, whitespace and then the heading itself // Parse any classes, whitespace and then the heading itself
var classStart = this.parser.pos;
var classes = this.parser.parseClasses(); var classes = this.parser.parseClasses();
var classEnd = this.parser.pos;
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true}); this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
var tree = this.parser.parseInlineRun(/(\r?\n)/mg); var tree = this.parser.parseInlineRun(/(\r?\n)/mg);
// Return the heading // Return the heading
return [{ return [{
type: "element", type: "element",
tag: "h" + headingLevel, tag: "h" + headingLevel,
attributes: { attributes: {
"class": {type: "string", value: classes.join(" "), start: classStart, end: classEnd} "class": {type: "string", value: classes.join(" ")}
}, },
children: tree children: tree
}]; }];

View File

@@ -44,10 +44,6 @@ Parse the most recent match
exports.parse = function() { exports.parse = function() {
// Retrieve the most recent match so that recursive calls don't overwrite it // Retrieve the most recent match so that recursive calls don't overwrite it
var tag = this.nextTag; var tag = this.nextTag;
if (!tag.isSelfClosing) {
tag.openTagStart = tag.start;
tag.openTagEnd = tag.end;
}
this.nextTag = null; this.nextTag = null;
// Advance the parser position to past the tag // Advance the parser position to past the tag
this.parser.pos = tag.end; this.parser.pos = tag.end;
@@ -64,27 +60,6 @@ exports.parse = function() {
var reEnd = new RegExp("(" + reEndString + ")","mg"); var reEnd = new RegExp("(" + reEndString + ")","mg");
tag.children = this.parser.parseInlineRun(reEnd,{eatTerminator: true}); tag.children = this.parser.parseInlineRun(reEnd,{eatTerminator: true});
} }
tag.end = this.parser.pos;
tag.closeTagEnd = tag.end;
if (tag.closeTagEnd === tag.openTagEnd || this.parser.source[tag.closeTagEnd - 1] !== '>') {
tag.closeTagStart = tag.end;
} else {
tag.closeTagStart = tag.closeTagEnd - 2;
var closeTagMinPos = tag.children.length > 0 ? tag.children[tag.children.length-1].end : tag.openTagEnd;
if (!Number.isSafeInteger(closeTagMinPos)) closeTagMinPos = tag.openTagEnd;
while (tag.closeTagStart >= closeTagMinPos) {
var char = this.parser.source[tag.closeTagStart];
if (char === '>') {
tag.closeTagStart = -1;
break;
}
if (char === '<') break;
tag.closeTagStart -= 1;
}
if (tag.closeTagStart < closeTagMinPos) {
tag.closeTagStart = tag.end;
}
}
} }
// Return the tag // Return the tag
return [tag]; return [tag];

View File

@@ -122,9 +122,9 @@ exports.parseImage = function(source,pos) {
} }
pos = token.end; pos = token.end;
if(token.match[1]) { if(token.match[1]) {
node.attributes.tooltip = {type: "string", value: token.match[1].trim(),start: token.start,end:token.start + token.match[1].length - 1}; node.attributes.tooltip = {type: "string", value: token.match[1].trim()};
} }
node.attributes.source = {type: "string", value: (token.match[2] || "").trim(), start: token.start + (token.match[1] ? token.match[1].length : 0), end: token.end - 2}; node.attributes.source = {type: "string", value: (token.match[2] || "").trim()};
// Update the end position // Update the end position
node.end = pos; node.end = pos;
return node; return node;

View File

@@ -38,14 +38,13 @@ exports.parse = function() {
// Parse the filter terminated by a line break // Parse the filter terminated by a line break
var reMatch = /(.*)(?:$|\r?\n)/mg; var reMatch = /(.*)(?:$|\r?\n)/mg;
reMatch.lastIndex = this.parser.pos; reMatch.lastIndex = this.parser.pos;
var filterStart = this.parser.source;
var match = reMatch.exec(this.parser.source); var match = reMatch.exec(this.parser.source);
this.parser.pos = reMatch.lastIndex; this.parser.pos = reMatch.lastIndex;
// Parse tree nodes to return // Parse tree nodes to return
return [{ return [{
type: "importvariables", type: "importvariables",
attributes: { attributes: {
filter: {type: "string", value: match[1], start: filterStart, end: this.parser.pos} filter: {type: "string", value: match[1]}
}, },
children: [] children: []
}]; }];

View File

@@ -74,7 +74,6 @@ exports.parse = function() {
// Match the list marker // Match the list marker
var reMatch = /([\*#;:>]+)/mg; var reMatch = /([\*#;:>]+)/mg;
reMatch.lastIndex = this.parser.pos; reMatch.lastIndex = this.parser.pos;
var start = this.parser.pos;
var match = reMatch.exec(this.parser.source); var match = reMatch.exec(this.parser.source);
if(!match || match.index !== this.parser.pos) { if(!match || match.index !== this.parser.pos) {
break; break;
@@ -95,21 +94,9 @@ exports.parse = function() {
} }
// Construct the list element or reuse the previous one at this level // Construct the list element or reuse the previous one at this level
if(listStack.length <= t) { if(listStack.length <= t) {
var listElement = { var listElement = {type: "element", tag: listInfo.listTag, children: [
type: "element", {type: "element", tag: listInfo.itemTag, children: []}
tag: listInfo.listTag, ]};
children: [
{
type: "element",
tag: listInfo.itemTag,
children: [],
start: start,
end: this.parser.pos,
}
],
start: start,
end: this.parser.pos,
};
// Link this list element into the last child item of the parent list item // Link this list element into the last child item of the parent list item
if(t) { if(t) {
var prevListItem = listStack[t-1].children[listStack[t-1].children.length-1]; var prevListItem = listStack[t-1].children[listStack[t-1].children.length-1];
@@ -118,33 +105,21 @@ exports.parse = function() {
// Save this element in the stack // Save this element in the stack
listStack[t] = listElement; listStack[t] = listElement;
} else if(t === (match[0].length - 1)) { } else if(t === (match[0].length - 1)) {
listStack[t].children.push({ listStack[t].children.push({type: "element", tag: listInfo.itemTag, children: []});
type: "element",
tag: listInfo.itemTag,
children: [],
start: start,
end: this.parser.pos,
});
} }
} }
if(listStack.length > match[0].length) { if(listStack.length > match[0].length) {
listStack.splice(match[0].length,listStack.length - match[0].length); listStack.splice(match[0].length,listStack.length - match[0].length);
} }
// Process the body of the list item into the last list item // Process the body of the list item into the last list item
var classStart = this.parser.pos;
var lastListChildren = listStack[listStack.length-1].children, var lastListChildren = listStack[listStack.length-1].children,
lastListItem = lastListChildren[lastListChildren.length-1], lastListItem = lastListChildren[lastListChildren.length-1],
classes = this.parser.parseClasses(); classes = this.parser.parseClasses();
var classEnd = this.parser.pos;
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true}); this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
var tree = this.parser.parseInlineRun(/(\r?\n)/mg); var tree = this.parser.parseInlineRun(/(\r?\n)/mg);
lastListItem.children.push.apply(lastListItem.children,tree); lastListItem.children.push.apply(lastListItem.children,tree);
lastListItem.end = this.parser.pos;
listStack[listStack.length-1].end = this.parser.pos;
if(classes.length > 0) { if(classes.length > 0) {
$tw.utils.addClassToParseTreeNode(lastListItem,classes.join(" ")); $tw.utils.addClassToParseTreeNode(lastListItem,classes.join(" "));
lastListItem.attributes.class.start = classStart;
lastListItem.attributes.class.end = classEnd;
} }
// Consume any whitespace following the list item // Consume any whitespace following the list item
this.parser.skipWhitespace(); this.parser.skipWhitespace();

View File

@@ -96,20 +96,15 @@ exports.parseLink = function(source,pos) {
splitPos = null; splitPos = null;
} }
// Pull out the tooltip and URL // Pull out the tooltip and URL
var tooltip, URL, urlStart; var tooltip, URL;
textNode.start = pos;
if(splitPos) { if(splitPos) {
urlStart = splitPos + 1;
URL = source.substring(splitPos + 1,closePos).trim(); URL = source.substring(splitPos + 1,closePos).trim();
textNode.text = source.substring(pos,splitPos).trim(); textNode.text = source.substring(pos,splitPos).trim();
textNode.end = splitPos;
} else { } else {
urlStart = pos;
URL = source.substring(pos,closePos).trim(); URL = source.substring(pos,closePos).trim();
textNode.text = URL; textNode.text = URL;
textNode.end = closePos;
} }
node.attributes.href = {type: "string", value: URL, start: urlStart, end: closePos}; node.attributes.href = {type: "string", value: URL};
node.attributes.target = {type: "string", value: "_blank"}; node.attributes.target = {type: "string", value: "_blank"};
node.attributes.rel = {type: "string", value: "noopener noreferrer"}; node.attributes.rel = {type: "string", value: "noopener noreferrer"};
// Update the end position // Update the end position

View File

@@ -29,39 +29,32 @@ exports.init = function(parser) {
exports.parse = function() { exports.parse = function() {
// Move past the match // Move past the match
var start = this.parser.pos + 2;
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Process the link // Process the link
var text = this.match[1], var text = this.match[1],
link = this.match[2] || text, link = this.match[2] || text;
textEndPos = this.parser.source.indexOf("|", start);
if (textEndPos < 0 || textEndPos > this.matchRegExp.lastIndex) {
textEndPos = this.matchRegExp.lastIndex - 2;
}
var linkStart = this.match[2] ? (start + this.match[1].length + 1) : start;
var linkEnd = linkStart + link.length;
if($tw.utils.isLinkExternal(link)) { if($tw.utils.isLinkExternal(link)) {
return [{ return [{
type: "element", type: "element",
tag: "a", tag: "a",
attributes: { attributes: {
href: {type: "string", value: link, start: linkStart, end: linkEnd}, href: {type: "string", value: link},
"class": {type: "string", value: "tc-tiddlylink-external"}, "class": {type: "string", value: "tc-tiddlylink-external"},
target: {type: "string", value: "_blank"}, target: {type: "string", value: "_blank"},
rel: {type: "string", value: "noopener noreferrer"} rel: {type: "string", value: "noopener noreferrer"}
}, },
children: [{ children: [{
type: "text", text: text, start: start, end: textEndPos type: "text", text: text
}] }]
}]; }];
} else { } else {
return [{ return [{
type: "link", type: "link",
attributes: { attributes: {
to: {type: "string", value: link, start: linkStart, end: linkEnd} to: {type: "string", value: link}
}, },
children: [{ children: [{
type: "text", text: text, start: start, end: textEndPos type: "text", text: text
}] }]
}]; }];
} }

View File

@@ -28,13 +28,9 @@ exports.parse = function() {
// Move past the <s // Move past the <s
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Parse any classes, whitespace and then the optional cite itself // Parse any classes, whitespace and then the optional cite itself
var classStart = this.parser.pos;
classes.push.apply(classes, this.parser.parseClasses()); classes.push.apply(classes, this.parser.parseClasses());
var classEnd = this.parser.pos;
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true}); this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
var citeStart = this.parser.pos;
var cite = this.parser.parseInlineRun(/(\r?\n)/mg); var cite = this.parser.parseInlineRun(/(\r?\n)/mg);
var citeEnd = this.parser.pos;
// before handling the cite, parse the body of the quote // before handling the cite, parse the body of the quote
var tree = this.parser.parseBlocks(reEndString); var tree = this.parser.parseBlocks(reEndString);
// If we got a cite, put it before the text // If we got a cite, put it before the text
@@ -42,24 +38,18 @@ exports.parse = function() {
tree.unshift({ tree.unshift({
type: "element", type: "element",
tag: "cite", tag: "cite",
children: cite, children: cite
start: citeStart,
end: citeEnd
}); });
} }
// Parse any optional cite // Parse any optional cite
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true}); this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
citeStart = this.parser.pos;
cite = this.parser.parseInlineRun(/(\r?\n)/mg); cite = this.parser.parseInlineRun(/(\r?\n)/mg);
citeEnd = this.parser.pos;
// If we got a cite, push it // If we got a cite, push it
if(cite.length > 0) { if(cite.length > 0) {
tree.push({ tree.push({
type: "element", type: "element",
tag: "cite", tag: "cite",
children: cite, children: cite
start: citeStart,
end: citeEnd
}); });
} }
// Return the blockquote element // Return the blockquote element
@@ -67,7 +57,7 @@ exports.parse = function() {
type: "element", type: "element",
tag: "blockquote", tag: "blockquote",
attributes: { attributes: {
class: { type: "string", value: classes.join(" "), start: classStart, end: classEnd }, class: { type: "string", value: classes.join(" ") },
}, },
children: tree children: tree
}]; }];

View File

@@ -29,11 +29,10 @@ exports.init = function(parser) {
exports.parse = function() { exports.parse = function() {
var match = this.match[0]; var match = this.match[0];
// Move past the match // Move past the match
var start = this.parser.pos;
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Create the link unless it is suppressed // Create the link unless it is suppressed
if(match.substr(0,1) === "~") { if(match.substr(0,1) === "~") {
return [{type: "text", text: match.substr(1), start: start+1, end: this.parser.pos}]; return [{type: "text", text: match.substr(1)}];
} else { } else {
return [{ return [{
type: "link", type: "link",
@@ -42,12 +41,10 @@ exports.parse = function() {
}, },
children: [{ children: [{
type: "text", type: "text",
text: match, text: match
start: start,
end: this.parser.pos
}] }]
}]; }];
} }
}; };
})(); })();

View File

@@ -93,12 +93,11 @@ var processRow = function(prevColumns) {
} }
// Check whether this is a heading cell // Check whether this is a heading cell
var cell; var cell;
var start = this.parser.pos;
if(chr === "!") { if(chr === "!") {
this.parser.pos++; this.parser.pos++;
cell = {type: "element", tag: "th", start: start, children: []}; cell = {type: "element", tag: "th", children: []};
} else { } else {
cell = {type: "element", tag: "td", start: start, children: []}; cell = {type: "element", tag: "td", children: []};
} }
tree.push(cell); tree.push(cell);
// Record information about this cell // Record information about this cell
@@ -122,7 +121,6 @@ var processRow = function(prevColumns) {
} }
// Move back to the closing `|` // Move back to the closing `|`
this.parser.pos--; this.parser.pos--;
cell.end = this.parser.pos;
} }
col++; col++;
cellRegExp.lastIndex = this.parser.pos; cellRegExp.lastIndex = this.parser.pos;
@@ -152,7 +150,7 @@ exports.parse = function() {
} else { } else {
// Otherwise, create a new row if this one is of a different type // Otherwise, create a new row if this one is of a different type
if(rowType !== currRowType) { if(rowType !== currRowType) {
rowContainer = {type: "element", tag: rowContainerTypes[rowType], children: [], start: this.parser.pos, end: this.parser.pos}; rowContainer = {type: "element", tag: rowContainerTypes[rowType], children: []};
table.children.push(rowContainer); table.children.push(rowContainer);
currRowType = rowType; currRowType = rowType;
} }
@@ -171,17 +169,15 @@ exports.parse = function() {
rowContainer.children = this.parser.parseInlineRun(rowTermRegExp,{eatTerminator: true}); rowContainer.children = this.parser.parseInlineRun(rowTermRegExp,{eatTerminator: true});
} else { } else {
// Create the row // Create the row
var theRow = {type: "element", tag: "tr", children: [], start: rowMatch.index}; var theRow = {type: "element", tag: "tr", children: []};
$tw.utils.addClassToParseTreeNode(theRow,rowCount%2 ? "oddRow" : "evenRow"); $tw.utils.addClassToParseTreeNode(theRow,rowCount%2 ? "oddRow" : "evenRow");
rowContainer.children.push(theRow); rowContainer.children.push(theRow);
// Process the row // Process the row
theRow.children = processRow.call(this,prevColumns); theRow.children = processRow.call(this,prevColumns);
this.parser.pos = rowMatch.index + rowMatch[0].length; this.parser.pos = rowMatch.index + rowMatch[0].length;
theRow.end = this.parser.pos;
// Increment the row count // Increment the row count
rowCount++; rowCount++;
} }
rowContainer.end = this.parser.pos;
} }
rowMatch = rowRegExp.exec(this.parser.source); rowMatch = rowRegExp.exec(this.parser.source);
} }

View File

@@ -46,7 +46,6 @@ exports.parse = function() {
renderType = this.match[2]; renderType = this.match[2];
// Move past the match // Move past the match
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
var start = this.parser.pos;
// Look for the end of the block // Look for the end of the block
reEnd.lastIndex = this.parser.pos; reEnd.lastIndex = this.parser.pos;
var match = reEnd.exec(this.parser.source), var match = reEnd.exec(this.parser.source),
@@ -75,9 +74,7 @@ exports.parse = function() {
tag: "pre", tag: "pre",
children: [{ children: [{
type: "text", type: "text",
text: text, text: text
start: start,
end: this.parser.pos
}] }]
}]; }];
} }

View File

@@ -36,7 +36,6 @@ exports.parse = function() {
// Get the details of the match // Get the details of the match
var linkText = this.match[0]; var linkText = this.match[0];
// Move past the macro call // Move past the macro call
var start = this.parser.pos;
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// If the link starts with the unwikilink character then just output it as plain text // If the link starts with the unwikilink character then just output it as plain text
if(linkText.substr(0,1) === $tw.config.textPrimitives.unWikiLink) { if(linkText.substr(0,1) === $tw.config.textPrimitives.unWikiLink) {
@@ -58,9 +57,7 @@ exports.parse = function() {
}, },
children: [{ children: [{
type: "text", type: "text",
text: linkText, text: linkText
start: start,
end: this.parser.pos
}] }]
}]; }];
}; };

View File

@@ -91,11 +91,6 @@ var WikiParser = function(type,text,options) {
} else { } else {
topBranch.push.apply(topBranch,this.parseBlocks()); topBranch.push.apply(topBranch,this.parseBlocks());
} }
// Build rules' name map
this.usingRuleMap = {};
$tw.utils.each(this.pragmaRules, function (ruleInfo) { self.usingRuleMap[ruleInfo.rule.name] = Object.getPrototypeOf(ruleInfo.rule); });
$tw.utils.each(this.blockRules, function (ruleInfo) { self.usingRuleMap[ruleInfo.rule.name] = Object.getPrototypeOf(ruleInfo.rule); });
$tw.utils.each(this.inlineRules, function (ruleInfo) { self.usingRuleMap[ruleInfo.rule.name] = Object.getPrototypeOf(ruleInfo.rule); });
// Return the parse tree // Return the parse tree
}; };
@@ -214,13 +209,8 @@ WikiParser.prototype.parsePragmas = function() {
break; break;
} }
// Process the pragma rule // Process the pragma rule
var start = this.pos;
var subTree = nextMatch.rule.parse(); var subTree = nextMatch.rule.parse();
if(subTree.length > 0) { if(subTree.length > 0) {
// Set the start and end positions of the pragma rule if
if (subTree[0].start === undefined) subTree[0].start = start;
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
$tw.utils.each(subTree, function (node) { node.rule = nextMatch.rule.name; });
// Quick hack; we only cope with a single parse tree node being returned, which is true at the moment // Quick hack; we only cope with a single parse tree node being returned, which is true at the moment
currentTreeBranch.push.apply(currentTreeBranch,subTree); currentTreeBranch.push.apply(currentTreeBranch,subTree);
subTree[0].children = []; subTree[0].children = [];
@@ -245,15 +235,7 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
// Look for a block rule that applies at the current position // Look for a block rule that applies at the current position
var nextMatch = this.findNextMatch(this.blockRules,this.pos); var nextMatch = this.findNextMatch(this.blockRules,this.pos);
if(nextMatch && nextMatch.matchIndex === this.pos) { if(nextMatch && nextMatch.matchIndex === this.pos) {
var start = this.pos; return nextMatch.rule.parse();
var subTree = nextMatch.rule.parse();
// Set the start and end positions of the first and last blocks if they're not already set
if (subTree.length > 0) {
if (subTree[0].start === undefined) subTree[0].start = start;
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
}
$tw.utils.each(subTree, function (node) { node.rule = nextMatch.rule.name; });
return subTree;
} }
// Treat it as a paragraph if we didn't find a block rule // Treat it as a paragraph if we didn't find a block rule
var start = this.pos; var start = this.pos;
@@ -350,16 +332,7 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
this.pos = nextMatch.matchIndex; this.pos = nextMatch.matchIndex;
} }
// Process the run rule // Process the run rule
var start = this.pos; tree.push.apply(tree,nextMatch.rule.parse());
var subTree = nextMatch.rule.parse();
// Set the start and end positions of the first and last child if they're not already set
if (subTree.length > 0) {
// Set the start and end positions of the first and last child if they're not already set
if (subTree[0].start === undefined) subTree[0].start = start;
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
}
$tw.utils.each(subTree, function (node) { node.rule = nextMatch.rule.name; });
tree.push.apply(tree,subTree);
// Look for the next run rule // Look for the next run rule
nextMatch = this.findNextMatch(this.inlineRules,this.pos); nextMatch = this.findNextMatch(this.inlineRules,this.pos);
} }
@@ -410,15 +383,7 @@ WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegEx
this.pos = inlineRuleMatch.matchIndex; this.pos = inlineRuleMatch.matchIndex;
} }
// Process the inline rule // Process the inline rule
var start = this.pos; tree.push.apply(tree,inlineRuleMatch.rule.parse());
var subTree = inlineRuleMatch.rule.parse();
// Set the start and end positions of the first and last child if they're not already set
if (subTree.length > 0) {
if (subTree[0].start === undefined) subTree[0].start = start;
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
}
$tw.utils.each(subTree, function (node) { node.rule = inlineRuleMatch.rule.name; });
tree.push.apply(tree,subTree);
// Look for the next inline rule // Look for the next inline rule
inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos); inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);
// Look for the next terminator match // Look for the next terminator match
@@ -444,7 +409,7 @@ WikiParser.prototype.pushTextWidget = function(array,text,start,end) {
text = $tw.utils.trim(text); text = $tw.utils.trim(text);
} }
if(text) { if(text) {
array.push({type: "text", text: text, start: start, end: end}); array.push({type: "text", text: text, start: start, end: end});
} }
}; };
@@ -497,3 +462,4 @@ WikiParser.prototype.amendRules = function(type,names) {
exports["text/vnd.tiddlywiki"] = WikiParser; exports["text/vnd.tiddlywiki"] = WikiParser;
})(); })();

View File

@@ -95,7 +95,6 @@ function SaverHandler(options) {
if($tw.browser) { if($tw.browser) {
$tw.rootWidget.addEventListener("tm-save-wiki",function(event) { $tw.rootWidget.addEventListener("tm-save-wiki",function(event) {
self.saveWiki({ self.saveWiki({
wiki: event.widget.wiki,
template: event.param, template: event.param,
downloadType: "text/plain", downloadType: "text/plain",
variables: event.paramObject variables: event.paramObject
@@ -103,7 +102,6 @@ function SaverHandler(options) {
}); });
$tw.rootWidget.addEventListener("tm-download-file",function(event) { $tw.rootWidget.addEventListener("tm-download-file",function(event) {
self.saveWiki({ self.saveWiki({
wiki: event.widget.wiki,
method: "download", method: "download",
template: event.param, template: event.param,
downloadType: "text/plain", downloadType: "text/plain",
@@ -149,22 +147,20 @@ Save the wiki contents. Options are:
method: "save", "autosave" or "download" method: "save", "autosave" or "download"
template: the tiddler containing the template to save template: the tiddler containing the template to save
downloadType: the content type for the saved file downloadType: the content type for the saved file
wiki: optional wiki, overriding the default wiki specified in the constructor
*/ */
SaverHandler.prototype.saveWiki = function(options) { SaverHandler.prototype.saveWiki = function(options) {
options = options || {}; options = options || {};
var self = this, var self = this,
wiki = options.wiki || this.wiki,
method = options.method || "save"; method = options.method || "save";
// Ignore autosave if disabled // Ignore autosave if disabled
if(method === "autosave" && ($tw.config.disableAutoSave || wiki.getTiddlerText(this.titleAutoSave,"yes") !== "yes")) { if(method === "autosave" && ($tw.config.disableAutoSave || this.wiki.getTiddlerText(this.titleAutoSave,"yes") !== "yes")) {
return false; return false;
} }
var variables = options.variables || {}, var variables = options.variables || {},
template = (options.template || template = (options.template ||
wiki.getTiddlerText("$:/config/SaveWikiButton/Template","$:/core/save/all")).trim(), this.wiki.getTiddlerText("$:/config/SaveWikiButton/Template","$:/core/save/all")).trim(),
downloadType = options.downloadType || "text/plain", downloadType = options.downloadType || "text/plain",
text = wiki.renderTiddler(downloadType,template,options), text = this.wiki.renderTiddler(downloadType,template,options),
callback = function(err) { callback = function(err) {
if(err) { if(err) {
alert($tw.language.getString("Error/WhileSaving") + ":\n\n" + err); alert($tw.language.getString("Error/WhileSaving") + ":\n\n" + err);

View File

@@ -20,7 +20,7 @@ Retrieve ETag if available
*/ */
var retrieveETag = function(self) { var retrieveETag = function(self) {
var headers = { var headers = {
Accept: "*/*" Accept: "*/*;charset=UTF-8"
}; };
$tw.utils.httpRequest({ $tw.utils.httpRequest({
url: self.uri(), url: self.uri(),
@@ -48,14 +48,14 @@ var PutSaver = function(wiki) {
var self = this; var self = this;
var uri = this.uri(); var uri = this.uri();
// Async server probe. Until probe finishes, save will fail fast // Async server probe. Until probe finishes, save will fail fast
// See also https://github.com/TiddlyWiki/TiddlyWiki5/issues/2276 // See also https://github.com/Jermolene/TiddlyWiki5/issues/2276
$tw.utils.httpRequest({ $tw.utils.httpRequest({
url: uri, url: uri,
type: "OPTIONS", type: "OPTIONS",
callback: function(err,data,xhr) { callback: function(err,data,xhr) {
// Check DAV header http://www.webdav.org/specs/rfc2518.html#rfc.section.9.1 // Check DAV header http://www.webdav.org/specs/rfc2518.html#rfc.section.9.1
if(!err) { if(!err) {
self.serverAcceptsPuts = xhr.status >= 200 && xhr.status < 300 && !!xhr.getResponseHeader("dav"); self.serverAcceptsPuts = xhr.status === 200 && !!xhr.getResponseHeader("dav");
} }
} }
}); });

View File

@@ -37,9 +37,7 @@ HeaderAuthenticator.prototype.authenticateRequest = function(request,response,st
return false; return false;
} else { } else {
// authenticatedUsername will be undefined for anonymous users // authenticatedUsername will be undefined for anonymous users
if(username) { state.authenticatedUsername = $tw.utils.decodeURIComponentSafe(username);
state.authenticatedUsername = $tw.utils.decodeURIComponentSafe(username);
}
return true; return true;
} }
}; };

View File

@@ -33,7 +33,13 @@ function Server(options) {
this.routes = options.routes || []; this.routes = options.routes || [];
this.authenticators = options.authenticators || []; this.authenticators = options.authenticators || [];
this.wiki = options.wiki; this.wiki = options.wiki;
this.logger = new $tw.utils.Logger("server",{colour: "cyan"});
this.logger.setPrefix(":" + process.pid + "-" + (Number(new Date()) - 1095776640000));
this.boot = options.boot || $tw.boot; this.boot = options.boot || $tw.boot;
// Name the server and init the boot state
this.servername = $tw.utils.transliterateToSafeASCII(this.get("server-name") || this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5");
this.boot.origin = this.get("origin")? this.get("origin"): this.protocol+"://"+this.get("host")+":"+this.get("port");
this.boot.pathPrefix = this.get("path-prefix") || "";
// Initialise the variables // Initialise the variables
this.variables = $tw.utils.extend({},this.defaultVariables); this.variables = $tw.utils.extend({},this.defaultVariables);
if(options.variables) { if(options.variables) {
@@ -92,10 +98,6 @@ function Server(options) {
this.protocol = "https"; this.protocol = "https";
} }
this.transport = require(this.protocol); this.transport = require(this.protocol);
// Name the server and init the boot state
this.servername = $tw.utils.transliterateToSafeASCII(this.get("server-name") || this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5");
this.boot.origin = this.get("origin")? this.get("origin"): this.protocol+"://"+this.get("host")+":"+this.get("port");
this.boot.pathPrefix = this.get("path-prefix") || "";
} }
/* /*
@@ -287,9 +289,9 @@ Server.prototype.requestHandler = function(request,response,options) {
var route = self.findMatchingRoute(request,state); var route = self.findMatchingRoute(request,state);
// Optionally output debug info // Optionally output debug info
if(self.get("debug-level") !== "none") { if(self.get("debug-level") !== "none") {
console.log("Request path:",JSON.stringify(state.urlInfo)); self.logger.log("Request path:",JSON.stringify(state.urlInfo.href));
console.log("Request headers:",JSON.stringify(request.headers)); self.logger.log("Request headers:",JSON.stringify(request.headers));
console.log("authenticatedUsername:",state.authenticatedUsername); self.logger.log("authenticatedUsername:",state.authenticatedUsername);
} }
// Return a 404 if we didn't find a route // Return a 404 if we didn't find a route
if(!route) { if(!route) {
@@ -364,11 +366,6 @@ Server.prototype.listen = function(port,host,prefix) {
} }
// Display the port number after we've started listening (the port number might have been specified as zero, in which case we will get an assigned port) // Display the port number after we've started listening (the port number might have been specified as zero, in which case we will get an assigned port)
server.on("listening",function() { server.on("listening",function() {
// Stop listening when we get the "th-quit" hook
$tw.hooks.addHook("th-quit",function() {
server.close();
});
// Log listening details
var address = server.address(), var address = server.address(),
url = self.protocol + "://" + (address.family === "IPv6" ? "[" + address.address + "]" : address.address) + ":" + address.port + prefix; url = self.protocol + "://" + (address.family === "IPv6" ? "[" + address.address + "]" : address.address) + ":" + address.port + prefix;
$tw.utils.log("Serving on " + url,"brown/orange"); $tw.utils.log("Serving on " + url,"brown/orange");

View File

@@ -61,7 +61,7 @@ exports.startup = function() {
// Collect the shadow tiddlers of any modified plugins // Collect the shadow tiddlers of any modified plugins
$tw.utils.each(changes.modifiedPlugins,function(pluginTitle) { $tw.utils.each(changes.modifiedPlugins,function(pluginTitle) {
var pluginInfo = $tw.wiki.getPluginInfo(pluginTitle); var pluginInfo = $tw.wiki.getPluginInfo(pluginTitle);
if(pluginInfo && pluginInfo.tiddlers) { if(pluginInfo) {
$tw.utils.each(Object.keys(pluginInfo.tiddlers),function(title) { $tw.utils.each(Object.keys(pluginInfo.tiddlers),function(title) {
changedShadowTiddlers[title] = false; changedShadowTiddlers[title] = false;
}); });

View File

@@ -52,9 +52,7 @@ exports.startup = function() {
basicAuthUsername: params["basic-auth-username"], basicAuthUsername: params["basic-auth-username"],
basicAuthUsernameFromStore: params["basic-auth-username-from-store"], basicAuthUsernameFromStore: params["basic-auth-username-from-store"],
basicAuthPassword: params["basic-auth-password"], basicAuthPassword: params["basic-auth-password"],
basicAuthPasswordFromStore: params["basic-auth-password-from-store"], basicAuthPasswordFromStore: params["basic-auth-password-from-store"]
bearerAuthToken: params["bearer-auth-token"],
bearerAuthTokenFromStore: params["bearer-auth-token-from-store"]
}); });
}); });
$tw.rootWidget.addEventListener("tm-http-cancel-all-requests",function(event) { $tw.rootWidget.addEventListener("tm-http-cancel-all-requests",function(event) {

View File

@@ -30,8 +30,12 @@ ClassicStoryView.prototype.navigateTo = function(historyInfo) {
if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) {
return; return;
} }
// Scroll the node into view if(duration) {
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement}); // Scroll the node into view
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
} else {
targetElement.scrollIntoView();
}
}; };
ClassicStoryView.prototype.insert = function(widget) { ClassicStoryView.prototype.insert = function(widget) {
@@ -78,10 +82,6 @@ ClassicStoryView.prototype.remove = function(widget) {
removeElement = function() { removeElement = function() {
widget.removeChildDomNodes(); widget.removeChildDomNodes();
}; };
// Blur the focus if it is within the descendents of the node we are removing
if($tw.utils.domContains(targetElement,targetElement.ownerDocument.activeElement)) {
targetElement.ownerDocument.activeElement.blur();
}
// Abandon if the list entry isn't a DOM element (it might be a text node) // Abandon if the list entry isn't a DOM element (it might be a text node)
if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) { if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) {
removeElement(); removeElement();

View File

@@ -257,11 +257,7 @@ Save an incoming tiddler in the store, and updates the associated tiddlerInfo
Syncer.prototype.storeTiddler = function(tiddlerFields) { Syncer.prototype.storeTiddler = function(tiddlerFields) {
// Save the tiddler // Save the tiddler
var tiddler = new $tw.Tiddler(tiddlerFields); var tiddler = new $tw.Tiddler(tiddlerFields);
// Only save the tiddler if it has changed this.wiki.addTiddler(tiddler);
var existingTiddler = this.wiki.getTiddler(tiddlerFields.title);
if(!existingTiddler || !existingTiddler.isEqual(tiddler)) {
this.wiki.addTiddler(tiddler);
}
// Save the tiddler revision and changeCount details // Save the tiddler revision and changeCount details
this.tiddlerInfo[tiddlerFields.title] = { this.tiddlerInfo[tiddlerFields.title] = {
revision: this.getTiddlerRevision(tiddlerFields.title), revision: this.getTiddlerRevision(tiddlerFields.title),
@@ -560,7 +556,6 @@ SaveTiddlerTask.prototype.run = function(callback) {
// Invoke the callback // Invoke the callback
callback(null); callback(null);
},{ },{
syncer: self.syncer,
tiddlerInfo: self.syncer.tiddlerInfo[self.title] tiddlerInfo: self.syncer.tiddlerInfo[self.title]
}); });
} else { } else {
@@ -591,7 +586,6 @@ DeleteTiddlerTask.prototype.run = function(callback) {
// Invoke the callback // Invoke the callback
callback(null); callback(null);
},{ },{
syncer: self.syncer,
tiddlerInfo: self.syncer.tiddlerInfo[this.title] tiddlerInfo: self.syncer.tiddlerInfo[this.title]
}); });
}; };
@@ -620,8 +614,6 @@ LoadTiddlerTask.prototype.run = function(callback) {
} }
// Invoke the callback // Invoke the callback
callback(null); callback(null);
},{
syncer: self.syncer
}); });
}; };

View File

@@ -12,7 +12,7 @@ Upgrader module that suppresses certain system tiddlers that shouldn't be import
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
var DONT_IMPORT_LIST = ["$:/Import", "$:/build"], var DONT_IMPORT_LIST = ["$:/Import"],
UNSELECT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/StoryList","$:/HistoryList"], UNSELECT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/StoryList","$:/HistoryList"],
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"]; WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];

View File

@@ -270,7 +270,6 @@ Copy plain text to the clipboard on browsers that support it
*/ */
exports.copyToClipboard = function(text,options) { exports.copyToClipboard = function(text,options) {
options = options || {}; options = options || {};
text = text || "";
var textArea = document.createElement("textarea"); var textArea = document.createElement("textarea");
textArea.style.position = "fixed"; textArea.style.position = "fixed";
textArea.style.top = 0; textArea.style.top = 0;
@@ -290,7 +289,7 @@ exports.copyToClipboard = function(text,options) {
var succeeded = false; var succeeded = false;
try { try {
succeeded = document.execCommand("copy"); succeeded = document.execCommand("copy");
} catch(err) { } catch (err) {
} }
if(!options.doNotNotify) { if(!options.doNotNotify) {
var successNotification = options.successNotification || "$:/language/Notifications/CopiedToClipboard/Succeeded", var successNotification = options.successNotification || "$:/language/Notifications/CopiedToClipboard/Succeeded",
@@ -327,7 +326,7 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
variables["tv-popup-coords"] = Popup.buildCoordinates(Popup.coordinatePrefix.csOffsetParent,nodeRect); variables["tv-popup-coords"] = Popup.buildCoordinates(Popup.coordinatePrefix.csOffsetParent,nodeRect);
var absRect = $tw.utils.extend({}, nodeRect); var absRect = $tw.utils.extend({}, nodeRect);
for(var currentNode = selectedNode.offsetParent; currentNode; currentNode = currentNode.offsetParent) { for (var currentNode = selectedNode.offsetParent; currentNode; currentNode = currentNode.offsetParent) {
absRect.left += currentNode.offsetLeft; absRect.left += currentNode.offsetLeft;
absRect.top += currentNode.offsetTop; absRect.top += currentNode.offsetTop;
} }

View File

@@ -104,8 +104,6 @@ basicAuthUsername: plain username for basic authentication
basicAuthUsernameFromStore: name of password store entry containing username basicAuthUsernameFromStore: name of password store entry containing username
basicAuthPassword: plain password for basic authentication basicAuthPassword: plain password for basic authentication
basicAuthPasswordFromStore: name of password store entry containing password basicAuthPasswordFromStore: name of password store entry containing password
bearerAuthToken: plain text token for bearer authentication
bearerAuthTokenFromStore: name of password store entry contain bear authorization token
*/ */
function HttpClientRequest(options) { function HttpClientRequest(options) {
var self = this; var self = this;
@@ -137,11 +135,8 @@ function HttpClientRequest(options) {
}); });
this.basicAuthUsername = options.basicAuthUsername || (options.basicAuthUsernameFromStore && $tw.utils.getPassword(options.basicAuthUsernameFromStore)) || ""; this.basicAuthUsername = options.basicAuthUsername || (options.basicAuthUsernameFromStore && $tw.utils.getPassword(options.basicAuthUsernameFromStore)) || "";
this.basicAuthPassword = options.basicAuthPassword || (options.basicAuthPasswordFromStore && $tw.utils.getPassword(options.basicAuthPasswordFromStore)) || ""; this.basicAuthPassword = options.basicAuthPassword || (options.basicAuthPasswordFromStore && $tw.utils.getPassword(options.basicAuthPasswordFromStore)) || "";
this.bearerAuthToken = options.bearerAuthToken || (options.bearerAuthTokenFromStore && $tw.utils.getPassword(options.bearerAuthTokenFromStore)) || "";
if(this.basicAuthUsername && this.basicAuthPassword) { if(this.basicAuthUsername && this.basicAuthPassword) {
this.requestHeaders.Authorization = "Basic " + $tw.utils.base64Encode(this.basicAuthUsername + ":" + this.basicAuthPassword); this.requestHeaders.Authorization = "Basic " + $tw.utils.base64Encode(this.basicAuthUsername + ":" + this.basicAuthPassword);
} else if(this.bearerAuthToken) {
this.requestHeaders.Authorization = "Bearer " + this.bearerAuthToken;
} }
} }

View File

@@ -29,14 +29,10 @@ exports.getEditionInfo = function() {
for(var entryIndex=0; entryIndex<entries.length; entryIndex++) { for(var entryIndex=0; entryIndex<entries.length; entryIndex++) {
var entry = entries[entryIndex]; var entry = entries[entryIndex];
// Check if directories have a valid tiddlywiki.info // Check if directories have a valid tiddlywiki.info
// Check if the entry is a hidden directory if(!editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
if((entry.charAt(0) !== ".") && !editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) { var info = $tw.utils.parseJSONSafe(fs.readFileSync(path.resolve(editionPath,entry,"tiddlywiki.info"),"utf8"),null);
var file=path.resolve(editionPath,entry,"tiddlywiki.info"); if(info) {
if(fs.existsSync(file)) { editionInfo[entry] = info;
var info = $tw.utils.parseJSONSafe(fs.readFileSync(file,"utf8"),null);
if(info) {
editionInfo[entry] = info;
}
} }
} }
} }
@@ -45,4 +41,4 @@ exports.getEditionInfo = function() {
return editionInfo; return editionInfo;
}; };
})(); })();

View File

@@ -56,65 +56,37 @@ Object.defineProperty(TW_TextNode.prototype, "formattedTextContent", {
} }
}); });
var TW_Style = function(el) { var TW_Element = function(tag,namespace) {
// Define the internal style object
var styleObject = {
// Method to get the entire style object
get: function() {
return el._style;
},
// Method to set styles using a string (e.g. "color:red; background-color:blue;")
set: function(str) {
var self = this;
str = str || "";
$tw.utils.each(str.split(";"),function(declaration) {
var parts = declaration.split(":"),
name = $tw.utils.trim(parts[0]),
value = $tw.utils.trim(parts[1]);
if(name && value) {
el._style[$tw.utils.convertStyleNameToPropertyName(name)] = value;
}
});
},
// Method to set a specific property without transforming the property name, such as a custom property
setProperty: function(name, value) {
el._style[name] = value;
}
};
// Return a Proxy to handle direct access to individual style properties
return new Proxy(styleObject, {
get: function(target, property) {
// If the property exists on styleObject, return it (get, set, setProperty methods)
if (property in target) {
return target[property];
}
// Otherwise, return the corresponding property from _style
return el._style[$tw.utils.convertStyleNameToPropertyName(property)] || "";
},
set: function(target, property, value) {
// Set the property in _style
el._style[$tw.utils.convertStyleNameToPropertyName(property)] = value;
return true;
}
});
};
var TW_Element = function(tag, namespace) {
bumpSequenceNumber(this); bumpSequenceNumber(this);
this.isTiddlyWikiFakeDom = true; this.isTiddlyWikiFakeDom = true;
this.tag = tag; this.tag = tag;
this.attributes = {}; this.attributes = {};
this.isRaw = false; this.isRaw = false;
this.children = []; this.children = [];
this._style = {}; // Internal style object this._style = {};
this.style = new TW_Style(this); // Proxy for style management
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml"; this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
}; };
Object.setPrototypeOf(TW_Element.prototype,TW_Node.prototype); Object.setPrototypeOf(TW_Element.prototype,TW_Node.prototype);
Object.defineProperty(TW_Element.prototype, "style", {
get: function() {
return this._style;
},
set: function(str) {
var self = this;
str = str || "";
$tw.utils.each(str.split(";"),function(declaration) {
var parts = declaration.split(":"),
name = $tw.utils.trim(parts[0]),
value = $tw.utils.trim(parts[1]);
if(name && value) {
self._style[$tw.utils.convertStyleNameToPropertyName(name)] = value;
}
});
}
});
Object.defineProperty(TW_Element.prototype, "nodeType", { Object.defineProperty(TW_Element.prototype, "nodeType", {
get: function() { get: function() {
return this.ELEMENT_NODE; return this.ELEMENT_NODE;
@@ -133,7 +105,7 @@ TW_Element.prototype.setAttribute = function(name,value) {
throw "Cannot setAttribute on a raw TW_Element"; throw "Cannot setAttribute on a raw TW_Element";
} }
if(name === "style") { if(name === "style") {
this.style.set(value); this.style = value;
} else { } else {
this.attributes[name] = value + ""; this.attributes[name] = value + "";
} }

View File

@@ -238,7 +238,7 @@ exports.generateTiddlerFileInfo = function(tiddler,options) {
} else { } else {
// Save as a .tid or a text/binary file plus a .meta file // Save as a .tid or a text/binary file plus a .meta file
var tiddlerType = tiddler.fields.type || "text/vnd.tiddlywiki"; var tiddlerType = tiddler.fields.type || "text/vnd.tiddlywiki";
if(tiddlerType === "text/vnd.tiddlywiki" || tiddlerType === "text/vnd.tiddlywiki-multiple" || tiddler.hasField("_canonical_uri")) { if(tiddlerType === "text/vnd.tiddlywiki" || tiddler.hasField("_canonical_uri")) {
// Save as a .tid file // Save as a .tid file
fileInfo.type = "application/x-tiddler"; fileInfo.type = "application/x-tiddler";
fileInfo.hasMetaFile = false; fileInfo.hasMetaFile = false;

View File

@@ -21,6 +21,7 @@ function Logger(componentName,options) {
options = options || {}; options = options || {};
this.componentName = componentName || ""; this.componentName = componentName || "";
this.colour = options.colour || "white"; this.colour = options.colour || "white";
this.prefix = options.prefix || "";
this.enable = "enable" in options ? options.enable : true; this.enable = "enable" in options ? options.enable : true;
this.save = "save" in options ? options.save : true; this.save = "save" in options ? options.save : true;
this.saveLimit = options.saveLimit || 100 * 1024; this.saveLimit = options.saveLimit || 100 * 1024;
@@ -33,6 +34,20 @@ Logger.prototype.setSaveBuffer = function(logger) {
this.saveBufferLogger = logger; this.saveBufferLogger = logger;
}; };
/*
Change the output colour
*/
Logger.prototype.setColour = function(colour) {
this.colour = colour || "white";
};
/*
Change the prefix
*/
Logger.prototype.setPrefix = function(prefix) {
this.prefix = prefix || "";
};
/* /*
Log a message Log a message
*/ */

View File

@@ -924,7 +924,7 @@ exports.transliterate = function(str) {
}; };
exports.transliterateToSafeASCII = function(str) { exports.transliterateToSafeASCII = function(str) {
return str.replace(/[^\x20-\x7F]/g,function(ch) { return str.replace(/[^\x00-\x7F]/g,function(ch) {
return exports.transliterationPairs[ch] || "" return exports.transliterationPairs[ch] || ""
}); });
}; };

View File

@@ -330,18 +330,16 @@ exports.formatTitleString = function(template,options) {
}] }]
]; ];
while(t.length){ while(t.length){
var matchString = "", var matchString = "";
found = false;
$tw.utils.each(matches, function(m) { $tw.utils.each(matches, function(m) {
var match = m[0].exec(t); var match = m[0].exec(t);
if(match) { if(match) {
found = true;
matchString = m[1].call(null,match); matchString = m[1].call(null,match);
t = t.substr(match[0].length); t = t.substr(match[0].length);
return false; return false;
} }
}); });
if(found) { if(matchString) {
result += matchString; result += matchString;
} else { } else {
result += t.charAt(0); result += t.charAt(0);

View File

@@ -66,12 +66,7 @@ LogWidget.prototype.log = function() {
}); });
for(var v in this.variables) { for(var v in this.variables) {
var variable = this.parentWidget && this.parentWidget.variables[v]; allVars[v] = this.getVariable(v,{defaultValue:""});
if(variable && variable.isFunctionDefinition) {
allVars[v] = variable.value;
} else {
allVars[v] = this.getVariable(v,{defaultValue:""});
}
} }
if(this.filter) { if(this.filter) {
filteredVars = this.wiki.compileFilter(this.filter).call(this.wiki,this.wiki.makeTiddlerIterator(allVars)); filteredVars = this.wiki.compileFilter(this.filter).call(this.wiki,this.wiki.makeTiddlerIterator(allVars));

View File

@@ -262,7 +262,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/ */
ButtonWidget.prototype.refresh = function(changedTiddlers) { ButtonWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(changedAttributes.tooltip || changedAttributes.actions || changedAttributes.to || changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes.selectedClass || changedAttributes.style || changedAttributes.dragFilter || changedAttributes.dragTiddler || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup]) || (this.popupTitle && changedTiddlers[this.popupTitle]) || changedAttributes.popupAbsCoords || changedAttributes.setTitle || changedAttributes.setField || changedAttributes.setIndex || changedAttributes.popupTitle || changedAttributes.disabled || changedAttributes["default"]) { if(changedAttributes.actions || changedAttributes.to || changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes.selectedClass || changedAttributes.style || changedAttributes.dragFilter || changedAttributes.dragTiddler || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup]) || (this.popupTitle && changedTiddlers[this.popupTitle]) || changedAttributes.popupAbsCoords || changedAttributes.setTitle || changedAttributes.setField || changedAttributes.setIndex || changedAttributes.popupTitle || changedAttributes.disabled || changedAttributes["default"]) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -75,9 +75,7 @@ DataWidget.prototype.computeDataTiddlerValues = function() {
} }
}); });
// Deal with $tiddler, $filter or $compound-tiddler attributes // Deal with $tiddler, $filter or $compound-tiddler attributes
var tiddlers = [], var tiddlers = [],title;
compoundTiddlers,
title;
if(this.hasAttribute("$tiddler")) { if(this.hasAttribute("$tiddler")) {
title = this.getAttribute("$tiddler"); title = this.getAttribute("$tiddler");
if(title) { if(title) {
@@ -93,9 +91,7 @@ DataWidget.prototype.computeDataTiddlerValues = function() {
var titles = this.wiki.filterTiddlers(filter); var titles = this.wiki.filterTiddlers(filter);
$tw.utils.each(titles,function(title) { $tw.utils.each(titles,function(title) {
var tiddler = self.wiki.getTiddler(title); var tiddler = self.wiki.getTiddler(title);
if(tiddler) { tiddlers.push(tiddler);
tiddlers.push(tiddler);
}
}); });
} }
} }
@@ -105,17 +101,8 @@ DataWidget.prototype.computeDataTiddlerValues = function() {
tiddlers.push.apply(tiddlers,this.extractCompoundTiddler(title)); tiddlers.push.apply(tiddlers,this.extractCompoundTiddler(title));
} }
} }
if(this.hasAttribute("$compound-filter")) {
filter = this.getAttribute("$compound-filter");
if(filter) {
compoundTiddlers = this.wiki.filterTiddlers(filter);
$tw.utils.each(compoundTiddlers, function(title){
tiddlers.push.apply(tiddlers,self.extractCompoundTiddler(title));
});
}
}
// Return the literal item if none of the special attributes were used // Return the literal item if none of the special attributes were used
if(!this.hasAttribute("$tiddler") && !this.hasAttribute("$filter") && !this.hasAttribute("$compound-tiddler") && !this.hasAttribute("$compound-filter")) { if(!this.hasAttribute("$tiddler") && !this.hasAttribute("$filter") && !this.hasAttribute("$compound-tiddler")) {
if(Object.keys(item).length > 0 && !!item.title) { if(Object.keys(item).length > 0 && !!item.title) {
return [new $tw.Tiddler(item)]; return [new $tw.Tiddler(item)];
} else { } else {
@@ -123,6 +110,7 @@ DataWidget.prototype.computeDataTiddlerValues = function() {
} }
} else { } else {
// Apply the item fields to each of the tiddlers // Apply the item fields to each of the tiddlers
delete item.title; // Do not overwrite the title
if(Object.keys(item).length > 0) { if(Object.keys(item).length > 0) {
$tw.utils.each(tiddlers,function(tiddler,index) { $tw.utils.each(tiddlers,function(tiddler,index) {
tiddlers[index] = new $tw.Tiddler(tiddler,item); tiddlers[index] = new $tw.Tiddler(tiddler,item);

View File

@@ -125,23 +125,11 @@ DroppableWidget.prototype.handleDropEvent = function(event) {
// Remove highlighting // Remove highlighting
$tw.utils.removeClass(this.domNodes[0],"tc-dragover"); $tw.utils.removeClass(this.domNodes[0],"tc-dragover");
// Try to import the various data types we understand // Try to import the various data types we understand
if(this.droppableActions) { $tw.utils.importDataTransfer(dataTransfer,null,function(fieldsArray) {
$tw.utils.importDataTransfer(dataTransfer,null,function(fieldsArray) { fieldsArray.forEach(function(fields) {
fieldsArray.forEach(function(fields) { self.performActions(fields.title || fields.text,event);
self.performActions(fields.title || fields.text,event);
});
}); });
} });
// Send a TitleList to performListActions
if(this.droppableListActions) {
$tw.utils.importDataTransfer(dataTransfer,null,function(fieldsArray) {
var titleList = [];
fieldsArray.forEach(function(fields) {
titleList.push(fields.title || fields.text);
});
self.performListActions($tw.utils.stringifyList(titleList),event);
});
}
// Tell the browser that we handled the drop // Tell the browser that we handled the drop
event.preventDefault(); event.preventDefault();
// Stop the drop ripple up to any parent handlers // Stop the drop ripple up to any parent handlers
@@ -149,13 +137,6 @@ DroppableWidget.prototype.handleDropEvent = function(event) {
return false; return false;
}; };
DroppableWidget.prototype.performListActions = function(titleList,event) {
if(this.droppableListActions) {
var modifierKey = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
this.invokeActionString(this.droppableListActions,this,event,{actionTiddlerList: titleList, modifier: modifierKey});
}
};
DroppableWidget.prototype.performActions = function(title,event) { DroppableWidget.prototype.performActions = function(title,event) {
if(this.droppableActions) { if(this.droppableActions) {
var modifierKey = $tw.keyboardManager.getEventModifierKeyDescriptor(event); var modifierKey = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
@@ -168,7 +149,6 @@ Compute the internal state of the widget
*/ */
DroppableWidget.prototype.execute = function() { DroppableWidget.prototype.execute = function() {
this.droppableActions = this.getAttribute("actions"); this.droppableActions = this.getAttribute("actions");
this.droppableListActions = this.getAttribute("listActions");
this.droppableEffect = this.getAttribute("effect","copy"); this.droppableEffect = this.getAttribute("effect","copy");
this.droppableTag = this.getAttribute("tag"); this.droppableTag = this.getAttribute("tag");
this.droppableEnable = (this.getAttribute("enable") || "yes") === "yes"; this.droppableEnable = (this.getAttribute("enable") || "yes") === "yes";
@@ -188,8 +168,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/ */
DroppableWidget.prototype.refresh = function(changedTiddlers) { DroppableWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(changedAttributes.tag || changedAttributes.enable || changedAttributes.disabledClass || if(changedAttributes.tag || changedAttributes.enable || changedAttributes.disabledClass || changedAttributes.actions || changedAttributes.effect) {
changedAttributes.actions|| changedAttributes.listActions || changedAttributes.effect) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -65,16 +65,6 @@ GenesisWidget.prototype.execute = function() {
children: this.parseTreeNode.children || [], children: this.parseTreeNode.children || [],
isNotRemappable: !this.genesisRemappable isNotRemappable: !this.genesisRemappable
}]; }];
// Apply attributes in $names/$values
this.attributeNames = [];
this.attributeValues = [];
if(this.genesisNames && this.genesisValues) {
this.attributeNames = this.wiki.filterTiddlers(self.genesisNames,this);
this.attributeValues = this.wiki.filterTiddlers(self.genesisValues,this);
$tw.utils.each(this.attributeNames,function(varname,index) {
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],varname,self.attributeValues[index] || "");
});
}
// Apply explicit attributes // Apply explicit attributes
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) { $tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) {
var name = attribute.name; var name = attribute.name;
@@ -89,6 +79,16 @@ GenesisWidget.prototype.execute = function() {
} }
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],$tw.utils.extend({},attribute,{name: name})); $tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],$tw.utils.extend({},attribute,{name: name}));
}); });
// Apply attributes in $names/$values
this.attributeNames = [];
this.attributeValues = [];
if(this.genesisNames && this.genesisValues) {
this.attributeNames = this.wiki.filterTiddlers(self.genesisNames,this);
this.attributeValues = this.wiki.filterTiddlers(self.genesisValues,this);
$tw.utils.each(this.attributeNames,function(varname,index) {
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],varname,self.attributeValues[index] || "");
});
}
// Construct the child widgets // Construct the child widgets
this.makeChildWidgets(parseTreeNodes); this.makeChildWidgets(parseTreeNodes);
}; };

View File

@@ -163,4 +163,4 @@ ImageWidget.prototype.refresh = function(changedTiddlers) {
exports.image = ImageWidget; exports.image = ImageWidget;
})(); })();

View File

@@ -96,15 +96,13 @@ KeyboardWidget.prototype.execute = function() {
this.param = this.getAttribute("param",""); this.param = this.getAttribute("param","");
this.key = this.getAttribute("key",""); this.key = this.getAttribute("key","");
this.tag = this.getAttribute("tag",""); this.tag = this.getAttribute("tag","");
if($tw.keyboardManager) { this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key); if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") { this.shortcutTiddlers = [];
this.shortcutTiddlers = []; var name = this.key.substring(2,this.key.length -2);
var name = this.key.substring(2,this.key.length -2); $tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) {
$tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) { self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name); });
});
}
} }
// Make child widgets // Make child widgets
this.makeChildWidgets(); this.makeChildWidgets();
@@ -128,7 +126,7 @@ KeyboardWidget.prototype.refresh = function(changedTiddlers) {
this.assignDomNodeClasses(); this.assignDomNodeClasses();
} }
// Update the keyInfoArray if one of its shortcut-config-tiddlers has changed // Update the keyInfoArray if one of its shortcut-config-tiddlers has changed
if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers) && $tw.keyboardManager) { if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers)) {
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key); this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
} }
return this.refreshChildren(changedTiddlers); return this.refreshChildren(changedTiddlers);

View File

@@ -44,8 +44,7 @@ NavigatorWidget.prototype.render = function(parent,nextSibling) {
{type: "tm-fold-tiddler", handler: "handleFoldTiddlerEvent"}, {type: "tm-fold-tiddler", handler: "handleFoldTiddlerEvent"},
{type: "tm-fold-other-tiddlers", handler: "handleFoldOtherTiddlersEvent"}, {type: "tm-fold-other-tiddlers", handler: "handleFoldOtherTiddlersEvent"},
{type: "tm-fold-all-tiddlers", handler: "handleFoldAllTiddlersEvent"}, {type: "tm-fold-all-tiddlers", handler: "handleFoldAllTiddlersEvent"},
{type: "tm-unfold-all-tiddlers", handler: "handleUnfoldAllTiddlersEvent"}, {type: "tm-unfold-all-tiddlers", handler: "handleUnfoldAllTiddlersEvent"}
{type: "tm-manage-acl", handler: "handleManageACLTiddlersEvent"}
]); ]);
this.parentDomNode = parent; this.parentDomNode = parent;
this.computeAttributes(); this.computeAttributes();
@@ -185,7 +184,7 @@ NavigatorWidget.prototype.handleCloseOtherTiddlersEvent = function(event) {
// Place a tiddler in edit mode // Place a tiddler in edit mode
NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) { NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
var editTiddler = $tw.hooks.invokeHook("th-editing-tiddler",event), var editTiddler = $tw.hooks.invokeHook("th-editing-tiddler",event),
win = event.event && event.event.view ? event.event.view : window; win = event.event && event.event.view ? event.event.view : window;
if(!editTiddler) { if(!editTiddler) {
return false; return false;
} }
@@ -307,7 +306,7 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
var title = event.param || event.tiddlerTitle, var title = event.param || event.tiddlerTitle,
tiddler = this.wiki.getTiddler(title), tiddler = this.wiki.getTiddler(title),
storyList = this.getStoryList(), storyList = this.getStoryList(),
win = event.event && event.event.view ? event.event.view : window; win = event.event && event.event.view ? event.event.view : window;
// Replace the original tiddler with the draft // Replace the original tiddler with the draft
if(tiddler) { if(tiddler) {
var draftTitle = (tiddler.fields["draft.title"] || "").trim(), var draftTitle = (tiddler.fields["draft.title"] || "").trim(),
@@ -413,8 +412,7 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
event = $tw.hooks.invokeHook("th-new-tiddler", event); event = $tw.hooks.invokeHook("th-new-tiddler", event);
// Get the story details // Get the story details
var storyList = this.getStoryList(), var storyList = this.getStoryList(),
templateTiddler, additionalFields, title, draftTitle, existingTiddler, templateTiddler, additionalFields, title, draftTitle, existingTiddler;
templateHasTags = false;
// Get the template tiddler (if any) // Get the template tiddler (if any)
if(typeof event.param === "string") { if(typeof event.param === "string") {
// Get the template tiddler // Get the template tiddler
@@ -459,10 +457,8 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
// Merge tags // Merge tags
mergedTags = $tw.utils.pushTop(mergedTags,$tw.utils.parseStringArray(additionalFields.tags)); mergedTags = $tw.utils.pushTop(mergedTags,$tw.utils.parseStringArray(additionalFields.tags));
} }
var additionalFieldsHasTags = !!(additionalFields && (additionalFields.tags === ""));
if(templateTiddler && templateTiddler.fields.tags) { if(templateTiddler && templateTiddler.fields.tags) {
// Merge tags // Merge tags
templateHasTags = true;
mergedTags = $tw.utils.pushTop(mergedTags,templateTiddler.fields.tags); mergedTags = $tw.utils.pushTop(mergedTags,templateTiddler.fields.tags);
} }
// Save the draft tiddler // Save the draft tiddler
@@ -478,8 +474,7 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
{ {
title: draftTitle, title: draftTitle,
"draft.of": title, "draft.of": title,
// If template or additionalFields have "tags" even if empty a tags field will be created. tags: mergedTags
tags: ((mergedTags.length > 0) || templateHasTags || additionalFieldsHasTags) ? mergedTags : undefined
},this.wiki.getModificationFields()); },this.wiki.getModificationFields());
this.wiki.addTiddler(draftTiddler); this.wiki.addTiddler(draftTiddler);
// Update the story to insert the new draft at the top and remove any existing tiddler // Update the story to insert the new draft at the top and remove any existing tiddler
@@ -531,7 +526,7 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
var systemMessage = $tw.language.getString("Import/Upgrader/Tiddler/Unselected"); var systemMessage = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
$tw.utils.each(messages,function(message,title) { $tw.utils.each(messages,function(message,title) {
newFields["message-" + title] = message; newFields["message-" + title] = message;
if(message.indexOf(systemMessage) !== -1) { if (message.indexOf(systemMessage) !== -1) {
newFields["selection-" + title] = "unchecked"; newFields["selection-" + title] = "unchecked";
} }
}); });
@@ -636,14 +631,6 @@ NavigatorWidget.prototype.handleUnfoldAllTiddlersEvent = function(event) {
}); });
}; };
NavigatorWidget.prototype.handleManageACLTiddlersEvent = function() {
var pathname = window.location.pathname;
var paths = pathname.split("/");
var recipeName = paths[paths.length - 1];
var bagName = document.querySelector("h1.tc-site-title").innerHTML;
window.location.href = "/admin/acl/"+recipeName+"/"+bagName
};
exports.navigator = NavigatorWidget; exports.navigator = NavigatorWidget;
})(); })();

View File

@@ -335,7 +335,7 @@ Widget.prototype.makeFakeWidgetWithVariables = function(variables) {
}; };
} else { } else {
opts = opts || {}; opts = opts || {};
opts.variables = $tw.utils.extend({},variables,opts.variables); opts.variables = $tw.utils.extend(variables,opts.variables);
return self.getVariableInfo(name,opts); return self.getVariableInfo(name,opts);
}; };
}, },
@@ -428,11 +428,6 @@ Widget.prototype.assignAttributes = function(domNode,options) {
destPrefix = options.destPrefix || "", destPrefix = options.destPrefix || "",
EVENT_ATTRIBUTE_PREFIX = "on"; EVENT_ATTRIBUTE_PREFIX = "on";
var assignAttribute = function(name,value) { var assignAttribute = function(name,value) {
// Process any CSS custom properties
if(name.substr(0,2) === "--" && name.length > 2) {
domNode.style.setProperty(name,value);
return;
}
// Process any style attributes before considering sourcePrefix and destPrefix // Process any style attributes before considering sourcePrefix and destPrefix
if(name.substr(0,6) === "style." && name.length > 6) { if(name.substr(0,6) === "style." && name.length > 6) {
domNode.style[$tw.utils.unHyphenateCss(name.substr(6))] = value; domNode.style[$tw.utils.unHyphenateCss(name.substr(6))] = value;

View File

@@ -194,24 +194,18 @@ options.prefix must be a string
*/ */
exports.generateNewTitle = function(baseTitle,options) { exports.generateNewTitle = function(baseTitle,options) {
options = options || {}; options = options || {};
var title = baseTitle, var c = 0,
template = options.template || "", title = baseTitle,
// test if .startCount is a positive integer. If not set to 0 template = options.template,
c = (parseInt(options.startCount,10) > 0) ? parseInt(options.startCount,10) : 0,
prefix = (typeof(options.prefix) === "string") ? options.prefix : " "; prefix = (typeof(options.prefix) === "string") ? options.prefix : " ";
if (template) { if (template) {
// "count" is important to avoid an endless loop in while(...)!! // "count" is important to avoid an endless loop in while(...)!!
template = (/\$count:?(\d+)?\$/i.test(template)) ? template : template + "$count$"; template = (/\$count:?(\d+)?\$/i.test(template)) ? template : template + "$count$";
// .formatTitleString() expects strings as input title = $tw.utils.formatTitleString(template,{"base":baseTitle,"separator":prefix,"counter":c});
title = $tw.utils.formatTitleString(template,{"base":baseTitle,"separator":prefix,"counter":c+""});
while(this.tiddlerExists(title) || this.isShadowTiddler(title) || this.findDraft(title)) { while(this.tiddlerExists(title) || this.isShadowTiddler(title) || this.findDraft(title)) {
title = $tw.utils.formatTitleString(template,{"base":baseTitle,"separator":prefix,"counter":(++c)+""}); title = $tw.utils.formatTitleString(template,{"base":baseTitle,"separator":prefix,"counter":(++c)});
} }
} else { } else {
if (c > 0) {
title = baseTitle + prefix + c;
}
while(this.tiddlerExists(title) || this.isShadowTiddler(title) || this.findDraft(title)) { while(this.tiddlerExists(title) || this.isShadowTiddler(title) || this.findDraft(title)) {
title = baseTitle + prefix + (++c); title = baseTitle + prefix + (++c);
} }
@@ -557,45 +551,28 @@ exports.getTiddlerBacklinks = function(targetTitle) {
/* /*
Return an array of tiddler titles that are directly transcluded within the given parse tree. `title` is the tiddler being parsed, we will ignore its self-referential transclusions, only return Return an array of tiddler titles that are directly transcluded within the given parse tree
*/ */
exports.extractTranscludes = function(parseTreeRoot, title) { exports.extractTranscludes = function(parseTreeRoot) {
// Count up the transcludes // Count up the transcludes
var transcludes = [], var transcludes = [],
checkParseTree = function(parseTree, parentNode) { checkParseTree = function(parseTree, parentNode) {
for(var t=0; t<parseTree.length; t++) { for(var t=0; t<parseTree.length; t++) {
var parseTreeNode = parseTree[t]; var parseTreeNode = parseTree[t];
if(parseTreeNode.type === "transclude") { if(parseTreeNode.type === "transclude" && parseTreeNode.attributes.$tiddler && parseTreeNode.attributes.$tiddler.type === "string") {
if(parseTreeNode.attributes.$tiddler) { var value;
if(parseTreeNode.attributes.$tiddler.type === "string") { // 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
var value; if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
// 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 value = parentNode.attributes.tiddler.value;
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") { } else {
// Empty value (like `{{!!field}}`) means self-referential transclusion. value = parseTreeNode.attributes.$tiddler.value;
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.$field && parseTreeNode.attributes.$field.type === "string") {
// Empty value (like `<$transclude $field='created'/>`) means self-referential transclusion.
value = title;
} else if(parseTreeNode.attributes.field && parseTreeNode.attributes.field.type === "string") {
// Old usage with Empty value (like `<$transclude field='created'/>`)
value = title;
} }
// Deduplicate the result. if(transcludes.indexOf(value) === -1) {
if(value && transcludes.indexOf(value) === -1) { transcludes.push(value);
$tw.utils.pushTop(transcludes,value);
} }
} }
if(parseTreeNode.children) { if(parseTreeNode.children) {
checkParseTree(parseTreeNode.children,parseTreeNode); checkParseTree(parseTreeNode.children, parseTreeNode);
} }
} }
}; };
@@ -614,8 +591,7 @@ exports.getTiddlerTranscludes = function(title) {
// Parse the tiddler // Parse the tiddler
var parser = self.parseTiddler(title); var parser = self.parseTiddler(title);
if(parser) { if(parser) {
// this will ignore self-referential transclusions from `title` return self.extractTranscludes(parser.tree);
return self.extractTranscludes(parser.tree,title);
} }
return []; return [];
}); });

View File

@@ -33,7 +33,6 @@ external-link-background: inherit
external-link-foreground-hover: inherit external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee external-link-foreground: #0000ee
footnote-target-background: #ecf2ff
foreground: #333333 foreground: #333333
highlight-background: #ffff00 highlight-background: #ffff00
highlight-foreground: #000000 highlight-foreground: #000000

View File

@@ -33,7 +33,6 @@ external-link-background: inherit
external-link-foreground-hover: inherit external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee external-link-foreground: #0000ee
footnote-target-background: #ecf2ff
foreground: #333353 foreground: #333353
highlight-background: #ffff00 highlight-background: #ffff00
highlight-foreground: #000000 highlight-foreground: #000000

View File

@@ -33,7 +33,6 @@ external-link-background: inherit
external-link-foreground-hover: inherit external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee external-link-foreground: #0000ee
footnote-target-background: #ecf2ff
foreground: #333333 foreground: #333333
highlight-background: #ffff00 highlight-background: #ffff00
highlight-foreground: #000000 highlight-foreground: #000000

View File

@@ -1,7 +1,7 @@
title: $:/palettes/ContrastDark title: $:/palettes/ContrastLight
name: Contrast (Dark) name: Contrast (Light)
color-scheme: dark color-scheme: light
description: High contrast and unambiguous (dark version) description: High contrast and unambiguous (light version)
tags: $:/tags/Palette tags: $:/tags/Palette
type: application/x-tiddler-dictionary type: application/x-tiddler-dictionary
@@ -9,7 +9,7 @@ alert-background: #f00
alert-border: <<colour background>> alert-border: <<colour background>>
alert-highlight: <<colour foreground>> alert-highlight: <<colour foreground>>
alert-muted-foreground: #800 alert-muted-foreground: #800
background: #000 background: #fff
blockquote-bar: <<colour muted-foreground>> blockquote-bar: <<colour muted-foreground>>
button-background: <<colour background>> button-background: <<colour background>>
button-foreground: <<colour foreground>> button-foreground: <<colour foreground>>
@@ -33,8 +33,7 @@ external-link-background: inherit
external-link-foreground-hover: inherit external-link-foreground-hover: inherit
external-link-foreground-visited: #00a external-link-foreground-visited: #00a
external-link-foreground: #00e external-link-foreground: #00e
footnote-target-background: #4c4c4c foreground: #000
foreground: #fff
highlight-background: #ffff00 highlight-background: #ffff00
highlight-foreground: #000000 highlight-foreground: #000000
message-background: <<colour foreground>> message-background: <<colour foreground>>
@@ -83,8 +82,8 @@ tab-foreground: <<colour background>>
table-border: #dddddd table-border: #dddddd
table-footer-background: #a8a8a8 table-footer-background: #a8a8a8
table-header-background: #f0f0f0 table-header-background: #f0f0f0
tag-background: #fff tag-background: #000
tag-foreground: #000 tag-foreground: #fff
tiddler-background: <<colour background>> tiddler-background: <<colour background>>
tiddler-border: <<colour foreground>> tiddler-border: <<colour foreground>>
tiddler-controls-foreground-hover: #ddd tiddler-controls-foreground-hover: #ddd

View File

@@ -1,7 +1,7 @@
title: $:/palettes/ContrastLight title: $:/palettes/ContrastDark
name: Contrast (Light) name: Contrast (Dark)
color-scheme: light color-scheme: dark
description: High contrast and unambiguous (light version) description: High contrast and unambiguous (dark version)
tags: $:/tags/Palette tags: $:/tags/Palette
type: application/x-tiddler-dictionary type: application/x-tiddler-dictionary
@@ -9,7 +9,7 @@ alert-background: #f00
alert-border: <<colour background>> alert-border: <<colour background>>
alert-highlight: <<colour foreground>> alert-highlight: <<colour foreground>>
alert-muted-foreground: #800 alert-muted-foreground: #800
background: #fff background: #000
blockquote-bar: <<colour muted-foreground>> blockquote-bar: <<colour muted-foreground>>
button-background: <<colour background>> button-background: <<colour background>>
button-foreground: <<colour foreground>> button-foreground: <<colour foreground>>
@@ -33,8 +33,7 @@ external-link-background: inherit
external-link-foreground-hover: inherit external-link-foreground-hover: inherit
external-link-foreground-visited: #00a external-link-foreground-visited: #00a
external-link-foreground: #00e external-link-foreground: #00e
footnote-target-background: #e5e5e5 foreground: #fff
foreground: #000
highlight-background: #ffff00 highlight-background: #ffff00
highlight-foreground: #000000 highlight-foreground: #000000
message-background: <<colour foreground>> message-background: <<colour foreground>>
@@ -83,8 +82,8 @@ tab-foreground: <<colour background>>
table-border: #dddddd table-border: #dddddd
table-footer-background: #a8a8a8 table-footer-background: #a8a8a8
table-header-background: #f0f0f0 table-header-background: #f0f0f0
tag-background: #000 tag-background: #fff
tag-foreground: #fff tag-foreground: #000
tiddler-background: <<colour background>> tiddler-background: <<colour background>>
tiddler-border: <<colour foreground>> tiddler-border: <<colour foreground>>
tiddler-controls-foreground-hover: #ddd tiddler-controls-foreground-hover: #ddd

Some files were not shown because too many files have changed in this diff Show More