prismic.io 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/prismic/api.rb +23 -2
- data/lib/prismic/version.rb +1 -1
- data/lib/prismic.rb +4 -0
- data/spec/prismic_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18f657d9d256a5349ddc73a96de913a1a6bed915
|
4
|
+
data.tar.gz: fd4d4892962175df4e46be5f8aadd3c2a122c95d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b7c685ea3ca894b8c1b5edf7ae6f42d05db80b0c1ac8981b456acecfb0bb00ac67a19bcf24fd20d4a8685862d60fb3be3376f68ed64d1fca38c5b21263e3a4c
|
7
|
+
data.tar.gz: 42150c5f18955907c3093266b646291fd991bed395d97bebc5da7951a9576f0cafcc1638da74d99ed948e685ba4c41c31574e30423c41f5dc2c21ce75b44ee12
|
data/Gemfile.lock
CHANGED
data/lib/prismic/api.rb
CHANGED
@@ -53,7 +53,7 @@ module Prismic
|
|
53
53
|
yield self if block_given?
|
54
54
|
@cache = cache
|
55
55
|
self.master = refs.values && refs.values.map { |ref| ref if ref.master? }.compact.first
|
56
|
-
raise BadPrismicResponseError,
|
56
|
+
raise BadPrismicResponseError, 'No master Ref found' unless master
|
57
57
|
end
|
58
58
|
|
59
59
|
# Get a bookmark by its name
|
@@ -89,12 +89,33 @@ module Prismic
|
|
89
89
|
# @deprecated Use {#form} instead.
|
90
90
|
def create_search_form(name, data={}, ref={})
|
91
91
|
unless @@warned_create_search_form
|
92
|
-
warn
|
92
|
+
warn '[DEPRECATION] `create_search_form` is deprecated. Please use `form` instead.'
|
93
93
|
@@warned_create_search_form = true
|
94
94
|
end
|
95
95
|
form(name, data, ref)
|
96
96
|
end
|
97
97
|
|
98
|
+
# Return the URL to display a given preview
|
99
|
+
# @param token [String] as received from Prismic server to identify the content to preview
|
100
|
+
# @param link_resolver the link resolver to build URL for your site
|
101
|
+
# @param default_url [String] the URL to default to return if the preview doesn't correspond to a document
|
102
|
+
# (usually the home page of your site)
|
103
|
+
#
|
104
|
+
# @return [String] the URL to redirect the user to
|
105
|
+
def preview_session(token, link_resolver, default_url)
|
106
|
+
response = self.http_client.get(token, {}, 'Accept' => 'application/json')
|
107
|
+
if response.code.to_s == '200'
|
108
|
+
documents = self.form('everything').query(Prismic::Predicates.at('document.id', response['mainDocument'])).submit(token)
|
109
|
+
if documents.results > 0
|
110
|
+
link_resolver.link_to(response.results[0])
|
111
|
+
else
|
112
|
+
default_url
|
113
|
+
end
|
114
|
+
else
|
115
|
+
default_url
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
98
119
|
def as_json
|
99
120
|
@json
|
100
121
|
end
|
data/lib/prismic/version.rb
CHANGED
data/lib/prismic.rb
CHANGED
@@ -9,6 +9,10 @@ require 'prismic/with_fragments'
|
|
9
9
|
|
10
10
|
module Prismic
|
11
11
|
|
12
|
+
EXPERIMENTS_COOKIE = 'io.prismic.experiment'
|
13
|
+
|
14
|
+
PREVIEW_COOKIE = 'io.prismic.preview'
|
15
|
+
|
12
16
|
# These exception can contains an error cause and is able to show them
|
13
17
|
class Error < Exception
|
14
18
|
attr_reader :cause
|
data/spec/prismic_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
describe 'Api' do
|
5
5
|
before do
|
6
6
|
json_representation = '{"foo": "bar"}'
|
7
|
-
@oauth_initiate_url =
|
7
|
+
@oauth_initiate_url = 'https://lesbonneschoses.prismic.io/auth'
|
8
8
|
@api = Prismic::API.new(json_representation, nil, Prismic::DefaultHTTPClient, false){|api|
|
9
9
|
api.bookmarks = {}
|
10
10
|
api.tags = {}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prismic.io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Étienne Vallette d'Osia
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-11-
|
14
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|