Download presentation
Presentation is loading. Please wait.
1
Developing extensions for Fluid Topics
FT 401 Copyright © Antidot 2016
2
Introducing FT connectors
Developing extensions for Fluid Topics Introducing FT connectors Copyright © Antidot 2014
3
Introducing FT connectors
Copyright © Antidot 2014
4
Introducing FT connectors
=FSON zip Copyright © Antidot 2014
5
Introducing FT connectors
A FT connector must send an archive to FluidTopics pipeline. ZIP fluid_source.json *.map *.topic fluid_action.json Copyright © Antidot 2014 fluid_{publish|delete|…}.json
6
Introducing FT connectors
A FT connector must send an archive to FluidTopics pipeline. ZIP fluid_source.json =FsonMap =FsonTopic fluid_action.json Copyright © Antidot 2014 fluid_{publish|delete|…}.json
7
Introducing FT connectors
Steps Set up development environment Initialize a project Fson API Basic objects Build basic objects Build Fson Zip Copyright © Antidot 2015
8
Development environment
Developing extensions for Fluid Topics Development environment Copyright © Antidot 2014
9
Development environment
Use: ft_connector_builder The command creates directories structure and provides scripts + configuration for packaging The README file explains the structure and how to put the project under a git repository.
10
Development environment
Example with PyCharm Copyright © Antidot 2015
11
Development environment
Example with PyCharm Copyright © Antidot 2015
12
Development environment
Example with PyCharm Copyright © Antidot 2015
13
Development environment
You are now ready to build FT connectors!
14
Exercise #1 Developing extensions for Fluid Topics
Copyright © Antidot 2014
15
Exercise #1 Send an archive to Fluid Topics PaF
Create 3 archives to be send to in FluidTopics topic1 MyMap1 Heineken Chimay Pietra BeerMap Yoda Anakin Leia Luke StarMap Copyright © Antidot 2014
16
Exercise #1 Send an archive to Fluid Topics PaF
Create 3 archives to be send to in FluidTopics ZIP maps/ |- MyMap1.map |- BeerMap.map |- StarMap.map topics/ |- topic1.topic |- Heineken.topic |- ... - fluid_source.json - fluid_action.json - fluid_{publish | delete | … }.json Copyright © Antidot 2014 No mandatory path in archive, except that topic must finish with the “.topic” extension and maps must finish with “.map” extension
17
Exercise #1 Send an archive to Fluid Topics PaF
Create 3 archives to be send to in FluidTopics ZIP maps/ |- MyMap1.map |- BeerMap.map |- StarMap.map topics/ |- topic1.topic |- Heineken.topic |- ... - fluid_source.json - fluid_action.json - fluid_{publish | delete | … }.json Copyright © Antidot 2014 FsonMap template 1 FsonMap template 2 No mandatory path in archive, except that topic must finish with the “.topic” extension and maps must finish with “.map” extension Please refer to given templates FsonTopic template
18
Exercise #1 FsonMap MyMap1 topic1 { "title": "MyMap1", "facets" : [],
"lang": "en-US", "tableOfContents": { "children": [ { "filePath": "../topics/topic1.topic", "children": [] }] } topic1 MyMap1 Absolute path of the Map in archive: maps/MyMap1.map Copyright © Antidot 2015
19
Exercise #1 FsonMap FsonTopic MyMap1 topic1 { "title": "MyMap1",
"facets" : [], "lang": "en-US", "tableOfContents": { "children": [ { "filePath": "../topics/topic1.topic", "children": [] }] } topic1 MyMap1 /!\ Relative path of the topic from the map FsonTopic { "title" : "topic1", "facets": {}, "body": "<div> <p> topic1 HTML content </p></div>" } Copyright © Antidot 2015 This is a path of the first topic of this map. The path design the topic location in archive relatively to the map location Absolute path of the Topic in archive: topics/topic1.topic1
20
Exercise #1 BeerMap Heineken Chimay Pietra Facets: 'Version’: 3.5, 3.6
'Product’: 'Beers' Facet: 'Version’: 3.5 Facet: 'Version’: 3.6 Copyright © Antidot 2015
21
Exercise #1 StarMap Yoda Anakin Leia Luke Facets:
"Force": "Right Side", "Bad Side" Facets: "Force": "Right Side” Facets: "Force": "Right Side", "Bad Side” Facets: "Force": "Right Side” Copyright © Antidot 2015 Facets: "Force": "Right Side”
22
Fson API Developing extensions for Fluid Topics
Copyright © Antidot 2014
23
Fson API Basic objects
24
Overview FsonZip ZIP Fson Book Fson ToC is composed of Fson_path (path in fson archive) Fson Topic Copyright © Antidot 2014 Contains serialization of FsonMap and FsonTopic from Fson_path
25
Basic Fson Objects FsonTopic - title body - facets - cluster
- attachment title body facets cluster attachment Topic title Html content, between <div> tag. List of facets Topic cluster value If the topic refers to a Pdf, Docx, etc. The topic has an attachment but no body. Copyright © Antidot 2015 The topic title (type string) The topic content. Must be a string at the Html format between <div> tag. List of topic facets (type list of FsonFacet, can be empty) Topic cluster. (type FsonCluster, can be None) If the topic is a document like Pdf, Docx, etc. The topic has an attachment but no body. (type FsonAttachment)
26
Basic Fson Objects FsonTopic - title body - facets - cluster
- attachment title body facets cluster attachment string FsonFacet FsonCluster FsonAttachment Copyright © Antidot 2015 The topic title (type string) The topic content. Must be a string at the Html format between <div> tag. List of topic facets (type list of FsonFacet, can be empty) Topic cluster. (type FsonCluster, can be None) If the topic is a document like Pdf, Docx, etc. The topic has an attachment but no body. (type FsonAttachment)
27
Basic Fson Objects FsonMap title rights facets cluster lang
table_of_contents Map title Map rights (PUBLIC by default) List of map facets Map cluster Map language Map table of content - title - facets - cluster - rights - lang - table_of_contents Copyright © Antidot 2015 The map title (type string) The map rights which is public by default. (type FsonRight) List of map facets (type list of FsonFacet, can be empty) Map cluster. (type FsonCluster, can be None) Map language (type string) Map table of content (type FsonToc)
28
Basic Fson Objects FsonMap title rights facets cluster lang
table_of_contents string FsonRight FsonFacet FsonCluster FsonToc - title - facets - cluster - rights - lang - table_of_contents Copyright © Antidot 2015 The map title (type string) The map rights which is public by default. (type FsonRight) List of map facets (type list of FsonFacet, can be empty) Map cluster. (type FsonCluster, can be None) Map language (type string) Map table of content (type FsonToc)
29
Basic Fson Objects Fson Builder Fson Object FT Object FsonMap
FsonTopic FsonToc FsonTocEntry Fson Object Book Topic TOC FT Object FsonMapBuilder FsonTopicBuilder FsonTocBuilder FsonTocEntryBuilder
30
How to build basic objects
Fson API How to build basic objects
31
How to build FsonTopic builder = FsonTopicBuilder()
builder.set_title('my_topic1') builder.set_body('<div>My HTML Body</div>') builder.set_facets([FsonFacet('Facet_key', ['val1', 'val2']),…]) fson_topic = builder.build() Copyright © Antidot 2015
32
How to build FsonTopic builder = FsonTopicBuilder()
builder.set_title('my_topic1') builder.set_body('<div>My HTML Body</div>') builder.set_facets([FsonFacet('Facet_key', ['val1', 'val2']),…]) fson_topic = builder.build() Copyright © Antidot 2015
33
Build FsonToc A Toc correspond to a tree structure Example: My_book1
|-topic1 | |-topic1.1 | |-topic1.2 |-topic2 |-topic3 |-topic3.1 |-topic3.1.1 My_book1 topic1 topic2 topic3 topic1.2 topic3.1 topic3.1.1 topic1.1 Copyright © Antidot 2015
34
Build FsonToc A Toc is built with FsonTocEntryBuilder and FsonTocBuilder Necessary to begin with the tree leaf. For each node element, create an fson path to be added in the ToC. FsonTopic and FsonMap will be then serialized in an archive with this path (repectively) Copyright © Antidot 2015
35
Build FsonToc My_book1 topic1 topic2 topic3 topic1.2 topic3.1
toc_entry_builder = FsonTocEntryBuilder() toc_entry_builder.set_file_path('topic1.1.topic') topic1_1_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.2.topic') topic1_2_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.topic') toc_entry_builder.add_child(topic1_1_entry) toc_entry_builder.add_child(topic1_2_entry) topic1_entry = toc_entry_builder.build() etc... Copyright © Antidot 2015 Using FsonTocBuilder and FsonTocEntryBuilder
36
Build FsonToc My_book1 topic1 topic2 topic3 topic1.2 topic3.1
toc_entry_builder = FsonTocEntryBuilder() toc_entry_builder.set_file_path('topic1.1.topic') topic1_1_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.2.topic') topic1_2_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.topic') toc_entry_builder.add_child(topic1_1_entry) toc_entry_builder.add_child(topic1_2_entry) topic1_entry = toc_entry_builder.build() etc... Copyright © Antidot 2015 Using FsonTocBuilder and FsonTocEntryBuilder
37
Build FsonToc My_book1 topic1 topic2 topic3 topic1.2 topic3.1
toc_entry_builder = FsonTocEntryBuilder() toc_entry_builder.set_file_path('topic1.1.topic') topic1_1_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.2.topic') topic1_2_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.topic') toc_entry_builder.add_child(topic1_1_entry) toc_entry_builder.add_child(topic1_2_entry) topic1_entry = toc_entry_builder.build() etc... Copyright © Antidot 2015 Using FsonTocBuilder and FsonTocEntryBuilder
38
Build FsonToc My_book1 topic1 topic2 topic3 topic1.2 topic3.1
toc_entry_builder = FsonTocEntryBuilder() toc_entry_builder.set_file_path('topic1.1.topic') topic1_1_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.2.topic') topic1_2_entry = toc_entry_builder.build() toc_entry_builder.set_file_path('topic1.topic') toc_entry_builder.add_child(topic1_1_entry) toc_entry_builder.add_child(topic1_2_entry) topic1_entry = toc_entry_builder.build() etc... Copyright © Antidot 2015 Using FsonTocBuilder and FsonTocEntryBuilder
39
Build FsonToc Building the Toc requires a post fixed course of the tree (i.e manage leaf before their parents) 5 7 6 8 3 4 2 1 10 9 Prefix: 1, 2, 4, 8, 9, 5, 10, 3, 6, 7 (VGD) Copyright © Antidot 2015 Infix: 8, 4, 9, 2, 10, 5, 1, 6, 3, 7 (GVD) Suffix: 8, 9, 4, 10, 5, 2, 6, 7, 3, 1 (GDV)
40
Build FsonToc Building the Toc requires a post fixed course of the tree (i.e manage leaf before their parents) 5 7 6 8 3 4 2 1 10 9 Prefix: 1, 2, 4, 8, 9, 5, 10, 3, 6, 7 (VGD) Copyright © Antidot 2015 Infix: 8, 4, 9, 2, 10, 5, 1, 6, 3, 7 (GVD) Suffix: 8, 9, 4, 10, 5, 2, 6, 7, 3, 1 (GDV) Cf. provided template: fson_toc_example.py
41
How to build FsonMap builder = FsonMapBuilder()
builder.set_title('my_map') builder.set_toc(fson_toc) #previously built fson_map = builder.build() Copyright © Antidot 2015
42
How to build FsonMap builder = FsonMapBuilder()
builder.set_title('my_map') builder.set_toc(fson_toc) #previously built fson_map = builder.build() Copyright © Antidot 2015
43
Exercise #2 Developing extensions for Fluid Topics
Copyright © Antidot 2014
44
Exercise #2 Use FSON builders statically
Create the previous 3 maps by using Fson Builders Copyright © Antidot 2014
45
Exercise #2 MyMap1 FsonMap MyMap1 topic1 FsonTopic {
"title": "MyMap1", "facets" : [], "lang": "en-US", "tableOfContents": { "children": [ { "filePath": "../topics/topic1.topic", "children": [] }] } FsonMap MyMap1 topic1 MyMap1 { "title" : "topic1", "facets": {}, "body": "<div> <p> topic1 HTML content </p></div>" } FsonTopic Copyright © Antidot 2014
46
Exercise #2 MyMap1 topic1 create_static_publis.py
def get_my_map(fson_zip_builder: FsonZipBuilder): # create topic 1 # create Table of Content # create MyMap1 # add Map and topic to zip archive Exercise #2 + + + + topic1 MyMap1 Copyright © Antidot 2015 create_static_publis.py
47
Exercise #2 _ _ MyMap1 topic1 create_static_publis.py
def get_my_map(fson_zip_builder: FsonZipBuilder): # create topic 1 topic_builder = FsonTopicBuilder() topic_builder.set_title('topic1') topic_builder.set_body(""" <div> <p> This is the content of the topic 1 </p> </div> """) fson_topic1 = topic_builder.build() # create Table of Content # create MyMap1 # add Map and topic to zip archive _ Exercise #2 topic1 MyMap1 _ + + + Copyright © Antidot 2015 create_static_publis.py
48
Exercise #2 _ MyMap1 _ topic1 create_static_publis.py
def get_my_map(fson_zip_builder: FsonZipBuilder): # create topic 1 # create Table of Content toc_entry_builder = FsonTocEntryBuilder() toc_entry_builder.set_file_path( '../topics/topic1.topic’ ) topic1_entry = toc_entry_builder.build() toc_builder = FsonTocBuilder() toc_builder.add_child(topic1_entry) toc = toc_builder.build() # create MyMap1 # add Map and topic to zip archive Exercise #2 + _ topic1 MyMap1 _ + Copyright © Antidot 2015 + create_static_publis.py
49
Exercise #2 _ _ MyMap1 topic1 create_static_publis.py
def get_my_map(fson_zip_builder: FsonZipBuilder): # create topic 1 # create Table of Content # create MyMap1 map_builder = FsonMapBuilder() map_builder.set_title('MyMap1') map_builder.set_toc(toc) my_map = map_builder.build() # add Map and topic to zip archive Exercise #2 + + _ topic1 MyMap1 _ + Copyright © Antidot 2015 create_static_publis.py
50
Exercise #2 _ MyMap1 _ topic1 create_static_publis.py
def get_my_map(fson_zip_builder: FsonZipBuilder): # create topic 1 # create Table of Content # create MyMap1 # add Map and topic to zip archive fson_zip_builder.add_ft_map(my_map, 'maps/MyMap1.map') fson_zip_builder.add_ft_topic(fson_topic1, 'topics/topic1.topic') Exercise #2 + + + _ topic1 MyMap1 _ Copyright © Antidot 2015 create_static_publis.py
51
How to build and send publication
Fson API How to build and send publication
52
Build Fson publication
fson_params = FSonParam(FsonSource(mapId, mapTitle, mapType, mapDescription)) map_pub = FsonMapPublication(mapId, mapPath, map, topics, assets) #NB : assets = images, pj, etc. fson_client = FsonClient(fson_sender) #fson_sender -> cf. ex filtre Robin fson_client.publish_map(fson_params, mode.{INCREMENTAL|FULL}, map_pub) Copyright © Antidot 2015
53
Send FsonZip sender = FsonZipSender(WSClientFactory(paf_configuration).get_paf_driver()) sender.send_zip('my_zip_name.zip', fson_zip_data) # previously built Copyright © Antidot 2015
54
Send FsonZip sender = FsonZipSender(WSClientFactory(paf_configuration).get_paf_driver()) sender.send_zip('my_zip_name.zip', fson_zip_data) # previously built Copyright © Antidot 2015
55
Exercise #3 Developing extensions for Fluid Topics
Copyright © Antidot 2014
56
Exercise #3 Use FSON builders dynamically
Parse a JSON input (cf. provided file: book.json) Use FsonBuilders to create the archive Copyright © Antidot 2014
57
Exercise #4 Developing extensions for Fluid Topics
Copyright © Antidot 2014
58
Exercise #4 Create a connector PaF
i.e create a PaF containing a PaF filter to instantiate the lib created on exercise #3 Copyright © Antidot 2014
59
Exercise #4 Create a connector PaF
Use ft_connector_builder to create the directories structure of the connector . ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 Copyright © Antidot 2014
60
Exercise #4 Copy lib created in exercise #3 in afs/fluidtopics/
. ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 . ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 Exercise #4 Copy lib created in exercise #3 in afs/fluidtopics/ Don’t forget to adjust the import instructions within .py files Copyright © Antidot 2015
61
Exercise #4 Create a PaF filter in afs/command
. ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 . ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 . ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 . ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 Exercise #4 Create a PaF filter in afs/command Create filter description (*.afd file) file in PaF/afd/ Create PaF configuration (paf.xml) in PaF/<pafName>/conf/ Copyright © Antidot 2015
62
Exercise #5 Developing extensions for Fluid Topics
Copyright © Antidot 2014
63
Exercise #5 Package your connector
Requires following packages (apt-get install) antidot-v78-python-3.4-packmeup antidot-packmeup-xsd antidot-v78-python-3.4-devkit ruby ruby-dev gem Packmeup requires fpm gem install fpm Copyright © Antidot 2014
64
Exercise #5 Package your connector Initialize Git
From project directory (e.g ~/PycharmProjects/TPConnectorSBI/tp_connector/exo4/) git init git add . git commit –m ”initialization” Copyright © Antidot 2014
65
Exercise #5 Package your connector Run package building
. ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 . ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 Exercise #5 Package your connector Run package building python3 ~/PycharmProjects/TPConnectorSBI/tp_connector/exo4/package/build_package.py --pmudb-dir . --debian --output-dir /tmp Copyright © Antidot 2014
66
Exercise #5 Package your connector Run package building
. ├── afs │ ├── command │ ├── fluidtopics │ └── test ├── docker │ ├── bootstrap │ └── packager ├── package │ └── antidot-fluidtopics-connector-exo4 └── PaF ├── afd └── Exo4 Exercise #5 Package your connector Run package building ls -l /tmp/packages/wheezy/ antidot-fluidtopics-connector-exo4_1.0-1_all.deb antidot-fluidtopics-connector-exo4_1.0-2_all.deb Copyright © Antidot 2014
67
Exercise #6 Developing extensions for Fluid Topics
Copyright © Antidot 2014
68
Exercise #6 Deploy and run Install the package previously built
dpkg –i /tmp/packages/wheezy/ antidot-fluidtopics-connector-exo4_1.0-2_all.deb Copyright © Antidot 2014
69
Exercise #6 Deploy and run
Edit the conf.json file to give the connector name to be used "pafs": { "connector": [ "Exo4" ], "legacy": [ "atict": false, "dita-ot": "DITA-OT-1.8", "related_links": "all” } "pafs": { "connector": [ "Exo4" ], "legacy": [ "atict": false, "dita-ot": "DITA-OT-1.8", "related_links": "all” } Copyright © Antidot 2014
70
Exercise #6 Deploy and run Deploy it on FT indexer + Back-Office or
a Singlebox instance Copyright © Antidot 2014
71
Exercise #6 Run the PaF by uploading the book.json file to the connector Back-Office portal or Upload API command Upload web service Copyright © Antidot 2014
72
Exercise #6 Run the PaF by uploading the book.json file to the connector Back-Office portal or Upload API command * Upload web service upload_file_to_paf -f … -m … -s … -S … … Copyright © Antidot 2014 * Requires antidot-v78-python-3.4-ws-tools package
73
Exercise #6 Run the PaF by uploading the book.json file to the connector Back-Office portal or Upload API command * Upload web service curl -H Expect: --form Copyright © Antidot 2014
74
Questions Developing extensions for Fluid Topics
Copyright © Antidot 2014
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.