Skip to content
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
543 commits
Select commit Hold shift + click to select a range
1dea0a0
Merge branch 'master' into parameterised-transclusions
Jermolene Jan 30, 2023
6a9de97
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Jan 30, 2023
176560d
Add XLSX import spec for demo real estate spreadsheets
Jermolene Jan 30, 2023
21ba5c5
Fix fieldname
Jermolene Jan 30, 2023
7278cc6
Improve map pin
Jermolene Jan 30, 2023
86569e5
Merge branch 'master' into parameterised-transclusions
Jermolene Jan 30, 2023
1ee77fb
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Jan 30, 2023
dbea341
RealEstate demo: Set lat, long, price fields to be numeric
Jermolene Jan 30, 2023
0d1667c
Merge branch 'master' into parameterised-transclusions
Jermolene Feb 10, 2023
be118af
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Feb 10, 2023
dae48d4
Clean up Flickr demo
Jermolene Feb 10, 2023
c8b2146
Update geomap widget to refresh properly
Jermolene Feb 12, 2023
b80cf8c
Add Leaflet MasterCluster plugin
Jermolene Feb 12, 2023
235b2f7
Setup the marker cluster plugin
Jermolene Feb 12, 2023
b1f8d3e
Rearrange real estate demo
Jermolene Feb 13, 2023
800049e
Reduce default cluster radius
Jermolene Feb 13, 2023
f36e45f
Beginnings of real estate demo
Jermolene Feb 13, 2023
ea055f2
Merge branch 'master' into parameterised-transclusions
Jermolene Feb 28, 2023
9700030
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Feb 28, 2023
3be822f
Fix interpretation of HTTP status codes
Jermolene Feb 28, 2023
6beb058
Real estate demo: Make columns hideable
Jermolene Feb 28, 2023
85bbb08
Real estate demo: sortability
Jermolene Mar 3, 2023
a1a1f9c
Real estate demo: search and limit
Jermolene Mar 3, 2023
44fb669
Fix typo
Jermolene Mar 4, 2023
f417bdb
Merge branch 'master' into parameterised-transclusions
Jermolene Mar 6, 2023
e051b2d
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Mar 6, 2023
9ab2623
Fix lat long transposition
Jermolene Mar 6, 2023
17ebeaf
Fix startup ordering
Jermolene Mar 6, 2023
bb5489b
Add geolookup operator
Jermolene Mar 6, 2023
b5d790a
Real Estate Demo: Add support for computed columns
Jermolene Mar 7, 2023
5a9bb0e
Real estate demo: Increase result limit
Jermolene Mar 8, 2023
2a2939f
Merge branch 'master' into parameterised-transclusions
Jermolene Mar 10, 2023
eab670a
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Mar 10, 2023
449562e
Remove demo data
Jermolene Mar 10, 2023
3699780
Track map pan and zoom state in a state tiddler
Jermolene Mar 10, 2023
f3d0de2
WIP
Jermolene Mar 10, 2023
18b8b12
Use geojson extension for geojson file
Jermolene Mar 10, 2023
aa532a9
Use geojson extensions for another geojson file
Jermolene Mar 11, 2023
f9751f1
Merge branch 'master' into parameterised-transclusions
Jermolene Mar 12, 2023
1dda5c8
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Mar 12, 2023
1fbc35e
Split demo from the geospatial plugin into its own edition
Jermolene Mar 16, 2023
ff70949
Add build targets required by ./bin/site-build.sh...
Jermolene Mar 16, 2023
c002390
CI Fixes
Jermolene Mar 16, 2023
57627b2
Fix default tab
Jermolene Mar 17, 2023
a96e3f4
Rearranging geospatial plugin vs. edition
Jermolene Mar 17, 2023
eba030a
More refactoring between demo and plugin
Jermolene Mar 17, 2023
cd46d9e
Start of plugin docs
Jermolene Mar 17, 2023
0cdf99d
Display GeoJSON properties on click
Jermolene Mar 17, 2023
b5e9219
Fix layer lookup demo
Jermolene Mar 17, 2023
3c0cae0
Restore XLSX Utils plugin and dependencies
Jermolene Mar 17, 2023
e2cc32a
Merge branch 'master' into parameterised-transclusions
Jermolene Mar 18, 2023
8c98fc4
Merge branch 'master' into parameterised-transclusions
Jermolene Mar 21, 2023
b74646a
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Mar 21, 2023
5940698
Cleanup docs
Jermolene Mar 24, 2023
cff3db6
Merge branch 'master' into parameterised-transclusions
Jermolene Mar 26, 2023
7ba666b
Merge branch 'master' into parameterised-transclusions
Jermolene Apr 2, 2023
3a42c86
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Apr 2, 2023
a93eda0
Remove 5.2.8 release note
Jermolene Apr 2, 2023
bb2dea2
Remove 5.2.8 release note
Jermolene Apr 2, 2023
9fdb81b
Docs update
Jermolene Apr 2, 2023
bd7742d
Fix minor refreshing bug for geomap widget
Jermolene Apr 3, 2023
ab845fe
Docs updates
Jermolene Apr 3, 2023
28a33df
Add jsonset operator
Jermolene Apr 4, 2023
2a19e20
Add geonearestpoint operator
Jermolene Apr 4, 2023
3a411e9
jsonset: support for other data types and documentation
Jermolene Apr 5, 2023
399089a
Add logo
Jermolene Apr 5, 2023
2e92297
Add link to preview build
Jermolene Apr 5, 2023
a71150a
jsonset: add support for assigning JSON strings
Jermolene Apr 5, 2023
5b271bb
Fix nonstandard initialisation code for fill/parameter/slot widgets
Jermolene Apr 6, 2023
a2cbb6f
Merge branch 'master' into parameterised-transclusions
Jermolene Apr 6, 2023
a4f0fc6
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Apr 6, 2023
3689171
Merge branch 'master' into parameterised-transclusions
Jermolene Apr 10, 2023
3bed84e
Merge branch 'master' into geospatial-plugin
Jermolene Apr 10, 2023
de9ea40
Introduce testcase widget so that we can reuse testcases as documenta…
Jermolene Apr 10, 2023
ae3ed08
Update logo
Jermolene Apr 10, 2023
ca75842
Testcasewidget: Add tabs for switching between source tiddlers
Jermolene Apr 10, 2023
da2d0be
Testcase appearance tweaks
Jermolene Apr 10, 2023
c405872
Switch to fluid-fixed layout
Jermolene Apr 10, 2023
386b015
Docs for the testcase-transclude and testcase-view widgets
Jermolene Apr 11, 2023
c348924
Split docs into separate tabs
Jermolene Apr 11, 2023
3c61e86
Extend testcase-view to be able to view other fields
Jermolene Apr 11, 2023
68cb325
Extend default testcase template to show all fields of payload tiddlers
Jermolene Apr 11, 2023
e2223c4
Add some geomap examples
Jermolene Apr 11, 2023
4427caa
Fix testcase rounded corners
Jermolene Apr 11, 2023
f41e712
Add a geomap layer demo
Jermolene Apr 11, 2023
b077208
Add favicon
Jermolene Apr 12, 2023
a5839ce
Switch from building the geospatial plugin as the main build back to …
Jermolene Apr 12, 2023
f41051b
Merge branch 'master' into parameterised-transclusions
Jermolene Apr 12, 2023
f6b3310
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Apr 12, 2023
60714a4
Remove obsolete comment
Jermolene Apr 12, 2023
d9cfaf1
Remove geospatial plugin from tw5.com build
Jermolene Apr 12, 2023
a5d4f7a
Fix build link
Jermolene Apr 12, 2023
3aac8e1
Add note about core enhancements included in this branch
Jermolene Apr 12, 2023
b6181e1
Refactor data widget implementation
Jermolene Apr 13, 2023
6d617ce
Integrate test cases with the docs
Jermolene Apr 13, 2023
f2ccce2
Remove erroneously pasted docs material
Jermolene Apr 13, 2023
6c9b811
Remove erroneously copied olc-encode tests within old-decode test case
Jermolene Apr 14, 2023
683ec33
Refactor compound tiddler handling into data widget
Jermolene Apr 17, 2023
1bc0662
Default test case template tweaks
Jermolene Apr 17, 2023
b91872b
Merge branch 'master' into parameterised-transclusions
Jermolene Apr 18, 2023
fca2552
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Apr 18, 2023
62d0dd3
Move Flickr macros into geospatial plugin from the demo edition
Jermolene Apr 18, 2023
a974658
FlickrDemo: Simplify UI
Jermolene Apr 18, 2023
59a8cf3
FlickrMacros: Use a template to define photo tiddler fields
Jermolene Apr 18, 2023
d057214
Remove geospatial plugin from prerelease default tiddlers
Jermolene Apr 19, 2023
20e873a
Extend Flickr helpers to support photoTiddlerTemplate parameter
Jermolene Apr 19, 2023
55e38eb
Update modification times of doc tiddlers
Jermolene Apr 19, 2023
3b3879d
Update 5.3.0 release note
Jermolene Apr 19, 2023
093274f
Remove custom CI step for this branch
Jermolene Apr 19, 2023
8816efa
Restore standard sitetitle
Jermolene Apr 19, 2023
0f61664
Merge branch 'parameterised-transclusions' into geospatial-plugin
Jermolene Apr 19, 2023
57a365f
Merge branch 'master' into geospatial-plugin
Jermolene Apr 19, 2023
ed6cbab
Merge branch 'master' into geospatial-plugin
Jermolene Apr 20, 2023
e6b9bac
Flickr macro docs
Jermolene Apr 20, 2023
546e55d
Rename $:/tags/GeoLayer to $:/tags/GeoFeature
Jermolene Apr 25, 2023
539cc56
More test data (from leaflet.js)
Jermolene Apr 25, 2023
d527ae9
Captions should be transcluded, not viewed raw
Jermolene Apr 25, 2023
88f4ad0
Make HTTP handler use wiki of widget that sent the message
Jermolene Apr 26, 2023
2cf0423
Switch testcase widget to use an intrinsic template
Jermolene Apr 26, 2023
60fbfa3
Complete Flickr demos
Jermolene Apr 26, 2023
6a3977d
Extend geonearestpoint operator to work with feature collections
Jermolene Apr 26, 2023
7f2d7ab
Extend realestate demo to show data on nearest volcano
Jermolene Apr 26, 2023
1cb5716
Flickr macros: fix pagination after first page
Jermolene Apr 26, 2023
5b8d281
Real estate demo: Fix nearest volcano
Jermolene Apr 27, 2023
7b787fc
Merge branch 'master' into geospatial-plugin
Jermolene Apr 27, 2023
0a2b0b3
Testcase docs update
Jermolene Apr 27, 2023
f700cd1
Testcase template: put title at the top and remove header row
Jermolene Apr 27, 2023
19d2fe9
Docs correction
Jermolene Apr 28, 2023
b47c757
New geonearestpoint test case
Jermolene Apr 28, 2023
4a0ffcf
Make test cases editable
Jermolene Apr 28, 2023
9c12d16
Test case default template: Always put "Output" tab first
Jermolene Apr 28, 2023
585c733
Initial Commit
Jermolene Apr 29, 2023
0adc051
HttpClient object shouldn't need to know about events
Jermolene May 1, 2023
be1882d
Add support for cancelling HTTP requests
Jermolene May 1, 2023
fc22df9
Make the number of outstanding HTTP requests available in a state tid…
Jermolene May 2, 2023
f798bf5
Add a network activity button
Jermolene May 2, 2023
499eafc
WIP
Jermolene May 2, 2023
b8b29aa
Merge branch 'tm-http-request-message' into geospatial-plugin
Jermolene May 2, 2023
53715bd
Fix typo
Jermolene May 2, 2023
cdf0d63
Merge branch 'tm-http-request-message' into geospatial-plugin
Jermolene May 2, 2023
c6f15d8
Data widget: parse carriage returns in compound tiddlers
Jermolene May 2, 2023
cc7b857
Fix crash when cancelling more than one HTTP request
Jermolene May 3, 2023
09e626e
Further fixes to cancelling outstanding HTTP requests
Jermolene May 3, 2023
d9b6384
Don't have data widget rendering its own JSON
Jermolene May 4, 2023
a927de5
Merge branch 'master' into tm-http-request-message
Jermolene May 4, 2023
cf71f6f
Merge branch 'tm-http-request-message' into geospatial-plugin
Jermolene May 4, 2023
7fc0c0b
Fix missed docs update
Jermolene May 4, 2023
29f4d34
Merge branch 'master' into geospatial-plugin
Jermolene May 7, 2023
7f4f48d
Introduce geolayer widget for specifying layers for geomap
Jermolene May 9, 2023
ec2ec00
Fix breaking tests
Jermolene May 9, 2023
c10eeea
Remove docs references to obsolete widgets
Jermolene May 13, 2023
a14f038
Merge branch 'master' into geospatial-plugin
Jermolene May 14, 2023
9bfe6e3
Tests for geounion, geointersect and geodifference
Jermolene May 21, 2023
dbabdfc
Support for multiple base layers
Jermolene May 21, 2023
1f73d70
Merge branch 'master' into geospatial-plugin
Jermolene May 21, 2023
7a82f15
Add a satellite base layer and another terrain base layer
Jermolene May 21, 2023
c7771c9
Add a note where to get more base layers
Jermolene May 21, 2023
908ea64
Docs update
Jermolene May 22, 2023
cf44e0b
Merge branch 'master' into geospatial-plugin
Jermolene May 30, 2023
d785fa4
Geomap widget: fix default base layer rendering
Jermolene May 30, 2023
463f0cd
Add startPosition and layersPanel attributes to geomap widget
Jermolene May 31, 2023
3ee09af
Update geolayer widget docs with missing attributes
Jermolene May 31, 2023
4b653c2
Add interactive demos for geounion, geodifference, geointersection
Jermolene May 31, 2023
e719d56
Open geofeature and geomarker maps on the bounds of their content
Jermolene May 31, 2023
ec7d248
Merge branch 'master' into tm-http-request-message
Jermolene Jun 11, 2023
9285470
Merge branch 'master' into geospatial-plugin
Jermolene Jun 11, 2023
d9fa39a
Move settings from demo into plugin
Jermolene Jun 12, 2023
33af598
Icon for geospatial plugin
Jermolene Jun 12, 2023
483ade1
Fix missing body
Jermolene Jun 12, 2023
fb02f15
Merge branch 'master' into tm-http-request-message
Jermolene Jun 12, 2023
c474964
Merge branch 'master' into geospatial-plugin
Jermolene Jun 12, 2023
8c9e669
Merge branch 'tm-http-request-message' into geospatial-plugin
Jermolene Jun 12, 2023
5806741
Flickr Demo typo
Jermolene Jun 12, 2023
b2b51a3
Docs update
Jermolene Jun 12, 2023
c918f43
Add support for draggable markers
Jermolene Jun 12, 2023
1a52286
Removed accidentally committed file
Jermolene Jun 12, 2023
39daa29
Merge branch 'master' into geospatial-plugin
Jermolene Jun 13, 2023
4b919e3
Remove unwanted log
Jermolene Jun 13, 2023
5b4c024
Merge branch 'master' into geospatial-plugin
Jermolene Jun 21, 2023
4494601
Merge branch 'master' into geospatial-plugin
Jermolene Sep 6, 2023
9ab8f57
Add support for tm-request-geolocation message
Jermolene Sep 9, 2023
65ac272
Fix typo
Jermolene Sep 9, 2023
fbcea2e
Fix bug when fitting to non-extistent bounds
Jermolene Sep 9, 2023
1560221
Update main wiki greeting
Jermolene Sep 9, 2023
87db53e
Merge branch 'master' into geospatial-plugin
Jermolene Sep 11, 2023
05d3271
Use "Flickr helpers" instead of "Flickr macros"
Jermolene Sep 14, 2023
38226cf
File renames for 05d32716037dd14b8a3741b28a82235defea4701
Jermolene Sep 14, 2023
a91a6f6
Fix testcase widget example
Jermolene Sep 14, 2023
03b6413
Fix testcase widget refreshing
Jermolene Sep 15, 2023
957cccd
Fix failing tests from 03b6413c7a519429ea75353faf32c0a0baf2b88e
Jermolene Sep 15, 2023
4407cc8
Docs: Clarify that template must be in the payload
Jermolene Sep 19, 2023
19c028a
Testcase widget: Exclude tab state tiddlers
Jermolene Sep 24, 2023
10f09e0
Merge branch 'master' into geospatial-plugin
Jermolene Oct 9, 2023
e191217
Remove obsolete setquerystring operator
Jermolene Oct 9, 2023
44736b6
Merge branch 'master' into geospatial-plugin
Jermolene Oct 26, 2023
18c38dc
Remove obsolete change to --setfield command
Jermolene Oct 26, 2023
45310bf
Fix tiddler name typo
Jermolene Oct 26, 2023
497c56d
Initial Commit
Jermolene Oct 26, 2023
86507ba
Add note to preview build
Jermolene Oct 27, 2023
81f1994
Merge branch 'master' into testcase-widget
Jermolene Oct 31, 2023
5eae32d
Fix whitespace and indenting
Jermolene Oct 31, 2023
a32d514
Fix crash with unset $tiddler attribute on <$data> widget
Jermolene Oct 31, 2023
2c07310
Merge branch 'master' into testcase-widget
Jermolene Nov 21, 2023
583ff88
Merge branch 'master' into geospatial-plugin
Jermolene Nov 21, 2023
88f2bef
Merge branch 'master' into geospatial-plugin
Jermolene Dec 11, 2023
056e7c2
Remove Stamen baselayers
Jermolene Dec 11, 2023
7470832
Disable test that won't run in browser CI
Jermolene Dec 11, 2023
4401081
Merge branch 'master' into testcase-widget
Jermolene Dec 11, 2023
e88895e
Disable broken tests
Jermolene Dec 11, 2023
3d7c626
Merge branch 'master' into geospatial-plugin
Jermolene Dec 11, 2023
786ab4d
Update olc-encode.tid (#7885)
Drevarr Dec 14, 2023
f70e047
Merge branch 'master' into geospatial-plugin
Jermolene May 2, 2024
f0d6779
Merge branch 'master' into testcase-widget
Jermolene May 2, 2024
17e939f
Don't duplicate "description" field in test cases
Jermolene May 2, 2024
22ad439
Use different background colours for nested testcase widgets
Jermolene May 5, 2024
57e74a0
Extend the testcase widget to run tests
Jermolene May 5, 2024
1be73ad
Add testcases to control panel
Jermolene May 5, 2024
fa9e643
Add a view template body template to render testcase tiddlers
Jermolene May 5, 2024
4758b6a
Test edition should display testcases
Jermolene May 5, 2024
d361a1e
Whitespace fixes
Jermolene May 5, 2024
39d4633
Make testcase tiddler tempalte link to itself
Jermolene May 5, 2024
0891331
Styling tweaks
Jermolene May 5, 2024
6b4bd47
Docs improvements
Jermolene May 5, 2024
e8a3ffd
Styling tweaks
Jermolene May 5, 2024
e378c6c
Run the new tw5.com testcases in the test edition
Jermolene May 6, 2024
1d89c79
Update data widget to display its content in JSON
Jermolene May 6, 2024
ff03a1b
Add testcase convenience procedure
Jermolene May 6, 2024
0db4c44
Clearer testcases for data widget, and docs tweaks
Jermolene May 6, 2024
43fe5e9
Don't expect our intentionally failing test to pass
Jermolene May 6, 2024
00ac550
Extend testcase default template so that the display format can be ch…
Jermolene May 6, 2024
d5b7bc7
DataWidget docs typo
Jermolene May 6, 2024
842434a
Merge branch 'testcase-widget' into geospatial-plugin
Jermolene May 6, 2024
5165fcd
Merge branch 'master' into geospatial-plugin
Jermolene May 20, 2024
7a25718
Merge branch 'master' into geospatial-plugin
Jermolene May 21, 2024
24f13ae
Mark Geospatial plugin as experimental
Jermolene May 21, 2024
f5bf377
Merge branch 'master' into geospatial-plugin
Jermolene May 21, 2024
e8782b7
Merge branch 'master' into geospatial-plugin
Jermolene May 29, 2024
6dc31b1
Update to Leaflet v1.9.4
Jermolene May 29, 2024
a0e8f32
Remove unneeded template
Jermolene May 29, 2024
a0d296c
Don't hide the volcanoes of the world data set
Jermolene May 29, 2024
bd2e329
Merge branch 'master' into geospatial-plugin
Jermolene May 29, 2024
9186fd5
Update Flickr demo docs
Jermolene May 29, 2024
fb1f076
Merge branch 'master' into geospatial-plugin
Jermolene May 30, 2024
6e342f9
Fix subtle typo that was preventing popups from working correctly
Jermolene May 30, 2024
2526b75
Go back to hiding the volcanoes of the world by default
Jermolene May 30, 2024
b0c5f1b
Merge branch 'master' into geospatial-plugin
Jermolene May 31, 2024
754fb6e
Clarify docs for tm-request-location
Jermolene May 31, 2024
a723055
Merge branch 'master' into geospatial-plugin
Jermolene May 31, 2024
d70167e
Update modified testcase from master
Jermolene May 31, 2024
e64aaaa
Prepare for merging
Jermolene May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bin/build-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,17 @@ node $TW5_BUILD_TIDDLYWIKI \
--rendertiddler $:/core/save/empty plugins/tiddlywiki/highlight/empty.html text/plain \
|| exit 1

# /plugins/tiddlywiki/geospatial/index.html Demo wiki with geospatial plugin
# /plugins/tiddlywiki/geospatial/empty.html Empty wiki with geospatial plugin
node $TW5_BUILD_TIDDLYWIKI \
./editions/geospatialdemo \
--verbose \
--load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \
--rendertiddler $:/core/save/all plugins/tiddlywiki/geospatial/index.html text/plain \
--rendertiddler $:/core/save/empty plugins/tiddlywiki/geospatial/empty.html text/plain \
|| exit 1

######################################################
#
# Language editions
Expand Down
5 changes: 3 additions & 2 deletions core/modules/commands/setfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ Command.prototype.execute = function() {
$tw.utils.each(tiddlers,function(title) {
var parser = wiki.parseTiddler(templatetitle),
newFields = {},
tiddler = wiki.getTiddler(title);
tiddler = wiki.getTiddler(title),
currentValue = tiddler ? (tiddler.fields[fieldname] || "") : "";
if(parser) {
var widgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title}});
var widgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title, currentValue: currentValue}});
var container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
newFields[fieldname] = rendertype === "text/html" ? container.innerHTML : container.textContent;
Expand Down
77 changes: 77 additions & 0 deletions core/modules/filters/json-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,54 @@ exports["jsontype"] = function(source,operator,options) {
return results;
};

exports["jsonset"] = function(source,operator,options) {
var suffixes = operator.suffixes || [],
type = suffixes[0] && suffixes[0][0],
indexes = operator.operands.slice(0,-1),
value = operator.operands[operator.operands.length - 1],
results = [];
if(operator.operands.length === 1 && operator.operands[0] === "") {
value = undefined; // Prevents the value from being assigned
}
switch(type) {
case "string":
// Use value unchanged
break;
case "boolean":
value = (value === "true" ? true : (value === "false" ? false : undefined));
break;
case "number":
value = $tw.utils.parseNumber(value);
break;
case "array":
indexes = operator.operands;
value = [];
break;
case "object":
indexes = operator.operands;
value = {};
break;
case "null":
indexes = operator.operands;
value = null;
break;
case "json":
value = $tw.utils.parseJSONSafe(value,function() {return undefined;});
break;
default:
// Use value unchanged
break;
}
source(function(tiddler,title) {
var data = $tw.utils.parseJSONSafe(title,title);
if(data) {
data = setDataItem(data,indexes,value);
results.push(JSON.stringify(data));
}
});
return results;
};

/*
Given a JSON data structure and an array of index strings, return an array of the string representation of the values at the end of the index chain, or "undefined" if any of the index strings are invalid
*/
Expand Down Expand Up @@ -186,5 +234,34 @@ function getDataItem(data,indexes) {
return item;
}

/*
Given a JSON data structure, an array of index strings and a value, return the data structure with the value added at the end of the index chain. If any of the index strings are invalid then the JSON data structure is returned unmodified. If the root item is targetted then a different data object will be returned
*/
function setDataItem(data,indexes,value) {
// Ignore attempts to assign undefined
if(value === undefined) {
return data;
}
// Check for the root item
if(indexes.length === 0 || (indexes.length === 1 && indexes[0] === "")) {
return value;
}
// Traverse the JSON data structure using the index chain
var current = data;
for(var i = 0; i < indexes.length - 1; i++) {
var index = indexes[i];
if($tw.utils.hop(current,index)) {
current = current[index];
} else {
// Return the original JSON data structure if any of the index strings are invalid
return data;
}
}
// Add the value to the end of the index chain
var lastIndex = indexes[indexes.length - 1];
current[lastIndex] = value;
return data;
}

})();

25 changes: 25 additions & 0 deletions core/modules/filters/url-ops.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*\
title: $:/core/modules/filters/url-ops.js
type: application/javascript
module-type: filteroperator

Filter operators for URL operations

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

exports["setquerystring"] = function(source,operator,options) {
var name = operator.operands.length >= 1 ? operator.operands[0] : null,
value = operator.operands.length >= 2 ? operator.operands[1] : "",
results = [];
source(function(tiddler,title) {
results.push($tw.utils.setQueryStringParameter(title,name,value));
});
return results;
};

})();
139 changes: 139 additions & 0 deletions core/modules/widgets/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*\
title: $:/core/modules/widgets/data.js
type: application/javascript
module-type: widget

Widget to represent a single item of data

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var Widget = require("$:/core/modules/widgets/widget.js").widget;

var DataWidget = function(parseTreeNode,options) {
this.dataWidgetTag = parseTreeNode.type;
this.initialise(parseTreeNode,options);
};

/*
Inherit from the base widget class
*/
DataWidget.prototype = new Widget();

/*
Render this widget into the DOM
*/
DataWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
this.execute();
this.renderChildren(parent,nextSibling);
};

/*
Compute the internal state of the widget
*/
DataWidget.prototype.execute = function() {
// Construct the child widgets
this.makeChildWidgets();
};

/*
Read the tiddler value(s) from a data widget – must be called after the .render() method
*/
DataWidget.prototype.readDataTiddlerValues = function() {
var self = this;
// Start with a blank object
var item = Object.create(null);
// Read any attributes not prefixed with $
$tw.utils.each(this.attributes,function(value,name) {
if(name.charAt(0) !== "$") {
item[name] = value;
}
});
item = new $tw.Tiddler(item);
// Deal with $tiddler, $filter or $compound-tiddler attributes
var tiddlers = [],title;
if(this.hasAttribute("$tiddler")) {
title = this.getAttribute("$tiddler");
if(title) {
tiddlers.push(this.wiki.getTiddler(title));
}
}
if(this.hasAttribute("$filter")) {
var filter = this.getAttribute("$filter");
if(filter) {
var titles = this.wiki.filterTiddlers(filter);
$tw.utils.each(titles,function(title) {
var tiddler = self.wiki.getTiddler(title);
tiddlers.push(tiddler);
});
}
}
if(this.hasAttribute("$compound-tiddler")) {
title = this.getAttribute("$compound-tiddler");
if(title) {
tiddlers.push.apply(tiddlers,this.extractCompoundTiddler(title));
}
}
// Convert the literal item to field strings
item = item.getFieldStrings();
if(tiddlers.length === 0) {
if(Object.keys(item).length > 0 && !!item.title) {
return [item];
} else {
return [];
}
} else {
var results = [];
$tw.utils.each(tiddlers,function(tiddler,index) {
var fields = tiddler.getFieldStrings();
results.push($tw.utils.extend({},fields,item));
});
return results;
}
};

/*
Helper to extract tiddlers from text/vnd.tiddlywiki-multiple tiddlers
*/
DataWidget.prototype.extractCompoundTiddler = function(title) {
var tiddler = this.wiki.getTiddler(title);
if(tiddler && tiddler.fields.type === "text/vnd.tiddlywiki-multiple") {
var text = tiddler.fields.text || "",
rawTiddlers = text.split(/\r?\n\+\r?\n/),
tiddlers = [];
$tw.utils.each(rawTiddlers,function(rawTiddler) {
var fields = Object.create(null),
split = rawTiddler.split(/\r?\n\r?\n/mg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rawTiddlers are split with 2 or more NLs ... text.split("\n+\n")
can rawTiddler be split with 2 new-lines again rawTiddler.split(/\r?\n\r?\n/mg); ... Did I misread something here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pmariotext.split("\n+\n") is not a regular expression, it's matching a plus sign surrounded by newlines. I think you're right that we should include support for carriage returns.

if(split.length >= 1) {
fields = $tw.utils.parseFields(split[0],fields);
}
if(split.length >= 2) {
fields.text = split.slice(1).join("\n\n");
}
tiddlers.push(new $tw.Tiddler(fields));
});
return tiddlers;
} else {
return [];
}
};

/*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
DataWidget.prototype.refresh = function(changedTiddlers) {
// Refresh our attributes
var changedAttributes = this.computeAttributes();
// Refresh our children, and indicate that we refreshed if any of our attribute values have changed
return this.refreshChildren(changedTiddlers) || $tw.utils.count(changedAttributes) > 0;
};

exports.data = DataWidget;

})();
Loading