This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
hax-app.html
160 lines (150 loc) · 3.66 KB
/
hax-app.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<link rel="import" href="../polymer/polymer.html">
<!--
`hax-app`
An app registered with HAX. This provides all the information needed for HAX
to understand how to talk to this backend as well as represent it in listings.
It also expresses how to take that data and wire it up to gizmos making it able to
utilize multiple display methods.
@demo demo/index.html
@microcopy - the mental model for this element
- data - this is the app data model for an element which expresses itself to hax
@example data call
```
{
"details": {
"title": "Flickr",
"icon": "image:collections",
"image": "flickr.jpg",
"color": "pink",
"author": "Yahoo",
"description": "The original photo sharing platform on the web.",
"status": "available",
"rating": "0",
"tags": ["images", "creative commons", "crowdsourced"]
},
"connection": {
"protocol": "https",
"url": "api.flickr.com",
"headers": {
"Authorization": "Bearer POTENTIALLYSOMEBIGSIGNATUREHERE"
},
"data": {
"api_key": "SOMEBIGKEYHERE"
},
"operations": {
"browse": {
"method": "GET",
"endPoint": "services/rest",
"pagination": {
"style": "page",
"props": {
"per_page": "photos.perpage",
"total_pages": "photos.pages",
"page": "photos.page"
}
},
"search": {
"text": {
"title": "Search",
"type": "textfield"
},
"license": {
"title": "License type",
"type": "select",
"options": {
"1": "Public domain",
"2": "CC attribution",
"3": "CC Zero",
"4": "CC Share-alike"
}
}
},
"data": {
"method": "flickr.photos.search",
"text": "",
"safe_search": "1",
"per_page": "20",
"page": "1",
"format": "json",
"nojsoncallback": "1",
"extras": "license,description,url_l,url_s"
},
"resultMap": {
"defaultGizmoType": "video",
"items": "resource.items.collection",
"preview": {
"title": "Stuff",
"details": "Details",
"image": "whatever.jpg",
"id": "meta.id"
},
"gizmo": {
"type": "",
"title": "",
"description": "",
"source": "",
"citation": "",
"alt": "",
"caption": "",
"color": ""
}
}
},
"read": {
"method": "GET",
"endPoint": "node/<%= id %>",
"data": {
"deep-load-refs": "node"
}
},
"edit": {
"method": "PUT",
"endPoint": "node/<%= id %>/update"
},
"add": {
"method": "POST",
"endPoint": "node",
"data": {
"title": "A new item",
"img": "This is the image"
}
},
"delete": {
"method": "DELETE",
"endPoint": "node/<%= id %>/delete"
}
}
}
}
```
-->
<dom-module id="hax-app">
<style>
:host {
display:none;
}
</style>
<template>
</template>
<script>
Polymer({
is: 'hax-app',
properties: {
/**
* The data model.
*/
data: {
type: Object,
},
},
/**
* ON attached life-cycle, meaning it's in the body most likely, then fire registration.
*/
attached: function() {
if (typeof this.data !== typeof undefined) {
this.fire('hax-register-app', this.data);
}
},
});
</script>
</dom-module>