1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Improve Zotero API demo

This commit is contained in:
jeremy@jermolene.com 2023-01-13 13:44:31 +00:00
parent 46e24042bf
commit e635de359e
2 changed files with 52 additions and 16 deletions

View File

@ -1,6 +1,16 @@
title: WidgetMessage: tm-http-request Example - Zotero title: WidgetMessage: tm-http-request Example - Zotero
tags: $:/tags/Macro tags: $:/tags/Macro
\define select-zotero-group()
Specify the Zotero group ID to import
<$edit-text tiddler="$:/config/zotero-group" tag="input"/> or
<$select tiddler="$:/config/zotero-group">
<option value="4813312">com216</option>
<option value="4913310">pos252</option>
<option value="4747244">idt575</option>
</$select>
\end
\define zotero-save-item(item) \define zotero-save-item(item)
<$action-createtiddler <$action-createtiddler
$basetitle={{{ =[[_zotero_import ]] =[<item>jsonget[key]] =[[ ]] =[<item>jsonget[title]] +[join[]] }}} $basetitle={{{ =[[_zotero_import ]] =[<item>jsonget[key]] =[[ ]] =[<item>jsonget[title]] +[join[]] }}}
@ -8,6 +18,9 @@ tags: $:/tags/Macro
tags="$:/tags/ZoteroImport" tags="$:/tags/ZoteroImport"
> >
<$action-setmultiplefields $tiddler=<<createTiddler-title>> $fields="[<item>jsonindexes[]addprefix[zotero-]]" $values="[<item>jsonindexes[]] :map[<item>jsonget<currentTiddler>else[.XXXXX.]]"/> <$action-setmultiplefields $tiddler=<<createTiddler-title>> $fields="[<item>jsonindexes[]addprefix[zotero-]]" $values="[<item>jsonindexes[]] :map[<item>jsonget<currentTiddler>else[.XXXXX.]]"/>
<$list filter="[<item>jsonindexes[creators]]" variable="creatorIndex">
<$action-setmultiplefields $tiddler=<<createTiddler-title>> $fields="[<item>jsonget[creators],<creatorIndex>,[creatorType]addprefix[zotero-]]" $values="[<item>jsonget[creators],<creatorIndex>,[lastName]] [<item>jsonget[creators],<creatorIndex>,[firstName]] +[join[, ]] :else[<item>jsonget[creators],<creatorIndex>,[name]] "/>
</$list>
</$action-createtiddler> </$action-createtiddler>
\end zotero-save-item \end zotero-save-item
@ -40,32 +53,53 @@ tags: $:/tags/Macro
\end progress \end progress
\define request-url() \define request-url()
https://api.zotero.org/groups/27508/items/?format=json&sort=title \rules only transcludeinline transcludeblock filteredtranscludeinline filteredtranscludeblock
https://api.zotero.org/groups/{{$:/config/zotero-group}}/items/
\end request-url \end request-url
<$action-sendmessage <$wikify name="url" text=<<request-url>>>
$message="tm-http-request" <$action-sendmessage
url={{{ [<request-url>setquerystring[start],<__start__>setquerystring[limit],<__limit__>] }}} $message="tm-http-request"
method="GET" url=<<url>>
header-accept="application/json" method="GET"
bind-status="$:/temp/zotero/status" query-format="json"
bind-progress="$:/temp/zotero/progress" query-sort="title"
oncompletion=<<completion>> query-start=<<__start__>>
onprogress=<<progress>> query-limit=<<__limit__>>
var-start=<<__start__>> header-accept="application/json"
var-limit=<<__limit__>> bind-status="$:/temp/zotero/status"
/> bind-progress="$:/temp/zotero/progress"
oncompletion=<<completion>>
onprogress=<<progress>>
var-start=<<__start__>>
var-limit=<<__limit__>>
/>
</$wikify>
\end \end
\define zotero-actions() \define zotero-actions()
<$macrocall $name="zotero-get-items" start="0" limit="5"/> <$macrocall $name="zotero-get-items" start="0" limit="50"/>
\end \end
<<select-zotero-group>>
<$button actions=<<zotero-actions>>> <$button actions=<<zotero-actions>>>
Call Zotero Start import from Zotero group
</$button> </$button>
Tiddlers: <$list filter="[tag[$:/tags/ZoteroImport]limit[1]]" variable="ignore">
!! Imported Tiddlers
<$button>
<$action-deletetiddler $filter="[tag[$:/tags/ZoteroImport]]"/>
Delete these tiddlers
</$button>
Export: <$macrocall $name="exportButton" exportFilter="[tag[$:/tags/ZoteroImport]]" lingoBase="$:/language/Buttons/ExportTiddlers/"/>
</$list>
<ol> <ol>
<$list filter="[tag[$:/tags/ZoteroImport]]"> <$list filter="[tag[$:/tags/ZoteroImport]]">

View File

@ -0,0 +1,2 @@
title: $:/config/zotero-group
text: 4813312