tdiary-contrib 5.0.4 → 5.0.5
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/appstore.js +1 -1
- data/js/google_photos.js +63 -0
- data/js/image_ex.js +2 -2
- data/js/jquery.socialbutton.js +1 -1
- data/js/show_and_hide.js +1 -1
- data/js/socialbutton.js +3 -3
- data/lib/tdiary/contrib/version.rb +1 -1
- data/plugin/en/profile.rb +13 -0
- data/plugin/google_photos.rb +67 -0
- data/plugin/mathjax.rb +10 -3
- data/plugin/nicovideo.rb +4 -2
- data/plugin/ogp.rb +17 -14
- data/plugin/prettify.rb +11 -5
- data/plugin/profile.rb +2 -1
- data/plugin/puboo.rb +2 -2
- data/plugin/tatsu_zine.rb +6 -5
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d47b569ca7f9fe177f670b8e60ba493b80831ce
|
4
|
+
data.tar.gz: 1575e8d48b554035e7d7d806eefaa8c64fcf909f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41cd6a1edd86c27e2e6412fc6a737f1759da17be066d82df9b4e97b382fbda663544fd939b2c98aaa6d30ddfcb2bb883c420d81adb7284dcc404b26d69cd8d78
|
7
|
+
data.tar.gz: 759786b536e9c10d7cd495de44bb90d80f34a6923199765019ded3f689ff46eeeff983ae60f52e7dbdd6eb0fd9c3a6a95f2a44529e937ae8807b796299e273bb
|
data/js/appstore.js
CHANGED
data/js/google_photos.js
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
$(function() {
|
2
|
+
var developerKey = $tDiary.plugin.google_photos.api_key;
|
3
|
+
var clientId = $tDiary.plugin.google_photos.client_id;
|
4
|
+
var oauthToken;
|
5
|
+
|
6
|
+
if (!developerKey || !clientId) {
|
7
|
+
$('#google_photos').after($('<p>設定画面でAPIキーとクライアントIDを登録してください</p>'));
|
8
|
+
return false;
|
9
|
+
}
|
10
|
+
|
11
|
+
gapi.load('auth',
|
12
|
+
{ callback: function() { console.debug('load auth function') } });
|
13
|
+
gapi.load('picker',
|
14
|
+
{ callback: function() { console.debug('load picker function') } });
|
15
|
+
|
16
|
+
$('#google_photos').click(function() {
|
17
|
+
if (oauthToken) {
|
18
|
+
createPicker();
|
19
|
+
} else {
|
20
|
+
authentication();
|
21
|
+
}
|
22
|
+
});
|
23
|
+
|
24
|
+
function authentication() {
|
25
|
+
window.gapi.auth.authorize(
|
26
|
+
{
|
27
|
+
'client_id': clientId,
|
28
|
+
'scope': ['https://www.googleapis.com/auth/photos'],
|
29
|
+
'immediate': false
|
30
|
+
},
|
31
|
+
function(authResult) {
|
32
|
+
if (!authResult || authResult.error) {
|
33
|
+
console.error('[google_photos] authentication faild');
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
oauthToken = authResult.access_token;
|
37
|
+
createPicker();
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
function createPicker() {
|
42
|
+
var picker = new google.picker.PickerBuilder()
|
43
|
+
.addView(new google.picker.PhotosView()
|
44
|
+
.setType(google.picker.PhotosView.Type.UPLOADED))
|
45
|
+
.addView(google.picker.ViewId.PHOTOS)
|
46
|
+
.addView(google.picker.ViewId.PHOTO_UPLOAD)
|
47
|
+
.setOAuthToken(oauthToken)
|
48
|
+
.setDeveloperKey(developerKey)
|
49
|
+
.setLocale('ja')
|
50
|
+
.setCallback(pickerCallback)
|
51
|
+
.build();
|
52
|
+
picker.setVisible(true);
|
53
|
+
}
|
54
|
+
|
55
|
+
function pickerCallback(data) {
|
56
|
+
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
|
57
|
+
var doc = data[google.picker.Response.DOCUMENTS][0];
|
58
|
+
var image = doc.thumbnails[doc.thumbnails.length - 1];
|
59
|
+
var tag = $.makePluginTag("google_photos '" + image.url + "', '" + image.width + "', '" + image.height + "'");
|
60
|
+
$('#body').insertAtCaret(tag);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
});
|
data/js/image_ex.js
CHANGED
@@ -64,13 +64,13 @@ $(function() {
|
|
64
64
|
|
65
65
|
if ($(window).width() <= 360) {
|
66
66
|
$(document).ready(function() {
|
67
|
-
$("img.image-ex").
|
67
|
+
$("img.image-ex").on("load", function() {
|
68
68
|
resizeImage(this);
|
69
69
|
});
|
70
70
|
});
|
71
71
|
|
72
72
|
// for when images have been cached
|
73
|
-
$(window).
|
73
|
+
$(window).on("load", function() {
|
74
74
|
$("img.image-ex").each(function() {
|
75
75
|
resizeImage(this);
|
76
76
|
});
|
data/js/jquery.socialbutton.js
CHANGED
data/js/show_and_hide.js
CHANGED
data/js/socialbutton.js
CHANGED
@@ -92,7 +92,7 @@ $(function() {
|
|
92
92
|
return bottom > $(this).offset().top;
|
93
93
|
})
|
94
94
|
.filter(function() {
|
95
|
-
return $(this).find('.socialbutton').
|
95
|
+
return $(this).find('.socialbutton').length == 0
|
96
96
|
})
|
97
97
|
.each(function() {
|
98
98
|
var anchor = $(this).find('h3 a');
|
@@ -100,7 +100,7 @@ $(function() {
|
|
100
100
|
var link = $(this).children('h2').find('a:first').get(0);
|
101
101
|
var url = link ? link.href : document.URL;
|
102
102
|
var title = $(this).children('h2').find('.title').text();
|
103
|
-
} else if (anchor.
|
103
|
+
} else if (anchor.length == 0) {
|
104
104
|
// The section may not have an anchor on etdiary style.
|
105
105
|
// https://github.com/tdiary/tdiary-contrib/issues/59
|
106
106
|
var url = ($(this).parents('.day').find('h2 a:first').get(0)||'').href;
|
@@ -129,7 +129,7 @@ $(function() {
|
|
129
129
|
});
|
130
130
|
}
|
131
131
|
|
132
|
-
$(window).
|
132
|
+
$(window).on('scroll', function(event) {
|
133
133
|
socialbutton(document);
|
134
134
|
});
|
135
135
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#
|
2
|
+
# profile.rb: english resource of profile plugin for tDiary
|
3
|
+
#
|
4
|
+
# Copyright (C) 2017 by Tada, Tadashi <t@tdtds.jp>
|
5
|
+
# Distributed under the GPL.
|
6
|
+
#
|
7
|
+
module ::Profile
|
8
|
+
module Service
|
9
|
+
class Gravatar < Base
|
10
|
+
HOST = 'en.gravatar.com'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# show Google Photos
|
3
|
+
#
|
4
|
+
# Copyright (c) MATSUOKA Kohei <http://www.machu.jp/>
|
5
|
+
# Distributed under the GPL
|
6
|
+
#
|
7
|
+
|
8
|
+
def google_photos(src, width, height, alt="photo", place="photo")
|
9
|
+
%Q|<img title="#{alt}" width="#{width}" height="#{height}" alt="#{alt}" src="#{src}" class="#{place} google">|
|
10
|
+
end
|
11
|
+
|
12
|
+
def google_photos_left(src, width, height, alt="photo")
|
13
|
+
google_photos(src, width, height, alt, 'left')
|
14
|
+
end
|
15
|
+
|
16
|
+
def google_photos_right(src, width, height, alt="photo")
|
17
|
+
google_photos(src, width, height, alt, 'right')
|
18
|
+
end
|
19
|
+
|
20
|
+
if /\A(form|edit|preview|showcomment)\z/ === @mode then
|
21
|
+
enable_js('google_photos.js')
|
22
|
+
add_js_setting('$tDiary.plugin.google_photos')
|
23
|
+
add_js_setting('$tDiary.plugin.google_photos.api_key', @conf['google_photos.api_key'].to_json)
|
24
|
+
add_js_setting('$tDiary.plugin.google_photos.client_id', @conf['google_photos.client_id'].to_json)
|
25
|
+
|
26
|
+
add_footer_proc do
|
27
|
+
'<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
add_edit_proc do |date|
|
32
|
+
<<-FORM
|
33
|
+
<div class="google_photos">
|
34
|
+
<input id="google_photos" type="button" value="Googleフォト"></input>
|
35
|
+
</div>
|
36
|
+
FORM
|
37
|
+
end
|
38
|
+
|
39
|
+
add_conf_proc('google_photos', 'Googleフォト') do
|
40
|
+
if @mode == 'saveconf'
|
41
|
+
@conf['google_photos.api_key'] = @cgi.params['google_photos.api_key'][0]
|
42
|
+
@conf['google_photos.client_id'] = @cgi.params['google_photos.client_id'][0]
|
43
|
+
end
|
44
|
+
|
45
|
+
r = <<-_HTML
|
46
|
+
<h3>概要</h3>
|
47
|
+
<p>Googleフォトの写真を日記に表示します。</p>
|
48
|
+
<h3>機能</h3>
|
49
|
+
<ul>
|
50
|
+
<li>Googleフォトの写真を選択して日記に貼り付ける</li>
|
51
|
+
<li>PC上の写真をGoogleフォトへアップロードする</li>
|
52
|
+
</ul>
|
53
|
+
<h3>制約事項</h3>
|
54
|
+
<ul>
|
55
|
+
<li>サムネイルを使用しているため、サイズが512pxまでしか表示できません</li>
|
56
|
+
</ul>
|
57
|
+
<h3>使い方</h3>
|
58
|
+
<p>
|
59
|
+
このプラグインを使うためには、Google Developers ConsoleからAPIキーと認証用クライアントIDを取得する必要があります。
|
60
|
+
手順は<a href="https://www.evernote.com/shard/s18/sh/7211b9c3-fb75-4af8-aa55-718ff6c81aac/77c3a51871f0f245">Googleフォトプラグインを利用するためのAPIキーとクライアントIDの取得手順</a>を参考にしてください。
|
61
|
+
</p>
|
62
|
+
<h3>APIキー</h3>
|
63
|
+
<p><input type="text" name="google_photos.api_key" size="100" value="#{@conf['google_photos.api_key']}"></p>
|
64
|
+
<h3>認証用クライアントID</h3>
|
65
|
+
<p><input type="text" name="google_photos.client_id" size="100" value="#{@conf['google_photos.client_id']}"></p>
|
66
|
+
_HTML
|
67
|
+
end
|
data/plugin/mathjax.rb
CHANGED
@@ -10,14 +10,21 @@
|
|
10
10
|
# Copyright (C) 2014 by Yuh Ohmura <http://yutopia.pussycat.jp/diary/>
|
11
11
|
#
|
12
12
|
=begin ChangeLog
|
13
|
+
2017-06-05 Yuh Ohmura
|
14
|
+
* Modity MathJax address.
|
13
15
|
2014-12-17 Yuh Ohmura
|
14
16
|
* created.
|
15
17
|
=end
|
16
18
|
add_header_proc do
|
17
19
|
'<script type="text/x-mathjax-config">
|
18
|
-
MathJax.Hub.Config({
|
20
|
+
MathJax.Hub.Config({
|
21
|
+
tex2jax: {
|
22
|
+
inlineMath: [[\'$\',\'$\'], ["\\\\(","\\\\)"]],
|
23
|
+
processEscapes: true
|
24
|
+
}
|
25
|
+
}
|
26
|
+
);
|
19
27
|
</script>
|
20
|
-
<script
|
21
|
-
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
28
|
+
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML">
|
22
29
|
</script>'
|
23
30
|
end
|
data/plugin/nicovideo.rb
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
require 'net/http'
|
24
24
|
require 'timeout'
|
25
25
|
|
26
|
-
enable_js(
|
26
|
+
enable_js('nicovideo.js') unless base_url =~ /\Ahttps:/
|
27
27
|
|
28
28
|
def nicovideo_call_api( video_id )
|
29
29
|
uri = "http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}"
|
@@ -76,6 +76,8 @@ end
|
|
76
76
|
def nicovideo_player( video_id, size = [544,384] )
|
77
77
|
if feed?
|
78
78
|
nicovideo( video_id )
|
79
|
+
elsif base_url =~ /\Ahttps:/
|
80
|
+
nicovideo(video_id)
|
79
81
|
else
|
80
82
|
q = ''
|
81
83
|
if size then
|
@@ -97,7 +99,7 @@ def nicovideo( video_id, label = nil, link = nil )
|
|
97
99
|
if feed?
|
98
100
|
r.gsub!( /<a(?:[ \t\n\r][^>]*)?>/, '' )
|
99
101
|
r.gsub!( %r{</a[ \t\n\r]*>}, '' )
|
100
|
-
|
102
|
+
elsif base_url !~ /\Ahttps:/
|
101
103
|
r << %Q|<div id="player-#{video_id}" style="display:none;background-color:#000;margin-left:2em;padding-bottom:4px;">|
|
102
104
|
r << %Q|<a name="player-#{video_id}">|
|
103
105
|
r << nicovideo_player( video_id, [544,384] )
|
data/plugin/ogp.rb
CHANGED
@@ -20,34 +20,37 @@ def ogp_image(html)
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
if defined? :ogp_tag && !defined? :ogp_tag_org
|
24
|
+
alias :ogp_tag_org :ogp_tag
|
25
|
+
end
|
26
|
+
|
27
|
+
def ogp_tag
|
28
|
+
ogp = ogp_tag_org || ''
|
24
29
|
headers = {
|
25
|
-
'og:title' => title_tag.match(/>([^<]+)</).to_a[1],
|
26
|
-
'og:site_name' => @conf.html_title,
|
27
|
-
'og:author' => @conf.author_name,
|
28
30
|
'fb:app_id' => @conf['ogp.facebook.app_id'],
|
29
31
|
'fb:admins' => @conf['ogp.facebook.admins']
|
30
32
|
}
|
31
33
|
|
32
34
|
if @mode == 'day'
|
35
|
+
# remove original og:image generated at 00default.rb
|
36
|
+
ogp.gsub!(/<meta property="og:image"[^>]+>\n/, '')
|
37
|
+
|
33
38
|
diary = @diaries[@date.strftime('%Y%m%d')]
|
34
39
|
if diary
|
35
40
|
sections = diary.instance_variable_get(:@sections)
|
36
41
|
section_index = @cgi.params['p'][0] || sections.size
|
37
|
-
|
38
|
-
|
42
|
+
begin
|
43
|
+
section = sections[section_index.to_i - 1].body_to_html
|
44
|
+
section_html = apply_plugin(section)
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
headers['og:description'] = ogp_description(section_html)
|
47
|
+
headers['og:image'] = ogp_image(section_html)
|
48
|
+
rescue
|
49
|
+
end
|
43
50
|
end
|
44
|
-
else
|
45
|
-
headers['og:description'] = @conf.description
|
46
|
-
headers['og:image'] = @conf.banner
|
47
|
-
headers['og:type'] = 'website'
|
48
51
|
end
|
49
52
|
|
50
|
-
headers.select {|key, val|
|
53
|
+
ogp + "\n" + headers.select {|key, val|
|
51
54
|
val && !val.empty?
|
52
55
|
}.map {|key, val|
|
53
56
|
%Q|<meta property="#{key}" content="#{CGI::escapeHTML(val)}">|
|
data/plugin/prettify.rb
CHANGED
@@ -3,15 +3,21 @@
|
|
3
3
|
if /\A(?:latest|day|month|nyear)\z/ =~ @mode then
|
4
4
|
add_header_proc do
|
5
5
|
<<-HTML
|
6
|
-
<
|
7
|
-
<script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
|
6
|
+
<script type="text/javascript" src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
|
8
7
|
<script type="text/javascript"><!--
|
8
|
+
var initPrettyPrint = function() {
|
9
|
+
var pres = document.querySelectorAll("div.body > div.section > pre");
|
10
|
+
Array.prototype.slice.call(pres).forEach(function(pre) {
|
11
|
+
pre.setAttribute("class", "prettyprint");
|
12
|
+
});
|
13
|
+
PR.prettyPrint();
|
14
|
+
};
|
9
15
|
if(window.addEventListener){
|
10
|
-
window.addEventListener("load",
|
16
|
+
window.addEventListener("load", initPrettyPrint, false);
|
11
17
|
}else if(window.attachEvent){
|
12
|
-
window.attachEvent("onload",
|
18
|
+
window.attachEvent("onload", initPrettyPrint);
|
13
19
|
}else{
|
14
|
-
window.onload=
|
20
|
+
window.onload=initPrettyPrint;
|
15
21
|
}
|
16
22
|
// --></script>
|
17
23
|
HTML
|
data/plugin/profile.rb
CHANGED
@@ -113,9 +113,10 @@ module ::Profile
|
|
113
113
|
|
114
114
|
# gravatar.com
|
115
115
|
class Gravatar < Base
|
116
|
+
HOST = 'ja.gravatar.com' unless const_defined?(:HOST)
|
116
117
|
endpoint {|id|
|
117
118
|
hash = Digest::MD5.hexdigest(id.downcase)
|
118
|
-
"https
|
119
|
+
"https://#{HOST}/#{hash}.json"
|
119
120
|
}
|
120
121
|
|
121
122
|
def image
|
data/plugin/puboo.rb
CHANGED
@@ -34,7 +34,7 @@ def puboo( id, doc = nil )
|
|
34
34
|
end
|
35
35
|
|
36
36
|
link = "http://p.booklog.jp/book/#{id}"
|
37
|
-
doc ||= open( link ).read
|
37
|
+
doc ||= open( link ).read.force_encoding('UTF-8')
|
38
38
|
title = doc.match(%r|<meta property="og:title"\s*content="(.*)"|).to_a[1]
|
39
39
|
image = doc.match(%r|<meta property="og:image"\s*content="(.*)"|).to_a[1]
|
40
40
|
price = doc.match(%r|<th class="th_2">価格</th>.*?<span>(.*?)</span>.*?<br />|m).to_a[1]
|
@@ -55,7 +55,7 @@ EOS
|
|
55
55
|
|
56
56
|
puboo_cache_set( id, result ) unless @conf.secure
|
57
57
|
result
|
58
|
-
rescue
|
58
|
+
rescue
|
59
59
|
link
|
60
60
|
end
|
61
61
|
|
data/plugin/tatsu_zine.rb
CHANGED
@@ -32,12 +32,12 @@ def tatsu_zine( id, doc = nil )
|
|
32
32
|
return result
|
33
33
|
end
|
34
34
|
|
35
|
-
link = "
|
36
|
-
doc ||= open(
|
35
|
+
link = "https://tatsu-zine.com/books/#{id}"
|
36
|
+
doc ||= open(link, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read
|
37
37
|
title = doc.match(%r|<meta property="og:title" content="(.*)">|).to_a[1]
|
38
38
|
image = doc.match(%r|<meta property="og:image" content="(.*)">|).to_a[1]
|
39
|
-
price = doc.match(%r
|
40
|
-
author = doc.match(%r|<
|
39
|
+
price = doc.match(%r|span itemprop="price">(.*)</span>|).to_a[1]
|
40
|
+
author = doc.match(%r|<p itemprop="author" class="author">(.*)</p>|).to_a[1]
|
41
41
|
|
42
42
|
result = <<-EOS
|
43
43
|
<a class="amazon-detail" href="#{h link}"><span class="amazon-detail">
|
@@ -54,7 +54,8 @@ EOS
|
|
54
54
|
|
55
55
|
tatsu_zine_cache_set( id, result ) unless @conf.secure
|
56
56
|
result
|
57
|
-
rescue
|
57
|
+
rescue => e
|
58
|
+
@logger.error(e)
|
58
59
|
link
|
59
60
|
end
|
60
61
|
|
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.
|
4
|
+
version: 5.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tDiary contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tdiary
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- js/datepicker.js
|
188
188
|
- js/editor.js
|
189
189
|
- js/flickr.js
|
190
|
+
- js/google_photos.js
|
190
191
|
- js/hide_sidebar_smartphone.js
|
191
192
|
- js/image_ex.js
|
192
193
|
- js/jquery.socialbutton.js
|
@@ -241,6 +242,7 @@ files:
|
|
241
242
|
- plugin/en/microsummary.rb
|
242
243
|
- plugin/en/nicovideo.rb
|
243
244
|
- plugin/en/openid.rb
|
245
|
+
- plugin/en/profile.rb
|
244
246
|
- plugin/en/section_footer.rb
|
245
247
|
- plugin/en/section_footer2.rb
|
246
248
|
- plugin/en/socialbutton.rb
|
@@ -255,6 +257,7 @@ files:
|
|
255
257
|
- plugin/google_adsense.rb
|
256
258
|
- plugin/google_analytics.rb
|
257
259
|
- plugin/google_map.rb
|
260
|
+
- plugin/google_photos.rb
|
258
261
|
- plugin/google_sitemaps.rb
|
259
262
|
- plugin/google_universal_analytics.rb
|
260
263
|
- plugin/google_webmaster.rb
|