tdiary-contrib 4.2.1 → 5.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: 2b963a36e85ed48eeaf351c67e1daaaa10b798d4
4
- data.tar.gz: 2f4633b77caadcaa50960a8e1350680818ba2087
3
+ metadata.gz: 951b6aa4dbb64c3c27286b17c127134c29294626
4
+ data.tar.gz: 4ec21935523768181cbbb5f1fd843ba06f648089
5
5
  SHA512:
6
- metadata.gz: 1755119971bbadaab70bcb37536111a1c89617aae4ef2b6dde6731f5821a8288051c9e1fce2b50671df31381387512c577c969e3f2fa08fc4af5171566435084
7
- data.tar.gz: eddddefe6eba29289006b8e19dc5b48fd548d7e4493b03be73048151f01b67dc31071ebd91132b81e097d38df527f75e90e8725f84bd4ccb97b347e9540f82c2
6
+ metadata.gz: 59961f3c4ac5a76f3f38bfb440661347355afeef28e91ead68e28599f3637bdec99c382ed1d1db34e210d55aba8cafb64dbc68f281883e521281104228c8649f
7
+ data.tar.gz: b170c62aa74a2dffbb13955dfa9a918827794199942c6c89fd72c3489576750651a378096220c5bac92ffc6b8c1b1fbb808d926a046e95034b043e2cde02967c
@@ -1,40 +1,40 @@
1
1
  /**
2
2
  * jquery.socialbutton - jQuery plugin for social networking websites
3
3
  * http://itra.jp/jquery_socialbutton_plugin/
4
- *
4
+ *
5
5
  * Copyright 2010, Itrans, Inc. http://itra.jp/
6
- *
6
+ *
7
7
  * Dual licensed under the MIT or GPL Version 2 licenses.
8
8
  * http://jquery.org/license
9
- *
10
- * Version: 1.8.1
9
+ *
10
+ * Version: 1.9.1
11
11
  */
12
12
 
13
13
  /**
14
14
  * SYNOPSIS
15
- *
16
- *
15
+ *
16
+ *
17
17
  * mixi_check
18
18
  * http://developer.mixi.co.jp/connect/mixi_plugin/mixi_check/spec_mixi_check
19
- *
19
+ *
20
20
  * $('#mixi_check').socialbutton('mixi_check', {
21
21
  * key: 'mixi-check-key'
22
22
  * });
23
- *
23
+ *
24
24
  * $('#mixi_check').socialbutton('mixi_check', {
25
25
  * key: 'mixi-check-key',
26
26
  * button: 'button-1',
27
27
  * url: 'http://itra.jp/'
28
28
  * });
29
- *
30
- *
29
+ *
30
+ *
31
31
  * mixi_like
32
32
  * http://developer.mixi.co.jp/connect/mixi_plugin/favorite_button/spec
33
- *
33
+ *
34
34
  * $('#mixi_like').socialbutton('mixi_like', {
35
35
  * key: 'mixi-check-key',
36
36
  * });
37
- *
37
+ *
38
38
  * $('#mixi_like').socialbutton('mixi_like', {
39
39
  * key: 'mixi-check-key',
40
40
  * url: 'http://itra.jp/',
@@ -43,13 +43,13 @@
43
43
  * show_faces: true,
44
44
  * style: 'additional-style-here'
45
45
  * });
46
- *
47
- *
46
+ *
47
+ *
48
48
  * facebook_like
49
49
  * http://developers.facebook.com/docs/reference/plugins/like
50
- *
50
+ *
51
51
  * $('#facebook_like').socialbutton('facebook_like');
52
- *
52
+ *
53
53
  * $('#facebook_like').socialbutton('facebook_like', {
54
54
  * button: 'standard', // synonym 'layout'
55
55
  * url: 'http://itra.jp',
@@ -61,25 +61,25 @@
61
61
  * font: 'arial',
62
62
  * colorscheme: 'light'
63
63
  * });
64
- *
65
- *
64
+ *
65
+ *
66
66
  * facebook_share
67
67
  * http://developers.facebook.com/docs/share
68
- *
68
+ *
69
69
  * $('#facebook_share').socialbutton('facebook_share');
70
- *
70
+ *
71
71
  * $('#facebook_share').socialbutton('facebook_share', {
72
72
  * button: 'button_count', // synonym 'type'
73
73
  * url: 'http://itra.jp',
74
74
  * text: 'Share'
75
75
  * });
76
- *
77
- *
76
+ *
77
+ *
78
78
  * Twitter
79
79
  * http://twitter.com/goodies/tweetbutton
80
- *
80
+ *
81
81
  * $('#twitter').socialbutton('twitter');
82
- *
82
+ *
83
83
  * $('#twitter').socialbutton('twitter', {
84
84
  * button: 'vertical', // synonym 'count'
85
85
  * url: 'http://itra.jp/',
@@ -88,26 +88,26 @@
88
88
  * via: 'ishiiyoshinori',
89
89
  * related: 'twitter'
90
90
  * });
91
- *
92
- *
91
+ *
92
+ *
93
93
  * GREE Social Feedback
94
94
  * http://developer.gree.co.jp/connect/plugins/sf
95
- *
95
+ *
96
96
  * $('#gree_sf').socialbutton('gree_sf');
97
- *
97
+ *
98
98
  * $('#gree_sf').socialbutton('gree_sf', {
99
99
  * button: 0, // synonym 'type'
100
100
  * url: 'http://itra.jp/',
101
101
  * width: 0, // auto
102
102
  * height: 20
103
103
  * });
104
- *
105
- *
104
+ *
105
+ *
106
106
  * Evernote Site Memory
107
107
  * http://www.evernote.com/about/developer/sitememory/
108
- *
108
+ *
109
109
  * $('#evernote').socialbutton('evernote');
110
- *
110
+ *
111
111
  * $('#evernote').socialbutton('evernote', {
112
112
  * button: 'article-clipper',
113
113
  * url: 'http://itra.jp/',
@@ -119,38 +119,38 @@
119
119
  * suggest_tags: 'comma-separated-tags,up-to-three-tags',
120
120
  * styling: 'full'
121
121
  * });
122
- *
123
- *
122
+ *
123
+ *
124
124
  * Hatena Bookmark
125
125
  * http://b.hatena.ne.jp/
126
- *
126
+ *
127
127
  * $('#hatena').socialbutton('hatena');
128
- *
128
+ *
129
129
  * $('#hatena').socialbutton('hatena', {
130
130
  * button: 'standard',
131
131
  * url: 'http://itra.jp/',
132
132
  * title: 'page-title'
133
133
  * });
134
- *
135
- *
134
+ *
135
+ *
136
136
  * Hatena Bookmark (Old Style)
137
137
  * http://b.hatena.ne.jp/
138
- *
138
+ *
139
139
  * $('#hatena').socialbutton('hatena_oldstyle');
140
- *
140
+ *
141
141
  * $('#hatena').socialbutton('hatena_oldstyle', {
142
142
  * button: '/path/to/your-icon.png',
143
143
  * url: 'http://itra.jp/',
144
144
  * padding: 10,
145
145
  * height: 15
146
146
  * });
147
- *
148
- *
147
+ *
148
+ *
149
149
  * Google +1 Button
150
150
  * http://www.google.com/webmasters/+1/button/
151
- *
151
+ *
152
152
  * $('#google').socialbutton('google_plusone');
153
- *
153
+ *
154
154
  * $('#google').socialbutton('google_plusone', {
155
155
  * button: 'standard', // synonym 'size'
156
156
  * url: 'http://itra.jp', // synonym 'href'
@@ -159,16 +159,16 @@
159
159
  * callback: 'some_callback_function',
160
160
  * count: true
161
161
  * });
162
- *
162
+ *
163
163
  *
164
164
  * Pintarest Button
165
165
  * http://pinterest.com/about/goodies/
166
166
  *
167
- * $('#pinterest').socialbutton('pinterest', {
167
+ * $('#pinterest').socialbutton('pintarest', {
168
168
  * button: 'horizontal', // or 'vertical', 'none'
169
169
  * url: 'http://itra.jp',
170
170
  * media: 'http://itra.jp/image.jpg',
171
- * description: 'This is an image.',
171
+ * description: 'This is an image.'
172
172
  * });
173
173
  */
174
174
  (function($) {
@@ -272,7 +272,7 @@ $.fn.socialbutton = function(service, options) {
272
272
  title: document.title
273
273
  },
274
274
  hatena_oldstyle: {
275
- button: 'http://d.hatena.ne.jp/images/b_append.gif',
275
+ button: 'https://d.hatena.ne.jp/images/b_append.gif',
276
276
  url: document.URL,
277
277
  height: 13,
278
278
  padding: 7
@@ -287,10 +287,10 @@ $.fn.socialbutton = function(service, options) {
287
287
  },
288
288
  pinterest: {
289
289
  button: 'horizontal', // horizontal, vertical, none
290
- url: '',
290
+ url: document.URL,
291
291
  media: '',
292
292
  description: ''
293
- },
293
+ }
294
294
  };
295
295
 
296
296
  var max_index = this.size() - 1;
@@ -496,7 +496,7 @@ function socialbutton_facebook_like(target, options, defaults, index, max_index)
496
496
  'height': height
497
497
  });
498
498
 
499
- var tag = '<iframe src="http://www.facebook.com/plugins/like.php?' + params + '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:' + width + 'px; height:' + height + 'px;" allowTransparency="true"></iframe>';
499
+ var tag = '<iframe src="https://www.facebook.com/plugins/like.php?' + params + '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:' + width + 'px; height:' + height + 'px;" allowTransparency="true"></iframe>';
500
500
 
501
501
  $(target).html(tag);
502
502
  }
@@ -545,7 +545,7 @@ function socialbutton_twitter(target, options, defaults, index, max_index)
545
545
  $(target).html(tag);
546
546
 
547
547
  if (index == max_index) {
548
- $('body').append('<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>');
548
+ $('body').append('<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>');
549
549
  }
550
550
  }
551
551
 
@@ -667,15 +667,15 @@ function socialbutton_hatena(target, options, defaults, index, max_index)
667
667
  title = htmlspecialchars(title);
668
668
 
669
669
  var attr = merge_attributes({
670
- 'href': 'http://b.hatena.ne.jp/entry/' + url,
670
+ 'href': 'https://b.hatena.ne.jp/entry/' + url,
671
671
  'class': 'hatena-bookmark-button',
672
672
  'data-hatena-bookmark-title': title,
673
673
  'data-hatena-bookmark-layout': layout,
674
674
  'title': 'このエントリーをはてなブックマークに追加'
675
675
  });
676
-
677
- var tag = '<a' + attr + '><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a>'
678
- + '<script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button_wo_al.js" charset="utf-8" async="async"></script>';
676
+
677
+ var tag = '<a' + attr + '><img src="https://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a>'
678
+ + '<script type="text/javascript" src="https://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>';
679
679
 
680
680
  $(target).html(tag);
681
681
  }
@@ -691,8 +691,8 @@ function socialbutton_hatena_oldstyle(target, options, defaults, index, max_inde
691
691
  url = htmlspecialchars(url);
692
692
 
693
693
  var tag = '<span style="font-size: ' + height + 'px; line-height: 100%; ">'
694
- + '<span style="padding-right: ' + padding + 'px"><a href="http://b.hatena.ne.jp/entry/add/' + url + '" target="_blank"><img src="' + button + '" style="border: none; vertical-align: text-bottom" /></a></span>'
695
- + '<a href="http://b.hatena.ne.jp/entry/' + url + '" target="_blank"><img src="http://b.hatena.ne.jp/entry/image/' + url + '" style="border: none; vertical-align: text-bottom" /></a>'
694
+ + '<span style="padding-right: ' + padding + 'px"><a href="https://b.hatena.ne.jp/entry/add/' + url + '" target="_blank"><img src="' + button + '" style="border: none; vertical-align: text-bottom" /></a></span>'
695
+ + '<a href="https://b.hatena.ne.jp/entry/' + url + '" target="_blank"><img src="https://b.hatena.ne.jp/entry/image/' + url + '" style="border: none; vertical-align: text-bottom" /></a>'
696
696
  + '</span>';
697
697
 
698
698
  $(target).html(tag);
@@ -700,7 +700,7 @@ function socialbutton_hatena_oldstyle(target, options, defaults, index, max_inde
700
700
 
701
701
  function socialbutton_google_plusone(target, options, defaults, index, max_index)
702
702
  {
703
- if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
703
+ if (!$.support.tbody) {
704
704
  return;
705
705
  }
706
706
 
data/js/picasa.js CHANGED
@@ -222,101 +222,47 @@ $(function () {
222
222
 
223
223
  var service = new PicasaService($tDiary.plugin.picasa.userId, $tDiary.plugin.picasa.imgMax);
224
224
  var loading = new CanvasLoadingImage();
225
-
226
- var showRecentlyPhotos = function() {
227
- $('h3.plugin_picasa span').unbind();
228
- service.setRecentlyUploadedPhotoStartIndex(1);
229
- loading.start();
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
+
230
250
  $(loading.canvas).show();
231
- service.getPhotosRecentlyUploaded(function (photos) {
251
+ loading.start();
252
+ service.getAlbums(function (albums) {
232
253
  $(loading.canvas).hide();
233
254
  loading.stop();
234
- $('h3.plugin_picasa span')
235
- .css('cursor', 'pointer')
236
- .attr('title', 'アルバム一覧を表示する')
237
- .click(function() {
238
- $(this).unbind('click');
239
- service.setAlbumStartIndex(1);
240
- $('h3.plugin_picasa span.title').remove();
241
- $('#albums').remove();
242
- $('.photo').remove();
243
- $('<ul>').css({
244
- 'overflow': 'auto',
245
- 'height': '300px'
246
- }).attr('id', 'albums').addClass('album')
247
- .scroll(function(){
248
- if (($(this).height() + $(this).scrollTop()) > ($(this).get(0).scrollHeight - 250)) {
249
- if (!service.active && service.hasMoreAlbums()) {
250
- service.active = true;
251
- service.getAlbums(function(next_albums) {
252
- service.active = false;
253
- $.each(next_albums, function(m, next_album) {
254
- showAlbum(next_album);
255
- });
256
- });
257
- }
258
- }
259
- })
260
- .appendTo('#plugin_picasa');
261
-
262
- $(loading.canvas).show();
263
- loading.start();
264
- service.getAlbums(function (albums) {
265
- $(loading.canvas).hide();
266
- loading.stop();
267
- $.each(albums, function(l, album) {
268
- showAlbum(album)
269
- });
270
- $('<input>')
271
- .attr({
272
- 'type': 'button',
273
- 'value': '最近アップロードした写真の一覧を表示する'
274
- })
275
- .insertAfter('#plugin_picasa')
276
- .click(function(){
277
- $(this).remove();
278
- $('h3.plugin_picasa span.title').remove();
279
- $('#albums').remove();
280
- $('.photo').remove();
281
- showRecentlyPhotos();
282
- });
283
- });
284
- });
285
- $('<span>', {
286
- text: ' > Recently uploaded photos'
287
- }).addClass('title').appendTo('h3.plugin_picasa');
288
- $('<div>')
289
- .css({
290
- 'overflow': 'auto',
291
- 'height': '300px'
292
- })
293
- .attr('id', 'photos')
294
- .addClass('photo')
295
- .appendTo('#plugin_picasa')
296
- .scroll(function(){
297
- if (($(this).height() + $(this).scrollTop()) > ($(this).get(0).scrollHeight - 400)) {
298
- if (!service.active && service.hasMorePhotos()) {
299
- service.active = true;
300
- service.getPhotosRecentlyUploaded(function(next_photos) {
301
- service.active = false;
302
- $.each(next_photos, function(j, next_photo) {
303
- showPhoto(next_photo);
304
- });
305
- });
306
- }
307
- }
308
- });
309
- $.each(photos, function(i, photo){
310
- showPhoto(photo);
255
+ $.each(albums, function(l, album) {
256
+ showAlbum(album)
311
257
  });
312
258
  });
313
- };
259
+ }
314
260
 
315
261
  $('#plugin_picasa_recent').click(function(){
316
262
  $('#plugin_picasa')
317
263
  .css('height', '300px')
318
264
  .empty();
319
265
  $(loading.canvas).appendTo($('#plugin_picasa'));
320
- showRecentlyPhotos();
266
+ showAlbums();
321
267
  });
322
268
  });
@@ -1,5 +1,5 @@
1
1
  module TDiary
2
2
  class Contrib
3
- VERSION = "4.2.1"
3
+ VERSION = "5.0.0"
4
4
  end
5
5
  end
data/plugin/coderwall.rb CHANGED
@@ -9,7 +9,7 @@ def coderwall(name, size = [60, 60])
9
9
  File::delete(cache) if Time::now > File::mtime( cache ) + 60*60*24
10
10
  rescue Errno::ENOENT
11
11
  begin
12
- timeout(10) do
12
+ Timeout.timeout(10) do
13
13
  json = open( "https://coderwall.com/#{name}.json" ) {|f| f.read }
14
14
  end
15
15
  open(cache, 'wb') {|f| f.write(json) }
data/plugin/flickr.rb CHANGED
@@ -89,7 +89,7 @@ def flickr_open(method, photo_id)
89
89
  req['method'] = method
90
90
  req['photo_id'] = photo_id
91
91
  begin
92
- timeout(5) do
92
+ Timeout.timeout(5) do
93
93
  open(file, 'w') {|fout|
94
94
  fout.puts req.open
95
95
  }
@@ -16,7 +16,7 @@ add_conf_proc('Google Webmaster', 'Google ウェブマスターツール', 'etc'
16
16
  <<-HTML
17
17
  <h3>Google ウェブマスターツールの検証コード</h3>
18
18
  <p>
19
- <input name='google_webmaster.verification'/>
19
+ <input name='google_webmaster.verification' value="#{h @conf['google_webmaster.verification']}" />
20
20
  </p>
21
21
  HTML
22
22
  end
data/plugin/iddy.rb CHANGED
@@ -75,7 +75,7 @@ def iddy_call_api( id, key )
75
75
 
76
76
  proxy = @conf['proxy']
77
77
  proxy = 'http://' + proxy if proxy
78
- timeout( 3 ) do
78
+ Timeout.timeout( 3 ) do
79
79
  open( request, :proxy => proxy ) {|f| f.read }
80
80
  end
81
81
  end
data/plugin/instagram.rb CHANGED
@@ -41,7 +41,7 @@ def instagram_serverside( short_url, size = :medium)
41
41
 
42
42
  begin
43
43
  Net::HTTP.version_1_2
44
- res = Net::HTTP::Proxy(px_host, px_port).get('instagram.com', "/api/v1/oembed/#{query}")
44
+ res = Net::HTTP::Proxy(px_host, px_port).get('api.instagram.com', "/oembed/#{query}")
45
45
  json_data = JSON::parse( res, &:read )
46
46
  width = option[:width] ? option[:width] : json_data["width"]
47
47
  height = option[:height] ? option[:height] : json_data["height"]
@@ -28,7 +28,7 @@ def lwws_request( city_id )
28
28
 
29
29
  proxy = @conf['proxy']
30
30
  proxy = 'http://' + proxy if proxy
31
- timeout( 10 ) do
31
+ Timeout.timeout( 10 ) do
32
32
  open( url, :proxy => proxy ) {|f| f.read }
33
33
  end
34
34
  end
@@ -42,7 +42,7 @@ class MyHotEntry
42
42
  rss_url << URI.escape(base_url, /[^-.!~*'()\w]/n)
43
43
  rss_url << "&sort=#{options[:sort]}&threshold=#{options[:threshold]}"
44
44
  begin
45
- timeout(5) do
45
+ Timeout.timeout(5) do
46
46
  # convert Tempfile to String because REXML can't accept Tempfile
47
47
  open(rss_url) do |f|
48
48
  rss = REXML::Document.new(f.readlines.join("\n"))
@@ -64,7 +64,7 @@ def call_nhk_json(id, service, area)
64
64
 
65
65
  status = nil
66
66
  data = nil
67
- timeout(10) do
67
+ Timeout.timeout(10) do
68
68
  open(*open_param){ |ff| data = ff.read; status = ff.status[0] }
69
69
  end
70
70
  raise "API Error" if status.to_s != '200'
data/plugin/nicovideo.rb CHANGED
@@ -29,7 +29,7 @@ def nicovideo_call_api( video_id )
29
29
  uri = "http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}"
30
30
  proxy = @conf['proxy']
31
31
  proxy = 'http://' + proxy if proxy
32
- xml = timeout( feed? ? 10 : 2 ) {
32
+ xml = Timeout.timeout( feed? ? 10 : 2 ) {
33
33
  px_host, px_port = (@conf['proxy'] || '').split( /:/ )
34
34
  px_port = 80 if px_host and !px_port
35
35
  Net::HTTP::Proxy( px_host, px_port ).get_response( URI::parse( uri ) ).body
@@ -31,7 +31,11 @@ def ohmsha_estore( id, doc = nil )
31
31
  return result
32
32
  end
33
33
 
34
- html = open("https://estore.ohmsha.co.jp#{domain}/titles/#{id}", &:read)
34
+ html = ''
35
+ begin
36
+ open("https://estore.ohmsha.co.jp/titles/#{id}"){|r|html = r.read}
37
+ rescue SecurityError # avoid error on unlink
38
+ end
35
39
  info = JSON.parse(html.scan(%r|<script type='application/ld\+json'>(.*?)</script>|m).flatten[0])
36
40
 
37
41
  result = <<-EOS
data/plugin/prettify.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  if /\A(?:latest|day|month|nyear)\z/ =~ @mode then
4
4
  add_header_proc do
5
5
  <<-HTML
6
- <link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet">
7
- <script type="text/javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
6
+ <link href="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet">
7
+ <script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
8
8
  <script type="text/javascript"><!--
9
9
  if(window.addEventListener){
10
10
  window.addEventListener("load", prettyPrint, false);
data/plugin/profile.rb CHANGED
@@ -58,7 +58,7 @@ module ::Profile
58
58
 
59
59
  # get a XML document from endpoint and create REXML::Document instance
60
60
  def fetch(endpoint)
61
- timeout(5) do
61
+ Timeout.timeout(5) do
62
62
  open(endpoint) do |f|
63
63
  doc = REXML::Document.new(f)
64
64
  end
@@ -89,7 +89,7 @@ module ::Profile
89
89
 
90
90
  def fetch(endpoint)
91
91
  require 'json'
92
- timeout(5) do
92
+ Timeout.timeout(5) do
93
93
  doc = open(endpoint) {|f| JSON.parse(f.read) }
94
94
  end
95
95
  end
@@ -125,7 +125,7 @@ module ::Profile
125
125
 
126
126
  def fetch(endpoint)
127
127
  require 'json'
128
- timeout(5) do
128
+ Timeout.timeout(5) do
129
129
  begin
130
130
  doc = open(endpoint) {|f| JSON.parse(f.read) }
131
131
  rescue RuntimeError => err
@@ -4,7 +4,6 @@
4
4
  # Copyright (C) 2012 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
5
5
  # You can redistribute it and/or modify it under GPL2.
6
6
  #
7
- require 'pygments'
8
7
 
9
8
  add_header_proc do
10
9
  <<-STYLE
@@ -65,7 +65,7 @@ def recent_tweet_call_api( id )
65
65
 
66
66
  proxy = @conf['proxy']
67
67
  proxy = 'http://' + proxy if proxy
68
- timeout( 10 ) do
68
+ Timeout.timeout( 10 ) do
69
69
  open( request, :proxy => proxy ) {|f| f.read }
70
70
  end
71
71
  end
@@ -152,7 +152,7 @@ def add_delicious_json(date, index)
152
152
 
153
153
  if cached_time.nil? or update
154
154
  begin
155
- timeout(10) do
155
+ Timeout.timeout(10) do
156
156
  open( "http://feeds.delicious.com/v2/json/urlinfo/#{url_md5}") do |file|
157
157
  File::open( file_name, 'wb' ) do |f|
158
158
  f.write( file.read )
@@ -56,11 +56,11 @@ end
56
56
 
57
57
  add_header_proc do
58
58
  <<-"EOS"
59
- <script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button_wo_al.js" charset="utf-8" async="async"></script>
59
+ <script type="text/javascript" src="//b.st-hatena.com/js/bookmark_button_wo_al.js" charset="utf-8" async="async"></script>
60
60
  <style type="text/css">iframe.hatena-bookmark-button-frame {margin-bottom: -7px; }</style>
61
- <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
61
+ <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
62
62
  <style type="text/css">iframe.twitter-share-button.twitter-count-horizontal {margin-bottom: -6px; }</style>
63
- <script src="http://connect.facebook.net/#{@section_footer2_locale}/all.js"></script>
63
+ <script src="//connect.facebook.net/#{@section_footer2_locale}/all.js"></script>
64
64
  <script>
65
65
  FB.init({
66
66
  appId : '',
@@ -70,7 +70,7 @@ add_header_proc do
70
70
  });
71
71
  </script>
72
72
  <style type="text/css">iframe.fb_ltr {margin-bottom: -2px; margin-right: 4px;}</style>
73
- <script type="text/javascript" src="http://apis.google.com/js/plusone.js">
73
+ <script type="text/javascript" src="//apis.google.com/js/plusone.js">
74
74
  {lang: '#{@section_footer2_locale}'}
75
75
  </script>
76
76
  <style type="text/css">.tags > div > iframe {margin-bottom: -6px !important; }</style>
@@ -123,7 +123,7 @@ end
123
123
  def call_delicious_json( url_md5 )
124
124
  json = nil
125
125
  begin
126
- timeout(10) do
126
+ Timeout.timeout(10) do
127
127
  open( "http://feeds.delicious.com/v2/json/urlinfo/#{url_md5}" ) do |f|
128
128
  json = JSON.parse( f.read )
129
129
  end
@@ -171,7 +171,7 @@ def add_delicious( date, index )
171
171
  end
172
172
 
173
173
  def add_hatena( date, index )
174
- %Q!<a href="http://b.hatena.ne.jp/entry/#{permalink( date, index )}" class="hatena-bookmark-button" data-hatena-bookmark-layout="standard"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" width="20" height="20" style="border: none;" /></a> | !
174
+ %Q!<a href="http://b.hatena.ne.jp/entry/#{permalink( date, index )}" class="hatena-bookmark-button" data-hatena-bookmark-layout="standard"><img src="//b.st-hatena.com/images/entry-button/button-only.gif" width="20" height="20" style="border: none;" /></a> | !
175
175
  end
176
176
 
177
177
  def add_facebook(date, index)
data/plugin/squeeze.rb ADDED
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # squeeze.rb
4
+ #
5
+ # Create daily HTML file from tDiary database.
6
+ #
7
+ # See URLs below for more details.
8
+ # http://ponx.s5.xrea.com/hiki/squeeze.rb.html (English)
9
+ # http://ponx.s5.xrea.com/hiki/ja/squeeze.rb.html (Japanese)
10
+ #
11
+ # Copyright (C) 2002 MUTOH Masao <mutoh@highway.ne.jp>
12
+ # You can redistribute it and/or modify it under GPL2 or any later version.
13
+ #
14
+ # The original version of this file was distributed with squeeze
15
+ # TADA Tadashi <sho@spc.gr.jp> with GPL2 or any later version.
16
+ #
17
+ unless $tdiary_squeeze_loaded
18
+ $tdiary_squeeze_loaded ||= true
19
+
20
+ mode = defined?(TDiary) ? "PLUGIN" : ENV["REQUEST_METHOD"]? "CGI" : "CMD"
21
+
22
+ if mode == "CMD" || mode == "CGI"
23
+ output_path = "./html/"
24
+ tdiary_path = "."
25
+ tdiary_conf = "."
26
+ suffix = ''
27
+ all_data = false
28
+ overwrite = false
29
+ compat = false
30
+ $stdout.sync = true
31
+
32
+ if mode == "CMD"
33
+ def usage
34
+ puts "squeeze $Revision: 1.25 $"
35
+ puts " making html files from tDiary's database."
36
+ puts " usage: ruby squeeze.rb [-p <tDiary path>] [-c <tdiary.conf path>] [-a] [-s] [-x suffix] <dest path>"
37
+ exit
38
+ end
39
+
40
+ require 'getoptlong'
41
+ parser = GetoptLong::new
42
+ parser.set_options(['--path', '-p', GetoptLong::REQUIRED_ARGUMENT],
43
+ ['--conf', '-c', GetoptLong::REQUIRED_ARGUMENT],
44
+ ['--suffix', '-x', GetoptLong::REQUIRED_ARGUMENT],
45
+ ['--all', '-a', GetoptLong::NO_ARGUMENT],
46
+ ['--overwrite', '-o', GetoptLong::NO_ARGUMENT],
47
+ ['--squeeze', '-s', GetoptLong::NO_ARGUMENT])
48
+ begin
49
+ parser.each do |opt, arg|
50
+ case opt
51
+ when '--path'
52
+ tdiary_path = arg.dup.untaint
53
+ when '--conf'
54
+ tdiary_conf = arg
55
+ when '--suffix'
56
+ suffix = arg
57
+ when '--all'
58
+ all_data = true
59
+ when '--overwrite'
60
+ overwrite = true
61
+ when '--squeeze'
62
+ compat = true
63
+ end
64
+ end
65
+ rescue
66
+ usage
67
+ exit( 1 )
68
+ end
69
+ output_path = ARGV.shift
70
+ usage unless output_path
71
+ output_path = File::expand_path(output_path)
72
+ output_path += '/' if /\/$/ !~ output_path
73
+
74
+ tdiary_conf = tdiary_path unless tdiary_conf
75
+ Dir::chdir( tdiary_conf )
76
+ ARGV << '' # dummy argument against cgi.rb offline mode.
77
+ $:.unshift tdiary_path
78
+ else
79
+ @options = Hash.new
80
+ File::readlines("tdiary.conf").each {|item|
81
+ if item =~ /@options/
82
+ begin
83
+ eval(item)
84
+ rescue SyntaxError
85
+ end
86
+ end
87
+ }
88
+ output_path = @options['squeeze.output_path'] || @options['yasqueeze.output_path']
89
+ suffix = @options['squeeze.suffix'] || ''
90
+ all_data = @options['squeeze.all_data'] || @options['yasqueeze.all_data']
91
+ overwrite = @options['squeeze.overwrite']
92
+ compat = @options['squeeze.compat_path'] || @options['yasqueeze.compat_path']
93
+
94
+ if FileTest::symlink?( __FILE__ ) then
95
+ org_path = File::dirname( File::readlink( __FILE__ ) )
96
+ else
97
+ org_path = File::dirname( __FILE__ )
98
+ end
99
+ $:.unshift( org_path.untaint )
100
+ end
101
+
102
+ begin
103
+ require "tdiary"
104
+ rescue LoadError
105
+ $stderr.print "squeeze.rb: cannot load tdiary.rb. <#{tdiary_path}/tdiary>\n"
106
+ exit( 1 )
107
+ end
108
+ end
109
+
110
+ #
111
+ # Dairy Squeeze
112
+ #
113
+ module ::TDiary
114
+ class YATDiarySqueeze < TDiaryBase
115
+ def initialize(diary, dest, all_data, overwrite, compat, conf, suffix)
116
+ @ignore_parser_cache = true
117
+
118
+ cgi = CGI::new
119
+ def cgi.referer; nil; end
120
+ def cgi.user_agent; 'bot'; end
121
+ super( cgi, 'day.rhtml', conf )
122
+ @diary = diary
123
+ @date = diary.date
124
+ @diaries = {@date.strftime('%Y%m%d') => @diary} if @diaries.size == 0
125
+ @dest = dest
126
+ @all_data = all_data
127
+ @overwrite = overwrite
128
+ @compat = compat
129
+ @suffix = suffix
130
+ end
131
+
132
+ def execute
133
+ if @compat
134
+ dir = @dest
135
+ name = @diary.date.strftime('%Y%m%d')
136
+ else
137
+ dir = @dest + "/" + @diary.date.strftime('%Y')
138
+ name = @diary.date.strftime('%m%d')
139
+ Dir.mkdir(dir, 0755) unless File.directory?(dir)
140
+ end
141
+ filename = dir + "/" + name + @suffix
142
+ if FileTest.exist?( filename ) and @overwrite
143
+ File::delete( filename )
144
+ end
145
+ if @diary.visible? or @all_data
146
+ if not FileTest::exist?(filename) or
147
+ File::mtime(filename) != @diary.last_modified
148
+ File::open(filename, 'w'){|f| f.write(eval_rhtml)}
149
+ File::utime(@diary.last_modified, @diary.last_modified, filename)
150
+ end
151
+ else
152
+ if FileTest.exist?(filename) and ! @all_data
153
+ name = "remove #{name}"
154
+ File::delete(filename)
155
+ else
156
+ name = ""
157
+ end
158
+ end
159
+ name
160
+ end
161
+
162
+ protected
163
+ def mode
164
+ 'day'
165
+ end
166
+
167
+ def cookie_name; ''; end
168
+ def cookie_mail; ''; end
169
+ end
170
+ end
171
+
172
+ #
173
+ # Main
174
+ #
175
+ module ::TDiary
176
+ class YATDiarySqueezeMain < TDiaryBase
177
+ def initialize(dest, all_data, overwrite, compat, conf, suffix)
178
+ @ignore_parser_cache = true
179
+
180
+ cgi = CGI::new
181
+ def cgi.referer; nil; end
182
+ super( cgi, 'day.rhtml', conf )
183
+ calendar
184
+ @years.keys.sort.each do |year|
185
+ print "(#{year.to_s}/) "
186
+ @years[year.to_s].sort.each do |month|
187
+ diaries2 = nil
188
+ @io.transaction(Time::local(year.to_i, month.to_i)) do |diaries|
189
+ diaries2 = diaries
190
+ DIRTY_NONE
191
+ end
192
+ diaries2.sort.each do |day, diary|
193
+ print YATDiarySqueeze.new(diary, dest, all_data, overwrite, compat, conf, suffix).execute + " "
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+
201
+ squeeze_navi_on_footer = '<div class="adminmenu"><%= navi_user %></div>'
202
+
203
+ if mode == "CGI" || mode == "CMD"
204
+ if mode == "CGI"
205
+ print %Q[Content-type:text/html\n\n
206
+ <html>
207
+ <head>
208
+ <title>Squeeze for tDiary</title>
209
+ <link href="./theme/default/default.css" type="text/css" rel="stylesheet"/>
210
+ </head>
211
+ <body><div style="text-align:center">
212
+ <h1>Squeeze for tDiary</h1>
213
+ <p>$Revision: 1.25 $</p>
214
+ <p>Copyright (C) 2002 MUTOH Masao&lt;mutoh@highway.ne.jp&gt;</p></div>
215
+ <br><br>Start!</p><hr>
216
+ ]
217
+ end
218
+
219
+ begin
220
+ require 'cgi'
221
+ cgi = CGI.new
222
+ def cgi.user_agent; 'bot'; end
223
+ conf = TDiary::Config::new(cgi)
224
+ conf.header = ''
225
+ conf.footer = squeeze_navi_on_footer
226
+ conf.show_comment = true
227
+ conf.hide_comment_form = true
228
+ output_path = "#{conf.data_path}/cache/html" unless output_path
229
+ Dir.mkdir(output_path, 0755) unless File.directory?(output_path)
230
+ ::TDiary::YATDiarySqueezeMain.new(output_path, all_data, overwrite, compat, conf, suffix)
231
+ rescue
232
+ print $!, "\n"
233
+ $@.each do |v|
234
+ print v, "\n"
235
+ end
236
+ exit( 1 )
237
+ end
238
+
239
+ if mode == "CGI"
240
+ print "<hr><p>End!</p></body></html>\n"
241
+ else
242
+ print "\n\n"
243
+ end
244
+ else
245
+ add_update_proc do
246
+ conf = @conf.clone
247
+ conf.header = ''
248
+ conf.footer = squeeze_navi_on_footer
249
+ conf.show_comment = true
250
+ conf.hide_comment_form = true
251
+
252
+ diary = @diaries[@date.strftime('%Y%m%d')]
253
+ dir = @options['squeeze.output_path'] || @options['yasqueeze.output_path']
254
+ dir = @cache_path + "/html" unless dir
255
+ Dir.mkdir(dir, 0755) unless File.directory?(dir)
256
+ ::TDiary::YATDiarySqueeze.new(diary, dir,
257
+ @options['squeeze.all_data'] || @options['yasqueeze.all_data'],
258
+ @options['squeeze.overwrite'],
259
+ @options['squeeze.compat_path'] || @options['yasqueeze.compat_path'],
260
+ conf,
261
+ @options['squeeze.suffix'] || ''
262
+ ).execute
263
+ end
264
+ end
265
+ end
266
+
267
+ # Local Variables:
268
+ # mode: ruby
269
+ # indent-tabs-mode: t
270
+ # tab-width: 3
271
+ # ruby-indent-level: 3
272
+ # End:
@@ -56,7 +56,7 @@ def twitter_statuses_show_api( tweet_id )
56
56
  "Authorization" => %Q[OAuth #{oauth_parameters.map{|k ,v| "#{URI.escape( k.to_s, unsafe )}=\"#{URI.escape( v, unsafe )}\""}.join( "," )}],
57
57
  :proxy => proxy
58
58
  }
59
- timeout( 20 ) do
59
+ Timeout.timeout( 20 ) do
60
60
  open( "#{url}?#{parameters.map{|k,v| "#{k}=#{v}"}.join( "&" )}", headers ) {|f| f.read }
61
61
  end
62
62
  end
data/plugin/twitter.rb CHANGED
@@ -12,7 +12,7 @@ require 'rexml/document'
12
12
  if /^(latest|day)$/ =~ @mode then
13
13
  add_header_proc do
14
14
  xml = nil
15
- timeout( 5 ) do
15
+ Timeout.timeout( 5 ) do
16
16
  begin
17
17
  xml = open( "http://twitter.com/statuses/user_timeline/#{@conf['twitter.user']}.xml" ){|f| f.read}
18
18
  rescue Exception
data/plugin/yo_update.rb CHANGED
@@ -48,7 +48,7 @@ def yo_update_access_api(req)
48
48
  proxy_port = nil
49
49
  end
50
50
  begin
51
- timeout(YO_UPDATE_TIMEOUT) do
51
+ Timeout.timeout(YO_UPDATE_TIMEOUT) do
52
52
  return Net::HTTP.start(req.uri.host, req.uri.port, proxy_addr, proxt_port){|http|
53
53
  http.request(req)
54
54
  }
data/plugin/youtube.rb CHANGED
@@ -7,20 +7,24 @@
7
7
  #
8
8
  def youtube( video_id, size = [425,350] )
9
9
  if feed?
10
- %Q|<div class="youtube"><a href="http://www.youtube.com/watch?v=#{video_id}">YouTube (#{video_id})</a></div>|
10
+ %Q|<div class="youtube"><a href="//www.youtube.com/watch?v=#{video_id}">YouTube (#{video_id})</a></div>|
11
11
  else
12
12
  <<-TAG
13
- <iframe class="youtube-player" type="text/html" width="#{size[0]}" height="#{size[1]}" src="http://www.youtube.com/embed/#{video_id}" frameborder="0">
13
+ <div class="youtube-player-wrapper">
14
+ <iframe class="youtube-player" type="text/html" width="#{size[0]}" height="#{size[1]}" src="//www.youtube.com/embed/#{video_id}" frameborder="0">
14
15
  </iframe>
16
+ </div>
15
17
  TAG
16
18
  end
17
19
  end
18
20
 
19
21
  def youtube_custom( video_id, size = [416,337] )
20
22
  <<-TAG
23
+ <div class="youtube-player-wrapper">
21
24
  <object width="#{size[0]}" height="#{size[1]}">
22
- <param name="movie" value="http://www.youtube.com/cp/#{video_id}"></param>
23
- <embed src="http://www.youtube.com/cp/#{video_id}" type="application/x-shockwave-flash" width="#{size[0]}" height="#{size[1]}"></embed>
25
+ <param name="movie" value="//www.youtube.com/cp/#{video_id}"></param>
26
+ <embed src="//www.youtube.com/cp/#{video_id}" type="application/x-shockwave-flash" width="#{size[0]}" height="#{size[1]}"></embed>
24
27
  </object>
28
+ </div>
25
29
  TAG
26
30
  end
data/spec/youtube_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe "youtube plugin" do
5
5
  DUMMY_YOUTUBE_VIDEO_ID = 1234567890
6
6
 
7
7
  {
8
- 'Mozilla' => %|\t\t<iframe class="youtube-player" type="text/html" width="425" height="350" src="http://www.youtube.com/embed/#{DUMMY_YOUTUBE_VIDEO_ID}" frameborder="0">\n\t\t</iframe>\n|
8
+ 'Mozilla' => %|\t\t<div class="youtube-player-wrapper">\n\t\t<iframe class="youtube-player" type="text/html" width="425" height="350" src="//www.youtube.com/embed/#{DUMMY_YOUTUBE_VIDEO_ID}" frameborder="0">\n\t\t</iframe>\n\t\t</div>\n|
9
9
  }.each do |k,v|
10
10
  it 'should render object tag in :user_agent' do
11
11
  plugin = fake_plugin(:youtube)
@@ -125,7 +125,7 @@ module Hatena
125
125
  File.open(kw, IO::WRONLY|IO::CREAT) do |fp|
126
126
  break unless fp.flock(IO::LOCK_EX|IO::LOCK_NB)
127
127
  uri = ::URI.parse('http://d.hatena.ne.jp/images/keyword/keywordlist')
128
- timeout(60) do
128
+ Timeout.timeout(60) do
129
129
  Net::HTTP.version_1_1
130
130
  Net::HTTP.new(uri.host, uri.port).start do |http|
131
131
  res, body = http.get(uri.request_uri,
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: 4.2.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tDiary contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-29 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tdiary
@@ -220,7 +220,6 @@ files:
220
220
  - plugin/bootstrap-navi.rb
221
221
  - plugin/brow_si.rb
222
222
  - plugin/canonical.rb
223
- - plugin/category-lite.rb
224
223
  - plugin/category_similar.rb
225
224
  - plugin/category_to_tag.rb
226
225
  - plugin/category_to_tagcloud.rb
@@ -342,6 +341,7 @@ files:
342
341
  - plugin/show_and_hide.rb
343
342
  - plugin/slideshare.rb
344
343
  - plugin/socialbutton.rb
344
+ - plugin/squeeze.rb
345
345
  - plugin/tatsu_zine.rb
346
346
  - plugin/tdiarytimes2.rb
347
347
  - plugin/tdiarytimes_flashstyle.rb
@@ -1,235 +0,0 @@
1
- #
2
- # category-lite.rb : tDiary plugin for show category pages (light edition)
3
- #
4
- # Copyright (C) 2015 TADA Tadashi
5
- # Distributed under the GPL2 or any later version.
6
- #
7
-
8
-
9
- # read cache here so that you can use category with secure mode.
10
- @conf['category.header1'] = ''
11
- @conf['category.header2'] = '<%= category_dropdown_list %>'
12
- @category_icon = {}
13
- @categories = transaction('category'){|db|db.keys}.sort_by{|c|c.downcase}
14
-
15
- module Category
16
- class Info
17
- def initialize(cgi, _, conf)
18
- @cgi, @conf = cgi, conf
19
- end
20
-
21
- def category
22
- @name || (@name = @conf.to_native(@cgi.params['category'][0], @conf.encoding_old))
23
- end
24
- end
25
- end
26
-
27
- def category_title
28
- info = Category::Info.new(@cgi, nil, @conf)
29
- "[#{info.category}]"
30
- end
31
-
32
- def category_anchor(category)
33
- %Q|[<a href="#{h @index}?category=#{u category}" title="#{h category}">#{h category}</a>]|
34
- end
35
-
36
- def category_dropdown_list(label = nil, _ = nil)
37
- label ||= 'show category list'
38
-
39
- info = Category::Info.new(@cgi, _, @conf)
40
- category = info.category
41
- category = [] if category.empty?
42
-
43
- options = ''
44
- @categories.each do |c|
45
- options << %Q|<option value="#{h c}"#{" selected" if category.include?(c)}>#{h c}</option>\n|
46
- end
47
-
48
- <<-HTML
49
- <form method="get" action="#{h @index}"><div>
50
- <select name="category">
51
- #{options}
52
- </select>
53
- <input type="submit" value="#{label}">
54
- </div></form>
55
- HTML
56
- end
57
-
58
- def category_transaction(categories)
59
- transaction('category') do |db|
60
- (categories || db.keys).each do |category|
61
- Hash[*JSON.load(db.get(category) || '{}').sort_by{|d,_|d}.flatten(1)].each do |ymd, diaries|
62
- yield db, category, ymd, diaries
63
- end
64
- end
65
- end
66
- end
67
-
68
- def category_list_sections
69
- info = Category::Info.new(@cgi, nil, @conf)
70
-
71
- r = ''
72
- r << <<-HTML
73
- <div class="category day">
74
- <h2>
75
- <span class="title">
76
- <a href="#{h @conf.index}?category=#{u info.category}">#{h info.category}</a>
77
- </span>
78
- </h2>
79
- <div class="body">
80
- <ul class="category">
81
- HTML
82
- category_transaction([info.category]) do |db, category, ymd, diaries|
83
- date = Time.local(*ymd.scan(/(.{4})(..)(..)/)[0]).strftime(@conf.date_format)
84
- diaries.sort_by{|i|i[0]}.each do |idx, title, excerpt|
85
- r << <<-HTML
86
- <li>
87
- <a href="#{h @index}#{anchor "#{ymd}#p#{'%02d' % idx}"}" title="#{h excerpt}">
88
- #{date}#p#{'%02d' % idx}
89
- </a>
90
- #{apply_plugin(title)}
91
- </li>
92
- HTML
93
- end
94
- end
95
- r << <<-HTML
96
- </ul>
97
- </div>
98
- </div>
99
- HTML
100
- return r
101
- end
102
-
103
- def category_serialize(diary)
104
- data = {}
105
- ymd = diary.date.strftime('%Y%m%d')
106
-
107
- idx = 1
108
- diary.each_section do |s|
109
- s.categories.each do |c|
110
- data[c] ||= {}
111
- data[c][ymd] ||= []
112
- body = <<-EVAL.gsub(/^\t+/, '')
113
- text = apply_plugin(<<'BODY', true)
114
- #{s.body_to_html}
115
- BODY
116
- EVAL
117
- shorten = begin
118
- @conf.shorten(eval(body.untaint))
119
- rescue NameError
120
- ""
121
- end
122
- data[c][ymd] << [idx, s.stripped_subtitle_to_html, shorten]
123
- end
124
- idx +=1
125
- end
126
- data
127
- end
128
-
129
- def category_rebuild(years)
130
- transaction('category') do |db|
131
- cache = Hash.new{{}}
132
- @years.each do |y, ms|
133
- ms.each do |m|
134
- m = DiaryContainer::find_by_month(@conf, "#{y}#{m}")
135
- m.diaries.each do |ymd, diary|
136
- next if !diary.visible? or !diary.categorizable?
137
- serialize = category_serialize(diary)
138
- serialize.keys.each do |category|
139
- cache[category] = cache[category].merge!(serialize[category])
140
- end
141
- end
142
- end
143
- end
144
- db.keys.each {|key| db.delete(key)}
145
- cache.each do |category, diaries|
146
- db.set(category, diaries.to_json)
147
- end
148
- end
149
- end
150
-
151
- add_update_proc do
152
- if /^(append|replace)$/ =~ @mode
153
- ymd = @date.strftime('%Y%m%d')
154
- diary = @diaries[ymd]
155
- serialize = category_serialize(diary)
156
-
157
- transaction('category') do |db|
158
- (db.keys + serialize.keys).uniq.each do |category|
159
- data = JSON.load(db.get(category) || '{}')
160
- if diary.visible? and serialize[category]
161
- data.update(serialize[category])
162
- db.set(category, data.to_json)
163
- else
164
- data.delete(ymd)
165
- if data.empty?
166
- db.delete(category)
167
- else
168
- db.set(category, data.to_json)
169
- end
170
- end
171
- end
172
- end
173
- end
174
- end
175
-
176
- #
177
- # edit support: insert category to editing diary using JavaScript
178
- #
179
- def category_edit_support_flatlist(categories)
180
- ret = ''
181
- ret << '<div class="field title">'
182
- ret << "#{@category_conf_label}:\n"
183
- categories.each do |c|
184
- ret << %Q!| <span class="category-item">#{h c}</span>\n!
185
- end
186
- ret << "|\n</div>\n<br>\n"
187
- ret
188
- end
189
-
190
- def category_edit_support_dropdown(categories)
191
- ret = ''
192
- ret << '<div class="field title">'
193
- ret << %Q|#{@category_conf_label}: <select id="category-candidate" name="category-candidate">\n|
194
- categories.each do |c|
195
- ret << %Q!<option>#{h c}</option>\n!
196
- end
197
- ret << "|\n</select>\n</div>\n<br>\n"
198
- ret
199
- end
200
-
201
- if @mode =~ /^(form|edit)$/ and @conf['category.edit_support'] != 0
202
- enable_js( 'category.js' )
203
- add_edit_proc do |date|
204
- ret = ''
205
- transaction('category') do |db|
206
- categories = db.keys
207
- unless categories.size == 0 then
208
- if @conf['category.edit_support'] == 2 then
209
- ret << category_edit_support_dropdown(categories)
210
- else
211
- ret << category_edit_support_flatlist(categories)
212
- end
213
- end
214
- end
215
- ret
216
- end
217
- end
218
-
219
- if @mode == 'conf' || @mode == 'saveconf'
220
- add_conf_proc('category', @category_conf_label, 'basic') do
221
- if @mode == 'saveconf'
222
- category_rebuild(@years) if @cgi.valid?('category_initialize')
223
- @conf['category.edit_support'] = (@cgi.params['category.edit_support'][0] || '1').to_i
224
- end
225
- category_conf_html
226
- end
227
- end
228
-
229
- # Local Variables:
230
- # mode: ruby
231
- # indent-tabs-mode: t
232
- # tab-width: 3
233
- # ruby-indent-level: 3
234
- # End:
235
- # vim: ts=3