jekyll-google-photos 0.0.2 → 1.0.0

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: bb7ae1fdffcb3907a967bf77c6aec0862803172c
4
- data.tar.gz: 522b31b1cf8985086d371b49d4a15cbb09f65c8a
3
+ metadata.gz: 4196827dd3a3b94ca00f5a0a3e7c4a5f47c9447a
4
+ data.tar.gz: ddbb5f23ce3c09a237db5c9a87b1de74315d644c
5
5
  SHA512:
6
- metadata.gz: c5d7d0de9d3bf09ce125b20a0e42af016c230f0983b213138401ccf824f8e624404b66e2aaf3cd8ec513a79d79d79aedc86b92520cd466af68f6f4fa624eda2b
7
- data.tar.gz: 88694193593b3c7a94b678eb61d1a09191b86304bef8008006d78e2843346fb958cdd6c8a45333bfd18dbb25c697691873696665986ddb951790b2cdd2f64762
6
+ metadata.gz: 427374f095a2a4f984a6b5c0ad6fce8e35c20d9bc310b12af509b13691a7a72de361b2c6c50cf0cad8d6d9378ae09b10d633b8a90d29f1f10d3c40efba33e89e
7
+ data.tar.gz: 50947e581864842ac80d77aaf70ef155ba31f2b49f8d285642ad4c73edcb95fb89550b46fc82fdaa32cbb5ae5499034d871384372f7ac8a4b49837855f277e86
data/Gemfile CHANGED
@@ -12,6 +12,3 @@ gem "wdm", "~> 0.1.0" if Gem.win_platform?
12
12
 
13
13
  gem "nokogiri", "~> 1.10"
14
14
 
15
- gem "image_size", "~> 2.0"
16
-
17
- gem "fastimage", "~> 2.1"
data/Gemfile.lock CHANGED
@@ -15,7 +15,6 @@ GEM
15
15
  http_parser.rb (0.6.0)
16
16
  i18n (0.9.5)
17
17
  concurrent-ruby (~> 1.0)
18
- image_size (2.0.1)
19
18
  jekyll (3.7.4)
20
19
  addressable (~> 2.4)
21
20
  colorator (~> 1.0)
@@ -71,7 +70,6 @@ PLATFORMS
71
70
 
72
71
  DEPENDENCIES
73
72
  fastimage (~> 2.1)
74
- image_size (~> 2.0)
75
73
  jekyll (~> 3.7.2)
76
74
  jekyll-feed (~> 0.6)
77
75
  minima (~> 2.0)
@@ -79,4 +77,4 @@ DEPENDENCIES
79
77
  tzinfo-data
80
78
 
81
79
  BUNDLED WITH
82
- 1.17.1
80
+ 2.0.1
data/README.md CHANGED
@@ -1,3 +1,41 @@
1
- # jekyll-google-photos
1
+ # Jekyll Google Photos
2
2
 
3
3
  > 💎 Embedd Google Photos Album to your Jekyll Site
4
+
5
+ [Check out the Demo](http://chira.ga/trip-to-annecy/)
6
+
7
+ # Installing
8
+
9
+ add the following to your Gemfile:
10
+ ```
11
+ gem 'jekyll-google-photos'
12
+ gem 'fastimage'
13
+ ```
14
+
15
+ then:
16
+ ```
17
+ bundle install
18
+ ```
19
+ Note: Simplified installation is still a WIP
20
+
21
+ You also need to add this plugin to your `_config.yml` file:
22
+ ```
23
+ plugins:
24
+ - jekyll-google-photos
25
+ ```
26
+
27
+ # Usage:
28
+ ```
29
+ {% google_photos <Link to Shared Google Photos Album> %}
30
+ ```
31
+ Example:
32
+ ```
33
+ {% google_photos https://photos.app.goo.gl/bhWukds8QVodFU246 %}
34
+ ```
35
+
36
+ # Features to implement
37
+
38
+ * Revamp Grid Layout Algorithm
39
+ * Let users decide how many photos in each row
40
+ * Full-Screen HQ Image View and Slider
41
+ * Do something about Videos
data/_config.yml CHANGED
@@ -1,9 +1,6 @@
1
- title: Your awesome title
2
- email: your-email@example.com
3
- description: >-
4
- Write an awesome description for your new site here. You can edit this
5
- line in _config.yml. It will appear in your document head meta (for
6
- Google search results) and in your feed.xml site description.
1
+ title: jekyll-google-photos
2
+ email: me@chia.ro
3
+ description: ""
7
4
  baseurl: ""
8
5
  url: ""
9
6
  twitter_username: jekyllrb
@@ -5,7 +5,7 @@ date: 2018-02-22 18:29:32 +0000
5
5
  categories: jekyll update
6
6
  ---
7
7
 
8
- {% google_photos https://photos.app.goo.gl/zSvo8gbDizZE4EKu5 %}
8
+ {% google_photos https://photos.app.goo.gl/bhWukds8QVodFU246 300 150 100 1280 400 5 %}
9
9
 
10
10
  You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
11
11
 
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
6
6
  spec.summary = "Embedd Google Photos Album to your Jekyll Site"
7
7
  spec.description = "Embedd Google Photos Album to your Jekyll Site"
8
8
  spec.version = JekyllGooglePhotos::VERSION
9
- spec.authors = ["heychirag"]
10
- spec.email = ["i@chira.ga"]
9
+ spec.authors = ["Chirag Arora"]
10
+ spec.email = ["me@chia.ro"]
11
11
  spec.homepage = "https://github.com/heychirag/jekyll-google-photos"
12
12
  spec.licenses = ["MIT"]
13
13
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
@@ -17,5 +17,4 @@ Gem::Specification.new do |spec|
17
17
  spec.add_development_dependency "rspec", "~> 3.5"
18
18
  spec.add_development_dependency "rubocop", "~> 0.52"
19
19
  spec.add_development_dependency "nokogiri", "~> 1.10"
20
- spec.add_development_dependency "fastimage", "~> 2.1"
21
20
  end
@@ -2,85 +2,162 @@ require "jekyll"
2
2
  require 'open-uri'
3
3
  require 'nokogiri'
4
4
  require 'fastimage'
5
-
6
- # https://jekyllrb.com/docs/plugins/#tags
5
+ require 'net/http'
7
6
 
8
7
  module JekyllGooglePhotos
9
8
  class Tag < Liquid::Tag
10
- def initialize(tagName, url, tokens)
9
+ def initialize(tagName, args, tokens)
11
10
  super
12
- @url = url
13
-
14
- @doc = Nokogiri::HTML(open(@url.strip).read)
15
-
16
- @scripts = @doc.xpath("//script")
11
+ args = args.split(" ")
12
+ url = args[0]
13
+ @row_height = args[1].to_i
14
+ @space = args[6].to_i
15
+ @tablet_max = args[4].to_i
16
+ @row_height_tablet = args[2].to_i
17
+ @space_tablet = @space
18
+ @phone_max = args[5].to_i
19
+ @row_height_phone = args[3].to_i
20
+ @space_phone = @space
21
+ @imgLinks = getImageLinks(url)
22
+ @dom = createDOM()
23
+ end
17
24
 
18
- for $x in @scripts do
19
- if $x.inner_html.match(/initDataCallback\(/)
20
- @jsonString = $x.inner_html
21
- @jsonString = @jsonString.sub(/.*function\(\)\{return /,"")
22
- @jsonString["\n}});"] = ""
25
+ def getImageLinks(url)
26
+ doc = Nokogiri::HTML(open(url.strip).read)
27
+ scripts = doc.xpath("//script")
28
+ for x in scripts do
29
+ if x.inner_html.match(/initDataCallback\(/)
30
+ jsonString = x.inner_html
31
+ jsonString = jsonString.sub(/.*function\(\)\{return /,"")
32
+ jsonString["\n}});"] = ""
23
33
  end
24
34
  end
35
+ json = JSON.parse(jsonString)
36
+ return json[1]
37
+ end
25
38
 
26
- @json = JSON.parse(@jsonString)
27
- @imgChildren = @json[1]
28
- $i = 0
29
- @margin = 7;
30
- @imgDOMS = %Q{<div class="google-photos-album" style="position:relative;margin-left:-#{@margin}px;margin-top:-#{@margin}px;">}
31
- for $x in @imgChildren do
32
- @dims = FastImage.size($x[1][0]);
33
- @imgDOMS += (%Q{<img src="#{$x[1][0]}" width="#{@dims[0]}" height="#{@dims[1]}" style="margin-left:#{@margin}px;margin-top:#{@margin}px;" />})
34
- puts $i
35
- $i += 1
36
- end
37
- @imgDOMS += %Q{</div>}
39
+ def flexbinCSS()
40
+ elem = %Q{
41
+ .flexbin {
42
+ display: flex;
43
+ overflow: hidden;
44
+ flex-wrap: wrap;
45
+ margin: -#{@space/2.0}px;
46
+ }
47
+ .flexbin:after {
48
+ content: '';
49
+ flex-grow: 999999999;
50
+ min-width: #{@row_height}px;
51
+ height: 0;
52
+ }
53
+ .flexbin > * {
54
+ position: relative;
55
+ display: block;
56
+ height: #{@row_height}px;
57
+ margin: #{@space/2.0}px;
58
+ flex-grow: 1;
59
+ }
60
+ .flexbin > * > img {
61
+ height: #{@row_height}px;
62
+ object-fit: cover;
63
+ max-width: 100%;
64
+ min-width: 100%;
65
+ vertical-align: bottom;
66
+ }
67
+ .flexbin.flexbin-margin {
68
+ margin: #{@space/2.0}px;
69
+ }
70
+ @media (max-width: #{@tablet_max}px) {
71
+ .flexbin {
72
+ display: flex;
73
+ overflow: hidden;
74
+ flex-wrap: wrap;
75
+ margin: -#{@space/2.0}px;
76
+ }
77
+ .flexbin:after {
78
+ content: '';
79
+ flex-grow: 999999999;
80
+ min-width: #{@row_height_tablet}px;
81
+ height: 0;
82
+ }
83
+ .flexbin > * {
84
+ position: relative;
85
+ display: block;
86
+ height: #{@row_height_tablet}px;
87
+ margin: #{@space/2.0}px;
88
+ flex-grow: 1;
89
+ }
90
+ .flexbin > * > img {
91
+ height: #{@row_height_tablet}px;
92
+ object-fit: cover;
93
+ max-width: 100%;
94
+ min-width: 100%;
95
+ vertical-align: bottom;
96
+ }
97
+ .flexbin.flexbin-margin {
98
+ margin: #{@space/2.0}px;
99
+ }
100
+ }
101
+ @media (max-width: #{@phone_max}px) {
102
+ .flexbin {
103
+ display: flex;
104
+ overflow: hidden;
105
+ flex-wrap: wrap;
106
+ margin: -#{@space/2.0}px;
107
+ }
108
+ .flexbin:after {
109
+ content: '';
110
+ flex-grow: 999999999;
111
+ min-width: #{@row_height_phone}px;
112
+ height: 0;
113
+ }
114
+ .flexbin > * {
115
+ position: relative;
116
+ display: block;
117
+ height: #{@row_height_phone}px;
118
+ margin: #{@space/2.0}px;
119
+ flex-grow: 1;
120
+ }
121
+ .flexbin > * > img {
122
+ height: #{@row_height_phone}px;
123
+ object-fit: cover;
124
+ max-width: 100%;
125
+ min-width: 100%;
126
+ vertical-align: bottom;
127
+ }
128
+ .flexbin.flexbin-margin {
129
+ margin: #{@space/2.0}px;
130
+ }
131
+ }
132
+
133
+ }
134
+ return elem
135
+ end
38
136
 
39
- @imgDOMS += %Q{<script>#{insertScript()}</script>}
137
+ def createDOM()
138
+ sp = %Q{<style>}
139
+ sp += flexbinCSS()
140
+ sp += %Q{</style>}
141
+ sp += addImages()
142
+ return sp
40
143
  end
41
144
 
42
- def insertScript
43
- result = 'var album = document.getElementsByClassName("google-photos-album")[0];'
44
- result += 'var albumImages = album.getElementsByTagName("img");'
45
- result += 'var minPicHeight = 200; var albumMargin ='+@margin.to_s+'; var noPics = 4;'
46
- result += 'var containerWidth = album.parentElement.clientWidth;'
47
- result += 'var xcoor = 0; var ycoor = 0;'
48
- result += '/*var setHeight = 0;*/'
49
- result += 'for(var i=0;i<albumImages.length;i+=noPics) {'
50
- result += 'var currMinHeight = 999999999;'
51
- result += 'for(var j=i;j<i+noPics&&j<albumImages.length;j++) {'
52
- result += 'if(albumImages[j].height<currMinHeight)'
53
- result += 'currMinHeight = albumImages[j].height;'
54
- result += '}'
55
- result += 'for(var j=i;j<i+noPics&&j<albumImages.length;j++) {'
56
- result += 'albumImages[j].width *= currMinHeight/albumImages[j].height;'
57
- result += 'albumImages[j].height = currMinHeight;'
58
- result += '}'
59
- result += 'var currWidth = (noPics)*albumMargin;'
60
- result += 'for(var j=i;j<i+noPics&&j<albumImages.length;j++) {'
61
- result += 'currWidth += albumImages[j].width;'
62
- result += '}'
63
- result += 'var k; var limitWidth = 0;'
64
- result += 'for(var k=i;k<i+noPics-1&&k<albumImages.length;k++) {'
65
- result += 'albumImages[k].width *= containerWidth/currWidth;'
66
- result += 'limitWidth = limitWidth + albumImages[k].width + albumMargin;'
67
- result += 'albumImages[k].height *= containerWidth/currWidth;'
68
- result += '}'
69
- result += 'albumImages[k].width = containerWidth-limitWidth;'
70
- result += 'albumImages[k].height *= containerWidth/currWidth;'
71
- result += '/*var setWidth = 0;'
72
- result += 'for(var j=i;j<i+noPics&&j<albumImages.length;j++) {'
73
- result += 'albumImages[j].style.transform = "translate3d($setWidth,$setHeight,0px)";'
74
- result += 'setWidth += albumImages[j].width;'
75
- result += 'setWidth += albumMargin;'
76
- result += '}'
77
- result += 'setHeight += albumImages[i].height;'
78
- result += 'setHeight += albumMargin;*/'
79
- result += '}'
145
+ def addImages()
146
+ sp = %Q{<div class="flexbin">}
147
+ for x in @imgLinks
148
+ link = x[1][0] + %Q{=w#{@tablet_max}}
149
+ sp += %Q{
150
+ <a href="#{x[1][0]}">
151
+ <img src="#{link}" />
152
+ </a>
153
+ }
154
+ end
155
+ sp += %Q{</div>}
156
+ return sp
80
157
  end
81
158
 
82
159
  def render(context)
83
- "#{@imgDOMS}"
160
+ @dom
84
161
  end
85
162
  end
86
163
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllGooglePhotos
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "1.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-google-photos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - heychirag
7
+ - Chirag Arora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-06 00:00:00.000000000 Z
11
+ date: 2019-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -80,23 +80,9 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.10'
83
- - !ruby/object:Gem::Dependency
84
- name: fastimage
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '2.1'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.1'
97
83
  description: Embedd Google Photos Album to your Jekyll Site
98
84
  email:
99
- - i@chira.ga
85
+ - me@chia.ro
100
86
  executables: []
101
87
  extensions: []
102
88
  extra_rdoc_files: []