from jps_gallery_tools.api import *
= JpsCuration() gallery
Japan Search Gallery Tools
Tools for working with Japan Search Gallery
Install
pip install jps_gallery_tools
実行例
How to use
See the documentation for full details of the Japan Search Gallery API Client.
ギャラリーの作成
'title', 'ja', 'はじめてのギャラリー')
gallery.setLangMetadata('summary', 'ja', 'はじめてのギャラリーを作成します。')
gallery.setLangMetadata("responsibility", "ja", "中村覚")
gallery.setLangMetadata("はじめて")
gallery.addTag("テスト") gallery.addTag(
トップ画像
= "https://blogger.googleusercontent.com/img/a/AVvXsEiTjjaWkCHeCslxeKujaQotjuR_HvhOHen7Ql7rQV8nmQl4ivLRF_CSabMY-JLJHNL-xHMe3VDyA9F-iv1RtQ2jFTk1Vnjck-veKLUZPdYqCcjzHkc8SGKb1fyZ_x8W66aTrSXQ78UN3CnyBakwwmmH_hmPKeEsTzq8J3e2zzUMylmDjCZ0LClPByBRRw=s400"
original_url = "https://blogger.googleusercontent.com/img/a/AVvXsEiTjjaWkCHeCslxeKujaQotjuR_HvhOHen7Ql7rQV8nmQl4ivLRF_CSabMY-JLJHNL-xHMe3VDyA9F-iv1RtQ2jFTk1Vnjck-veKLUZPdYqCcjzHkc8SGKb1fyZ_x8W66aTrSXQ78UN3CnyBakwwmmH_hmPKeEsTzq8J3e2zzUMylmDjCZ0LClPByBRRw=s180-c"
thumbnail_url = "初日の出のキャラクター"
title = "いらすとや"
source = JpsCurationUrlImage(original_url, title, source, thumbnail_url)
top_image gallery.setImage(top_image)
テキスト
= JpsCurationText()
part_01
gallery.addPart(part_01)"ja", "テキスト。テキスト。テキスト。テキスト。") part_01.addText(
リスト
= JpsCurationList("tile")
part_02 "title", "ja", "リストのタイトル")
part_02.setLangMetadata("title", "en", "List Title")
part_02.setLangMetadata( gallery.addPart(part_02)
4件の画像を追加
for i in range(4):
= JpsCurationListExternalLink()
item
part_02.addPart(item)"title", "ja", "外部リンクのタイトル")
item.setLangMetadata( item.setImage(top_image)
年表
= JpsCurationTimeline(1800, 2050)
part_03
gallery.addPart(part_03)"title", "ja", "年表のタイトル")
part_03.setLangMetadata("title", "en", "Timeline Title") part_03.setLangMetadata(
= JpsCurationTimepoint("時点のタイトル", "Timepoint Title", 1877, 1877)
part_03_01 part_03.addPart(part_03_01)
= JpsCurationText()
part_03_01_01
part_03_01.addPart(part_03_01_01)"ja", "時点のテキスト。時点のテキスト。時点のテキスト。時点のテキスト。") part_03_01_01.addText(
地図
= JpsCurationList("map")
part_04
gallery.addPart(part_04)"title", "ja", "地図のタイトル")
part_04.setLangMetadata("title", "en", "Map Title")
part_04.setLangMetadata(
"openActionType", "link")
part_04.setMetadata("mapParam", {
part_04.setMetadata("center": {
"lat": 35.713736762125464,
"lon": 139.76272050237696
},"zoom": 15,
"mode": "NORMAL"
})
import copy
from pprint import pprint
= copy.copy(item)
item_04_01
"latlon", {
item_04_01.setMetadata("lat": 35.713333,
"lon": 139.762222
}) part_04.addPart(item_04_01)
出力
"tmp/gallery.json") gallery.save(
= gallery.encode(curationType="GALLERY") b
import IPython
from IPython.display import display, HTML
= "ja"
lang
= HTML(f'''\
htm <div
class="jps"
data-lang="{lang}"
data-cur="{b}">
</div>
<script src="https://jpsearch.go.jp/assets/js/wp.bundle.js"></script>
''')
display(htm)