tdiary-contrib 5.0.13 → 5.1.4
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 +4 -4
- data/js/gyazo.js +23 -0
- data/lib/tdiary/contrib/version.rb +1 -1
- data/plugin/add_bookmark.rb +1 -1
- data/plugin/gyazo.rb +90 -0
- data/plugin/hb_footer.rb +2 -2
- data/plugin/image_ex.rb +5 -4
- data/plugin/instagram.rb +3 -2
- data/plugin/ja/openbd.rb +40 -0
- data/plugin/mm_footer.rb +2 -2
- data/plugin/my_hotentry.rb +1 -1
- data/plugin/notify_miniblog.rb +1 -1
- data/plugin/openbd.rb +306 -0
- data/plugin/puboo.rb +10 -10
- data/plugin/socialbutton.rb +2 -2
- data/plugin/tweet_quote.rb +4 -5
- data/plugin/twitter.rb +5 -41
- data/plugin/twitter_js.rb +8 -57
- data/plugin/yahoo_kousei.rb +1 -1
- data/plugin/yo_update.rb +1 -1
- data/spec/spec_helper.rb +7 -7
- data/style/hatena_style.rb +3 -3
- data/util/image-gallery/misc/plugin/recent_image.rb +2 -2
- data/util/image-gallery/misc/plugin/view_exif.rb +2 -2
- data/util/tdiary-grep/grep.rb +1 -1
- metadata +36 -6
- data/spec/twitter_js_spec.rb +0 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7589d91925dead78181297d0bfb4e994d79d2d362cbc822084367b85a593b56
|
4
|
+
data.tar.gz: 424a594824fad56caf9c40825d96c1c7eac62857dd0b04bad7028f4a7a7a5685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 656e6bdfc9982c2744c0a323e7b46037dbcf0eab0750add8b4b84807cf1ba99e6ce82f6f130c1e26139ee74dff629bdc7a14390f23537741680a0185ecef7925
|
7
|
+
data.tar.gz: '0463607988a55b8575c9fa62e16786e7f51e139f3f3cf9c461a7b3930d2efa9b782afaf52a08279e499bcc027399e4040f9a4f221cb306bcfcc7dba1d56e84a8'
|
data/js/gyazo.js
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
/*
|
2
|
+
* gyazo.js: gyazo plugin for tDiary
|
3
|
+
*
|
4
|
+
* SPDX-License-Identifier: GPL-2.0-or-later
|
5
|
+
*/
|
6
|
+
$(function() {
|
7
|
+
$('.gyazo-images img')
|
8
|
+
.on({
|
9
|
+
'mouseenter': function(){
|
10
|
+
$(this).css('cursor', 'pointer');
|
11
|
+
},
|
12
|
+
'mouseleave': function(){
|
13
|
+
$(this).css('cursor', 'default');
|
14
|
+
},
|
15
|
+
'click': function(){
|
16
|
+
var url = $(this).attr('data-url');
|
17
|
+
var text = $.makePluginTag('gyazo', function(){
|
18
|
+
return ["'" + url + "'", "'[description]'"]
|
19
|
+
})
|
20
|
+
$('#body').insertAtCaret(text);
|
21
|
+
}
|
22
|
+
})
|
23
|
+
})
|
data/plugin/add_bookmark.rb
CHANGED
@@ -20,7 +20,7 @@ add_subtitle_proc do |date, index, subtitle|
|
|
20
20
|
section_url = @conf.base_url + anchor(date.strftime('%Y%m%d')) + '#p' + ('%02d' % index)
|
21
21
|
|
22
22
|
if @conf['add.bookmark.delicious'] == 't' then
|
23
|
-
escaped_url =
|
23
|
+
escaped_url = CGI.escape(section_url)
|
24
24
|
caption += %Q|<a href="http://delicious.com/save?url=#{escaped_url}" onclick="window.open('http://delicious.com/save?v=5;noui;jump=close;url=#{escaped_url};title='+encodeURIComponent(document.title), 'delicious', 'toolbar=no,width=550,height=550'); return false">|
|
25
25
|
caption += %Q|<img src="http://static.delicious.com/img/delicious.small.gif" width="10" height="10" style="border: 0 none;vertical-align: middle;" alt="#{@caption_delicious}">|
|
26
26
|
caption += %Q|</a> |
|
data/plugin/gyazo.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#
|
2
|
+
# gyazo.rb: gyazo plugin for tDiary
|
3
|
+
#
|
4
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
5
|
+
#
|
6
|
+
require 'net/http'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
if /^(form|edit|formplugin|showcomment)$/ =~ @mode then
|
10
|
+
enable_js('gyazo.js')
|
11
|
+
end
|
12
|
+
|
13
|
+
def gyazo(permalink_url, alt = '[description]', style = 'photo')
|
14
|
+
size = @conf['gyazo_max_size'] || 512
|
15
|
+
begin
|
16
|
+
oembed = JSON.parse(Net::HTTP.get(URI("https://api.gyazo.com/api/oembed?url=#{permalink_url}")), symbolize_names: true)
|
17
|
+
rescue => e
|
18
|
+
@logger.error(e)
|
19
|
+
return ''
|
20
|
+
end
|
21
|
+
url = oembed[:url].gsub(%r|/thumb/\d+/|, "/thumb/#{size}/")
|
22
|
+
width = oembed[:width].to_i
|
23
|
+
height = oembed[:height].to_i
|
24
|
+
if width > 0 && height > 0
|
25
|
+
if width > height
|
26
|
+
height = size * height / width
|
27
|
+
width = size
|
28
|
+
else
|
29
|
+
width = size * width / height
|
30
|
+
height = size
|
31
|
+
end
|
32
|
+
%Q[<img src="#{url}" class="#{style}" width=#{width} height=#{height} alt="#{alt}" title="#{alt}">]
|
33
|
+
else # no size informations in API
|
34
|
+
%Q[<img src="#{url}" class="#{style}" width=#{size} alt="#{alt}" title="#{alt}">]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def gyazo_right(permalink_url, alt = '[description]')
|
39
|
+
gyazo(permalink_url, alt, 'right')
|
40
|
+
end
|
41
|
+
|
42
|
+
def gyazo_left(permalink_url, alt = '[description]')
|
43
|
+
gyazo(permalink_url, alt, 'left')
|
44
|
+
end
|
45
|
+
|
46
|
+
def gyazo_list
|
47
|
+
endpoint = "https://api.gyazo.com/api/images"
|
48
|
+
access_token = @conf['gyazo_token']
|
49
|
+
return [] if access_token == nil || access_token.empty?
|
50
|
+
per_page = @conf['gyazo_max_images'] || 5
|
51
|
+
uri = "#{endpoint}?access_token=#{access_token};per_page=#{per_page}"
|
52
|
+
begin
|
53
|
+
JSON.parse(Net::HTTP.get(URI(uri)), symbolize_names: true).map{|i|
|
54
|
+
[i[:permalink_url], i[:thumb_url]]
|
55
|
+
}.delete_if{|is|
|
56
|
+
is[1].empty?
|
57
|
+
}
|
58
|
+
rescue => e
|
59
|
+
@logger.error(e)
|
60
|
+
return []
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
add_form_proc() do |date|
|
65
|
+
'<div class="form"><div class="caption">Gyazo</div><div class="gyazo-images">' +
|
66
|
+
gyazo_list.map{|i|
|
67
|
+
%Q[<img src="#{i[1]}" data-url="#{i[0]}"> ]
|
68
|
+
}.join +
|
69
|
+
'</div></div>'
|
70
|
+
end
|
71
|
+
|
72
|
+
add_conf_proc('gyazo', 'Gyazo') do
|
73
|
+
if @mode == 'saveconf'
|
74
|
+
@conf['gyazo_token'] = @cgi.params['gyazo_token'][0]
|
75
|
+
@conf['gyazo_max_images'] = @cgi.params['gyazo_max_images'][0].to_i
|
76
|
+
@conf['gyazo_max_size'] = @cgi.params['gyazo_max_size'][0].to_i
|
77
|
+
end
|
78
|
+
@conf['gyazo_max_images'] = 5 if @conf['gyazo_max_images'].to_i < 1
|
79
|
+
@conf['gyazo_max_size'] = 512 if @conf['gyazo_max_size'].to_i < 1
|
80
|
+
|
81
|
+
r = ''
|
82
|
+
r << %Q|<h3 class="subtitle">Gyazo API Access Token</h3>|
|
83
|
+
r << %Q|<p>Get your token from <a href="https://gyazo.com/oauth/applications">Gyazo Applications</a></p>|
|
84
|
+
r << %Q|<p><input name="gyazo_token" value="#{h @conf['gyazo_token']}" size=64></p>|
|
85
|
+
r << %Q|<h3 class="subtitle">Max images in list</h3>|
|
86
|
+
r << %Q|<p><input name="gyazo_token" value="#{h @conf['gyazo_max_images']}" size=3></p>|
|
87
|
+
r << %Q|<h3 class="subtitle">Max image size</h3>|
|
88
|
+
r << %Q|<p><input name="gyazo_token" value="#{h @conf['gyazo_max_size']}" size=4> px</p>|
|
89
|
+
r
|
90
|
+
end
|
data/plugin/hb_footer.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# Author: ishinao <ishinao@ishinao.net>
|
9
9
|
#
|
10
10
|
|
11
|
-
add_body_leave_proc
|
11
|
+
add_body_leave_proc do |date|
|
12
12
|
if @mode == 'day' or @mode == 'latest'
|
13
13
|
diary = @diaries[date.strftime('%Y%m%d')]
|
14
14
|
pnum = 1
|
@@ -33,7 +33,7 @@ add_body_leave_proc(Proc.new do |date|
|
|
33
33
|
else
|
34
34
|
''
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
37
37
|
|
38
38
|
# rss-recent.rb: RSS recent plugin
|
39
39
|
#
|
data/plugin/image_ex.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
# image_plugin_ex.rb
|
2
3
|
# version 0.3
|
3
4
|
# -pv-
|
@@ -86,11 +87,11 @@
|
|
86
87
|
|
87
88
|
enable_js("image_ex.js")
|
88
89
|
|
89
|
-
add_body_enter_proc
|
90
|
+
add_body_enter_proc do |date|
|
90
91
|
@image_date = date.strftime("%Y%m%d")
|
91
92
|
@image_year = date.strftime("%Y")
|
92
93
|
""
|
93
|
-
end
|
94
|
+
end
|
94
95
|
|
95
96
|
|
96
97
|
def image( id, alt = "image", id2 = nil, width = nil, place="none" )
|
@@ -199,7 +200,7 @@ add_form_proc do |date|
|
|
199
200
|
imageex_convertedsize = %Q[#{imageex_convertedheight}x#{imageex_convertedwidth}]
|
200
201
|
imageex_convertedsize
|
201
202
|
end
|
202
|
-
system(imageex_convertpath , "-geometry", imageex_convertedsize , orig, new)
|
203
|
+
system(imageex_convertpath , "-auto-orient", "-geometry", imageex_convertedsize , orig, new)
|
203
204
|
if FileTest::size?( new ) == 0
|
204
205
|
File::delete( new )
|
205
206
|
end
|
@@ -373,7 +374,7 @@ add_form_proc do |date|
|
|
373
374
|
posttable << %Q[</TR></TABLE>]
|
374
375
|
end
|
375
376
|
|
376
|
-
if @conf.respond_to?(:style) and @conf.style =~ /Wiki$/i
|
377
|
+
if @conf.respond_to?(:style) and @conf.style =~ /(Wiki|GFM)$/i
|
377
378
|
image_plugin_tag1 = "{{"
|
378
379
|
image_plugin_tag2 = "}}"
|
379
380
|
elsif @conf.respond_to?(:style) and @conf.style =~ /RD$/i
|
data/plugin/instagram.rb
CHANGED
@@ -10,7 +10,6 @@ require 'uri'
|
|
10
10
|
require 'net/http'
|
11
11
|
require 'open-uri'
|
12
12
|
|
13
|
-
|
14
13
|
def instagram(*args)
|
15
14
|
uri = URI::parse(args[0])
|
16
15
|
return instagram_iframe(*args) if uri.scheme.nil?
|
@@ -19,7 +18,9 @@ end
|
|
19
18
|
|
20
19
|
def instagram_iframe(code, width=612, height=700)
|
21
20
|
return <<-BODY
|
22
|
-
<
|
21
|
+
<div class="embed embed-instagram">
|
22
|
+
<iframe src="//instagram.com/p/#{code}/embed/" width="#{width}" height="#{height}" frameborder="0" scrolling="no" allowtransparency="true"></iframe>
|
23
|
+
</div>
|
23
24
|
BODY
|
24
25
|
end
|
25
26
|
|
data/plugin/ja/openbd.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Japanese resource of openBD plugin
|
3
|
+
#
|
4
|
+
# Copyright (C) 2020 OGAWA KenIchi <kenichi@ice.email.ne.jp>
|
5
|
+
# You can redistribute it and/or modify it under GPL2 or any later version.
|
6
|
+
#
|
7
|
+
|
8
|
+
@openbd_label_title = 'isbn_imageプラグインで商品名を'
|
9
|
+
@openbd_label_title_hide = '表示しない'
|
10
|
+
@openbd_label_title_show = '表示する'
|
11
|
+
@openbd_label_clearcache = 'キャッシュの削除'
|
12
|
+
@openbd_label_clearcache_desc = '書籍情報のキャッシュを削除する'
|
13
|
+
|
14
|
+
@openbd_label_default_image = 'デフォルトの画像ファイル'
|
15
|
+
@openbd_label_default_image_desc =
|
16
|
+
'書影がない場合に表示する画像ファイルのパスを指定します。' \
|
17
|
+
'未指定の場合はデフォルトの画像が表示されます。'
|
18
|
+
|
19
|
+
@openbd_label_image_width = '書影の表示幅'
|
20
|
+
@openbd_label_image_width_desc =
|
21
|
+
'数値を指定すると書影を表すimg要素のwidth属性に値が出力されます。'
|
22
|
+
|
23
|
+
@openbd_label_image_height = '書影の表示高'
|
24
|
+
@openbd_label_image_height_desc =
|
25
|
+
'数値を指定すると書影を表すimg要素のheight属性に値が出力されます。'
|
26
|
+
|
27
|
+
@openbd_label_detail_image_width = 'isbn_detail使用時の書影の表示幅'
|
28
|
+
@openbd_label_detail_image_width_desc =
|
29
|
+
'数値を指定すると書影を表すimg要素のwidth属性に値が出力されます。'
|
30
|
+
|
31
|
+
@openbd_label_detail_image_height = 'isbn_detail使用時の書影の表示高'
|
32
|
+
@openbd_label_detail_image_height_desc =
|
33
|
+
'数値を指定すると書影を表すimg要素のheight属性に値が出力されます。'
|
34
|
+
|
35
|
+
# Local Variables:
|
36
|
+
# mode: ruby
|
37
|
+
# indent-tabs-mode: t
|
38
|
+
# tab-width: 3
|
39
|
+
# ruby-indent-level: 3
|
40
|
+
# End:
|
data/plugin/mm_footer.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
require 'nkf'
|
11
11
|
|
12
|
-
add_body_leave_proc
|
12
|
+
add_body_leave_proc do |date|
|
13
13
|
|
14
14
|
oldest_date = Time.local(2005, 1, 11)
|
15
15
|
if date > oldest_date
|
@@ -38,7 +38,7 @@ add_body_leave_proc(Proc.new do |date|
|
|
38
38
|
''
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
42
42
|
|
43
43
|
require "rss/rss"
|
44
44
|
|
data/plugin/my_hotentry.rb
CHANGED
@@ -39,7 +39,7 @@ class MyHotEntry
|
|
39
39
|
# RSSを取得
|
40
40
|
rss = nil
|
41
41
|
rss_url = 'http://b.hatena.ne.jp/entrylist?mode=rss&url='
|
42
|
-
rss_url <<
|
42
|
+
rss_url << CGI.escape(base_url)
|
43
43
|
rss_url << "&sort=#{options[:sort]}&threshold=#{options[:threshold]}"
|
44
44
|
begin
|
45
45
|
Timeout.timeout(5) do
|
data/plugin/notify_miniblog.rb
CHANGED
@@ -53,7 +53,7 @@ def notify_miniblog
|
|
53
53
|
|
54
54
|
# strip category
|
55
55
|
sectitle.gsub!(/\[[^\]]+\] */, '')
|
56
|
-
url =
|
56
|
+
url = CGI.escape(@conf.base_url + anchor("#{date}p%02d" % index))
|
57
57
|
prefix = @conf['miniblog.notify.prefix']
|
58
58
|
format = @conf['miniblog.notify.format']
|
59
59
|
source = 'tdiary/notify_miniblog.rb'
|
data/plugin/openbd.rb
ADDED
@@ -0,0 +1,306 @@
|
|
1
|
+
# openbd.rb
|
2
|
+
#
|
3
|
+
# Copyright (C) 2020 OGAWA KenIchi <kenichi@ice.email.ne.jp>
|
4
|
+
# You can redistribute it and/or modify it under GPL2 or any later version.
|
5
|
+
#
|
6
|
+
|
7
|
+
require "net/http"
|
8
|
+
require "json"
|
9
|
+
require "uri"
|
10
|
+
|
11
|
+
module OpenBD
|
12
|
+
class Item
|
13
|
+
attr_reader :isbn
|
14
|
+
|
15
|
+
def initialize(isbn, json)
|
16
|
+
@isbn = isbn
|
17
|
+
@data = JSON.parse(json)[0] || {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def normalized_isbn
|
21
|
+
nil_if_empty(@data.dig("summary", "isbn"))
|
22
|
+
end
|
23
|
+
|
24
|
+
def image_url
|
25
|
+
nil_if_empty(@data.dig("summary", "cover"))
|
26
|
+
end
|
27
|
+
|
28
|
+
def title
|
29
|
+
nil_if_empty(@data.dig("summary", "title"))
|
30
|
+
end
|
31
|
+
|
32
|
+
def author
|
33
|
+
nil_if_empty(@data.dig("summary", "author"))
|
34
|
+
end
|
35
|
+
|
36
|
+
def title_and_author
|
37
|
+
author ? "#{title}(#{author})" : title
|
38
|
+
end
|
39
|
+
|
40
|
+
def publisher
|
41
|
+
nil_if_empty(@data.dig("summary", "publisher"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def price
|
45
|
+
price = @data.dig("onix", "ProductSupply", "SupplyDetail", "Price", 0)
|
46
|
+
return nil unless price
|
47
|
+
value = price["PriceAmount"]
|
48
|
+
currency_code = price["CurrencyCode"]
|
49
|
+
case currency_code
|
50
|
+
when "JPY"
|
51
|
+
"#{value}円"
|
52
|
+
else
|
53
|
+
"#{currency_code} #{value}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private def nil_if_empty(s)
|
58
|
+
s&.empty? ? nil : s
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Cache
|
63
|
+
def initialize(cache_path)
|
64
|
+
@dir = File.join(cache_path, "openbd")
|
65
|
+
end
|
66
|
+
|
67
|
+
def load(isbn)
|
68
|
+
File.read(path_for(isbn))
|
69
|
+
rescue Errno::ENOENT
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def save(isbn, json)
|
74
|
+
Dir.mkdir(@dir) unless File.directory?(@dir)
|
75
|
+
File.write(path_for(isbn), json)
|
76
|
+
end
|
77
|
+
|
78
|
+
def clear
|
79
|
+
Dir.glob("#{@dir}/*").each { |f| File.delete(f) }
|
80
|
+
end
|
81
|
+
|
82
|
+
private def path_for(isbn)
|
83
|
+
File.join(@dir, "#{isbn}.json")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
module_function
|
88
|
+
|
89
|
+
def get_item(isbn, cache_path, mode)
|
90
|
+
cache = OpenBD::Cache.new(cache_path)
|
91
|
+
json = cache.load(isbn) if mode != "preview"
|
92
|
+
unless json
|
93
|
+
uri = URI("https://api.openbd.jp/v1/get?isbn=#{isbn}")
|
94
|
+
response = Net::HTTP.get_response(uri)
|
95
|
+
response.value # raise on errors
|
96
|
+
json = response.body
|
97
|
+
cache.save(isbn, json)
|
98
|
+
end
|
99
|
+
OpenBD::Item.new(isbn, json)
|
100
|
+
end
|
101
|
+
|
102
|
+
def reference_url(item)
|
103
|
+
isbn13 = item.normalized_isbn
|
104
|
+
if isbn13
|
105
|
+
"https://www.hanmoto.com/bd/isbn/#{isbn13}"
|
106
|
+
else
|
107
|
+
isbn = item.isbn.length == 13 ? isbn13to10(item.isbn) : item.isbn
|
108
|
+
"https://www.amazon.co.jp/dp/#{isbn}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def image_info(item, conf)
|
113
|
+
width = conf["openbd.image_width"]
|
114
|
+
height = conf["openbd.image_height"]
|
115
|
+
url = item.image_url || conf["openbd.default_image"]
|
116
|
+
if !url || url.empty?
|
117
|
+
url = <<~EOS
|
118
|
+
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAECAIAAADETxJQAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
|
119
|
+
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAXSURBVBhXYzx8+DADGDBBKCDAZDEwAABXngJR
|
120
|
+
1c/tyAAAAABJRU5ErkJggg==
|
121
|
+
EOS
|
122
|
+
url.rstrip!
|
123
|
+
width = 200 if !width && !height
|
124
|
+
end
|
125
|
+
{ url: url, width: width, height: height }
|
126
|
+
end
|
127
|
+
|
128
|
+
# from tdiary-core/lib/aws/pa_api.rb
|
129
|
+
def isbn13to10(isbn13)
|
130
|
+
sum, = isbn13[3, 9].split(//).map(&:to_i).reduce([0,10]){|s,d|[s[0] + d * s[1], s[1]-1]}
|
131
|
+
return isbn13[3, 9] + %w(0 1 2 3 4 5 6 7 8 9 X 0)[11 - sum % 11]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def openbd_image(item, label, css_class)
|
136
|
+
label ||= item.title_and_author || item.isbn
|
137
|
+
href = OpenBD.reference_url(item)
|
138
|
+
if @mode == "categoryview"
|
139
|
+
img = ""
|
140
|
+
else
|
141
|
+
alt = ""
|
142
|
+
if @conf["amazon.hidename"] || css_class != "amazon"
|
143
|
+
label, alt = alt, label
|
144
|
+
end
|
145
|
+
image = OpenBD.image_info(item, @conf)
|
146
|
+
width = image[:width]
|
147
|
+
height = image[:height]
|
148
|
+
img_width = width && %Q|width="#{h width}"|
|
149
|
+
img_height = height && %Q|height="#{h height}"|
|
150
|
+
img = <<~EOS
|
151
|
+
<img class="#{h css_class}"
|
152
|
+
src="#{h image[:url]}" #{img_width} #{img_height}
|
153
|
+
alt="#{h alt}">
|
154
|
+
EOS
|
155
|
+
end
|
156
|
+
%Q|<a href="#{h href}">#{img.rstrip}#{h label}</a>|
|
157
|
+
end
|
158
|
+
|
159
|
+
def openbd_process(isbn, &block)
|
160
|
+
isbn = isbn.to_s.strip.gsub("-", "")
|
161
|
+
block.call(OpenBD.get_item(isbn, @cache_path, @mode))
|
162
|
+
rescue => e
|
163
|
+
@logger.error "openbd.rb: isbn=#{isbn}, message=#{e.message}"
|
164
|
+
message = "[openBD plugin error]"
|
165
|
+
if @mode == "preview"
|
166
|
+
message << %Q|<span class="message">(#{h e.message})</span>|
|
167
|
+
end
|
168
|
+
message
|
169
|
+
end
|
170
|
+
|
171
|
+
def isbn_image(isbn, label = nil )
|
172
|
+
openbd_process(isbn) do |item|
|
173
|
+
openbd_image(item, label, "amazon")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def isbn_image_left(isbn, label = nil)
|
178
|
+
openbd_process(isbn) do |item|
|
179
|
+
openbd_image(item, label, "left")
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def isbn_image_right(isbn, label = nil)
|
184
|
+
openbd_process(isbn) do |item|
|
185
|
+
openbd_image(item, label, "right")
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def isbn(isbn, label = nil)
|
190
|
+
openbd_process(isbn) do |item|
|
191
|
+
label ||= item.title_and_author || item.isbn
|
192
|
+
%Q|<a href="#{h OpenBD.reference_url(item)}">#{h label}</a>|
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def isbn_detail(isbn)
|
197
|
+
openbd_process(isbn) do |item|
|
198
|
+
image = OpenBD.image_info(item, @conf)
|
199
|
+
width = @conf["openbd.detail_image_width"]
|
200
|
+
height = @conf["openbd.detail_image_height"]
|
201
|
+
width = 57 if !width && !height
|
202
|
+
img_width = width && %Q|width="#{h width}"|
|
203
|
+
img_height = height && %Q|height="#{h height}"|
|
204
|
+
url = OpenBD.reference_url(item)
|
205
|
+
<<-EOS
|
206
|
+
<a class="amazon-detail" href="#{h url}"><span class="amazon-detail">
|
207
|
+
<img class="amazon-detail left"
|
208
|
+
src="#{h image[:url]}" #{img_width} #{img_height} alt="">
|
209
|
+
<span class="amazon-detail-desc">
|
210
|
+
<span class="amazon-title">#{h item.title}</span><br>
|
211
|
+
<span class="amazon-author">#{h item.author || "-"}</span><br>
|
212
|
+
<span class="amazon-label">#{h item.publisher || "-"}</span><br>
|
213
|
+
<span class="amazon-price">#{h item.price || "-"}</span>
|
214
|
+
</span>
|
215
|
+
</span></a>
|
216
|
+
EOS
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
# for compatibility
|
221
|
+
alias isbnImgLeft isbn_image_left
|
222
|
+
alias isbnImgRight isbn_image_right
|
223
|
+
alias isbnImg isbn_image
|
224
|
+
alias amazon isbn_image
|
225
|
+
|
226
|
+
add_conf_proc("openbd", "openBD") do
|
227
|
+
if @mode == "saveconf" then
|
228
|
+
@conf["amazon.hidename"] = (@cgi.params["openbd.hidename"][0] == "true")
|
229
|
+
@conf["openbd.default_image"] = @cgi.params["openbd.default_image"][0]
|
230
|
+
|
231
|
+
to_px = lambda do |v|
|
232
|
+
i = v.to_i
|
233
|
+
i > 0 ? i : nil
|
234
|
+
end
|
235
|
+
@conf["openbd.image_width"] =
|
236
|
+
to_px[@cgi.params["openbd.image_width"][0]]
|
237
|
+
@conf["openbd.image_height"] =
|
238
|
+
to_px[@cgi.params["openbd.image_height"][0]]
|
239
|
+
@conf["openbd.detail_image_width"] =
|
240
|
+
to_px[@cgi.params["openbd.detail_image_width"][0]]
|
241
|
+
@conf["openbd.detail_image_height"] =
|
242
|
+
to_px[@cgi.params["openbd.detail_image_height"][0]]
|
243
|
+
|
244
|
+
if @cgi.params["openbd.clearcache"][0] == "true"
|
245
|
+
OpenBD::Cache.new(@cache_path).clear
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
hidename = @conf["amazon.hidename"]
|
250
|
+
<<-EOS
|
251
|
+
<h3>#{h @openbd_label_title}</h3>
|
252
|
+
<p><select name="openbd.hidename">
|
253
|
+
<option value="true"#{" selected" if hidename}>
|
254
|
+
#{h @openbd_label_title_hide}
|
255
|
+
</option>
|
256
|
+
<option value="false"#{" selected" unless hidename}>
|
257
|
+
#{h @openbd_label_title_show}
|
258
|
+
</option>
|
259
|
+
</select></p>
|
260
|
+
|
261
|
+
<h3>#{h @openbd_label_clearcache}</h3>
|
262
|
+
<p><label for="openbd.clearcache">
|
263
|
+
<input type="checkbox" id="openbd.clearcache" name="openbd.clearcache" value="true">
|
264
|
+
#{h @openbd_label_clearcache_desc}
|
265
|
+
</label></p>
|
266
|
+
|
267
|
+
<h3>#{h @openbd_label_default_image}</h3>
|
268
|
+
<p>#{h @openbd_label_default_image_desc}</p>
|
269
|
+
<p><input type="text" name="openbd.default_image" value="#{h @conf["openbd.default_image"]}" size="70"></p>
|
270
|
+
|
271
|
+
<h3>#{h @openbd_label_image_width}</h3>
|
272
|
+
<p>#{h @openbd_label_image_width_desc}</p>
|
273
|
+
<p>
|
274
|
+
<input type="text" name="openbd.image_width" value="#{h @conf["openbd.image_width"]}" size="5">
|
275
|
+
<label for="openbd.image_width">px</label>
|
276
|
+
</p>
|
277
|
+
|
278
|
+
<h3>#{h @openbd_label_image_height}</h3>
|
279
|
+
<p>#{h @openbd_label_image_height_desc}</p>
|
280
|
+
<p>
|
281
|
+
<input type="text" name="openbd.image_height" value="#{h @conf["openbd.image_height"]}" size="5">
|
282
|
+
<label for="openbd.image_height">px</label>
|
283
|
+
</p>
|
284
|
+
|
285
|
+
<h3>#{h @openbd_label_detail_image_width}</h3>
|
286
|
+
<p>#{h @openbd_label_detail_image_width_desc}</p>
|
287
|
+
<p>
|
288
|
+
<input type="text" name="openbd.detail_image_width" value="#{h @conf["openbd.detail_image_width"]}" size="5">
|
289
|
+
<label for="openbd.detail_image_width">px</label>
|
290
|
+
</p>
|
291
|
+
|
292
|
+
<h3>#{h @openbd_label_detail_image_height}</h3>
|
293
|
+
<p>#{h @openbd_label_detail_image_height_desc}</p>
|
294
|
+
<p>
|
295
|
+
<input type="text" name="openbd.detail_image_height" value="#{h @conf["openbd.detail_image_height"]}" size="5">
|
296
|
+
<label for="openbd.detail_image_height">px</label>
|
297
|
+
</p>
|
298
|
+
EOS
|
299
|
+
end
|
300
|
+
|
301
|
+
# Local Variables:
|
302
|
+
# mode: ruby
|
303
|
+
# indent-tabs-mode: t
|
304
|
+
# tab-width: 3
|
305
|
+
# ruby-indent-level: 3
|
306
|
+
# End:
|
data/plugin/puboo.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Original code from tatsu_zine.rb by KADO Masanori <kdmsnr@gmail.com>
|
4
4
|
# You can redistribute it and/or modify it under GPL.
|
5
5
|
#
|
6
|
-
# display book info in
|
6
|
+
# display book info in https://puboo.jp/ like amazon.rb
|
7
7
|
# USAGE: {{puboo 9999}}
|
8
8
|
|
9
9
|
require 'open-uri'
|
@@ -33,12 +33,12 @@ def puboo( id, doc = nil )
|
|
33
33
|
return result
|
34
34
|
end
|
35
35
|
|
36
|
-
link = "
|
37
|
-
doc ||= open( link ).read.force_encoding('UTF-8')
|
38
|
-
title = doc.match(%r|<meta property="og:title"\s*content="(.*)"|).to_a[1]
|
36
|
+
link = "https://puboo.jp/book/#{id}"
|
37
|
+
doc ||= URI.open( link ).read.force_encoding('UTF-8')
|
38
|
+
title = doc.match(%r|<meta property="og:title"\s*content="(.*)"|).to_a[1].split(/|/)[0]
|
39
39
|
image = doc.match(%r|<meta property="og:image"\s*content="(.*)"|).to_a[1]
|
40
|
-
price = doc.match(%r|<
|
41
|
-
author = doc.match(%r
|
40
|
+
price = doc.match(%r|<span\s*class="h2">(.*?)</span>|m).to_a[1]
|
41
|
+
author = doc.match(%r|著: <a.*?>(.*?)</a>|m).to_a[1]
|
42
42
|
|
43
43
|
result = <<-EOS
|
44
44
|
<a class="amazon-detail" href="#{h link}"><span class="amazon-detail">
|
@@ -61,7 +61,7 @@ end
|
|
61
61
|
|
62
62
|
if __FILE__ == $0
|
63
63
|
require 'test/unit'
|
64
|
-
class
|
64
|
+
class TestPuboo < Test::Unit::TestCase
|
65
65
|
def setup
|
66
66
|
@conf = Struct.new("Conf", :secure).new(true)
|
67
67
|
def h(str); str; end
|
@@ -69,14 +69,14 @@ if __FILE__ == $0
|
|
69
69
|
|
70
70
|
def test_puboo
|
71
71
|
expect = <<-EOS
|
72
|
-
<a class="amazon-detail" href="
|
73
|
-
<img class="amazon-detail left" src="
|
72
|
+
<a class="amazon-detail" href="https://puboo.jp/book/70667"><span class="amazon-detail">
|
73
|
+
<img class="amazon-detail left" src="https://img.puboo.jp/667BDD9E-B13E-11E2-82F3-6425FFDA975F_l.jpg"
|
74
74
|
height="150" width="100"
|
75
75
|
alt="入門Puppet - Automate Your Infrastructure">
|
76
76
|
<span class="amazon-detail-desc">
|
77
77
|
<span class="amazon-title">入門Puppet - Automate Your Infrastructure</span><br>
|
78
78
|
<span class="amazon-author">栗林健太郎</span><br>
|
79
|
-
<span class="amazon-price">890
|
79
|
+
<span class="amazon-price">890円</span>
|
80
80
|
</span><br style="clear: left">
|
81
81
|
</span></a>
|
82
82
|
EOS
|
data/plugin/socialbutton.rb
CHANGED
@@ -52,9 +52,9 @@ end
|
|
52
52
|
if @mode =~ /^(latest|day|month|nyear)$/
|
53
53
|
socialbutton_footer = Proc.new { %Q|<div class="socialbuttons"></div>| }
|
54
54
|
if respond_to?(:blogkit?) && blogkit?
|
55
|
-
add_body_leave_proc(socialbutton_footer)
|
55
|
+
add_body_leave_proc(&socialbutton_footer)
|
56
56
|
else
|
57
|
-
add_section_leave_proc(socialbutton_footer)
|
57
|
+
add_section_leave_proc(&socialbutton_footer)
|
58
58
|
end
|
59
59
|
|
60
60
|
# load javascript
|
data/plugin/tweet_quote.rb
CHANGED
@@ -29,7 +29,6 @@ end
|
|
29
29
|
|
30
30
|
def twitter_statuses_show_api( tweet_id )
|
31
31
|
url = "https://api.twitter.com/1.1/statuses/show.json"
|
32
|
-
unsafe = /[^a-zA-Z0-9\-\.\_\~]/
|
33
32
|
parameters = {
|
34
33
|
:id => tweet_id
|
35
34
|
}
|
@@ -41,11 +40,11 @@ def twitter_statuses_show_api( tweet_id )
|
|
41
40
|
:oauth_token => @conf["twitter_quote.oauth_token"],
|
42
41
|
:oauth_version => "1.0"
|
43
42
|
}
|
44
|
-
data = "GET&#{
|
45
|
-
data <<
|
43
|
+
data = "GET&#{CGI.escape( url )}&"
|
44
|
+
data << CGI.escape( oauth_parameters.merge( parameters ).sort.map{|k, v| "#{k}=#{v}" }.join( "&" ) )
|
46
45
|
oauth_parameters[:oauth_signature] = [OpenSSL::HMAC.digest(
|
47
46
|
OpenSSL::Digest::SHA1.new,
|
48
|
-
|
47
|
+
CGI.escape( "#{@conf["twitter_quote.oauth_consumer_secret"]}&#{@conf["twitter_quote.oauth_token_secret"]}" ),
|
49
48
|
data
|
50
49
|
)].pack( "m" ).chomp
|
51
50
|
|
@@ -53,7 +52,7 @@ def twitter_statuses_show_api( tweet_id )
|
|
53
52
|
proxy = 'http://' + proxy if proxy
|
54
53
|
|
55
54
|
headers = {
|
56
|
-
"Authorization" => %Q[OAuth #{oauth_parameters.map{|k ,v| "#{
|
55
|
+
"Authorization" => %Q[OAuth #{oauth_parameters.map{|k ,v| "#{CGI.escape( k.to_s )}=\"#{CGI.escape( v )}\""}.join( "," )}],
|
57
56
|
:proxy => proxy
|
58
57
|
}
|
59
58
|
Timeout.timeout( 20 ) do
|
data/plugin/twitter.rb
CHANGED
@@ -1,45 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'timeout'
|
6
|
-
require 'time'
|
7
|
-
require 'open-uri'
|
8
|
-
require 'rexml/document'
|
9
|
-
|
10
|
-
@twitter_statuses = []
|
11
|
-
|
12
|
-
if /^(latest|day)$/ =~ @mode then
|
13
|
-
add_header_proc do
|
14
|
-
xml = nil
|
15
|
-
Timeout.timeout( 5 ) do
|
16
|
-
begin
|
17
|
-
xml = open( "http://twitter.com/statuses/user_timeline/#{@conf['twitter.user']}.xml" ){|f| f.read}
|
18
|
-
rescue Exception
|
19
|
-
end
|
20
|
-
end
|
21
|
-
doc = REXML::Document.new( xml ).root if xml
|
22
|
-
if doc then
|
23
|
-
doc.elements.each( 'status' ) do |e|
|
24
|
-
@twitter_statuses << [@conf.to_native( e.elements['text'].text ), Time.parse( e.elements['created_at'].text ).localtime]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
''
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
1
|
+
#
|
2
|
+
# twitter plugin is deprecate
|
3
|
+
#
|
31
4
|
add_body_leave_proc do |date|
|
32
|
-
|
33
|
-
|
34
|
-
today_statuses << [t, d] if d.to_a[3,3] == date.to_a[3,3]
|
35
|
-
end
|
36
|
-
if !today_statuses.empty?
|
37
|
-
r = %Q[<div class="section">]
|
38
|
-
r << %Q[<h3><a href="http://twitter.com/#{@conf['twitter.user']}">Twitter statuses</a></h3>]
|
39
|
-
today_statuses.sort{|a, b| b.last<=>a.last}.each do |t, d|
|
40
|
-
r << %Q[<p><strong>#{CGI::escapeHTML( t )}</strong> (#{d.strftime( '%H:%M:%S' )})</p>]
|
41
|
-
end
|
42
|
-
r << %Q[</div>]
|
5
|
+
if @mode == 'preview'
|
6
|
+
%Q[<p class="message">twitter plugin was deprecated.</p>]
|
43
7
|
else
|
44
8
|
''
|
45
9
|
end
|
data/plugin/twitter_js.rb
CHANGED
@@ -1,59 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
|
5
|
-
if
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
result = <<-HTML
|
10
|
-
<script type="text/javascript"><!--
|
11
|
-
function twitter_cb(a){
|
12
|
-
var f=function(n){return (n<10?'0':'')+n};
|
13
|
-
for(var i=0,l=a.length;i<l;i++){
|
14
|
-
var d=new Date(a[i]['created_at'].replace('+0000','UTC'));
|
15
|
-
var id='twitter_statuses_'+f(d.getFullYear())+f(d.getMonth()+1)+f(d.getDate());
|
16
|
-
var e=document.getElementById(id);
|
17
|
-
if(!e) continue;
|
18
|
-
if(!e.innerHTML) e.innerHTML='<h3><a href="http://twitter.com/#{h twitter_user}">Twitter statuses</a></h3>';
|
19
|
-
e.innerHTML+='<p><strong>'+a[i]['text']+'</strong> ('+f(d.getHours())+':'+f(d.getMinutes())+':'+f(d.getSeconds())+')</p>';
|
20
|
-
}
|
21
|
-
}
|
22
|
-
function twitter_js(){
|
23
|
-
var e=document.createElement('script');
|
24
|
-
e.type='text/javascript';
|
25
|
-
e.src='http://twitter.com/statuses/user_timeline/#{h twitter_user}.json?callback=twitter_cb&count=20';
|
26
|
-
document.documentElement.appendChild(e);
|
27
|
-
}
|
28
|
-
if(window.addEventListener){
|
29
|
-
window.addEventListener('load',twitter_js,false);
|
30
|
-
}else if(window.attachEvent){
|
31
|
-
window.attachEvent('onload',twitter_js);
|
32
|
-
}else{
|
33
|
-
window.onload=twitter_js;
|
34
|
-
}
|
35
|
-
// --></script>
|
36
|
-
HTML
|
37
|
-
result.gsub( /^\t\t/, '' )
|
38
|
-
end
|
39
|
-
|
40
|
-
add_body_leave_proc do |date|
|
41
|
-
result = <<-HTML
|
42
|
-
<div id="twitter_statuses_#{date.strftime( "%Y%m%d" )}" class="section"></div>
|
43
|
-
HTML
|
44
|
-
result.gsub( /^\t\t/, '' )
|
45
|
-
end
|
1
|
+
#
|
2
|
+
# twitter_js plugin is deprecate
|
3
|
+
#
|
4
|
+
add_body_leave_proc do |date|
|
5
|
+
if @mode == 'preview'
|
6
|
+
%Q[<p class="message">twitter_js plugin was deprecated.</p>]
|
7
|
+
else
|
8
|
+
''
|
46
9
|
end
|
47
10
|
end
|
48
|
-
|
49
|
-
add_conf_proc( 'twitter_js', 'Twitter' ) do
|
50
|
-
|
51
|
-
if @mode == 'saveconf' then
|
52
|
-
@conf['twitter.user'] = @cgi.params['twitter.user'][0]
|
53
|
-
end
|
54
|
-
|
55
|
-
<<-HTML
|
56
|
-
<h3 class="subtitle">Account Name</h3>
|
57
|
-
<p><input name="twitter.user" value="#{h @conf['twitter.user']}"></p>
|
58
|
-
HTML
|
59
|
-
end
|
data/plugin/yahoo_kousei.rb
CHANGED
@@ -26,7 +26,7 @@ Net::HTTP.version_1_2
|
|
26
26
|
def kousei_api( sentence )
|
27
27
|
appid = @conf['yahoo_kousei.appid']
|
28
28
|
|
29
|
-
query = "appid=#{appid}&sentence=#{
|
29
|
+
query = "appid=#{appid}&sentence=#{CGI.escape( sentence.gsub( /\n/, '' ) )}"
|
30
30
|
query << "&filter_group=" + @conf['yahoo_kousei.filter_group'] if @conf['yahoo_kousei.filter_group']
|
31
31
|
query << "&no_filter=" + @conf['yahoo_kousei.no_filter'] if @conf['yahoo_kousei.no_filter']
|
32
32
|
|
data/plugin/yo_update.rb
CHANGED
@@ -100,7 +100,7 @@ def yo_update_subscribers_count
|
|
100
100
|
raise YoUpdateError, "Yo API Key is not set"
|
101
101
|
end
|
102
102
|
req = Net::HTTP::Get.new(
|
103
|
-
URI("http://api.justyo.co/subscribers_count/?api_token=#{
|
103
|
+
URI("http://api.justyo.co/subscribers_count/?api_token=#{CGI.escape(api_key)}")
|
104
104
|
)
|
105
105
|
res = yo_update_access_api(req)
|
106
106
|
data = res.body
|
data/spec/spec_helper.rb
CHANGED
@@ -49,19 +49,19 @@ class PluginFake
|
|
49
49
|
@conf_procs << block
|
50
50
|
end
|
51
51
|
|
52
|
-
def add_edit_proc(
|
52
|
+
def add_edit_proc(&block)
|
53
53
|
@edit_procs << block
|
54
54
|
end
|
55
55
|
|
56
|
-
def add_header_proc(
|
56
|
+
def add_header_proc(&block)
|
57
57
|
@header_procs << block
|
58
58
|
end
|
59
59
|
|
60
|
-
def add_footer_proc(
|
60
|
+
def add_footer_proc(&block)
|
61
61
|
@footer_procs << block
|
62
62
|
end
|
63
63
|
|
64
|
-
def add_update_proc(
|
64
|
+
def add_update_proc(&block)
|
65
65
|
@update_procs << block
|
66
66
|
end
|
67
67
|
|
@@ -89,7 +89,7 @@ class PluginFake
|
|
89
89
|
r.join.chomp
|
90
90
|
end
|
91
91
|
|
92
|
-
def add_body_enter_proc(
|
92
|
+
def add_body_enter_proc(&block)
|
93
93
|
@body_enter_procs << block
|
94
94
|
end
|
95
95
|
|
@@ -101,7 +101,7 @@ class PluginFake
|
|
101
101
|
r.join.chomp
|
102
102
|
end
|
103
103
|
|
104
|
-
def add_body_leave_proc(
|
104
|
+
def add_body_leave_proc(&block)
|
105
105
|
@body_leave_procs << block
|
106
106
|
end
|
107
107
|
|
@@ -200,7 +200,7 @@ def fake_plugin( name_sym, cgi=nil, base=nil, &block )
|
|
200
200
|
plugin.instance_variable_set(:@cache_path, @cache_path)
|
201
201
|
|
202
202
|
plugin.instance_eval do
|
203
|
-
eval( File.
|
203
|
+
eval( File.open(file_path, 'r:utf-8').read, binding,
|
204
204
|
"(#{File.basename(file_path)})", 1 )
|
205
205
|
end
|
206
206
|
plugin_sym = plugin_name.to_sym
|
data/style/hatena_style.rb
CHANGED
@@ -844,7 +844,7 @@ class Hatena::Google
|
|
844
844
|
end
|
845
845
|
|
846
846
|
def convert(mode)
|
847
|
-
uri = 'http://www.google.com/search?q=%s&ie=euc-jp&oe=euc-jp' %
|
847
|
+
uri = 'http://www.google.com/search?q=%s&ie=euc-jp&oe=euc-jp' % CGI.escape(@str)
|
848
848
|
return uri unless @tag_p
|
849
849
|
template=nil
|
850
850
|
if mode == :CHTML
|
@@ -889,7 +889,7 @@ class Hatena::Keyword
|
|
889
889
|
end
|
890
890
|
|
891
891
|
def convert(mode)
|
892
|
-
uri = '%skeyword/%s' % [@group,
|
892
|
+
uri = '%skeyword/%s' % [@group, CGI.escape(@str)]
|
893
893
|
return uri unless @tag_p
|
894
894
|
template=nil
|
895
895
|
if mode == :CHTML
|
@@ -958,7 +958,7 @@ class Hatena::AmazonSearch
|
|
958
958
|
end
|
959
959
|
|
960
960
|
def convert(mode)
|
961
|
-
uri = 'http://www.amazon.co.jp/exec/obidos/external-search?mode=blended&tag=%s&encoding-string-jp=%%c6%%fc%%cb%%dc%%b8%%ec&keyword=%s' % [Hatena.conf['amazon.aid'] || '',
|
961
|
+
uri = 'http://www.amazon.co.jp/exec/obidos/external-search?mode=blended&tag=%s&encoding-string-jp=%%c6%%fc%%cb%%dc%%b8%%ec&keyword=%s' % [Hatena.conf['amazon.aid'] || '', CGI.escape(@str)]
|
962
962
|
return uri unless @tag_p
|
963
963
|
template=nil
|
964
964
|
if mode == :CHTML
|
@@ -259,10 +259,10 @@ end
|
|
259
259
|
# Callback Functions
|
260
260
|
|
261
261
|
# this is for view_exif().
|
262
|
-
add_body_enter_proc
|
262
|
+
add_body_enter_proc do |date|
|
263
263
|
@image_date_exif = date.strftime("%Y%m%d")
|
264
264
|
""
|
265
|
-
end
|
265
|
+
end
|
266
266
|
|
267
267
|
# Update Proc of the plugin
|
268
268
|
add_update_proc do
|
data/util/tdiary-grep/grep.rb
CHANGED
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.
|
4
|
+
version: 5.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tDiary contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tdiary
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coderay
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +129,21 @@ dependencies:
|
|
115
129
|
- !ruby/object:Gem::Version
|
116
130
|
version: '0'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
132
|
+
name: ruby-debug-ide
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: debase
|
119
147
|
requirement: !ruby/object:Gem::Requirement
|
120
148
|
requirements:
|
121
149
|
- - ">="
|
@@ -194,6 +222,7 @@ files:
|
|
194
222
|
- js/editor.js
|
195
223
|
- js/flickr.js
|
196
224
|
- js/google_photos.js
|
225
|
+
- js/gyazo.js
|
197
226
|
- js/hide_sidebar_smartphone.js
|
198
227
|
- js/image_ex.js
|
199
228
|
- js/jquery.socialbutton.js
|
@@ -268,6 +297,7 @@ files:
|
|
268
297
|
- plugin/google_sitemaps.rb
|
269
298
|
- plugin/google_universal_analytics.rb
|
270
299
|
- plugin/google_webmaster.rb
|
300
|
+
- plugin/gyazo.rb
|
271
301
|
- plugin/hatena_bookmark_nocomment.rb
|
272
302
|
- plugin/hatena_star.rb
|
273
303
|
- plugin/hb_footer.rb
|
@@ -290,6 +320,7 @@ files:
|
|
290
320
|
- plugin/ja/livedoor_weather.rb
|
291
321
|
- plugin/ja/microsummary.rb
|
292
322
|
- plugin/ja/nicovideo.rb
|
323
|
+
- plugin/ja/openbd.rb
|
293
324
|
- plugin/ja/openid.rb
|
294
325
|
- plugin/ja/section_footer.rb
|
295
326
|
- plugin/ja/section_footer2.rb
|
@@ -319,6 +350,7 @@ files:
|
|
319
350
|
- plugin/notify_miniblog.rb
|
320
351
|
- plugin/ogp.rb
|
321
352
|
- plugin/ohmsha_estore.rb
|
353
|
+
- plugin/openbd.rb
|
322
354
|
- plugin/openid.rb
|
323
355
|
- plugin/opensearch_ad.rb
|
324
356
|
- plugin/picasa.rb
|
@@ -401,7 +433,6 @@ files:
|
|
401
433
|
- spec/rcov.opts
|
402
434
|
- spec/spec_helper.rb
|
403
435
|
- spec/title_anchor_spec.rb
|
404
|
-
- spec/twitter_js_spec.rb
|
405
436
|
- spec/youtube_spec.rb
|
406
437
|
- style/hatena_style.rb
|
407
438
|
- style/markdown_style.rb
|
@@ -513,7 +544,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
513
544
|
- !ruby/object:Gem::Version
|
514
545
|
version: '0'
|
515
546
|
requirements: []
|
516
|
-
rubygems_version: 3.
|
547
|
+
rubygems_version: 3.1.4
|
517
548
|
signing_key:
|
518
549
|
specification_version: 4
|
519
550
|
summary: tDiary contributions package
|
@@ -541,5 +572,4 @@ test_files:
|
|
541
572
|
- spec/rcov.opts
|
542
573
|
- spec/spec_helper.rb
|
543
574
|
- spec/title_anchor_spec.rb
|
544
|
-
- spec/twitter_js_spec.rb
|
545
575
|
- spec/youtube_spec.rb
|
data/spec/twitter_js_spec.rb
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__))
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'time'
|
4
|
-
|
5
|
-
describe "twitter_js plugin" do
|
6
|
-
def setup_twitter_js_plugin(mode, user_id)
|
7
|
-
fake_plugin(:twitter_js) { |plugin|
|
8
|
-
plugin.mode = mode
|
9
|
-
plugin.conf['twitter.user'] = user_id
|
10
|
-
plugin.date = Time.parse("20080124")
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "should render javascript and div tag in day" do
|
15
|
-
before do
|
16
|
-
@plugin = setup_twitter_js_plugin("day", "123456789")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "for header" do
|
20
|
-
snippet = @plugin.header_proc
|
21
|
-
expect(snippet).to eq(expected_html_header_snippet("123456789"))
|
22
|
-
end
|
23
|
-
|
24
|
-
it "for body leave" do
|
25
|
-
snippet = @plugin.body_leave_proc(Time.parse("20080124"))
|
26
|
-
expect(snippet).to eq(expected_html_body_snippet)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "should render javascript and div tag in latest" do
|
31
|
-
before do
|
32
|
-
@plugin = setup_twitter_js_plugin("latest", "123456789")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "for header" do
|
36
|
-
snippet = @plugin.header_proc
|
37
|
-
expect(snippet).to eq(expected_html_header_snippet("123456789"))
|
38
|
-
end
|
39
|
-
|
40
|
-
it "for body leave" do
|
41
|
-
snippet = @plugin.body_leave_proc(Time.parse("20080124"))
|
42
|
-
expect(snippet).to eq(expected_html_body_snippet)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "should not render in edit" do
|
47
|
-
before do
|
48
|
-
@plugin = setup_twitter_js_plugin("edit", "123456789")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "for header" do
|
52
|
-
snippet = @plugin.header_proc
|
53
|
-
expect(snippet).to be_empty
|
54
|
-
end
|
55
|
-
|
56
|
-
it "for body leave" do
|
57
|
-
snippet = @plugin.body_leave_proc(Time.parse("20080124"))
|
58
|
-
expect(snippet).to be_empty
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "should not render when user_id is empty" do
|
63
|
-
before do
|
64
|
-
@plugin = setup_twitter_js_plugin("edit", "")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "for header" do
|
68
|
-
snippet = @plugin.header_proc
|
69
|
-
expect(snippet).to be_empty
|
70
|
-
end
|
71
|
-
|
72
|
-
it "for body leave" do
|
73
|
-
snippet = @plugin.body_leave_proc(Time.parse("20080124"))
|
74
|
-
expect(snippet).to be_empty
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def expected_html_header_snippet(user_id)
|
79
|
-
expected = <<-EXPECTED
|
80
|
-
<script type="text/javascript"><!--
|
81
|
-
function twitter_cb(a){
|
82
|
-
var f=function(n){return (n<10?'0':'')+n};
|
83
|
-
for(var i=0,l=a.length;i<l;i++){
|
84
|
-
var d=new Date(a[i]['created_at'].replace('+0000','UTC'));
|
85
|
-
var id='twitter_statuses_'+f(d.getFullYear())+f(d.getMonth()+1)+f(d.getDate());
|
86
|
-
var e=document.getElementById(id);
|
87
|
-
if(!e) continue;
|
88
|
-
if(!e.innerHTML) e.innerHTML='<h3><a href="http://twitter.com/#{user_id}">Twitter statuses</a></h3>';
|
89
|
-
e.innerHTML+='<p><strong>'+a[i]['text']+'</strong> ('+f(d.getHours())+':'+f(d.getMinutes())+':'+f(d.getSeconds())+')</p>';
|
90
|
-
}
|
91
|
-
}
|
92
|
-
function twitter_js(){
|
93
|
-
var e=document.createElement('script');
|
94
|
-
e.type='text/javascript';
|
95
|
-
e.src='http://twitter.com/statuses/user_timeline/#{user_id}.json?callback=twitter_cb&count=20';
|
96
|
-
document.documentElement.appendChild(e);
|
97
|
-
}
|
98
|
-
if(window.addEventListener){
|
99
|
-
window.addEventListener('load',twitter_js,false);
|
100
|
-
}else if(window.attachEvent){
|
101
|
-
window.attachEvent('onload',twitter_js);
|
102
|
-
}else{
|
103
|
-
window.onload=twitter_js;
|
104
|
-
}
|
105
|
-
// --></script>
|
106
|
-
EXPECTED
|
107
|
-
expected.gsub(/^\t/, '').chomp
|
108
|
-
end
|
109
|
-
|
110
|
-
def expected_html_body_snippet
|
111
|
-
expected = <<-HTML
|
112
|
-
<div id="twitter_statuses_20080124" class="section"></div>
|
113
|
-
HTML
|
114
|
-
expected.gsub( /^\t/, '' ).chomp
|
115
|
-
end
|
116
|
-
end
|