/
seed-harvester.html
162 lines (137 loc) · 6.04 KB
/
seed-harvester.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
161
162
<link rel="import" href="../polymer/polymer.html">
<!-- syntax highlighting -->
<link rel="import" href="../syntax-highlight/syntax-highlight.html">
<!-- code editing -->
<link rel="import" href="../code-mirror/code-mirror.html">
<polymer-element name="seed-harvester" attributes="seed db progress">
<template>
<link rel="stylesheet" href="../bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="seed-harvester.css">
<template if="{{ progress == 'loading' }}">
<div class="alert alert-info">Loading…</div>
</template>
<!-- viewing -->
<template if="{{ !editing }}">
<div class="row">
<div class="col-md-4">
<template if="{{ seed.description }}">
<marked-element text="{{ seed.description }}"></marked-element>
</template>
</div>
<div class="col-md-8">
<!--
<template if="{{ seed.data }}">
<pre id="fetch"
language="{{ seed.language }}">{{ seed.data }}</pre>
</template>
-->
<template if="{{ seed.code }}">
<pre is="syntax-highlight" id="code"
language="javascript" content="{{ seed.code }}"></pre>
</template>
<span class="label label-info
label-type-{{ seed.language }}">{{ seed.language }}</span>
<template if="{{ db }}">
<div class="form-actions pull-right">
<button class="btn btn-primary" on-click="{{ openEditor }}"><span
class="glyphicon glyphicon-edit"></span> Edit seeds</button>
<template if="{{ seed.data }}">
<button type="submit" class="btn btn-primary" on-click="{{ plantSeeds }}">Plant seeds</button>
</template>
</div>
</template>
</div>
</div>
</template>
<!-- editing -->
<template if="{{ editing }}">
<form on-submit="{{ closeEditor }}">
<div class="form-group">
<label for="language">Type</label>
<select id="language" value="{{ editing.language }}">
<option value="csv">CSV</option>
<option value="json">JSON</option>
<option value="resource">Collection</option>
<option value="javascript">JavaScript</option>
</select>
</div>
<div class="row">
<div class="col-sm-8">
<template if="{{ editing.language == 'csv' }}">
<div class="form-group">
<textarea class="form-control" value="{{ editing.data }}" rows="10"></textarea>
</div>
</template>
<template if="{{ editing.language == 'json' }}">
<div class="form-group">
<code-mirror language="{{ editing.language }}" value="{{ editing.data }}"></code-mirror>
</div>
</template>
<template if="{{ editing.language == 'javascript'}}">
<div class="form-group">
<code-mirror language="{{ editing.language }}" value="{{ editing.code }}"></code-mirror>
</div>
</template>
<template if="{{ editing.language == 'resource'}}">
<div class="form-group">
<span class="input-group">
<span class="input-group-addon">URL</span>
<!-- TODO: autocomplete/search -->
<input type="url" required class="form-control"
value="{{ editing.url }}" placeholder="http://…">
</span>
</div>
<div class="form-group">
<label for="format">Format</label>
<select id="format" value="{{ editing.format }}" required>
<option></option>
<option value="html">HTML</option>
<option value="json">JSON</option>
<option value="jsonld">JSON-LD</option>
<option value="csv">CSV</option>
<option value="xml">XML</option>
</select>
</div>
<div class="form-group">
<div class="function-header">collection.items = function(document) {</div>
<code-mirror language="javascript" value="{{ editing.itemsSelector }}"></code-mirror>
<div class="function-footer">}</div>
</div>
<div class="form-group">
<div class="function-header">collection.next = function(document) {</div>
<code-mirror language="javascript" value="{{ editing.nextSelector }}"></code-mirror>
<div class="function-footer">}</div>
</div>
</template>
<!-- description -->
<div class="form-group">
<label for="description">Description</label>
<code-mirror
value="{{ editing.description }}"
mode="markdown"
lineNumbers="true"
lineWrapping="true"></code-mirror>
</div>
<div class="form-actions">
<button type="button" class="btn btn-danger" on-click="{{ clearItems }}"><span class="glyphicon glyphicon-trash"></span> Clear items</button>
<button type="button" class="btn btn-danger" on-click="{{ cancelEditor }}">Cancel</button>
<button type="button" class="btn btn-warning" on-click="{{ generatePreview }}">Preview</button>
<button type="submit" class="btn btn-primary" on-click="{{ saveSeeds }}">Plant seeds</button>
</div>
</div>
<div class="col-sm-4">
<!-- previews -->
<template if="{{ preview }}">
<pre is="syntax-highlight" id="preview" class="seed-preview"
language="json" content="{{ preview }}"></pre>
</template>
</div>
</div>
</form>
</template>
<template if="{{ error }}">
<div class="alert alert-error">{{ error }}</div>
</template>
</template>
<script src="seed-harvester.js"></script>
</polymer-element>