1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-07 18:39:57 +00:00
TiddlyWiki5/plugins/tiddlywiki/geospatial/demo/flickr.tid

106 lines
3.5 KiB
Plaintext
Raw Normal View History

title: $:/plugins/tiddlywiki/geospatial/demo/flickr
caption: Flickr
tags: $:/tags/Macro $:/tags/GeospatialDemo
<!--
Get items from a Flickr album/interestingness/collection etc.
-->
2023-01-18 11:55:20 +00:00
\procedure flickr-get-items(per_page:"100",page_number:"1",method:"flickr.photosets.getPhotos",resultPhotoRoot:"photoset")
2023-01-18 11:27:14 +00:00
\procedure completion()
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
<$action-log msg="In completion"/>
<$action-log/>
<!-- Success -->
<$list filter="[<status>compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore">
<$list filter="[<data>jsonindexes<resultPhotoRoot>,[photo]]" variable="photoIndex">
<$let
photoData={{{ [<data>jsonextract<resultPhotoRoot>,[photo],<photoIndex>] }}}
photoFarm={{{ [<photoData>jsonget[farm]] }}}
photoServer={{{ [<photoData>jsonget[server]] }}}
photoID={{{ [<photoData>jsonget[id]] }}}
photoSecret={{{ [<photoData>jsonget[secret]] }}}
>
<$action-setfield
$tiddler={{{ [<photoID>addprefix[Flickr Photo ]] }}}
tags="$:/tags/GeoMarker $:/tags/FlickrPhoto"
caption={{{ [<photoData>jsonget[title]] }}}
lat={{{ [<photoData>jsonget[latitude]] }}}
long={{{ [<photoData>jsonget[longitude]] }}}
alt="0"
photo-url={{{ [[https://farm]addsuffix<photoFarm>addsuffix[.staticflickr.com/]addsuffix<photoServer>addsuffix[/]addsuffix<photoID>addsuffix[_]addsuffix<photoSecret>addsuffix[_b.jpg]] }}}
icon-url={{{ [[https://farm]addsuffix<photoFarm>addsuffix[.staticflickr.com/]addsuffix<photoServer>addsuffix[/]addsuffix<photoID>addsuffix[_]addsuffix<photoSecret>addsuffix[_s.jpg]] }}}
/>
</$let>
</$list>
2023-01-18 11:55:20 +00:00
<$let
pages={{{ [<data>jsonget[photos],[pages]] }}}
>
<$list filter="[<page_number>compare:number:lt<pages>]" variable="ignore">
<$macrocall $name="flickr-get-items" page_page=<<per_page>> page_number={{{ [<page_number>add[1]] }}} method=<<method>> resultPhotoRoot=<<resultPhotoRoot>>/>
</$list>
</$let>
</$list>
\end completion
2023-01-18 11:27:14 +00:00
\procedure progress()
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
<$action-log message="In progress-actions"/>
\end progress
2023-01-18 11:27:14 +00:00
\procedure request-url()
https://api.flickr.com/services/rest/
\end request-url
<$action-sendmessage
$message="tm-http-request"
url=<<request-url>>
method="GET"
2023-01-18 11:27:14 +00:00
query-method=<<method>>
query-extras="geo"
2023-01-18 11:55:20 +00:00
query-per_page=<<per_page>>
query-page=<<page_number>>
query-format="json"
query-nojsoncallback="1"
query-photoset_id={{$:/config/flickr-album}}
header-accept="application/json"
password-query-api_key="flickr-api-key"
bind-status="$:/temp/flickr/status"
bind-progress="$:/temp/flickr/progress"
oncompletion=<<completion>>
onprogress=<<progress>>
2023-01-18 11:55:20 +00:00
var-method=<<method>>
var-per_page=<<per_page>>
var-page_number=<<page_number>>
2023-01-18 11:27:14 +00:00
var-resultPhotoRoot=<<resultPhotoRoot>>
/>
\end
2023-01-18 11:27:14 +00:00
\procedure flickr-get-album-items()
<$macrocall $name="flickr-get-items" method="flickr.photosets.getPhotos" resultPhotoRoot="photoset"/>
\end
2023-01-18 11:27:14 +00:00
\procedure flickr-get-interesting-items()
<$macrocall $name="flickr-get-items" method="flickr.interestingness.getList" resultPhotoRoot="photos"/>
\end
2023-01-18 11:27:14 +00:00
\procedure flickr-actions()
<$macrocall $name="flickr-get-album-items"/>
\end
! Retrieve Geotagged Flickr Photos
Flickr API Key: <$password name="flickr-api-key"/>
Flickr album ID: <$edit-text tiddler="$:/config/flickr-album" tag="input"/>
<$button>
<$macrocall $name="flickr-get-album-items"/>
Get Flickr album
</$button>
<$button>
<$macrocall $name="flickr-get-interesting-items"/>
Get Flickr interesting items
</$button>