embed_me 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f34b72a5e480ff4c77fcba238096495eaed357a04d79387d94422b434e48613
4
- data.tar.gz: 8d16e4658c9f7b96bb58449d8f2ebe6afc578b98709a6fd5e5f070cd3858165c
3
+ metadata.gz: 6c628ce31537a49b18079252bd49617f003742a93221a2ecbf2ba645738f9e7e
4
+ data.tar.gz: 46b44b37276d1405fb5de4d1ccb3f3820092a4f3ee920f9e69391190fda3e8d5
5
5
  SHA512:
6
- metadata.gz: 313650c65265522742117bbd42f4988746ca7c18023b3fa61d644fa6aee74d3fef5b9a399bc91328a99eb79b325a8f379605670483f05df011e0d089d27b7073
7
- data.tar.gz: 785d785ca873ef98e1ff782896284be47050ffdfbc61aa2063c38387a32dcedcaf0e8e858f3f5aedbfb213c87f783ded71a6a8053979da2695292690488a94b6
6
+ metadata.gz: 0c579ab7593c3071b070ca29ec0960b99cc51396d623308b9f129737c2eca0a35be1b05174e8aa1687102ffdfac02cf54b1a7ba641cc784b00b193b746e51b8e
7
+ data.tar.gz: '007769ff6db0b0e7b9ef854fc1fa4e05e8f9bd0c122e932d80ae6b3b05aee11fd9108b214c05399fbd9fc9e4a66f84b414c502a79aa427a2747fc6b12576b5db'
@@ -1,8 +1,7 @@
1
1
  require "embed_me/engine"
2
- require "embed_me/embeddable"
3
2
  require "embed_me/rails/routes"
4
3
 
5
4
  module EmbedMe
6
5
  # defines a scoped route under which the embedded content can be found
7
- mattr_accessor :scope_name, default: 'embed'
6
+ mattr_accessor :scope_name, default: :embed
8
7
  end
@@ -4,8 +4,28 @@ module EmbedMe
4
4
 
5
5
  initializer "embed_me" do
6
6
  ActiveSupport.on_load(:action_controller) do
7
- include EmbedMe::Embeddable
8
- before_action :set_embeddable!
7
+ before_action :check_embedding!
8
+
9
+ def default_url_options(options={})
10
+ hash_embed = Hash.new
11
+ hash_embed[EmbedMe.scope_name] = EmbedMe.scope_name.to_s
12
+ hash_normal = Hash.new
13
+ hash_normal[EmbedMe.scope_name] = nil
14
+ params[EmbedMe.scope_name] == EmbedMe.scope_name.to_s ? hash_embed : hash_normal
15
+ end
16
+
17
+ def embedded?
18
+ # using path instead of params because path[:embed] != params[:embed] if
19
+ # URL: http://localhost:3000/posts?embed=embed
20
+ path = Rails.application.routes.recognize_path(request.path)
21
+ path[EmbedMe.scope_name] == EmbedMe.scope_name.to_s
22
+ end
23
+
24
+ def check_embedding!
25
+ if embedded?
26
+ response.headers.except! 'X-Frame-Options'
27
+ end
28
+ end
9
29
  end
10
30
  end
11
31
  end
@@ -1,8 +1,7 @@
1
1
  module ActionDispatch::Routing
2
2
  class Mapper
3
3
  def embeddable
4
- yield
5
- scope path: "/#{EmbedMe.scope_name}", as: EmbedMe.scope_name, is_embedded: true do
4
+ scope "(:#{EmbedMe.scope_name.to_s})", embed: /#{EmbedMe.scope_name.to_s}/ do
6
5
  yield
7
6
  end
8
7
  end
@@ -1,3 +1,3 @@
1
1
  module EmbedMe
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embed_me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Bohn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-15 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -79,7 +79,6 @@ files:
79
79
  - app/views/layouts/embed_me/application.html.erb
80
80
  - config/routes.rb
81
81
  - lib/embed_me.rb
82
- - lib/embed_me/embeddable.rb
83
82
  - lib/embed_me/engine.rb
84
83
  - lib/embed_me/rails/routes.rb
85
84
  - lib/embed_me/version.rb
@@ -1,9 +0,0 @@
1
- module EmbedMe
2
- module Embeddable
3
- def set_embeddable!
4
- if params[:is_embedded].present?
5
- puts "\nEmbedded Request\n"
6
- end
7
- end
8
- end
9
- end