anecdote 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/anecdote/_wysicontent.css.scss +12 -2
  3. data/lib/anecdote/version.rb +1 -1
  4. data/lib/anecdote.rb +70 -6
  5. data/test/dummy/app/views/pages/article.markdown +2 -2
  6. data/test/dummy/log/development.log +2485 -0
  7. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/-KqaPMrquoaEBhON4MqdgoBdR88-WoftXBpVMpRgLyA.cache +0 -0
  8. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/0767levYXqefxXu5KqMcpYn70EE-pEug-ATjPMPQY6s.cache +0 -0
  9. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/0kU6eBq3fRif39VIvjmzixbLice69Adm-V1KDtNrXZs.cache +1 -0
  10. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/2J5rDXC0mav8zXfx9Kbr6ZKjgovddwjoEOaNgAs3wtQ.cache +2 -0
  11. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/31gA6lGmMS691M_8D_ceiQGVOKuwRHUu0c4BDbLDstE.cache +0 -0
  12. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/4mza3-dO3nbCGKjXw_Rsd_q43HTmLKdCzSZxXKVcZF4.cache +0 -0
  13. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/5MdmfwKlDvo4oq-otD7pKrnvJckaJArm2o_-8AjivRE.cache +2 -0
  14. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6WmYsR3AJSKnfNfH4JIoVoRXGYe7wuKY6uwSko76vEk.cache +2 -0
  15. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6fptZWqD71zwtsDois8yWCqQFl-Trr1t51pWtn-bZ1k.cache +0 -0
  16. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6hkVSE4R70vFEaCzOi48C0jhAWgwDD7jQ6kcOSUMp60.cache +0 -0
  17. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/7x1CA86gEllbAPbtwGJVjjJeVOmsBCb1umsgWCLvsEc.cache +1 -0
  18. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/97zFyxwSapuPWrAfWm1228SGsAW4jOCQd1ByQ2hfAKw.cache +1 -0
  19. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/9BxpPJx9otMr_nu8M52YLgmucndWDuhj_87mmWzUbgs.cache +0 -0
  20. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/A5Fl_4MOxuLA59xm7A5uBHq_e2mMCfG99Vxige9pRWQ.cache +2 -0
  21. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/C6zkjC9v02FI_-gPxLJE4a6opcDNjj59vPA-DSRQSLg.cache +0 -0
  22. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/DCmOpXGAA1NvHdR-SD07FHM4mb4-FI7NUEuoCyUsvwk.cache +0 -0
  23. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Hfb55S1I2_3UmgwFQ7-ijJpJCIH2BNObGldFmS4OKl8.cache +1 -0
  24. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/IF3RbZ8QLRLbAiFKJySugh9CouSnqXSqF9eRZYoWVXg.cache +0 -0
  25. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ItqFpTQ279YgNQTHjfSmt8p5koqH05kLKXszdDBgImU.cache +2 -0
  26. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/JimhNrihLluAM9zROb1oYLE104JOAEWtyJlPEAKUuU8.cache +1 -0
  27. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/LXR48I8apMC5gxhFVNRrja-2zTcw8Kt3qnl2Ww-KXUQ.cache +1 -0
  28. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Veu1uTqk2gamhzkdCZq-bTWt0lZjvLstnD7oi1Hp2Mg.cache +1 -0
  29. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Vsq_g4j6Y2ZpFWKIz0Vdcos3r7re7BHVHZ8u3rVO87A.cache +2 -0
  30. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/W-UxfNGpBGKoTt-1C3P5R0S9NIzR8AUv2_Oo_CC3K_M.cache +0 -0
  31. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/XNqufCzosYlKFxfucKmmCBqHdwJH3kXS17x4Q4Y6hc0.cache +0 -0
  32. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZoPx-lXaxawAJ5qCjSH8PhO-Jqne-rOuT1Hgp2RqHXA.cache +1 -0
  33. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/_taiuif9Fi4_9FjfKwQyrPTEv4fMWdJBtY933VA5sgI.cache +1 -0
  34. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/cQlEWgw3_lrr9_hnJTe-R2PUTIsD_8Q9oopsBIpApAI.cache +0 -0
  35. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/cdeJ3PG9A3NDQlJn2Tcc0dCDeCidcUg9gGKthBZ9suc.cache +1 -0
  36. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/cp7Hah4kScUUD0OSc1omcQYArvHmV-HqrY02i2c4Ojc.cache +1 -0
  37. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/dCDXG_vOpgwCKsk-ZV-yjLAWxVHDyJwLNgkOaI34-4M.cache +0 -0
  38. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/dDTyBChpOgK1E5HXsomIVf-qIUbioDjpF3QE4YHqgS0.cache +1 -0
  39. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/eQ-n27uuoi_JMF5iwKZsIt2ondxIvBkBQtawLkF7Clo.cache +2 -0
  40. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/gqbdF8h5kWNa3KcImFTUeZhX1ab_6LgePRrXo9txeO8.cache +0 -0
  41. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/hEF9ExosLSBGWDTJ223-V2SFQjcgoKJjH8Wv4xguo1U.cache +0 -0
  42. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/o6PIi0ANNS7zSCujFQ60uYtbxGph0-thrjvdmZal32Y.cache +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/wWfeB3hcmPMayy4bmrSRXZuyF7Uej00zxnJ-fIbo_4Y.cache +1 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/yNiA-ljrjGd5D1VOzzpTEnn1Z7xwOf21FmC30m30hyA.cache +1 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ydXcgdAQ3SNZT2JYwrdZ9NRdRVqKODfGhuseVCOShtA.cache +1 -0
  46. metadata +76 -4
  47. data/test/dummy/tmp/pids/server.pid +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80e6132b765240d3646c13c4fcef7ac592d8b9af
4
- data.tar.gz: 7eac6016355dc32ca78ae3d5b06b8f1252749b8a
3
+ metadata.gz: 9c2e79f493a9e06b0ad695a797274253265aff11
4
+ data.tar.gz: 9b4b055de45e5f1f595b7897d77472651aac596b
5
5
  SHA512:
6
- metadata.gz: 60576bb54a30471159fd75fe6ee84c9c98623c740f17271d9ec27e9c841a21bdb5d9c253bf4df4b22a5e5d2b28f3a77997a2eba6bd15dab96dd68597f485bad3
7
- data.tar.gz: 820e4b4a41512e6ff25884f9e58a069841ee9b9abc3ea2b6d345300b98375355a1620dbe835da458d620ec296acc491e64ef9370cd324a72ddaa34ff08a4ba3e
6
+ metadata.gz: 2a8a4006c4eb94bc0854b368b9bbeda220f0740588408f99a622cded5facb557e566e1de90d45f66f48a4a23bee11e2e1fa5b86af881b9caba5543bbfd397733
7
+ data.tar.gz: 8bfd2f762597c7d58d23bad7493f00a310a0820f539a23e7f2840331236919ad9ca6ae81c392aaf7fa85462a8d61933948f8350c038893c1cfd69b6123cffb40
@@ -106,7 +106,9 @@
106
106
  }
107
107
  @include respond(min, large-handheld) {
108
108
  &.v-size-small {
109
- @include remify( margin, 0.35, 2, 1 );
109
+ &.v-float-right, &.v-float-left {
110
+ @include remify( margin, 0.35, 2, 1 );
111
+ }
110
112
  &.v-float-right {
111
113
  float: right;
112
114
  margin-right: 0;
@@ -119,7 +121,9 @@
119
121
  }
120
122
  @include respond(min, laptop) {
121
123
  &.v-size-medium {
122
- @include remify( margin, 0.35, 2, 1 );
124
+ &.v-float-right, &.v-float-left {
125
+ @include remify( margin, 0.35, 2, 1 );
126
+ }
123
127
  &.v-float-right {
124
128
  float: right;
125
129
  margin-right: 0;
@@ -163,9 +167,15 @@
163
167
  margin-top: 0;
164
168
  }
165
169
  }
170
+ .anecdote-gallery-offset-dn2bak {
171
+ display: none;
172
+ }
166
173
 
167
174
  @include respond(min, tablet) {
168
175
  .flexbox & {
176
+ .anecdote-gallery-offset-dn2bak {
177
+ display: block;
178
+ }
169
179
  .content {
170
180
  display: -ms-flexbox;
171
181
  display: -webkit-flex;
@@ -1,3 +1,3 @@
1
1
  module Anecdote
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/anecdote.rb CHANGED
@@ -18,17 +18,26 @@ module Anecdote
18
18
 
19
19
  def self.init_raconteur
20
20
  raconteur.settings.setting_quotes = '$'
21
+
21
22
  raconteur.processors.register!('graphic', {
22
23
  handler: lambda do |settings|
23
24
  klass = (['anecdote-graphic-dn32ja'] + module_classes(settings)).flatten.join(' ')
24
25
  contents = []
25
26
  contents << view_context.content_tag(:div, class: 'anecdote-intrinsic-embed-n42ha1') do
26
- geo = Paperclip::Geometry.from_file(Rails.root.join('app', 'assets', 'images', settings[:assets_path]))
27
+ if settings[:assets_path]
28
+ image_url = settings[:assets_path]
29
+ paperclip_geo = Paperclip::Geometry.from_file(Rails.root.join('app', 'assets', 'images', settings[:assets_path]))
30
+ geo = { width: paperclip_geo.width, height: paperclip_geo.height }
31
+ elsif settings[:image_url]
32
+ image_url = settings[:image_url]
33
+ dimensions = settings[:image_dimensions].split('x').map(&:to_f)
34
+ geo = { width: dimensions.first, height: dimensions.last }
35
+ end
27
36
  if settings[:_scope_].present? && settings[:_scope_][:processor].tag == 'gallery'
28
37
  settings[:_scope_][:settings][:_graphics_] ||= []
29
38
  settings[:_scope_][:settings][:_graphics_] << geo
30
39
  end
31
- view_context.content_tag(:div, view_context.image_tag(settings[:assets_path], alt: ''), class: 'inner', style: "padding-bottom: #{geo.height / geo.width * 100}%;")
40
+ view_context.content_tag(:div, view_context.image_tag(image_url, alt: ''), class: 'inner', style: "padding-bottom: #{geo[:height] / geo[:width] * 100}%;")
32
41
  end
33
42
  if settings[:caption].present?
34
43
  contents << view_context.content_tag(:div, view_context.content_tag(:div, markdown_and_parse(settings[:caption]), class: 'inner anecdote-wysicontent-ndj4ab'), class: 'anecdote-caption-ajkd3b')
@@ -36,18 +45,72 @@ module Anecdote
36
45
  view_context.content_tag(:div, view_context.content_tag(:div, contents.join("\n").html_safe, class: 'inner'), class: klass)
37
46
  end
38
47
  })
48
+
39
49
  raconteur.processors.register!('gallery', {
40
50
  handler: lambda do |settings|
41
51
  klass = (['anecdote-gallery-dn2bak'] + module_classes(settings)).flatten.join(' ')
42
- contents = []
43
52
  graphics = settings[:_yield_].html_safe
53
+
54
+ # handle scaling
55
+ flexes = []
56
+ if settings[:scale_by] == 'relative-width-bottom-alignment'
57
+ # images scaled based on their relative width with bottom alignment
58
+ total_width = settings[:_graphics_].sum { |hsh| hsh[:width]}
59
+ settings[:_graphics_].each do |graphic|
60
+ flex = {
61
+ width: graphic[:width] / total_width,
62
+ graphic: graphic,
63
+ ratio: graphic[:width] / graphic[:height],
64
+ gfx_height_pad: graphic[:height] / graphic[:width]
65
+ }
66
+ flex[:width_ratio_balance] = flex[:width] / flex[:ratio]
67
+ flexes << flex
68
+ end
69
+ tallest = flexes.sort_by { |k| k[:width_ratio_balance] }.last
70
+ flexes.map do |flex|
71
+ flex[:faux] = flex[:width_ratio_balance] / tallest[:width_ratio_balance]
72
+ flex[:gfx_height_pad_faux] = flex[:gfx_height_pad] / flex[:faux]
73
+ flex[:top_offset] = flex[:gfx_height_pad_faux] - flex[:gfx_height_pad]
74
+ end
75
+ index = 0
76
+ graphics.gsub!('<div class="anecdote-intrinsic-embed-n42ha1">') do |match|
77
+ flex = flexes[index]
78
+ index += 1
79
+ (view_context.content_tag(:div, '', class: 'anecdote-gallery-offset-dn2bak', style: "padding-top: #{flex[:top_offset] * 100}%;").html_safe + match.html_safe).html_safe
80
+ end
81
+ # graphics.gsub!(/anecdote-intrinsic-embed-n42ha1.*?padding-bottom:\s*([\d|\.]*)/mi) do |match|
82
+ # flex = flexes[index]
83
+ # index += 1
84
+ # match.sub(/[\d|\.]*$/, (flex[:gfx_height_pad_faux] * 100).to_s).html_safe
85
+ # end
86
+ elsif settings[:scale_by] == 'relative-width'
87
+ # images scaled based on their relative width
88
+ total_width = settings[:_graphics_].sum { |hsh| hsh[:width]}
89
+ settings[:_graphics_].each do |graphic|
90
+ flexes << { width: graphic[:width] / total_width, graphic: graphic }
91
+ end
92
+ else
93
+ # images scaled to equal height
94
+ total_ratio = settings[:_graphics_].sum { |geo| geo[:width] / geo[:height] }
95
+ settings[:_graphics_].each do |graphic|
96
+ flexes << { width: (graphic[:width] / graphic[:height]) / total_ratio, graphic: graphic }
97
+ end
98
+ end
44
99
  index = 0
45
- total_width = settings[:_graphics_].sum { |geo| geo.width / geo.height }
46
100
  graphics.gsub!(/class="[^"]*?anecdote-graphic-dn32ja[\s|"]/mi) do |match|
47
- width = (settings[:_graphics_][index].width / settings[:_graphics_][index].height) / total_width
101
+ flex = flexes[index]
48
102
  index += 1
49
- "style=\"-webkit-flex-basis:#{width * 100}%;-moz-flex-basis:#{width * 100}%;flex-basis:#{width * 100}%;\" #{match}".html_safe
103
+ styles = []
104
+ if flex[:width].present?
105
+ styles << "-webkit-flex-basis:#{flex[:width] * 100}%"
106
+ styles << "-moz-flex-basis:#{flex[:width] * 100}%"
107
+ styles << "flex-basis:#{flex[:width] * 100}%"
108
+ end
109
+ "style=\"#{styles.join(';')}\" #{match}".html_safe
50
110
  end
111
+
112
+ # build HTML output
113
+ contents = []
51
114
  contents << view_context.content_tag(:div, graphics.html_safe, class: 'content')
52
115
  if settings[:caption].present?
53
116
  contents << view_context.content_tag(:div, view_context.content_tag(:div, markdown_and_parse(settings[:caption]), class: 'inner anecdote-wysicontent-ndj4ab'), class: 'anecdote-caption-ajkd3b')
@@ -55,6 +118,7 @@ module Anecdote
55
118
  view_context.content_tag(:div, view_context.content_tag(:div, contents.join("\n").html_safe, class: 'inner'), class: klass)
56
119
  end
57
120
  })
121
+
58
122
  raconteur.processors.register!('pull-quote', {
59
123
  handler: lambda do |settings|
60
124
  klass = (['anecdote-pull-quote-sba2ha'] + module_classes(settings)).flatten.join(' ')
@@ -8,14 +8,14 @@ We considered naming this article "the sort type all users want but zero sites o
8
8
 
9
9
  During our research study on product list usability the test subjects repeatedly sought out these kinds of category-specific sort types – however, to no avail since seemingly **zero sites** offer them. Even after [benchmarking](http://baymard.com/ecommerce-product-lists/benchmark/site-reviews) the product lists of 50 major e-commerce sites we have yet to find a site that truly offer category-specific sorting.
10
10
 
11
- {{% gallery: size=big %}}
11
+ {{% gallery: size=big + scale-by=relative-width-bottom-alignment %}}
12
12
  {{ graphic: assets-path=category-specific-sorting-02-bestbuy.jpg + mood=positive + caption=$A mockup we've created of what category-specific sort types could look like at BestBuy. Here the three last sorting options – for TV screen size, refresh rate, and display depth – are available exclusively within the TV category while the other sort types are available site-wide.$ }}
13
13
  {{ graphic: assets-path=category-specific-sorting-08-faceted-sorting.jpg + mood=negative + caption=$An example of how things can go really wrong.$ }}
14
14
  {{% end %}}
15
15
 
16
16
  In this article we'll outline our research findings on why **category-specific sorting** is so important to the user's product finding abilities, and how it can be implemented.
17
17
 
18
- {{ graphic: float=left + size=small + assets-path=category-specific-sorting-02-bestbuy.jpg + caption=$A mockup we've created of what category-specific sort types could look like at BestBuy. Here the three last sorting options – for TV screen size, refresh rate, and display depth – are available exclusively within the TV category while the other sort types are available site-wide.$ }}
18
+ {{ graphic: float=left + size=small + image-url=http://assets.baymard.com/blog/category-specific-sorting-02-bestbuy-d0496405ef767b1f469cc0e71cc4f84d.jpg + image-dimensions=1032x688 + caption=$A mockup we've created of what category-specific sort types could look like at BestBuy. Here the three last sorting options – for TV screen size, refresh rate, and display depth – are available exclusively within the TV category while the other sort types are available site-wide.$ }}
19
19
 
20
20
  Given that category-specific sorting is such an uncommon features, let's quickly **define** the term. By "category-specific sort types" we mean any sorting options that are only available in one or a few select categories (because they wouldn't make sense as site-wide sorting options – they only make sense for the products within those particular categories). Examples include being able to sort suitcases by volume, fishing rods by length, pens by point size, hard drives by storage capacity and spindle speed, road bikes by weight, etc. It's this category specificity that makes them different from common site-wide sort types such as 'Best Selling', 'Relevance', 'User Ratings', and 'Price', which are typically available for all products and categories throughout a site.
21
21