prismic.io 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -14
- data/docs/Prismic.html +1074 -0
- data/docs/Prismic/API.html +2987 -0
- data/docs/Prismic/API/BadPrismicResponseError.html +147 -0
- data/docs/Prismic/API/OAuth.html +560 -0
- data/docs/Prismic/API/PrismicWSAuthError.html +375 -0
- data/docs/Prismic/API/PrismicWSConnectionError.html +221 -0
- data/docs/Prismic/BasicNullCache.html +255 -0
- data/docs/Prismic/DefaultHTTPClient.html +350 -0
- data/docs/Prismic/Document.html +873 -0
- data/docs/Prismic/Error.html +418 -0
- data/docs/Prismic/Experiment.html +633 -0
- data/docs/Prismic/Experiments.html +633 -0
- data/docs/Prismic/Field.html +424 -0
- data/docs/Prismic/Form.html +827 -0
- data/docs/Prismic/Fragments.html +117 -0
- data/docs/Prismic/Fragments/Color.html +632 -0
- data/docs/Prismic/Fragments/Date.html +399 -0
- data/docs/Prismic/Fragments/DocumentLink.html +1048 -0
- data/docs/Prismic/Fragments/Embed.html +679 -0
- data/docs/Prismic/Fragments/FileLink.html +604 -0
- data/docs/Prismic/Fragments/Fragment.html +339 -0
- data/docs/Prismic/Fragments/GeoPoint.html +469 -0
- data/docs/Prismic/Fragments/Group.html +710 -0
- data/docs/Prismic/Fragments/GroupDocument.html +382 -0
- data/docs/Prismic/Fragments/Image.html +780 -0
- data/docs/Prismic/Fragments/Image/View.html +759 -0
- data/docs/Prismic/Fragments/Image/ViewDoesNotExistException.html +147 -0
- data/docs/Prismic/Fragments/ImageLink.html +336 -0
- data/docs/Prismic/Fragments/Link.html +412 -0
- data/docs/Prismic/Fragments/Multiple.html +513 -0
- data/docs/Prismic/Fragments/Number.html +401 -0
- data/docs/Prismic/Fragments/Select.html +349 -0
- data/docs/Prismic/Fragments/Separator.html +396 -0
- data/docs/Prismic/Fragments/Slice.html +632 -0
- data/docs/Prismic/Fragments/SliceZone.html +474 -0
- data/docs/Prismic/Fragments/StructuredText.html +664 -0
- data/docs/Prismic/Fragments/StructuredText/Block.html +232 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Embed.html +367 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Heading.html +366 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Image.html +755 -0
- data/docs/Prismic/Fragments/StructuredText/Block/ListItem.html +372 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Paragraph.html +223 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Preformatted.html +223 -0
- data/docs/Prismic/Fragments/StructuredText/Block/Text.html +818 -0
- data/docs/Prismic/Fragments/StructuredText/BlockGroup.html +423 -0
- data/docs/Prismic/Fragments/StructuredText/Span.html +384 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Em.html +213 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Hyperlink.html +359 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Label.html +362 -0
- data/docs/Prismic/Fragments/StructuredText/Span/Strong.html +213 -0
- data/docs/Prismic/Fragments/Text.html +396 -0
- data/docs/Prismic/Fragments/Timestamp.html +399 -0
- data/docs/Prismic/Fragments/WebLink.html +340 -0
- data/docs/Prismic/HtmlSerializer.html +270 -0
- data/docs/Prismic/JsonParser.html +1764 -0
- data/docs/Prismic/LinkResolver.html +399 -0
- data/docs/Prismic/LruCache.html +1140 -0
- data/docs/Prismic/Predicates.html +1630 -0
- data/docs/Prismic/Ref.html +643 -0
- data/docs/Prismic/Response.html +1159 -0
- data/docs/Prismic/SearchForm.html +2172 -0
- data/docs/Prismic/SearchForm/AuthenticationException.html +147 -0
- data/docs/Prismic/SearchForm/AuthorizationException.html +147 -0
- data/docs/Prismic/SearchForm/FormSearchException.html +147 -0
- data/docs/Prismic/SearchForm/NoRefSetException.html +147 -0
- data/docs/Prismic/SearchForm/RefNotFoundException.html +147 -0
- data/docs/Prismic/SearchForm/UnsupportedFormKind.html +147 -0
- data/docs/Prismic/Variation.html +546 -0
- data/docs/Prismic/WithFragments.html +1803 -0
- data/docs/_index.html +752 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +57 -0
- data/docs/css/style.css +339 -0
- data/docs/file.README.html +180 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +26 -0
- data/docs/index.html +180 -0
- data/docs/js/app.js +219 -0
- data/docs/js/full_list.js +178 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +2381 -0
- data/docs/top-level-namespace.html +112 -0
- data/lib/prismic.rb +17 -1
- data/lib/prismic/api.rb +31 -19
- data/lib/prismic/fragments/image.rb +6 -0
- data/lib/prismic/json_parsers.rb +2 -0
- data/lib/prismic/version.rb +1 -1
- data/spec/cache_spec.rb +12 -12
- data/spec/json_parsers_spec.rb +10 -5
- data/spec/oauth_spec.rb +3 -3
- data/spec/prismic_spec.rb +7 -7
- data/spec/responses_mocks/api.json +12 -12
- data/spec/responses_mocks/document.json +4 -2
- data/spec/responses_mocks/document_with_unknown_fragment.json +2 -0
- data/spec/responses_mocks/fragments.json +5 -3
- data/spec/responses_mocks/slices.json +2 -0
- data/spec/responses_mocks/structured_text_with_labels.json +2 -2
- data/spec/simple_search_spec.rb +55 -0
- metadata +103 -24
- data/deploy-doc.sh +0 -9
- data/spec/doc_spec.rb +0 -298
- data/spec/lesbonneschoses_spec.rb +0 -228
@@ -0,0 +1,664 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Prismic::Fragments::StructuredText
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!Prismic/Fragments/StructuredText.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (S)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Prismic.html" title="Prismic (module)">Prismic</a></span></span> » <span class='title'><span class='object_link'><a href="../Fragments.html" title="Prismic::Fragments (module)">Fragments</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">StructuredText</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: Prismic::Fragments::StructuredText
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName"><span class='object_link'><a href="Fragment.html" title="Prismic::Fragments::Fragment (class)">Fragment</a></span></span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next"><span class='object_link'><a href="Fragment.html" title="Prismic::Fragments::Fragment (class)">Fragment</a></span></li>
|
82
|
+
|
83
|
+
<li class="next">Prismic::Fragments::StructuredText</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
<a href="#" class="inheritanceTree">show all</a>
|
87
|
+
|
88
|
+
</dd>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
<dt class="r2 last">Defined in:</dt>
|
99
|
+
<dd class="r2 last">lib/prismic/fragments/structured_text.rb</dd>
|
100
|
+
|
101
|
+
</dl>
|
102
|
+
<div class="clear"></div>
|
103
|
+
|
104
|
+
<h2>Defined Under Namespace</h2>
|
105
|
+
<p class="children">
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="StructuredText/Block.html" title="Prismic::Fragments::StructuredText::Block (class)">Block</a></span>, <span class='object_link'><a href="StructuredText/BlockGroup.html" title="Prismic::Fragments::StructuredText::BlockGroup (class)">BlockGroup</a></span>, <span class='object_link'><a href="StructuredText/Span.html" title="Prismic::Fragments::StructuredText::Span (class)">Span</a></span>
|
111
|
+
|
112
|
+
|
113
|
+
</p>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
119
|
+
<ul class="summary">
|
120
|
+
|
121
|
+
<li class="public ">
|
122
|
+
<span class="summary_signature">
|
123
|
+
|
124
|
+
<a href="#blocks-instance_method" title="#blocks (instance method)">- (Object) <strong>blocks</strong> </a>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
</span>
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute blocks.</p>
|
142
|
+
</div></span>
|
143
|
+
|
144
|
+
</li>
|
145
|
+
|
146
|
+
|
147
|
+
</ul>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
<h2>
|
154
|
+
Instance Method Summary
|
155
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
156
|
+
</h2>
|
157
|
+
|
158
|
+
<ul class="summary">
|
159
|
+
|
160
|
+
<li class="public ">
|
161
|
+
<span class="summary_signature">
|
162
|
+
|
163
|
+
<a href="#as_html-instance_method" title="#as_html (instance method)">- (String) <strong>as_html</strong>(link_resolver, html_serializer = nil) </a>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
</span>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<span class="summary_desc"><div class='inline'><p>Serializes the current StructuredText fragment into a fully usable HTML code.</p>
|
178
|
+
</div></span>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
<li class="public ">
|
184
|
+
<span class="summary_signature">
|
185
|
+
|
186
|
+
<a href="#as_text-instance_method" title="#as_text (instance method)">- (String) <strong>as_text</strong>(separator = ' ') </a>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
</span>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
<span class="summary_desc"><div class='inline'><p>Returns the StructuredText as plain text, with zero formatting.</p>
|
201
|
+
</div></span>
|
202
|
+
|
203
|
+
</li>
|
204
|
+
|
205
|
+
|
206
|
+
<li class="public ">
|
207
|
+
<span class="summary_signature">
|
208
|
+
|
209
|
+
<a href="#first_title-instance_method" title="#first_title (instance method)">- (Object) <strong>first_title</strong> </a>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</span>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<span class="summary_desc"><div class='inline'><p>Finds the first highest title in a structured text.</p>
|
224
|
+
</div></span>
|
225
|
+
|
226
|
+
</li>
|
227
|
+
|
228
|
+
|
229
|
+
<li class="public ">
|
230
|
+
<span class="summary_signature">
|
231
|
+
|
232
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (StructuredText) <strong>initialize</strong>(blocks) </a>
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
</span>
|
237
|
+
|
238
|
+
|
239
|
+
<span class="note title constructor">constructor</span>
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of StructuredText.</p>
|
249
|
+
</div></span>
|
250
|
+
|
251
|
+
</li>
|
252
|
+
|
253
|
+
|
254
|
+
</ul>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<div id="constructor_details" class="method_details_list">
|
264
|
+
<h2>Constructor Details</h2>
|
265
|
+
|
266
|
+
<div class="method_details first">
|
267
|
+
<h3 class="signature first" id="initialize-instance_method">
|
268
|
+
|
269
|
+
- (<tt><span class='object_link'><a href="" title="Prismic::Fragments::StructuredText (class)">StructuredText</a></span></tt>) <strong>initialize</strong>(blocks)
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
</h3><div class="docstring">
|
276
|
+
<div class="discussion">
|
277
|
+
<p>Returns a new instance of StructuredText</p>
|
278
|
+
|
279
|
+
|
280
|
+
</div>
|
281
|
+
</div>
|
282
|
+
<div class="tags">
|
283
|
+
|
284
|
+
|
285
|
+
</div><table class="source_code">
|
286
|
+
<tr>
|
287
|
+
<td>
|
288
|
+
<pre class="lines">
|
289
|
+
|
290
|
+
|
291
|
+
22
|
292
|
+
23
|
293
|
+
24</pre>
|
294
|
+
</td>
|
295
|
+
<td>
|
296
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/fragments/structured_text.rb', line 22</span>
|
297
|
+
|
298
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_blocks'>blocks</span><span class='rparen'>)</span>
|
299
|
+
<span class='ivar'>@blocks</span> <span class='op'>=</span> <span class='id identifier rubyid_blocks'>blocks</span>
|
300
|
+
<span class='kw'>end</span></pre>
|
301
|
+
</td>
|
302
|
+
</tr>
|
303
|
+
</table>
|
304
|
+
</div>
|
305
|
+
|
306
|
+
</div>
|
307
|
+
|
308
|
+
<div id="instance_attr_details" class="attr_details">
|
309
|
+
<h2>Instance Attribute Details</h2>
|
310
|
+
|
311
|
+
|
312
|
+
<span id="blocks=-instance_method"></span>
|
313
|
+
<div class="method_details first">
|
314
|
+
<h3 class="signature first" id="blocks-instance_method">
|
315
|
+
|
316
|
+
- (<tt>Object</tt>) <strong>blocks</strong>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
</h3><div class="docstring">
|
323
|
+
<div class="discussion">
|
324
|
+
<p>Returns the value of attribute blocks</p>
|
325
|
+
|
326
|
+
|
327
|
+
</div>
|
328
|
+
</div>
|
329
|
+
<div class="tags">
|
330
|
+
|
331
|
+
|
332
|
+
</div><table class="source_code">
|
333
|
+
<tr>
|
334
|
+
<td>
|
335
|
+
<pre class="lines">
|
336
|
+
|
337
|
+
|
338
|
+
20
|
339
|
+
21
|
340
|
+
22</pre>
|
341
|
+
</td>
|
342
|
+
<td>
|
343
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/fragments/structured_text.rb', line 20</span>
|
344
|
+
|
345
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_blocks'>blocks</span>
|
346
|
+
<span class='ivar'>@blocks</span>
|
347
|
+
<span class='kw'>end</span></pre>
|
348
|
+
</td>
|
349
|
+
</tr>
|
350
|
+
</table>
|
351
|
+
</div>
|
352
|
+
|
353
|
+
</div>
|
354
|
+
|
355
|
+
|
356
|
+
<div id="instance_method_details" class="method_details_list">
|
357
|
+
<h2>Instance Method Details</h2>
|
358
|
+
|
359
|
+
|
360
|
+
<div class="method_details first">
|
361
|
+
<h3 class="signature first" id="as_html-instance_method">
|
362
|
+
|
363
|
+
- (<tt>String</tt>) <strong>as_html</strong>(link_resolver, html_serializer = nil)
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
</h3><div class="docstring">
|
370
|
+
<div class="discussion">
|
371
|
+
<p>Serializes the current StructuredText fragment into a fully usable HTML code.
|
372
|
+
You need to pass a proper link_resolver so that internal links are turned into the proper URL in
|
373
|
+
your website. If you use a starter kit, one is provided, that you can still update later.</p>
|
374
|
+
|
375
|
+
<p>This method simply executes the as_html methods on blocks;
|
376
|
+
it is not advised to override this method if you want to change the HTML output, you should
|
377
|
+
override the as_html method at the block level (like Heading.as_html, or Preformatted.as_html,
|
378
|
+
for instance).</p>
|
379
|
+
|
380
|
+
|
381
|
+
</div>
|
382
|
+
</div>
|
383
|
+
<div class="tags">
|
384
|
+
<p class="tag_title">Parameters:</p>
|
385
|
+
<ul class="param">
|
386
|
+
|
387
|
+
<li>
|
388
|
+
|
389
|
+
<span class='name'>link_resolver</span>
|
390
|
+
|
391
|
+
|
392
|
+
<span class='type'>(<tt><span class='object_link'><a href="../LinkResolver.html" title="Prismic::LinkResolver (class)">LinkResolver</a></span></tt>)</span>
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
</li>
|
397
|
+
|
398
|
+
<li>
|
399
|
+
|
400
|
+
<span class='name'>html_serializer</span>
|
401
|
+
|
402
|
+
|
403
|
+
<span class='type'>(<tt><span class='object_link'><a href="../HtmlSerializer.html" title="Prismic::HtmlSerializer (class)">HtmlSerializer</a></span></tt>)</span>
|
404
|
+
|
405
|
+
|
406
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
407
|
+
|
408
|
+
|
409
|
+
</li>
|
410
|
+
|
411
|
+
</ul>
|
412
|
+
|
413
|
+
<p class="tag_title">Returns:</p>
|
414
|
+
<ul class="return">
|
415
|
+
|
416
|
+
<li>
|
417
|
+
|
418
|
+
|
419
|
+
<span class='type'>(<tt>String</tt>)</span>
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
—
|
424
|
+
<div class='inline'><p>the resulting html snippet</p>
|
425
|
+
</div>
|
426
|
+
|
427
|
+
</li>
|
428
|
+
|
429
|
+
</ul>
|
430
|
+
|
431
|
+
</div><table class="source_code">
|
432
|
+
<tr>
|
433
|
+
<td>
|
434
|
+
<pre class="lines">
|
435
|
+
|
436
|
+
|
437
|
+
38
|
438
|
+
39
|
439
|
+
40
|
440
|
+
41
|
441
|
+
42
|
442
|
+
43
|
443
|
+
44
|
444
|
+
45
|
445
|
+
46
|
446
|
+
47
|
447
|
+
48
|
448
|
+
49
|
449
|
+
50
|
450
|
+
51
|
451
|
+
52
|
452
|
+
53
|
453
|
+
54
|
454
|
+
55
|
455
|
+
56
|
456
|
+
57
|
457
|
+
58
|
458
|
+
59
|
459
|
+
60
|
460
|
+
61
|
461
|
+
62
|
462
|
+
63
|
463
|
+
64
|
464
|
+
65
|
465
|
+
66
|
466
|
+
67
|
467
|
+
68
|
468
|
+
69
|
469
|
+
70
|
470
|
+
71</pre>
|
471
|
+
</td>
|
472
|
+
<td>
|
473
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/fragments/structured_text.rb', line 38</span>
|
474
|
+
|
475
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_as_html'>as_html</span><span class='lparen'>(</span><span class='id identifier rubyid_link_resolver'>link_resolver</span><span class='comma'>,</span> <span class='id identifier rubyid_html_serializer'>html_serializer</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
476
|
+
<span class='comment'># Defining blocks that deserve grouping, assigning them "group kind" names
|
477
|
+
</span> <span class='id identifier rubyid_block_group'>block_group</span> <span class='op'>=</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span><span class='tlambeg'>{</span>
|
478
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_block'>block</span>
|
479
|
+
<span class='kw'>when</span> <span class='const'>Block</span><span class='op'>::</span><span class='const'>ListItem</span>
|
480
|
+
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_ordered?'>ordered?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ol</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ul</span><span class='tstring_end'>"</span></span>
|
481
|
+
<span class='kw'>else</span>
|
482
|
+
<span class='kw'>nil</span>
|
483
|
+
<span class='kw'>end</span>
|
484
|
+
<span class='rbrace'>}</span>
|
485
|
+
<span class='comment'># Initializing groups, which is an array of BlockGroup objects
|
486
|
+
</span> <span class='id identifier rubyid_groups'>groups</span><span class='comma'>,</span> <span class='id identifier rubyid_last'>last</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span>
|
487
|
+
<span class='id identifier rubyid_blocks'>blocks</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
|
488
|
+
<span class='id identifier rubyid_group'>group</span> <span class='op'>=</span> <span class='id identifier rubyid_block_group'>block_group</span><span class='period'>.</span><span class='lparen'>(</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
489
|
+
<span class='id identifier rubyid_groups'>groups</span> <span class='op'><<</span> <span class='const'>BlockGroup</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_group'>group</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_last'>last</span> <span class='op'>||</span> <span class='id identifier rubyid_group'>group</span> <span class='op'>!=</span> <span class='id identifier rubyid_last'>last</span>
|
490
|
+
<span class='id identifier rubyid_groups'>groups</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span> <span class='op'><<</span> <span class='id identifier rubyid_block'>block</span>
|
491
|
+
<span class='id identifier rubyid_last'>last</span> <span class='op'>=</span> <span class='id identifier rubyid_group'>group</span>
|
492
|
+
<span class='rbrace'>}</span>
|
493
|
+
<span class='comment'># HTML-serializing the groups object (delegating the serialization of Block objects),
|
494
|
+
</span> <span class='comment'># without forgetting to frame the BlockGroup objects right if needed
|
495
|
+
</span> <span class='id identifier rubyid_groups'>groups</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_group'>group</span><span class='op'>|</span>
|
496
|
+
<span class='id identifier rubyid_html'>html</span> <span class='op'>=</span> <span class='id identifier rubyid_group'>group</span><span class='period'>.</span><span class='id identifier rubyid_blocks'>blocks</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_b'>b</span><span class='op'>|</span>
|
497
|
+
<span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_as_html'>as_html</span><span class='lparen'>(</span><span class='id identifier rubyid_link_resolver'>link_resolver</span><span class='comma'>,</span> <span class='id identifier rubyid_html_serializer'>html_serializer</span><span class='rparen'>)</span>
|
498
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span>
|
499
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_group'>group</span><span class='period'>.</span><span class='id identifier rubyid_kind'>kind</span>
|
500
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ol</span><span class='tstring_end'>"</span></span>
|
501
|
+
<span class='tstring'><span class='tstring_beg'>%(</span><span class='tstring_content'><ol></span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_html'>html</span><span class='embexpr_end'>}</span><span class='tstring_content'></ol></span><span class='tstring_end'>)</span></span>
|
502
|
+
<span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ul</span><span class='tstring_end'>"</span></span>
|
503
|
+
<span class='tstring'><span class='tstring_beg'>%(</span><span class='tstring_content'><ul></span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_html'>html</span><span class='embexpr_end'>}</span><span class='tstring_content'></ul></span><span class='tstring_end'>)</span></span>
|
504
|
+
<span class='kw'>else</span>
|
505
|
+
<span class='id identifier rubyid_html'>html</span>
|
506
|
+
<span class='kw'>end</span>
|
507
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
508
|
+
<span class='kw'>end</span></pre>
|
509
|
+
</td>
|
510
|
+
</tr>
|
511
|
+
</table>
|
512
|
+
</div>
|
513
|
+
|
514
|
+
<div class="method_details ">
|
515
|
+
<h3 class="signature " id="as_text-instance_method">
|
516
|
+
|
517
|
+
- (<tt>String</tt>) <strong>as_text</strong>(separator = ' ')
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
</h3><div class="docstring">
|
524
|
+
<div class="discussion">
|
525
|
+
<p>Returns the StructuredText as plain text, with zero formatting.
|
526
|
+
Non-textual blocks (like images and embeds) are simply ignored.</p>
|
527
|
+
|
528
|
+
|
529
|
+
</div>
|
530
|
+
</div>
|
531
|
+
<div class="tags">
|
532
|
+
<p class="tag_title">Parameters:</p>
|
533
|
+
<ul class="param">
|
534
|
+
|
535
|
+
<li>
|
536
|
+
|
537
|
+
<span class='name'>separator</span>
|
538
|
+
|
539
|
+
|
540
|
+
<span class='type'>(<tt>String</tt>)</span>
|
541
|
+
|
542
|
+
|
543
|
+
<em class="default">(defaults to: <tt>' '</tt>)</em>
|
544
|
+
|
545
|
+
|
546
|
+
—
|
547
|
+
<div class='inline'><p>The string separator inserted between the blocks (a blank space by default)</p>
|
548
|
+
</div>
|
549
|
+
|
550
|
+
</li>
|
551
|
+
|
552
|
+
</ul>
|
553
|
+
|
554
|
+
<p class="tag_title">Returns:</p>
|
555
|
+
<ul class="return">
|
556
|
+
|
557
|
+
<li>
|
558
|
+
|
559
|
+
|
560
|
+
<span class='type'>(<tt>String</tt>)</span>
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
—
|
565
|
+
<div class='inline'><p>The complete string representing the textual value of the StructuredText field.</p>
|
566
|
+
</div>
|
567
|
+
|
568
|
+
</li>
|
569
|
+
|
570
|
+
</ul>
|
571
|
+
|
572
|
+
</div><table class="source_code">
|
573
|
+
<tr>
|
574
|
+
<td>
|
575
|
+
<pre class="lines">
|
576
|
+
|
577
|
+
|
578
|
+
78
|
579
|
+
79
|
580
|
+
80</pre>
|
581
|
+
</td>
|
582
|
+
<td>
|
583
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/fragments/structured_text.rb', line 78</span>
|
584
|
+
|
585
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_as_text'>as_text</span><span class='lparen'>(</span><span class='id identifier rubyid_separator'>separator</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
586
|
+
<span class='id identifier rubyid_blocks'>blocks</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_block'>block</span><span class='op'>|</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_as_text'>as_text</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_separator'>separator</span><span class='rparen'>)</span>
|
587
|
+
<span class='kw'>end</span></pre>
|
588
|
+
</td>
|
589
|
+
</tr>
|
590
|
+
</table>
|
591
|
+
</div>
|
592
|
+
|
593
|
+
<div class="method_details ">
|
594
|
+
<h3 class="signature " id="first_title-instance_method">
|
595
|
+
|
596
|
+
- (<tt>Object</tt>) <strong>first_title</strong>
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
</h3><div class="docstring">
|
603
|
+
<div class="discussion">
|
604
|
+
<p>Finds the first highest title in a structured text</p>
|
605
|
+
|
606
|
+
|
607
|
+
</div>
|
608
|
+
</div>
|
609
|
+
<div class="tags">
|
610
|
+
|
611
|
+
|
612
|
+
</div><table class="source_code">
|
613
|
+
<tr>
|
614
|
+
<td>
|
615
|
+
<pre class="lines">
|
616
|
+
|
617
|
+
|
618
|
+
83
|
619
|
+
84
|
620
|
+
85
|
621
|
+
86
|
622
|
+
87
|
623
|
+
88
|
624
|
+
89
|
625
|
+
90
|
626
|
+
91
|
627
|
+
92
|
628
|
+
93
|
629
|
+
94
|
630
|
+
95</pre>
|
631
|
+
</td>
|
632
|
+
<td>
|
633
|
+
<pre class="code"><span class="info file"># File 'lib/prismic/fragments/structured_text.rb', line 83</span>
|
634
|
+
|
635
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_first_title'>first_title</span>
|
636
|
+
<span class='id identifier rubyid_max_level'>max_level</span> <span class='op'>=</span> <span class='int'>6</span> <span class='comment'># any title with a higher level kicks the current one out
|
637
|
+
</span> <span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='kw'>false</span>
|
638
|
+
<span class='ivar'>@blocks</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_block'>block</span><span class='op'>|</span>
|
639
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Prismic</span><span class='op'>::</span><span class='const'>Fragments</span><span class='op'>::</span><span class='const'>StructuredText</span><span class='op'>::</span><span class='const'>Block</span><span class='op'>::</span><span class='const'>Heading</span><span class='rparen'>)</span>
|
640
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'><</span> <span class='id identifier rubyid_max_level'>max_level</span>
|
641
|
+
<span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_text'>text</span>
|
642
|
+
<span class='id identifier rubyid_max_level'>max_level</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='comment'># new maximum
|
643
|
+
</span> <span class='kw'>end</span>
|
644
|
+
<span class='kw'>end</span>
|
645
|
+
<span class='kw'>end</span>
|
646
|
+
<span class='id identifier rubyid_title'>title</span>
|
647
|
+
<span class='kw'>end</span></pre>
|
648
|
+
</td>
|
649
|
+
</tr>
|
650
|
+
</table>
|
651
|
+
</div>
|
652
|
+
|
653
|
+
</div>
|
654
|
+
|
655
|
+
</div>
|
656
|
+
|
657
|
+
<div id="footer">
|
658
|
+
Generated on Tue Sep 27 10:47:07 2016 by
|
659
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
660
|
+
0.8.7.4 (ruby-2.0.0).
|
661
|
+
</div>
|
662
|
+
|
663
|
+
</body>
|
664
|
+
</html>
|