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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3aab8aa8c04948a2b6be0c2b1a99f9991b916d5
4
- data.tar.gz: 7d07488a5d104cbd2a57a764d5e66fa109e76eed
3
+ metadata.gz: 18f657d9d256a5349ddc73a96de913a1a6bed915
4
+ data.tar.gz: fd4d4892962175df4e46be5f8aadd3c2a122c95d
5
5
  SHA512:
6
- metadata.gz: 17f223d1112c5c27a56e935e242c5577f925e26099fd514789e7ee095d57567af68ac4059e3cdaf65f0571d77d6b3f36c969cdd55a9c0db851f3dab2f01fad66
7
- data.tar.gz: a9bc31cbc6eb1d747595d3e3f839c4cad2b6b4d25f3847c324415cf49d7492044a620f81a163d3dc034415e2c5fda32b7b6d4f2679ea2043ab48d43a6e72a8a5
6
+ metadata.gz: 1b7c685ea3ca894b8c1b5edf7ae6f42d05db80b0c1ac8981b456acecfb0bb00ac67a19bcf24fd20d4a8685862d60fb3be3376f68ed64d1fca38c5b21263e3a4c
7
+ data.tar.gz: 42150c5f18955907c3093266b646291fd991bed395d97bebc5da7951a9576f0cafcc1638da74d99ed948e685ba4c41c31574e30423c41f5dc2c21ce75b44ee12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prismic.io (1.0.6)
4
+ prismic.io (1.0.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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, "No master Ref found" unless master
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 "[DEPRECATION] `create_search_form` is deprecated. Please use `form` instead."
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
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Prismic
3
3
 
4
- VERSION = '1.0.6'
4
+ VERSION = '1.0.7'
5
5
 
6
6
  end
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 = "https://lesbonneschoses.prismic.io/auth"
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.6
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-12 00:00:00.000000000 Z
14
+ date: 2014-11-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler