hamloft 0.2.7 → 2.0.2

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
  SHA1:
3
- metadata.gz: 113c06e824ad187b4ff9ff2fa781d18bac54f295
4
- data.tar.gz: 017326d8fb0800435c70542c8994241634c607f4
3
+ metadata.gz: 8569026b061930afc52b6ab828d4d8148020ff87
4
+ data.tar.gz: 07a4764607bf3ecee70ad7dd7435bcdbc3b483dd
5
5
  SHA512:
6
- metadata.gz: f379f89815e31ec317928f7a2dfec30809206fba71caac6f30ed5bdf8bdc2c9b95ebca5e7e622de103526a97994465beb6fa6e5e06e33f02f2d542449a897bdf
7
- data.tar.gz: 063e1da499ad39faf8f8840483ab2651816942fcdfdd6102885efef39b6052d26ac2c4c7161a95c48043410e547c26962553f2b99aa09420ef3318943b85a842
6
+ metadata.gz: c8f309ab38a398063b273ff0097af269d5ca3c479e092e7f6663aa4cc8969a64583cb35817e04ce3e867cdae05a2cb5b9bd3e5f2264ccd7074c1ffc4ba2595d3
7
+ data.tar.gz: 60a36a85a83e142ab2ac07ffedd6dee280d82fb1a3ace22c5e7ab0cdcc44b273e9815d0760df54220fc1cb929f5e5974d3fe93af6ed6f224cea129ba7b2f4768
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hamloft (0.2.6)
4
+ hamloft (2.0.2)
5
5
  haml (~> 5.0)
6
6
  nokogiri (~> 1.8)
7
7
 
@@ -11,7 +11,7 @@ GEM
11
11
  ast (2.3.0)
12
12
  coderay (1.1.1)
13
13
  diff-lcs (1.3)
14
- haml (5.0.1)
14
+ haml (5.0.2)
15
15
  temple (>= 0.8.0)
16
16
  tilt
17
17
  method_source (0.8.2)
@@ -52,7 +52,7 @@ GEM
52
52
  ruby-progressbar (1.8.1)
53
53
  slop (3.6.0)
54
54
  temple (0.8.0)
55
- tilt (2.0.7)
55
+ tilt (2.0.8)
56
56
  unicode-display_width (1.2.1)
57
57
 
58
58
  PLATFORMS
@@ -65,4 +65,4 @@ DEPENDENCIES
65
65
  rubocop (~> 0.49)
66
66
 
67
67
  BUNDLED WITH
68
- 1.14.6
68
+ 1.15.1
@@ -19,7 +19,7 @@ module Hamloft
19
19
  extend Hamloft::Helpers
20
20
 
21
21
  # Inject widget helpers
22
- Hamloft.widgets.each do |widget|
22
+ Hamloft.widgets.values.each do |widget|
23
23
  extend widget::Helpers if defined?(widget::Helpers)
24
24
  end
25
25
 
@@ -41,7 +41,10 @@ module Hamloft
41
41
  end
42
42
  end
43
43
 
44
- def link(href, &block)
44
+ def link(href, referrer = 'Baker', &block)
45
+ if referrer && !referrer.empty? && !href.include?('referrer=')
46
+ href = "#{href}#{href.include?('?') ? '&' : '?'}referrer=#{referrer}"
47
+ end
45
48
  haml_tag :a, href: href do
46
49
  yield if block
47
50
  end
@@ -72,11 +75,10 @@ module Hamloft
72
75
  haml_tag :div, class: '_typeloft_widget_drop_container'
73
76
  end
74
77
 
75
- # widgets
76
-
77
- def widget_block(widget, &block)
78
- haml_tag :div, widget.typeloft_widget_options do
79
- yield(widget) if block
78
+ def widget(identifier, options={}, &block)
79
+ widget = Hamloft.widgets[identifier].new(options, self)
80
+ haml_tag :widget, widget.widget_options do
81
+ widget.template(&block)
80
82
  end
81
83
  end
82
84
  end
@@ -1,3 +1,3 @@
1
1
  module Hamloft
2
- VERSION = '0.2.7'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
data/lib/hamloft.rb CHANGED
@@ -5,11 +5,10 @@ require 'hamloft/engine'
5
5
  require 'hamloft/style_builder'
6
6
  require 'hamloft/helpers'
7
7
  require 'hamloft/template'
8
- require 'hamloft/widget'
9
8
 
10
9
  module Hamloft
11
10
  @@_templates = {}
12
- @@_widgets = []
11
+ @@_widgets = {}
13
12
  @@_block_resolver = nil
14
13
  @@_asset_uri = nil
15
14
 
@@ -37,8 +36,8 @@ module Hamloft
37
36
  @@_templates[key] = template
38
37
  end
39
38
 
40
- def self.register_widget(klass)
41
- @@_widgets.push(klass)
39
+ def self.register_widget(identifier, klass)
40
+ @@_widgets[identifier] = klass
42
41
  end
43
42
 
44
43
  def self.widgets
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamloft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -99,7 +99,6 @@ files:
99
99
  - lib/hamloft/style_builder.rb
100
100
  - lib/hamloft/template.rb
101
101
  - lib/hamloft/version.rb
102
- - lib/hamloft/widget.rb
103
102
  - spec/fixtures/template/tumblr.rb
104
103
  - spec/fixtures/test.haml
105
104
  - spec/fixtures/widget/sample.rb
@@ -1,29 +0,0 @@
1
- module Hamloft
2
- class Widget
3
- include Hamloft::Helpers
4
- attr_accessor :options
5
-
6
- def identifier
7
- 'base'
8
- end
9
-
10
- def defaults
11
- {}
12
- end
13
-
14
- def initialize(options)
15
- @options = defaults.merge(options)
16
- end
17
-
18
- def typeloft_widget_options
19
- attributes = {
20
- :class => '_typeloft_widget',
21
- :"data-widget-identifier" => identifier
22
- }
23
- @options.each do |k, v|
24
- attributes["data-attribute-#{k}"] = v
25
- end
26
- attributes
27
- end
28
- end
29
- end