From 62d0dd33725546baa272e5676b1d564bfb11c188 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 18 Apr 2023 18:55:32 +0100 Subject: [PATCH] Move Flickr macros into geospatial plugin from the demo edition --- .../geospatialdemo/tiddlers/Flickr Demo.tid | 99 +------------------ .../tiddlywiki/geospatial/macros/Flickr.tid | 93 +++++++++++++++++ 2 files changed, 97 insertions(+), 95 deletions(-) create mode 100644 plugins/tiddlywiki/geospatial/macros/Flickr.tid diff --git a/editions/geospatialdemo/tiddlers/Flickr Demo.tid b/editions/geospatialdemo/tiddlers/Flickr Demo.tid index 5f43636b0..e6e12710b 100644 --- a/editions/geospatialdemo/tiddlers/Flickr Demo.tid +++ b/editions/geospatialdemo/tiddlers/Flickr Demo.tid @@ -1,104 +1,13 @@ title: Flickr Demo caption: Flickr -tags: $:/tags/Macro $:/tags/GeospatialDemo - - -\procedure flickr-get-items(per_page:"100",page_number:"1",method:"flickr.photosets.getPhotos",paramName:"group_id",resultPhotoRoot:"photoset") - -\procedure completion() -\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]] - <$action-log msg="In completion"/> - <$action-log/> - - <$list filter="[compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore"> - <$list filter="[jsonindexes,[photo]]" variable="photoIndex"> - <$let - photoData={{{ [jsonextract,[photo],] }}} - photoFarm={{{ [jsonget[farm]] }}} - photoServer={{{ [jsonget[server]] }}} - photoID={{{ [jsonget[id]] }}} - photoSecret={{{ [jsonget[secret]] }}} - > - <$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]] }}} - /> - - - <$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=<>/> - - - -\end completion - -\procedure progress() -\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]] - <$action-log message="In progress-actions"/> -\end progress - -\procedure request-url() -https://api.flickr.com/services/rest/ -\end request-url - -<$action-sendmessage - $message="tm-http-request" - url=<> - method="GET" - query-method=<> - query-extras="geo" - query-per_page=<> - query-page=<> - query-format="json" - query-nojsoncallback="1" - $names="[addprefix[query-]]" - $values={{$:/config/flickr-param}} - header-accept="application/json" - password-query-api_key="flickr-api-key" - bind-status="$:/temp/flickr/status" - bind-progress="$:/temp/flickr/progress" - oncompletion=<> - onprogress=<> - var-method=<> - var-per_page=<> - var-page_number=<> - var-resultPhotoRoot=<> -/> -\end - -\procedure flickr-get-photos-of-user-items() -<$macrocall $name="flickr-get-items" method="flickr.people.getPhotosOf" paramName="user_id" resultPhotoRoot="photos"/> -\end - -\procedure flickr-get-group-items() -<$macrocall $name="flickr-get-items" method="flickr.groups.pools.getPhotos" paramName="group_id" resultPhotoRoot="photos"/> -\end - -\procedure flickr-get-album-items() -<$macrocall $name="flickr-get-items" method="flickr.photosets.getPhotos" paramName="photoset_id" resultPhotoRoot="photoset"/> -\end - -\procedure flickr-get-interesting-items() -<$macrocall $name="flickr-get-items" method="flickr.interestingness.getList" resultPhotoRoot="photos"/> -\end +tags: $:/tags/GeospatialDemo ! Retrieve Geotagged Flickr Photos Parameter for Flickr retrievals: <$edit-text tiddler="$:/config/flickr-param" tag="input"/> <$button> -<$macrocall $name="flickr-get-album-items"/> +<$macrocall $name="flickr-get-album-items" albumID={{$:/config/flickr-param}}/> Get Flickr album (parameter shuld be an album ID, e.g. 72157630297432522) @@ -108,11 +17,11 @@ Get Flickr interesting items (no parameter needed) <$button> -<$macrocall $name="flickr-get-photos-of-user-items"/> +<$macrocall $name="flickr-get-photos-of-user-items" userID={{$:/config/flickr-param}}/> Get Flickr photos of user (parameter shuld be a user ID, e.g. 35468148136@N01) <$button> -<$macrocall $name="flickr-get-group-items"/> +<$macrocall $name="flickr-get-group-items" groupID={{$:/config/flickr-param}}/> Get Flickr group (parameter shuld be an album ID, e.g. 22075379@N00) diff --git a/plugins/tiddlywiki/geospatial/macros/Flickr.tid b/plugins/tiddlywiki/geospatial/macros/Flickr.tid new file mode 100644 index 000000000..42cc2eb39 --- /dev/null +++ b/plugins/tiddlywiki/geospatial/macros/Flickr.tid @@ -0,0 +1,93 @@ +title: $:/plugins/tiddlywiki/geospatial/macros/Flickr +tags: $:/tags/Macro + + +\procedure flickr-get-items(per_page:"100",page_number:"1",method:"flickr.photosets.getPhotos",paramName:"group_id",paramValue:"",resultPhotoRoot:"photoset") + +\procedure completion() +\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]] + <$action-log msg="In completion"/> + <$action-log/> + + <$list filter="[compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore"> + <$list filter="[jsonindexes,[photo]]" variable="photoIndex"> + <$let + photoData={{{ [jsonextract,[photo],] }}} + photoFarm={{{ [jsonget[farm]] }}} + photoServer={{{ [jsonget[server]] }}} + photoID={{{ [jsonget[id]] }}} + photoSecret={{{ [jsonget[secret]] }}} + > + <$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]] }}} + /> + + + <$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=<>/> + + + +\end completion + +\procedure progress() +\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]] + <$action-log message="In progress-actions"/> +\end progress + +\procedure request-url() +https://api.flickr.com/services/rest/ +\end request-url + +<$action-sendmessage + $message="tm-http-request" + url=<> + method="GET" + query-method=<> + query-extras="geo" + query-per_page=<> + query-page=<> + query-format="json" + query-nojsoncallback="1" + $names="[addprefix[query-]]" + $values=<> + header-accept="application/json" + password-query-api_key="flickr-api-key" + bind-status="$:/temp/flickr/status" + bind-progress="$:/temp/flickr/progress" + oncompletion=<> + onprogress=<> + var-method=<> + var-per_page=<> + var-page_number=<> + var-resultPhotoRoot=<> +/> +\end + +\procedure flickr-get-photos-of-user-items(userID) +<$macrocall $name="flickr-get-items" method="flickr.people.getPhotosOf" paramName="user_id" paramValue=<> resultPhotoRoot="photos"/> +\end + +\procedure flickr-get-group-items(groupID) +<$macrocall $name="flickr-get-items" method="flickr.groups.pools.getPhotos" paramName="group_id" paramValue=<> resultPhotoRoot="photos"/> +\end + +\procedure flickr-get-album-items(albumID) +<$macrocall $name="flickr-get-items" method="flickr.photosets.getPhotos" paramName="photoset_id" paramValue=<> resultPhotoRoot="photoset"/> +\end + +\procedure flickr-get-interesting-items() +<$macrocall $name="flickr-get-items" method="flickr.interestingness.getList" resultPhotoRoot="photos"/> +\end