From 59a8cf327440be21e1fcbe3eaae28f926af226db Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 18 Apr 2023 22:32:02 +0100 Subject: [PATCH] FlickrMacros: Use a template to define photo tiddler fields --- .../tiddlywiki/geospatial/macros/Flickr.tid | 31 ++++++++++++------- .../macros/FlickrDefaultPhotoTemplate.tid | 11 +++++++ 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 plugins/tiddlywiki/geospatial/macros/FlickrDefaultPhotoTemplate.tid diff --git a/plugins/tiddlywiki/geospatial/macros/Flickr.tid b/plugins/tiddlywiki/geospatial/macros/Flickr.tid index 42cc2eb39..f014714a5 100644 --- a/plugins/tiddlywiki/geospatial/macros/Flickr.tid +++ b/plugins/tiddlywiki/geospatial/macros/Flickr.tid @@ -4,7 +4,7 @@ tags: $:/tags/Macro -\procedure flickr-get-items(per_page:"100",page_number:"1",method:"flickr.photosets.getPhotos",paramName:"group_id",paramValue:"",resultPhotoRoot:"photoset") +\procedure flickr-get-items(per_page:"100",page_number:"1",method:"flickr.photosets.getPhotos",paramName:"group_id",paramValue:"",resultPhotoRoot:"photoset",photoTiddlerTemplate:"$:/plugins/tiddlywiki/geospatial/macros/Flickr/DefaultPhotoTemplate") \procedure completion() \import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]] @@ -19,24 +19,30 @@ Get items from a Flickr album/interestingness/collection etc. photoServer={{{ [jsonget[server]] }}} photoID={{{ [jsonget[id]] }}} photoSecret={{{ [jsonget[secret]] }}} + photoTiddlerTitleFilter={{{ [getindex[title]] }}} + photoTiddlerTitle={{{ [subfilter] }}} > - <$action-setfield - $tiddler={{{ [addprefix[Flickr Photo ]] }}} - tags="$:/tags/GeoMarker $:/tags/FlickrPhoto" - caption={{{ [jsonget[title]] }}} - lat={{{ [jsonget[latitude]] }}} - long={{{ [jsonget[longitude]] }}} - alt="0" - photo-url={{{ [[https://farm]addsuffixaddsuffix[.staticflickr.com/]addsuffixaddsuffix[/]addsuffixaddsuffix[_]addsuffixaddsuffix[_b.jpg]] }}} - icon-url={{{ [[https://farm]addsuffixaddsuffix[.staticflickr.com/]addsuffixaddsuffix[/]addsuffixaddsuffix[_]addsuffixaddsuffix[_s.jpg]] }}} - /> + <$list filter="[indexes[]]" variable="fieldName"> + <$let fieldValueFilter={{{ [getindex] }}}> + <$action-log + $tiddler=<> + $field=<> + $value={{{ [subfilter] }}} + /> + <$action-setfield + $tiddler=<> + $field=<> + $value={{{ [subfilter] }}} + /> + + <$let pages={{{ [jsonget[photos],[pages]] }}} > <$list filter="[compare:number:lt]" variable="ignore"> - <$macrocall $name="flickr-get-items" page_page=<> page_number={{{ [add[1]] }}} method=<> resultPhotoRoot=<>/> + <$macrocall $name="flickr-get-items" page_page=<> page_number={{{ [add[1]] }}} method=<> resultPhotoRoot=<> photoTiddlerTemplate=<>/> @@ -73,6 +79,7 @@ https://api.flickr.com/services/rest/ var-per_page=<> var-page_number=<> var-resultPhotoRoot=<> + var-photoTiddlerTemplate=<> /> \end diff --git a/plugins/tiddlywiki/geospatial/macros/FlickrDefaultPhotoTemplate.tid b/plugins/tiddlywiki/geospatial/macros/FlickrDefaultPhotoTemplate.tid new file mode 100644 index 000000000..0a4e666e7 --- /dev/null +++ b/plugins/tiddlywiki/geospatial/macros/FlickrDefaultPhotoTemplate.tid @@ -0,0 +1,11 @@ +title: $:/plugins/tiddlywiki/geospatial/macros/Flickr/DefaultPhotoTemplate +type: application/x-tiddler-dictionary + +title: [addprefix[Flickr Photo ]] +tags: $:/tags/GeoMarker $:/tags/FlickrPhoto +[join[ ]] +caption: [jsonget[title]] +lat: [jsonget[latitude]] +long: [jsonget[longitude]] +alt: 0 +photo-url: [[https://farm]addsuffixaddsuffix[.staticflickr.com/]addsuffixaddsuffix[/]addsuffixaddsuffix[_]addsuffixaddsuffix[_b.jpg]] +icon-url: [[https://farm]addsuffixaddsuffix[.staticflickr.com/]addsuffixaddsuffix[/]addsuffixaddsuffix[_]addsuffixaddsuffix[_s.jpg]]