tdiary-contrib 5.0.2 → 5.0.3

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: df4146a150a383f7921897e986ff0f4290deff9e
4
- data.tar.gz: 6f26f9bf9908f34579a6c21a36303ed74197105f
3
+ metadata.gz: 8b861b8e242e49d48b1bf2a4d221e45358aeac56
4
+ data.tar.gz: da7a57a662ae3892930d9b6854ed82070a0cc277
5
5
  SHA512:
6
- metadata.gz: a55826575cd0c91657388f0ea94614bb87e14d83dfe4cdd1ed0ba52664665a9c51fe62a35e8081e79851aab081d0ee697405b76a3bfb4c71584bf5a2ab8f189a
7
- data.tar.gz: 33f849299b5e56e2f9ea699cc10607c3f72a16465850750e94d4aece07891ae15f0d7b3183d34bd67e695b00f81a2e9aab963052934a48051a5cd3eb25196cd5
6
+ metadata.gz: a1a4b72e93928bac1131636987550e6f2ca4fa4a9bc5ce13fa8ef822ecbf4b04e9493f0d51595e542adf165f34976634bfb9d0827b819ed8ae5b0f78918f616a
7
+ data.tar.gz: ad99181c743a43a23eb42be2627130cc608d3634cce262509856858bc0b148c1146d7098abb9f9f8653691198edaa71fdbeac7874e07764fc38361710202d6b2
@@ -1,5 +1,5 @@
1
1
  module TDiary
2
2
  class Contrib
3
- VERSION = "5.0.2"
3
+ VERSION = "5.0.3"
4
4
  end
5
5
  end
data/plugin/flickr.rb CHANGED
@@ -43,7 +43,7 @@ def flickr(photo_id, size = nil, place = 'flickr')
43
43
  return '[ERROR] flickr.rb: failed to get photo.'
44
44
  end
45
45
 
46
- %Q|<a href="#{photo[:page]}" class="flickr"><img title="#{photo[:title]}" alt="#{photo[:title]}" src="#{photo[:src]}" class="#{place} photo"></a>|
46
+ %Q|<a href="#{photo[:page]}" class="flickr"><img title="#{photo[:title]}" alt="#{photo[:title]}" src="#{photo[:src]}" class="#{place} photo" height="#{photo[:height]}" width="#{photo[:width]}"></a>|
47
47
  end
48
48
 
49
49
  def flickr_left(photo_id, size = nil)
data/plugin/ogp.rb CHANGED
@@ -7,31 +7,46 @@
7
7
  # @conf['ogp.facebook.app_id'] - your facebook application ID.
8
8
  # @conf['ogp.facebook.admins'] - your facebook ID.
9
9
 
10
- def ogp_description
11
- section_index = @cgi.params['p'][0]
12
- # section_index = "1"
13
- if @mode == 'day' and section_index
14
- diary = @diaries[@date.strftime('%Y%m%d')]
15
- sections = diary.instance_variable_get(:@sections)
16
- section = sections[section_index.to_i - 1].body_to_html
17
- @conf.shorten(apply_plugin(section, true), 200)
10
+ def ogp_description(html)
11
+ @conf.shorten(remove_tag(html), 200)
12
+ end
13
+
14
+ def ogp_image(html)
15
+ images = html.scan(/<img.*?src="(.*?)"/)
16
+ if !images.empty?
17
+ images.first[0]
18
18
  else
19
- @conf.description
19
+ @conf.banner
20
20
  end
21
21
  end
22
22
 
23
23
  add_header_proc do
24
24
  headers = {
25
- # TODO: og:urlへ対応
26
25
  'og:title' => title_tag.match(/>([^<]+)</).to_a[1],
27
26
  'og:site_name' => @conf.html_title,
28
- 'og:description' => ogp_description,
29
- 'og:image' => @conf.banner,
30
- 'og:type' => (@mode == 'day') ? 'article' : 'blog',
31
27
  'og:author' => @conf.author_name,
32
28
  'fb:app_id' => @conf['ogp.facebook.app_id'],
33
29
  'fb:admins' => @conf['ogp.facebook.admins']
34
30
  }
31
+
32
+ if @mode == 'day'
33
+ diary = @diaries[@date.strftime('%Y%m%d')]
34
+ if diary
35
+ sections = diary.instance_variable_get(:@sections)
36
+ section_index = @cgi.params['p'][0] || sections.size
37
+ section = sections[section_index.to_i - 1].body_to_html
38
+ section_html = apply_plugin(section)
39
+
40
+ headers['og:description'] = ogp_description(section_html)
41
+ headers['og:image'] = ogp_image(section_html)
42
+ headers['og:type'] = 'article'
43
+ end
44
+ else
45
+ headers['og:description'] = @conf.description
46
+ headers['og:image'] = @conf.banner
47
+ headers['og:type'] = 'website'
48
+ end
49
+
35
50
  headers.select {|key, val|
36
51
  val && !val.empty?
37
52
  }.map {|key, val|
data/plugin/playstore.rb CHANGED
@@ -131,7 +131,7 @@ def playstore_text(app_id)
131
131
  when :notfound
132
132
  "<em>#{app_id} was not found</em>"
133
133
  else
134
- %Q[<a href="#{app.market_url}">#{app.title}</a>]
134
+ %Q[<a href="#{app.store_url}">#{app.title}</a>]
135
135
  end
136
136
  end
137
137
 
data/spec/flicker_spec.rb CHANGED
@@ -15,7 +15,7 @@ describe "flickr plugin" do
15
15
  subject { plugin.flickr('5950109223', size = nil) }
16
16
 
17
17
  it do
18
- expect(subject).to eq %Q|<a href=\"https://www.flickr.com/photos/machu/5950109223/\" class=\"flickr\"><img title=\"RubyKaigi 2011\" alt=\"RubyKaigi 2011\" src=\"https://farm7.staticflickr.com/6006/5950109223_040097db92.jpg\" class=\"flickr photo\"></a>|
18
+ expect(subject).to eq %Q|<a href=\"https://www.flickr.com/photos/machu/5950109223/\" class=\"flickr\"><img title=\"RubyKaigi 2011\" alt=\"RubyKaigi 2011\" src=\"https://farm7.staticflickr.com/6006/5950109223_040097db92.jpg\" class=\"flickr photo\" height=\"375\" width=\"500\"></a>|
19
19
  end
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tDiary contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-29 00:00:00.000000000 Z
11
+ date: 2016-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tdiary
@@ -503,7 +503,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
503
  version: '0'
504
504
  requirements: []
505
505
  rubyforge_project:
506
- rubygems_version: 2.5.1
506
+ rubygems_version: 2.5.2
507
507
  signing_key:
508
508
  specification_version: 4
509
509
  summary: tDiary contributions package