tdiary-contrib 5.0.3 → 5.0.4

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: 8b861b8e242e49d48b1bf2a4d221e45358aeac56
4
- data.tar.gz: da7a57a662ae3892930d9b6854ed82070a0cc277
3
+ metadata.gz: a618c3a15f193c43756a0bb8ecd1df26e9d317a6
4
+ data.tar.gz: d0a68910bcda472a2d9f056378f0d90157420b75
5
5
  SHA512:
6
- metadata.gz: a1a4b72e93928bac1131636987550e6f2ca4fa4a9bc5ce13fa8ef822ecbf4b04e9493f0d51595e542adf165f34976634bfb9d0827b819ed8ae5b0f78918f616a
7
- data.tar.gz: ad99181c743a43a23eb42be2627130cc608d3634cce262509856858bc0b148c1146d7098abb9f9f8653691198edaa71fdbeac7874e07764fc38361710202d6b2
6
+ metadata.gz: c7b58f2bef33ed390c5d7de5159991a6b114eec164f1e18b0ad758cfc6c6d0ffe2b6dd7f12f240da6551d942a08c5b9d973cb2b077a92ace9fa3285e20e005d2
7
+ data.tar.gz: e3245824b3d1f11295fd172e0043dc7f5ea46d3fd5876ea2b1ed89406af74adbe20c92ce229175c28d3db06869338f89a0dead941d5c1728e037c847aaf308d1
@@ -1,5 +1,5 @@
1
1
  module TDiary
2
2
  class Contrib
3
- VERSION = "5.0.3"
3
+ VERSION = "5.0.4"
4
4
  end
5
5
  end
@@ -29,10 +29,44 @@ end
29
29
  add_conf_proc( 'google_analytics', 'Google Analytics' ) do
30
30
  if @mode == 'saveconf' then
31
31
  @conf['google_analytics.profile'] = @cgi.params['google_analytics.profile'][0]
32
+ @conf['google_analytics.amp.profile'] = @cgi.params['google_analytics.amp.profile'][0]
32
33
  end
33
- <<-HTML
34
+ r = <<-HTML
34
35
  <h3>Google Analytics Profile</h3>
35
36
  <p>set your Profile ID (NNNNN-N)</p>
36
37
  <p><input name="google_analytics.profile" value="#{h @conf['google_analytics.profile']}"></p>
37
38
  HTML
39
+ if defined? AMP
40
+ r << <<-HTML
41
+ <h3>Google Analytics Profile for AMP page</h3>
42
+ <p>set your Profile ID (NNNNN-N) for AMP page</p>
43
+ <p><input name="google_analytics.amp.profile" value="#{h @conf['google_analytics.amp.profile']}"></p>
44
+ HTML
45
+ end
46
+ r
47
+ end
48
+
49
+ if defined? AMP
50
+ add_amp_header_proc do
51
+ %Q|<script async custom-element="amp-analytics"
52
+ src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>|
53
+ end
54
+
55
+ add_amp_body_enter_proc do
56
+ profile_id = %w(google_analytics.amp.profile google_analytics.profile).map {|key|
57
+ @conf[key]
58
+ }.find {|profile|
59
+ profile && !profile.empty?
60
+ }
61
+ <<-HTML
62
+ <amp-analytics type="googleanalytics" id="analytics1">
63
+ <script type="application/json">
64
+ {
65
+ "vars": { "account": "UA-#{h profile_id}" },
66
+ "triggers": { "trackPageview": { "on": "visible", "request": "pageview" } }
67
+ }
68
+ </script>
69
+ </amp-analytics>
70
+ HTML
71
+ end
38
72
  end
data/plugin/picasa.rb CHANGED
@@ -29,37 +29,3 @@ end
29
29
  def picasa_right( src, alt = "photo" )
30
30
  picasa( src, alt, 'right' )
31
31
  end
32
-
33
- if /\A(form|edit|preview|showcomment)\z/ === @mode then
34
- enable_js( 'picasa.js' )
35
- add_js_setting( '$tDiary.plugin.picasa' )
36
- add_js_setting( '$tDiary.plugin.picasa.userId', %Q|'#{@conf['picasa.user']}'| )
37
- add_js_setting( '$tDiary.plugin.picasa.imgMax', %Q|'#{@conf[ 'picasa.default_size'] || 400}'| )
38
- end
39
-
40
- add_edit_proc do |date|
41
- unless @conf['picasa.user']
42
- '<p>[ERROR] picasa.rb: Picasa username is not specified.</p>'
43
- else
44
- <<-HTML
45
- <h3 class="plugin_picasa"><span>Picasa Web Album</span></h3>
46
- <div id="plugin_picasa"></div>
47
- HTML
48
- end
49
- end
50
-
51
- add_conf_proc( 'picasa', 'Picasa' ) do
52
- if @mode == 'saveconf'
53
- @conf['picasa.user'], = @cgi.params['picasa.user']
54
- @conf['picasa.default_size'] = @cgi.params['picasa.default_size'][0].to_i
55
- @conf['picasa.default_size'] = 400 if @conf['picasa.default_size'] == 0
56
- end
57
-
58
- <<-HTML
59
- <h3 class="subtitle">Picasa user name</h3>
60
- <p><input name="picasa.user" value="#{h @conf['picasa.user']}"></p>
61
-
62
- <h3 class="subtitle">default size</h3>
63
- <p><input name="picasa.default_size" value="#{h @conf['picasa.default_size']}"></p>
64
- HTML
65
- 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.3
4
+ version: 5.0.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: 2016-12-29 00:00:00.000000000 Z
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tdiary
@@ -191,7 +191,6 @@ files:
191
191
  - js/image_ex.js
192
192
  - js/jquery.socialbutton.js
193
193
  - js/nicovideo.js
194
- - js/picasa.js
195
194
  - js/plugin_checker.js
196
195
  - js/referer.js
197
196
  - js/show_and_hide.js
@@ -503,7 +502,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
502
  version: '0'
504
503
  requirements: []
505
504
  rubyforge_project:
506
- rubygems_version: 2.5.2
505
+ rubygems_version: 2.6.11
507
506
  signing_key:
508
507
  specification_version: 4
509
508
  summary: tDiary contributions package
data/js/picasa.js DELETED
@@ -1,268 +0,0 @@
1
- /*
2
- picasa.js: javascript for picasa.rb plugin of tDiary
3
-
4
- Copyright (C) 2011 by hb <smallstyle@gmail.com>
5
- You can redistribute it and/or modify it under GPL2.
6
- */
7
- $(function () {
8
- var CanvasLoadingImage = function (rgb) {
9
- this.canvas = null;
10
- this.ctx = null;
11
- this.width = 200;
12
- this.height = 32;
13
- this.rgb = rgb || '0, 0, 0';
14
- this.initialize();
15
- }
16
-
17
- CanvasLoadingImage.prototype = {
18
- initialize: function () {
19
- this.canvas = $('<canvas>', {
20
- text: 'loading...'
21
- }).attr({
22
- 'width': this.width,
23
- 'height': this.height
24
- });
25
- if (this.canvas.get(0).getContext) {
26
- this.ctx = this.canvas.get(0).getContext('2d');
27
- }
28
- },
29
-
30
- draw: function (idx) {
31
- var ctx = this.ctx;
32
- ctx.clearRect(0, 0, this.width, this.height);
33
- for (i = 0; i < 10; i++) {
34
- ctx.fillStyle = i > idx ? 'rgba(' + this.rgb + ', 0.25)' : 'rgb(' + this.rgb + ')';
35
- ctx.fillRect(i * (this.width / 10), 0, (this.width / 10) - 4, this.height);
36
- }
37
- return idx < 10 ? idx + 1 : 0;
38
- },
39
-
40
- start: function () {
41
- var self = this;
42
- var idx = 0;
43
- this.timer = setInterval(function () {
44
- idx = self.draw(idx);
45
- }, 100)
46
- },
47
-
48
- stop: function () {
49
- clearInterval(this.timer);
50
- }
51
- }
52
-
53
- var PicasaService = function (userId, imgMax) {
54
- this.userId = userId;
55
- this.imgMax = imgMax || 400;
56
- this.has_more_photos = false;
57
- this.has_more_albums = false;
58
- this.recently_uploaded_photo_start_index = 1;
59
- this.album_start_index = 1;
60
- };
61
-
62
- PicasaService.prototype = {
63
- setRecentlyUploadedPhotoStartIndex: function(index) {
64
- this.recently_uploaded_photo_start_index = index;
65
- },
66
-
67
- setAlbumStartIndex: function(index) {
68
- this.album_start_index = 1;
69
- },
70
-
71
- hasMorePhotos: function () {
72
- return this.has_more_photos;
73
- },
74
-
75
- hasMoreAlbums: function() {
76
- return this.has_more_albums;
77
- },
78
-
79
- getAlbums: function (fn) {
80
- var timerId = this.setErrorHandler();
81
- var self = this;
82
- $.ajax({
83
- url: '//picasaweb.google.com/data/feed/api/user/' + this.userId,
84
- data: 'alt=json-in-script&max-results=25&thumbsize=128c&start-index=' + this.album_start_index,
85
- dataType: 'jsonp',
86
- success: function (data) {
87
- clearTimeout(timerId);
88
- self.album_start_index += 25;
89
- if (self.album_start_index < data.feed.openSearch$totalResults.$t) {
90
- self.has_more_albums = true;
91
- } else {
92
- self.has_more_albums = false;
93
- }
94
- fn(data.feed.entry);
95
- }
96
- });
97
- },
98
-
99
- getPhotos: function (albumId, fn) {
100
- var timerId = this.setErrorHandler();
101
- $.ajax({
102
- url: '//picasaweb.google.com/data/feed/api/user/' + this.userId + '/albumid/' + albumId,
103
- data: 'alt=json-in-script&imgmax=' + this.imgMax + '&thumbsize=200',
104
- dataType: 'jsonp',
105
- success: function (data) {
106
- clearTimeout(timerId);
107
- fn(data.feed.entry);
108
- }
109
- });
110
- },
111
-
112
- getPhotosRecentlyUploaded: function (fn) {
113
- var timerId = this.setErrorHandler();
114
- var self = this;
115
- $.ajax({
116
- url: '//picasaweb.google.com/data/feed/api/user/' + this.userId,
117
- data: 'alt=json-in-script&imgmax=' + this.imgMax + '&thumbsize=200&kind=photo&max-results=25&start-index=' + this.recently_uploaded_photo_start_index,
118
- dataType: 'jsonp',
119
- success: function (data) {
120
- clearTimeout(timerId);
121
- self.recently_uploaded_photo_start_index += 25;
122
- if (self.recently_uploaded_photo_start_index < data.feed.openSearch$totalResults.$t) {
123
- self.has_more_photos = true;
124
- } else {
125
- self.has_more_photos = false;
126
- }
127
- fn(data.feed.entry);
128
- }
129
- });
130
- },
131
-
132
- setErrorHandler: function () {
133
- var timerId = setTimeout(function () {
134
- clearTimeout(timerId);
135
- $('#plugin_picasa canvas').hide();
136
- $('#plugin_picasa').append(
137
- $('<span>', {
138
- text: 'Picasa Web Serviceの呼び出しに失敗しました'
139
- }).css('color', 'red'));
140
- }, 10000);
141
- return timerId;
142
- }
143
- };
144
-
145
- $('<input>')
146
- .attr({
147
- id: 'plugin_picasa_recent',
148
- type: 'button',
149
- value: 'Picasaから写真を取得する'
150
- })
151
- .css({
152
- 'margin-left': '5px'
153
- })
154
- .appendTo('#plugin_picasa');
155
-
156
- var showPhoto = function(photo) {
157
- $('<img>')
158
- .click(function () {
159
- $('#body').insertAtCaret($.makePluginTag('picasa', [photo.content.src, $.trim(photo.summary.$t)]));
160
- })
161
- .attr({
162
- src: photo.media$group.media$thumbnail[0].url,
163
- title: $.trim(photo.summary.$t),
164
- alt: $.trim(photo.summary.$t)
165
- })
166
- .css({
167
- 'cursor': 'pointer',
168
- 'margin': '5px',
169
- 'border': 'solid 1px #aaa'
170
- })
171
- .appendTo('#photos');
172
- };
173
-
174
- var showAlbum = function (album) {
175
- $('<li>').attr('title', album.title.$t + 'の写真一覧を表示する').css({
176
- 'cursor': 'pointer',
177
- 'list-style': 'none',
178
- 'float': 'left',
179
- 'width': '128px',
180
- 'height': '128px',
181
- 'background-image': 'url(' + album.media$group.media$thumbnail[0].url + ')',
182
- 'margin': '5px',
183
- 'border': 'solid 1px #aaaaaa',
184
- 'overflow': 'hidden'
185
- }).click(function () {
186
- $('h3.plugin_picasa span')
187
- .css('cursor', 'pointer')
188
- .attr('title', 'アルバム一覧を表示する')
189
- .unbind('click')
190
- .click(function () {
191
- $('h3.plugin_picasa span.title').remove();
192
- $('.photo').remove();
193
- $('.album').show();
194
- });
195
- $('<span>', {
196
- text: ' > ' + album.title.$t
197
- }).addClass('title').appendTo('h3.plugin_picasa');
198
- $('<div>').css({
199
- 'overflow': 'auto',
200
- 'height': '300px'
201
- }).attr('id', 'photos').addClass('photo').appendTo('#plugin_picasa');
202
- $('.album').hide();
203
- $(loading.canvas).show();
204
- loading.start();
205
- service.getPhotos(album.gphoto$id.$t, function (photos) {
206
- $(loading.canvas).hide();
207
- loading.stop();
208
- $.each(photos, function (j, photo) {
209
- showPhoto(photo);
210
- });
211
- });
212
- }).append(
213
- $('<span>', {
214
- text: album.title.$t
215
- }).css({
216
- 'display': 'block',
217
- 'text-align': 'center',
218
- 'color': '#fff',
219
- 'background-color': 'rgba(0, 0, 0, 0.5)'
220
- })).appendTo('#albums');
221
- };
222
-
223
- var service = new PicasaService($tDiary.plugin.picasa.userId, $tDiary.plugin.picasa.imgMax);
224
- var loading = new CanvasLoadingImage();
225
-
226
- var showAlbums = function(){
227
- service.setAlbumStartIndex(1);
228
- $('h3.plugin_picasa span.title').remove();
229
- $('#albums').remove();
230
- $('.photo').remove();
231
- $('<ul>').css({
232
- 'overflow': 'auto',
233
- 'height': '300px'
234
- }).attr('id', 'albums').addClass('album')
235
- .scroll(function(){
236
- if (($(this).height() + $(this).scrollTop()) > ($(this).get(0).scrollHeight - 250)) {
237
- if (!service.active && service.hasMoreAlbums()) {
238
- service.active = true;
239
- service.getAlbums(function(next_albums) {
240
- service.active = false;
241
- $.each(next_albums, function(m, next_album) {
242
- showAlbum(next_album);
243
- });
244
- });
245
- }
246
- }
247
- })
248
- .appendTo('#plugin_picasa');
249
-
250
- $(loading.canvas).show();
251
- loading.start();
252
- service.getAlbums(function (albums) {
253
- $(loading.canvas).hide();
254
- loading.stop();
255
- $.each(albums, function(l, album) {
256
- showAlbum(album)
257
- });
258
- });
259
- }
260
-
261
- $('#plugin_picasa_recent').click(function(){
262
- $('#plugin_picasa')
263
- .css('height', '300px')
264
- .empty();
265
- $(loading.canvas).appendTo($('#plugin_picasa'));
266
- showAlbums();
267
- });
268
- });